LifeV
QuadratureRuleProvider.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 ************************************************************************
4 
5  This file is part of the LifeV Applications.
6  Copyright (C) 2001-2010 EPFL, Politecnico di Milano, INRIA
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as
10  published by the Free Software Foundation; either version 2.1 of the
11  License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21  USA
22 
23 ************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief A short description of the file content
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @date 25 Nov 2010
33 
34  A more detailed description of the file (if necessary)
35  */
36 
37 #include <lifev/core/fem/QuadratureRuleProvider.hpp>
38 
39 namespace LifeV
40 {
41 
45 
46 // ===================================================
47 // Methods
48 // ===================================================
49 
52 provideExactness (const ReferenceShapes& shape, const UInt& exactness)
53 {
54  switch (shape)
55  {
56  case TETRA:
57  {
59  {
60  return provideExactnessTetraNoNeg (exactness);
61  }
62  return provideExactnessTetra (exactness);
63  break;
64  }
65 
66  case PRISM:
67  return provideExactnessPrism (exactness);
68  break;
69 
70  case HEXA:
71  return provideExactnessHexa (exactness);
72  break;
73 
74  case QUAD:
75  return provideExactnessQuad (exactness);
76  break;
77 
78  case TRIANGLE:
80  {
81  return provideExactnessTriangleNoNeg (exactness);
82  }
83  return provideExactnessTriangle (exactness);
84  break;
85 
86  case LINE:
87  return provideExactnessLine (exactness);
88  break;
89 
90  case POINT:
91  return provideExactnessPoint (exactness);
92  break;
93 
94  case NONE:
95  default:
96  std::cerr << " QuadratureRuleProvider: No quadrature for this shape! " << std::endl;
97  std::abort();
98  };
99 
100  // Impossible case, but avoids a warning
101  return QuadratureRule();
102 }
103 
104 
108 {
109  switch (shape)
110  {
111  case TETRA:
112  {
114  {
115  return quadRuleTetra64pt;
116  }
118  QuadratureRule qr;
119  qr.import ( QRKeast<7>() );
120  return qr;
121  break;
122  }
123 
124  case HEXA:
125  return quadRuleHexa8pt;
126  break;
127 
128  case QUAD:
129  return quadRuleQuad9pt;
130  break;
131 
132  case TRIANGLE:
133  return quadRuleTria7pt;
134  break;
135 
136  case LINE:
137  return quadRuleTria3pt;
138  break;
139 
140  case POINT:
141  return quadRuleNode1pt;
142  break;
143 
144  case PRISM:
145  case NONE:
146  default:
147  std::cerr << " QuadratureRuleProvider: No quadrature for this shape! " << std::endl;
148  std::abort();
149  };
150 
151  // Impossible case, but avoids a warning
152  return QuadratureRule();
153 }
154 
155 // ===================================================
156 // Private Methods
157 // ===================================================
158 
161 provideExactnessTetra (const UInt& exactness)
162 {
163  switch (exactness)
164  {
165  case 0:
166  case 1:
167  return quadRuleTetra1pt;
168  break;
169  case 2:
170  return quadRuleTetra4pt;
171  break;
172  case 3:
174  return quadRuleTetra5pt;
175  break;
176  case 4:
177  {
179  QuadratureRule qr;
180  qr.import ( QRKeast<4>() );
181  return qr;
182  break;
183  }
184  case 5:
185  return quadRuleTetra15pt;
186  break;
187  case 6:
188  {
189  QuadratureRule qr;
190  qr.import ( QRKeast<6>() );
191  return qr;
192  break;
193  }
194 
195  case 7:
196  {
198  QuadratureRule qr;
199  qr.import ( QRKeast<7>() );
200  return qr;
201  break;
202  }
203  default:
204 
207  QuadratureRule qr;
208  qr.import ( QRKeast<7>() );
209  return qr;
210  };
211 
212  return QuadratureRule();
213 }
214 
217 provideExactnessPrism (const UInt& exactness)
218 {
219  switch (exactness)
220  {
221  default:
222  std::cerr << " QuadratureRuleProvider: No quadrature for this exactness (prism) ";
223  std::cerr << std::endl;
224  std::abort();
225  };
226 
227  /*
228  * Fix to remove warning
229  */
230  return QuadratureRule();
231 }
232 
235 provideExactnessHexa (const UInt& exactness)
236 {
237  switch (exactness)
238  {
239  case 0:
240 
241  case 1:
242  return quadRuleHexa1pt;
243  break;
244 
245  case 2:
247  // No break here!
248 
249  case 3:
250  return quadRuleHexa8pt;
251  break;
252 
253  default:
254 
256  return quadRuleHexa8pt;
257 
258  };
259 
260  return QuadratureRule();
261 }
262 
265 provideExactnessQuad (const UInt& exactness)
266 {
267  switch (exactness)
268  {
269  case 0:
270 
271  case 1:
272  return quadRuleQuad1pt;
273  break;
274 
275  case 2:
277  // No break!
278 
279  case 3:
280  return quadRuleQuad4pt;
281  break;
282 
283  case 4:
285  // No break!
286 
287  case 5:
288  return quadRuleQuad9pt;
289  break;
290 
291  default:
292 
294  return quadRuleQuad9pt;
295  };
296 
297  return QuadratureRule();
298 }
299 
302 provideExactnessTriangle (const UInt& exactness)
303 {
304  switch (exactness)
305  {
306  case 0:
307 
308  case 1:
309  return quadRuleTria1pt;
310  break;
311 
312  case 2:
313  return quadRuleTria3pt;
314  break;
315 
316  case 3:
318  return quadRuleTria4pt;
319  break;
320 
321  case 4:
322  return quadRuleTria6pt;
323  break;
324 
325  case 5:
326  return quadRuleTria7pt;
327  break;
328 
329  default:
331  return quadRuleTria7pt;
332 
333  };
334 
335  return QuadratureRule();
336 }
337 
340 provideExactnessLine (const UInt& exactness)
341 {
342  switch (exactness)
343  {
344  case 0:
345 
346  case 1:
347  return quadRuleSeg1pt;
348  break;
349 
350  case 2:
351  return quadRuleSeg2pt;
352  break;
353 
354  case 3:
355  return quadRuleTria3pt;
356  break;
357 
358  default:
359 
361  return quadRuleTria3pt;
362  };
363 
364  return QuadratureRule();
365 }
366 
369 provideExactnessPoint (const UInt& exactness)
370 {
371  switch (exactness)
372  {
373  default:
374  return quadRuleNode1pt;
375  };
376 }
377 
381 {
382  switch (exactness)
383  {
384  case 0:
385  case 1:
386  return quadRuleTetra1pt;
387  break;
388  case 2:
389  return quadRuleTetra4pt;
390  break;
391  case 3:
393  // No break!
394  case 4:
396  // No break!
397  case 5:
398  return quadRuleTetra15pt;
399  break;
400  case 6:
401  {
402  QuadratureRule qr;
403  qr.import ( QRKeast<6>() );
404  return qr;
405  break;
406  }
407 
408  case 7:
409  return quadRuleTetra64pt;
410  break;
411 
412  default:
413 
415  return quadRuleTetra64pt;
416  };
417 
418  return QuadratureRule();
419 }
420 
424 {
425  switch (exactness)
426  {
427  case 0:
428 
429  case 1:
430  return quadRuleTria1pt;
431  break;
432 
433  case 2:
434  return quadRuleTria3pt;
435  break;
436 
437  case 3:
439  // No break!
440 
441  case 4:
442  return quadRuleTria6pt;
443  break;
444 
445  case 5:
446  return quadRuleTria7pt;
447  break;
448 
449  default:
451  return quadRuleTria7pt;
452 
453  };
454 
455  return QuadratureRule();
456 }
457 
458 
459 
460 void
463 {
465  {
466  std::cerr << "QuadratureRuleProvider: Error: required degree does not exist" << std::endl;
467  std::abort();
468  }
470  {
471  std::cerr << "QuadratureRuleProvider: Warning: required degree does not exist" << std::endl;
472  std::cerr << " => attempting to find with degree+1" << std::endl;
473 
474  }
475 }
476 
477 void
480 {
482  {
483  std::cerr << "QuadratureRuleProvider: Error: required degree too high. " << std::endl;
484  std::abort();
485  }
487  {
488  std::cerr << "QuadratureRuleProvider: Warning: required degree too high. " << std::endl;
489  std::cerr << " => returning highest degree" << std::endl;
490  }
491 }
492 
493 void
496 {
498  {
499  std::cerr << "QuadratureRuleProvider: Warning: negative weights. " << std::endl;
500  }
501 }
502 
503 
504 
505 } // Namespace LifeV
const QuadratureRule quadRuleTetra64pt(pt_tetra_64pt, 6, "Quadrature rule 64 points on a tetraedra", TETRA, 64, 7)
const QuadratureRule quadRuleQuad4pt(pt_quad_4pt, 2, "Quadrature rule 4 points on a quadrangle", QUAD, 4, 3)
static QuadratureRule provideExactnessQuad(const UInt &exactness)
const QuadratureRule quadRuleTetra15pt(pt_tetra_15pt, 5, "Quadrature rule 15 points on a tetraedra", TETRA, 15, 5)
const QuadratureRule quadRuleTria4pt(pt_tria_4pt, 3, "Quadrature rule 4 points on a triangle", TRIANGLE, 4, 3)
const QuadratureRule quadRuleTetra4pt(pt_tetra_4pt, 2, "Quadrature rule 4 points on a tetraedra", TETRA, 4, 2)
static QuadratureRule provideExactnessTriangleNoNeg(const UInt &exactness)
static QuadratureRule provideExactnessTriangle(const UInt &exactness)
const QuadratureRule quadRuleNode1pt(pt_node_1pt, QUAD_RULE_NODE_1PT, "Gauss Legendre 1 point on a node", POINT, 1, 1)
void updateInverseJacobian(const UInt &iQuadPt)
const QuadratureRule quadRuleSeg2pt(pt_seg_2pt, QUAD_RULE_SEG_2PT, "Gauss Legendre 2 points on a segment", LINE, 2, 3)
const QuadratureRule quadRuleQuad9pt(pt_quad_9pt, 3, "Quadrature rule 9 points on a quadrangle", QUAD, 9, 5)
const QuadratureRule quadRuleQuad1pt(pt_quad_1pt, 1, "Quadrature rule 1 point on a quadrangle", QUAD, 1, 1)
QuadratureRule()
Empty constructor.
const QuadratureRule quadRuleTetra5pt(pt_tetra_5pt, 4, "Quadrature rule 5 points on a tetraedra", TETRA, 5, 3)
static TooHighExactness S_BehaviorTooHighExactness
const QuadratureRule quadRuleSeg1pt(pt_seg_1pt, QUAD_RULE_SEG_1PT, "Gauss Legendre 1 point on a segment", LINE, 1, 1)
static QuadratureRule provideMaximal(const ReferenceShapes &shape)
Provide the quadrature rule with the highest exactness available.
static NoPreciseExactness S_BehaviorNoPreciseExactness
const QuadratureRule quadRuleTria3pt(pt_tria_3pt, 2, "Quadrature rule 3 points on a triangle", TRIANGLE, 3, 2)
const QuadratureRule quadRuleTetra1pt(pt_tetra_1pt, 1, "Quadrature rule 1 point on a tetraedra", TETRA, 1, 1)
const QuadratureRule quadRuleTria7pt(pt_tria_7pt, 5, "Quadrature rule 7 points on a triangle", TRIANGLE, 7, 5)
const QuadratureRule quadRuleTria6pt(pt_tria_6pt, 4, "Quadrature rule 6 points on a triangle", TRIANGLE, 6, 4)
static QuadratureRule provideExactnessTetraNoNeg(const UInt &exactness)
static QuadratureRule provideExactnessTetra(const UInt &exactness)
Method for the differentShapes.
static QuadratureRule provideExactnessPrism(const UInt &exactness)
static QuadratureRule provideExactness(const ReferenceShapes &shape, const UInt &exactness)
Provide a quadrature rule with the given exactness.
static QuadratureRule provideExactnessLine(const UInt &exactness)
static QuadratureRule provideExactnessHexa(const UInt &exactness)
const QuadratureRule quadRuleHexa1pt(pt_hexa_1pt, 1, "Quadrature rule 1 point on a hexa", HEXA, 1, 1)
const QuadratureRule quadRuleHexa8pt(pt_hexa_8pt, 2, "Quadrature rule 8 points on a hexa", HEXA, 8, 3)
QuadratureRule - The basis class for storing and accessing quadrature rules.
const QuadratureRule quadRuleTria1pt(pt_tria_1pt, 1, "Quadrature rule 1 point on a triangle", TRIANGLE, 1, 1)
QuadratureRuleProvider - This class is used to generate quadrature rules.
static NegativeWeight S_BehaviorNegativeWeight
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
static QuadratureRule provideExactnessPoint(const UInt &exactness)