Intrepid
Intrepid_Types.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid Package
5 // Copyright (2007) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Pavel Bochev (pbboche@sandia.gov)
38 // Denis Ridzal (dridzal@sandia.gov), or
39 // Kara Peterson (kjpeter@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 #ifndef INTREPID_INTREPID_TYPES_HPP
50 #define INTREPID_INTREPID_TYPES_HPP
51 
52 #ifdef HAVE_INTREPID_DEBUG
53 #define INTREPID_VALIDATE( A ) A
54 #else
55 #define INTREPID_VALIDATE( A ) /* empty */
56 #endif
57 
58 #include <Teuchos_ScalarTraits.hpp>
59 
63 #define INTREPID_MAX_ORDER 10
64 
68 #define INTREPID_MAX_INTEGRATION_POINTS 1001
69 
74 #define INTREPID_MAX_CUBATURE_DEGREE_EDGE 61
75 
80 #define INTREPID_MAX_CUBATURE_DEGREE_TRI 20
81 
86 #define INTREPID_MAX_CUBATURE_DEGREE_TET 20
87 
92 #define INTREPID_MAX_CUBATURE_DEGREE_PYR 11
93 
97 #define INTREPID_MAX_DIMENSION 3
98 
103 #define INTREPID_MAX_NEWTON 15
104 
108 #define INTREPID_MAX_DERIVATIVE 10
109 
110 namespace Intrepid {
111 
114  static const double INTREPID_EPSILON = std::abs(Teuchos::ScalarTraits<double>::eps());
115 
118  static const double INTREPID_THRESHOLD = 10.0 * INTREPID_EPSILON;
119 
122  static const double INTREPID_TOL = 10.0* INTREPID_THRESHOLD;
123 
127  enum ECoordinates{
128  COORDINATES_CARTESIAN=0,
129  COORDINATES_POLAR,
130  COORDINATES_CYLINDRICAL,
131  COORDINATES_SPHERICAL,
132  COORDINATES_MAX
133  };
134 
135  inline std::string ECoordinatesToString(ECoordinates coords) {
136  std::string retString;
137  switch(coords) {
138  case COORDINATES_CARTESIAN: retString = "Cartesian"; break;
139  case COORDINATES_POLAR: retString = "Polar"; break;
140  case COORDINATES_CYLINDRICAL: retString = "Cylindrical"; break;
141  case COORDINATES_SPHERICAL: retString = "Spherical"; break;
142  case COORDINATES_MAX: retString = "Max. Coordinates"; break;
143  default: retString = "INVALID ECoordinates";
144  }
145  return retString;
146  }
147 
153  inline int isValidCoordinate(ECoordinates coordinateType){
154  return( ( coordinateType == COORDINATES_CARTESIAN) ||
155  ( coordinateType == COORDINATES_POLAR) ||
156  ( coordinateType == COORDINATES_CYLINDRICAL) ||
157  ( coordinateType == COORDINATES_SPHERICAL) );
158  }
159 
160 
161 
165  enum ENorm{
166  NORM_ONE = 0,
167  NORM_TWO,
168  NORM_INF,
169  NORM_FRO, // Frobenius matrix norm
170  NORM_MAX
171  };
172 
173  inline std::string ENormToString(ENorm norm) {
174  std::string retString;
175  switch(norm) {
176  case NORM_ONE: retString = "1-Norm"; break;
177  case NORM_TWO: retString = "2-Norm"; break;
178  case NORM_INF: retString = "Infinity Norm"; break;
179  case NORM_FRO: retString = "Frobenius Norm"; break;
180  case NORM_MAX: retString = "Max. Norm"; break;
181  default: retString = "INVALID ENorm";
182  }
183  return retString;
184  }
185 
191  inline int isValidNorm(ENorm normType){
192  return( (normType == NORM_ONE) ||
193  (normType == NORM_TWO) ||
194  (normType == NORM_INF) ||
195  (normType == NORM_FRO) ||
196  (normType == NORM_MAX) );
197  }
198 
199 
200 
206  enum EOperator{
207  OPERATOR_VALUE = 0,
208  OPERATOR_GRAD, // 1
209  OPERATOR_CURL, // 2
210  OPERATOR_DIV, // 3
211  OPERATOR_D1, // 4
212  OPERATOR_D2, // 5
213  OPERATOR_D3, // 6
214  OPERATOR_D4, // 7
215  OPERATOR_D5, // 8
216  OPERATOR_D6, // 9
217  OPERATOR_D7, // 10
218  OPERATOR_D8, // 11
219  OPERATOR_D9, // 12
220  OPERATOR_D10, // 13
221  OPERATOR_MAX // 14
222  };
223 
224  inline std::string EOperatorToString(EOperator op) {
225  std::string retString;
226  switch(op) {
227  case OPERATOR_VALUE: retString = "Value"; break;
228  case OPERATOR_GRAD: retString = "Grad"; break;
229  case OPERATOR_CURL: retString = "Curl"; break;
230  case OPERATOR_DIV: retString = "Div"; break;
231  case OPERATOR_D1: retString = "D1"; break;
232  case OPERATOR_D2: retString = "D2"; break;
233  case OPERATOR_D3: retString = "D3"; break;
234  case OPERATOR_D4: retString = "D4"; break;
235  case OPERATOR_D5: retString = "D5"; break;
236  case OPERATOR_D6: retString = "D6"; break;
237  case OPERATOR_D7: retString = "D7"; break;
238  case OPERATOR_D8: retString = "D8"; break;
239  case OPERATOR_D9: retString = "D9"; break;
240  case OPERATOR_D10: retString = "D10"; break;
241  case OPERATOR_MAX: retString = "Max. Operator"; break;
242  default: retString = "INVALID EOperator";
243  }
244  return retString;
245  }
246 
247  inline EOperator & operator++(EOperator &type) {
248  return type = static_cast<EOperator>(type+1);
249  }
250 
251  inline EOperator operator++(EOperator &type, int) {
252  EOperator oldval = type;
253  ++type;
254  return oldval;
255  }
256 
257  inline EOperator & operator--(EOperator &type) {
258  return type = static_cast<EOperator>(type-1);
259  }
260 
261  inline EOperator operator--(EOperator &type, int) {
262  EOperator oldval = type;
263  --type;
264  return oldval;
265  }
266 
272  inline int isValidOperator(const EOperator operatorType){
273  return ( (operatorType == OPERATOR_VALUE) ||
274  (operatorType == OPERATOR_GRAD) ||
275  (operatorType == OPERATOR_CURL) ||
276  (operatorType == OPERATOR_DIV) ||
277  (operatorType == OPERATOR_D1) ||
278  (operatorType == OPERATOR_D2) ||
279  (operatorType == OPERATOR_D3) ||
280  (operatorType == OPERATOR_D4) ||
281  (operatorType == OPERATOR_D5) ||
282  (operatorType == OPERATOR_D6) ||
283  (operatorType == OPERATOR_D7) ||
284  (operatorType == OPERATOR_D8) ||
285  (operatorType == OPERATOR_D9) ||
286  (operatorType == OPERATOR_D10) );
287  }
288 
289 
293  enum EFunctionSpace
294  {
295  FUNCTION_SPACE_HGRAD = 0,
296  FUNCTION_SPACE_HCURL,
297  FUNCTION_SPACE_HDIV,
298  FUNCTION_SPACE_HVOL,
299  FUNCTION_SPACE_VECTOR_HGRAD,
300  FUNCTION_SPACE_TENSOR_HGRAD,
301  FUNCTION_SPACE_MAX
302  };
303 
304  inline std::string EFunctionSpaceToString(EFunctionSpace space) {
305  std::string retString;
306  switch(space) {
307  case FUNCTION_SPACE_HGRAD: retString = "H(grad)"; break;
308  case FUNCTION_SPACE_HCURL: retString = "H(curl)"; break;
309  case FUNCTION_SPACE_HDIV: retString = "H(div)"; break;
310  case FUNCTION_SPACE_HVOL: retString = "H(vol)"; break;
311  case FUNCTION_SPACE_VECTOR_HGRAD: retString = "Vector H(grad)"; break;
312  case FUNCTION_SPACE_TENSOR_HGRAD: retString = "Tensor H(grad)"; break;
313  case FUNCTION_SPACE_MAX: retString = "Max. Function space"; break;
314  default: retString = "INVALID EFunctionSpace";
315  }
316  return retString;
317  }
318 
324  inline int isValidFunctionSpace(const EFunctionSpace spaceType){
325  return ( (spaceType == FUNCTION_SPACE_HGRAD) ||
326  (spaceType == FUNCTION_SPACE_HCURL) ||
327  (spaceType == FUNCTION_SPACE_HDIV) ||
328  (spaceType == FUNCTION_SPACE_HVOL) ||
329  (spaceType == FUNCTION_SPACE_VECTOR_HGRAD) ||
330  (spaceType == FUNCTION_SPACE_TENSOR_HGRAD) );
331  }
332 
333 
334 
343  enum EDiscreteSpace
344  {
345  DISCRETE_SPACE_COMPLETE = 0, // value = 0
346  DISCRETE_SPACE_INCOMPLETE, // value = 1
347  DISCRETE_SPACE_BROKEN, // value = 2
348  DISCRETE_SPACE_MAX // value = 3
349  };
350 
351  inline std::string EDiscreteSpaceToString(EDiscreteSpace space) {
352  std::string retString;
353  switch(space) {
354  case DISCRETE_SPACE_COMPLETE: retString = "Complete"; break;
355  case DISCRETE_SPACE_INCOMPLETE: retString = "Incomplete"; break;
356  case DISCRETE_SPACE_BROKEN: retString = "Broken"; break;
357  case DISCRETE_SPACE_MAX: retString = "Max. Rec. Space"; break;
358  default: retString = "INVALID EDiscreteSpace";
359  }
360  return retString;
361  }
362 
368  inline int isValidDiscreteSpace(const EDiscreteSpace spaceType){
369  return ( (spaceType == DISCRETE_SPACE_COMPLETE) ||
370  (spaceType == DISCRETE_SPACE_INCOMPLETE) ||
371  (spaceType ==DISCRETE_SPACE_BROKEN) );
372  }
373 
377  enum EPointType
378  {
379  POINTTYPE_EQUISPACED = 0, // value = 0
380  POINTTYPE_SPECTRAL,
381  POINTTYPE_SPECTRAL_OPEN,
382  POINTTYPE_WARPBLEND
383  };
384 
385  inline std::string EPointTypeToString(EPointType pointType) {
386  std::string retString;
387  switch (pointType) {
388  case POINTTYPE_EQUISPACED:
389  retString = "Equispaced Points";
390  break;
391  case POINTTYPE_WARPBLEND:
392  retString = "WarpBlend Points";
393  break;
394  case POINTTYPE_SPECTRAL:
395  retString = "Spectral Points";
396  break;
397  case POINTTYPE_SPECTRAL_OPEN:
398  retString = "Open Spectral Points";
399  break;
400  }
401  return retString;
402  }
403 
409  inline int isValidPointType( const EPointType pointType ) {
410  return ( (pointType == POINTTYPE_EQUISPACED ) ||
411  (pointType == POINTTYPE_WARPBLEND ) );
412  }
413 
417  enum EBasis
418  {
419  BASIS_FEM_DEFAULT = 0, // value = 0
420  BASIS_FEM_HIERARCHICAL, // value = 1
421  BASIS_FEM_FIAT, // value = 2
422  BASIS_FVD_DEFAULT, // value = 3
423  BASIS_FVD_COVOLUME, // value = 4
424  BASIS_FVD_MIMETIC, // value = 5
425  BASIS_MAX // value = 6
426  };
427 
428  inline std::string EBasisToString(EBasis basis) {
429  std::string retString;
430  switch(basis) {
431  case BASIS_FEM_DEFAULT: retString = "FEM Default"; break;
432  case BASIS_FEM_HIERARCHICAL: retString = "FEM Hierarchical"; break;
433  case BASIS_FEM_FIAT: retString = "FEM FIAT"; break;
434  case BASIS_FVD_DEFAULT: retString = "FVD Default"; break;
435  case BASIS_FVD_COVOLUME: retString = "FVD Covolume"; break;
436  case BASIS_FVD_MIMETIC: retString = "FVD Mimetic"; break;
437  case BASIS_MAX: retString = "Max. Basis"; break;
438  default: retString = "INVALID EBasis";
439  }
440  return retString;
441  }
442 
448  inline int isValidBasis(const EBasis basisType){
449  return ( (basisType == BASIS_FEM_DEFAULT) ||
450  (basisType == BASIS_FEM_HIERARCHICAL) ||
451  (basisType == BASIS_FEM_FIAT) ||
452  (basisType == BASIS_FVD_DEFAULT) ||
453  (basisType == BASIS_FVD_COVOLUME) ||
454  (basisType == BASIS_FVD_MIMETIC) );
455  }
456 
457 
507 
511 
515 
519 
520  };
521 
522 
523 
528  enum ECompEngine
529  {
530  COMP_CPP = 0,
531  COMP_BLAS,
532  COMP_ENGINE_MAX
533  };
534 
535  inline std::string ECompEngineToString(ECompEngine cEngine) {
536  std::string retString;
537  switch(cEngine) {
538  case COMP_CPP: retString = "Native C++"; break;
539  case COMP_BLAS: retString = "BLAS"; break;
540  case COMP_ENGINE_MAX: retString = "Max. Comp. Engine"; break;
541  default: retString = "INVALID ECompEngine";
542  }
543  return retString;
544  }
545 
546  inline ECompEngine & operator++(ECompEngine &type) {
547  return type = static_cast<ECompEngine>(type+1);
548  }
549 
550  inline ECompEngine operator++(ECompEngine &type, int) {
551  ECompEngine oldval = type;
552  ++type;
553  return oldval;
554  }
555 
556  inline ECompEngine & operator--(ECompEngine &type) {
557  return type = static_cast<ECompEngine>(type-1);
558  }
559 
560  inline ECompEngine operator--(ECompEngine &type, int) {
561  ECompEngine oldval = type;
562  --type;
563  return oldval;
564  }
565 
566 
572  inline int isValidCompEngine(const ECompEngine compEngType){
573  return ( (compEngType == COMP_CPP) ||
574  (compEngType == COMP_BLAS) );
575  }
576 
577 } //namespace Intrepid
578 
734 #endif
#define INTREPID_MAX_DIMENSION
The maximum ambient space dimension.
Template for the cubature rules used by Intrepid. Cubature template consists of cubature points and c...
#define INTREPID_MAX_INTEGRATION_POINTS
The maximum number of integration points for direct cubature rules.
double points_[INTREPID_MAX_INTEGRATION_POINTS][INTREPID_MAX_DIMENSION]
Array with the (X,Y,Z) coordinates of the cubature points.
double weights_[INTREPID_MAX_INTEGRATION_POINTS]
Array with the associated cubature weights.
int numPoints_
Number of cubature points stored in the template.