LifeV
QuadratureRuleProvider.hpp
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 #ifndef QUADRATURE_RULE_PROVIDER_H
38 #define QUADRATURE_RULE_PROVIDER_H 1
39 
40 #include <lifev/core/LifeV.hpp>
41 
42 #include <lifev/core/fem/QuadratureRule.hpp>
43 
44 #include <lifev/core/fem/QRKeast.hpp>
45 
46 namespace LifeV
47 {
48 
49 //! QuadratureRuleProvider - This class is used to generate quadrature rules
50 /*!
51  @author Samuel Quinodoz
52 
53  Thanks to this class, it is possible to adopt the best suitable quadrature
54  rule for each case, depending on the degree of the expression to be
55  integrated.
56 
57  Two important methods are provided:
58  <ul>
59  <li> provideExactness that attempts to give, for a given shape and exactness
60  the best suitable quadrature rule (i.e. with the lowest possible number of points)
61  <li> provideMaximal that returns the highest order quadrature available for the
62  given shape.
63  </ul>
64 
65  These two methods are influenced by the 3 behaviors available, which
66  give the way to handle special situations:
67  <ul>
68  <li> NoPreciseExactness: if the exactness required is not available,
69  but more precise quadrature rule exist. There are 3 possible behaviors:
70  <ol>
71  <li> ErrorNoPrecise: display an error and abort.
72  <li> WarningAndReturnSup: display a warning and return a more precise quadrature.
73  <li> ReturnSup: (default) return a more precise quadrature.
74  </ol>
75  <li> TooHighExactness: if there is no quadrature precise enough available.
76  3 behaviors are possible:
77  <ol>
78  <li> ErrorTooHigh: (default) display an error and abort.
79  <li> WarningAndReturnMax: display a warning and return the best quadrature available.
80  <li> ReturnMax: return the best quadrature available.
81  </ol>
82  <li> NegativeWeight: sometimes, the quadrature with the least number of
83  points contains negative weights. 3 possible choices are available in that
84  case:
85  <ol>
86  <li> Accept: (default) return the quadrature with negative weight.
87  <li> WarningAndAccept: issue a warning and return the quadrature with negative weight.
88  <li> Reject: search the quadrature only among the ones with positive weights only.
89  </ol>
90  </ul>
91 
92  These 3 behaviors can be changed via the ad-hoc setter.
93 
94  <b> Remark </b> When running in parallel, it is a good practice
95  to issue warning only with the leader process. Do not "Reject"
96  negative quadratures with only one process (different processes
97  would have different quadratures!).
98 
99  */
100 class QuadratureRuleProvider
101 {
102 public:
103 
104  //! @name Public Types
105  //@{
106 
107  enum NoPreciseExactness { ErrorNoPrecise, WarningAndReturnSup, ReturnSup };
108  enum TooHighExactness { ErrorTooHigh, WarningAndReturnMax, ReturnMax };
109  enum NegativeWeight { Accept, WarningAndAccept, Reject};
110 
111  //@}
112 
113 
114  //! @name Methods
115  //@{
116 
117  //! Provide a quadrature rule with the given exactness
118  /*!
119  Given a shape, this method will try to return a quadrature rule that has the
120  given exactness. If such a quadrature rule is not defined, the program will
121  abort.
122  */
123  static QuadratureRule provideExactness (const ReferenceShapes& shape, const UInt& exactness);
124 
125  //! Provide the quadrature rule with the highest exactness available.
126  static QuadratureRule provideMaximal (const ReferenceShapes& shape);
127 
128  //@}
129 
130 
131 
132  //! @name Operators
133  //@{
134 
135  //@}
136 
137 
138  //! @name Set Methods
139  //@{
140 
141 
142  /*!
143  Setter for the behavior in case a quadrature rule with the precise exactness
144  required could not be found.
145  */
146  static void setBehaviorNoPreciseExactness ( const NoPreciseExactness& behavior)
147  {
148  S_BehaviorNoPreciseExactness = behavior;
149  }
150 
151  /*!
152  Setter for the behavior in case the exactness required cannot be achieved
153  by a known quadrature rule.
154  */
155  static void setBehaviorTooHighExactness ( const TooHighExactness& behavior)
156  {
157  S_BehaviorTooHighExactness = behavior;
158  }
159 
160  /*!
161  Setter for the behavior in case the quadrature rule asked for has
162  negative weights for some quadrature nodes.
163  */
164  static void setBehaviorNegativeWeight ( const NegativeWeight& behavior)
165  {
166  S_BehaviorNegativeWeight = behavior;
167  }
168 
169 
170  //@}
171 
172 
173 private:
174 
175  //! @name Private Methods
176  //@{
177 
178  //! Empty Constructor
179  QuadratureRuleProvider();
180 
181  //! Copy Constructor
182  QuadratureRuleProvider ( const QuadratureRuleProvider&);
183 
184  //! Destructor
185  virtual ~QuadratureRuleProvider();
186 
187  //! Method for the differentShapes
188 
189  static QuadratureRule provideExactnessTetra (const UInt& exactness);
190  static QuadratureRule provideExactnessPrism (const UInt& exactness);
191  static QuadratureRule provideExactnessHexa (const UInt& exactness);
192  static QuadratureRule provideExactnessQuad (const UInt& exactness);
193  static QuadratureRule provideExactnessTriangle (const UInt& exactness);
194  static QuadratureRule provideExactnessLine (const UInt& exactness);
195  static QuadratureRule provideExactnessPoint (const UInt& exactness);
196 
197  static QuadratureRule provideExactnessTetraNoNeg (const UInt& exactness);
198  static QuadratureRule provideExactnessTriangleNoNeg (const UInt& exactness);
199 
200  static void manageNoPreciseExactnessCase();
201  static void manageTooHighExactnessCase();
202  static void manageWarningNegativeWeight();
203 
204  //@}
205 
206  static NoPreciseExactness S_BehaviorNoPreciseExactness;
207  static TooHighExactness S_BehaviorTooHighExactness;
208  static NegativeWeight S_BehaviorNegativeWeight;
209 };
210 
211 } // Namespace LifeV
212 
213 #endif /* QUADRATURERULEPROVIDER_H */
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191