Intrepid
Intrepid_CellTools.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_CELLTOOLS_HPP
50 #define INTREPID_CELLTOOLS_HPP
51 
52 
55 #include "Intrepid_ConfigDefs.hpp"
56 #include "Intrepid_Types.hpp"
57 #include "Intrepid_Utils.hpp"
58 #include "Intrepid_Basis.hpp"
60 #include "Intrepid_HGRAD_QUAD_C1_FEM.hpp"
61 #include "Intrepid_HGRAD_TET_C1_FEM.hpp"
62 #include "Intrepid_HGRAD_WEDGE_C1_FEM.hpp"
63 #include "Intrepid_HGRAD_HEX_C1_FEM.hpp"
64 
66 
68 #include "Intrepid_HGRAD_QUAD_C2_FEM.hpp"
73 
74 #include "Shards_CellTopology.hpp"
75 #include "Shards_BasicTopologies.hpp"
76 
77 #include "Teuchos_Assert.hpp"
78 #include "Teuchos_RCP.hpp"
79 
80 namespace Intrepid {
81 
82 
83  //============================================================================================//
84  // //
85  // CellTools //
86  // //
87  //============================================================================================//
88 
97 template<class Scalar>
98 class CellTools {
99 private:
100 
101  //============================================================================================//
102  // //
103  // Parametrization coefficients of edges and faces of reference cells //
104  // //
105  //============================================================================================//
106 
107 
120  static const FieldContainer<double>& getSubcellParametrization(const int subcellDim,
121  const shards::CellTopology& parentCell);
122 
123 
124 
164  static void setSubcellParametrization(FieldContainer<double>& subcellParametrization,
165  const int subcellDim,
166  const shards::CellTopology& parentCell);
167 
168  //============================================================================================//
169  // //
170  // Validation of input/output arguments for CellTools methods //
171  // //
172  //============================================================================================//
173 
181  template<class ArrayJac, class ArrayPoint, class ArrayCell>
182  static void validateArguments_setJacobian(const ArrayJac & jacobian,
183  const ArrayPoint & points,
184  const ArrayCell & cellWorkset,
185  const int & whichCell,
186  const shards::CellTopology & cellTopo);
187 
188 
189 
194  template<class ArrayJacInv, class ArrayJac>
195  static void validateArguments_setJacobianInv(const ArrayJacInv & jacobianInv,
196  const ArrayJac & jacobian);
197 
198 
199 
204  template<class ArrayJacDet, class ArrayJac>
205  static void validateArguments_setJacobianDetArgs(const ArrayJacDet & jacobianDet,
206  const ArrayJac & jacobian);
207 
208 
209 
217  template<class ArrayPhysPoint, class ArrayRefPoint, class ArrayCell>
218  static void validateArguments_mapToPhysicalFrame(const ArrayPhysPoint & physPoints,
219  const ArrayRefPoint & refPoints,
220  const ArrayCell & cellWorkset,
221  const shards::CellTopology & cellTopo,
222  const int& whichCell);
223 
224 
225 
233  template<class ArrayRefPoint, class ArrayPhysPoint, class ArrayCell>
234  static void validateArguments_mapToReferenceFrame(const ArrayRefPoint & refPoints,
235  const ArrayPhysPoint & physPoints,
236  const ArrayCell & cellWorkset,
237  const shards::CellTopology & cellTopo,
238  const int& whichCell);
239 
240 
241 
250  template<class ArrayRefPoint, class ArrayInitGuess, class ArrayPhysPoint, class ArrayCell>
251  static void validateArguments_mapToReferenceFrame(const ArrayRefPoint & refPoints,
252  const ArrayInitGuess & initGuess,
253  const ArrayPhysPoint & physPoints,
254  const ArrayCell & cellWorkset,
255  const shards::CellTopology & cellTopo,
256  const int& whichCell);
257 
258 
259 
267  template<class ArrayIncl, class ArrayPoint, class ArrayCell>
268  static void validateArguments_checkPointwiseInclusion(ArrayIncl & inCell,
269  const ArrayPoint & physPoints,
270  const ArrayCell & cellWorkset,
271  const int & whichCell,
272  const shards::CellTopology & cell);
273 public:
274 
277  CellTools(){ };
278 
279 
283 
284  //============================================================================================//
285  // //
286  // Jacobian, inverse Jacobian and Jacobian determinant //
287  // //
288  //============================================================================================//
289 
337  template<class ArrayJac, class ArrayPoint, class ArrayCell>
338  static void setJacobian(ArrayJac & jacobian,
339  const ArrayPoint & points,
340  const ArrayCell & cellWorkset,
341  const shards::CellTopology & cellTopo,
342  const int & whichCell = -1);
343 
344 
345 
358  template<class ArrayJacInv, class ArrayJac>
359  static void setJacobianInv(ArrayJacInv & jacobianInv,
360  const ArrayJac & jacobian);
361 
362 
363 
376  template<class ArrayJacDet, class ArrayJac>
377  static void setJacobianDet(ArrayJacDet & jacobianDet,
378  const ArrayJac & jacobian);
379 
380  //============================================================================================//
381  // //
382  // Reference-to-physical frame mapping and its inverse //
383  // //
384  //============================================================================================//
385 
441  template<class ArrayPhysPoint, class ArrayRefPoint, class ArrayCell>
442  static void mapToPhysicalFrame(ArrayPhysPoint & physPoints,
443  const ArrayRefPoint & refPoints,
444  const ArrayCell & cellWorkset,
445  const shards::CellTopology & cellTopo,
446  const int & whichCell = -1);
447 
448 
449 
508  template<class ArrayRefPoint, class ArrayPhysPoint, class ArrayCell>
509  static void mapToReferenceFrame(ArrayRefPoint & refPoints,
510  const ArrayPhysPoint & physPoints,
511  const ArrayCell & cellWorkset,
512  const shards::CellTopology & cellTopo,
513  const int & whichCell = -1);
514 
515 
516 
562  template<class ArrayRefPoint, class ArrayInitGuess, class ArrayPhysPoint, class ArrayCell>
563  static void mapToReferenceFrameInitGuess(ArrayRefPoint & refPoints,
564  const ArrayInitGuess & initGuess,
565  const ArrayPhysPoint & physPoints,
566  const ArrayCell & cellWorkset,
567  const shards::CellTopology & cellTopo,
568  const int & whichCell = -1);
569 
570 
571 
622  template<class ArraySubcellPoint, class ArrayParamPoint>
623  static void mapToReferenceSubcell(ArraySubcellPoint & refSubcellPoints,
624  const ArrayParamPoint & paramPoints,
625  const int subcellDim,
626  const int subcellOrd,
627  const shards::CellTopology & parentCell);
628 
629 
630 
656  template<class ArrayEdgeTangent>
657  static void getReferenceEdgeTangent(ArrayEdgeTangent & refEdgeTangent,
658  const int & edgeOrd,
659  const shards::CellTopology & parentCell);
660 
661 
662 
699  template<class ArrayFaceTangentU, class ArrayFaceTangentV>
700  static void getReferenceFaceTangents(ArrayFaceTangentU & refFaceTanU,
701  ArrayFaceTangentV & refFaceTanV,
702  const int & faceOrd,
703  const shards::CellTopology & parentCell);
704 
705 
706 
769  template<class ArraySideNormal>
770  static void getReferenceSideNormal(ArraySideNormal & refSideNormal,
771  const int & sideOrd,
772  const shards::CellTopology & parentCell);
773 
774 
775 
814  template<class ArrayFaceNormal>
815  static void getReferenceFaceNormal(ArrayFaceNormal & refFaceNormal,
816  const int & faceOrd,
817  const shards::CellTopology & parentCell);
818 
819 
820 
850  template<class ArrayEdgeTangent, class ArrayJac>
851  static void getPhysicalEdgeTangents(ArrayEdgeTangent & edgeTangents,
852  const ArrayJac & worksetJacobians,
853  const int & worksetEdgeOrd,
854  const shards::CellTopology & parentCell);
855 
856 
857 
897  template<class ArrayFaceTangentU, class ArrayFaceTangentV, class ArrayJac>
898  static void getPhysicalFaceTangents(ArrayFaceTangentU & faceTanU,
899  ArrayFaceTangentV & faceTanV,
900  const ArrayJac & worksetJacobians,
901  const int & worksetFaceOrd,
902  const shards::CellTopology & parentCell);
903 
904 
905 
966  template<class ArraySideNormal, class ArrayJac>
967  static void getPhysicalSideNormals(ArraySideNormal & sideNormals,
968  const ArrayJac & worksetJacobians,
969  const int & worksetSideOrd,
970  const shards::CellTopology & parentCell);
971 
972 
973 
1012  template<class ArrayFaceNormal, class ArrayJac>
1013  static void getPhysicalFaceNormals(ArrayFaceNormal & faceNormals,
1014  const ArrayJac & worksetJacobians,
1015  const int & worksetFaceOrd,
1016  const shards::CellTopology & parentCell);
1017 
1018 
1019  //============================================================================================//
1020  // //
1021  // Inclusion tests //
1022  // //
1023  //============================================================================================//
1024 
1035  static int checkPointInclusion(const Scalar* point,
1036  const int pointDim,
1037  const shards::CellTopology & cellTopo,
1038  const double & threshold = INTREPID_THRESHOLD);
1039 
1040 
1041 
1054  template<class ArrayPoint>
1055  static int checkPointsetInclusion(const ArrayPoint & points,
1056  const shards::CellTopology & cellTopo,
1057  const double & threshold = INTREPID_THRESHOLD);
1058 
1059 
1060 
1087  template<class ArrayIncl, class ArrayPoint>
1088  static void checkPointwiseInclusion(ArrayIncl & inRefCell,
1089  const ArrayPoint & points,
1090  const shards::CellTopology & cellTopo,
1091  const double & threshold = INTREPID_THRESHOLD);
1092 
1093 
1094 
1130  template<class ArrayIncl, class ArrayPoint, class ArrayCell>
1131  static void checkPointwiseInclusion(ArrayIncl & inCell,
1132  const ArrayPoint & points,
1133  const ArrayCell & cellWorkset,
1134  const shards::CellTopology & cell,
1135  const int & whichCell = -1,
1136  const double & threshold = INTREPID_THRESHOLD);
1137 
1138 
1139 
1150  static const double* getReferenceVertex(const shards::CellTopology& cell,
1151  const int vertexOrd);
1152 
1153 
1154 
1169  template<class ArraySubcellVert>
1170  static void getReferenceSubcellVertices(ArraySubcellVert & subcellVertices,
1171  const int subcellDim,
1172  const int subcellOrd,
1173  const shards::CellTopology& parentCell);
1174 
1175 
1176 
1192  static const double* getReferenceNode(const shards::CellTopology& cell,
1193  const int nodeOrd);
1194 
1195 
1196 
1210  template<class ArraySubcellNode>
1211  static void getReferenceSubcellNodes(ArraySubcellNode& subcellNodes,
1212  const int subcellDim,
1213  const int subcellOrd,
1214  const shards::CellTopology& parentCell);
1215 
1216 
1217 
1223  static int hasReferenceCell(const shards::CellTopology & cellTopo);
1224 
1225 
1226 
1227  //============================================================================================//
1228  // //
1229  // Debug //
1230  // //
1231  //============================================================================================//
1232 
1233 
1239  static void printSubcellVertices(const int subcellDim,
1240  const int subcellOrd,
1241  const shards::CellTopology & parentCell);
1242 
1243 
1244 
1248  template<class ArrayCell>
1249  static void printWorksetSubcell(const ArrayCell & cellWorkset,
1250  const shards::CellTopology & parentCell,
1251  const int& pCellOrd,
1252  const int& subcellDim,
1253  const int& subcellOrd,
1254  const int& fieldWidth = 3);
1255 
1256  }; // class CellTools
1257 
1258 } // namespace Intrepid
1259 
1260 // include templated function definitions
1261 
1262 #include "Intrepid_CellToolsDef.hpp"
1263 
1264 #endif
1265 
1266 /***************************************************************************************************
1267  ** **
1268  ** D O C U M E N T A T I O N P A G E S **
1269  ** **
1270  **************************************************************************************************/
1271 
static const double * getReferenceNode(const shards::CellTopology &cell, const int nodeOrd)
Retrieves the Cartesian coordinates of a reference cell node.
static void validateArguments_mapToReferenceFrame(const ArrayRefPoint &refPoints, const ArrayPhysPoint &physPoints, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell)
Validates arguments to Intrepid::CellTools::mapToReferenceFrame with default initial guess...
static void getReferenceEdgeTangent(ArrayEdgeTangent &refEdgeTangent, const int &edgeOrd, const shards::CellTopology &parentCell)
Computes constant tangent vectors to edges of 2D or 3D reference cells.
static void mapToReferenceSubcell(ArraySubcellPoint &refSubcellPoints, const ArrayParamPoint &paramPoints, const int subcellDim, const int subcellOrd, const shards::CellTopology &parentCell)
Computes parameterization maps of 1- and 2-subcells of reference cells.
Definition file for the Intrepid::CellTools class.
static void getPhysicalFaceNormals(ArrayFaceNormal &faceNormals, const ArrayJac &worksetJacobians, const int &worksetFaceOrd, const shards::CellTopology &parentCell)
Computes non-normalized normal vectors to physical faces in a face workset ; (see Subcell worksets fo...
static void setJacobianInv(ArrayJacInv &jacobianInv, const ArrayJac &jacobian)
Computes the inverse of the Jacobian matrix DF of the reference-to-physical frame map F...
static void getPhysicalEdgeTangents(ArrayEdgeTangent &edgeTangents, const ArrayJac &worksetJacobians, const int &worksetEdgeOrd, const shards::CellTopology &parentCell)
Computes non-normalized tangent vectors to physical edges in an edge workset ; (see Subcell worksets ...
static void mapToReferenceFrame(ArrayRefPoint &refPoints, const ArrayPhysPoint &physPoints, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell=-1)
Computes , the inverse of the reference-to-physical frame map using a default initial guess...
static void getReferenceSideNormal(ArraySideNormal &refSideNormal, const int &sideOrd, const shards::CellTopology &parentCell)
Computes constant normal vectors to sides of 2D or 3D reference cells.
static void getReferenceFaceTangents(ArrayFaceTangentU &refFaceTanU, ArrayFaceTangentV &refFaceTanV, const int &faceOrd, const shards::CellTopology &parentCell)
Computes pairs of constant tangent vectors to faces of a 3D reference cells.
static void printSubcellVertices(const int subcellDim, const int subcellOrd, const shards::CellTopology &parentCell)
Prints the reference space coordinates of the vertices of the specified subcell.
Header file for the Intrepid::HGRAD_TRI_C1_FEM class.
static void getReferenceFaceNormal(ArrayFaceNormal &refFaceNormal, const int &faceOrd, const shards::CellTopology &parentCell)
Computes constant normal vectors to faces of 3D reference cell.
Header file for utility class to provide multidimensional containers.
Contains definitions of custom data types in Intrepid.
static void mapToPhysicalFrame(ArrayPhysPoint &physPoints, const ArrayRefPoint &refPoints, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell=-1)
Computes F, the reference-to-physical frame map.
Header file for the Intrepid::HGRAD_TET_C2_FEM class.
static void getReferenceSubcellVertices(ArraySubcellVert &subcellVertices, const int subcellDim, const int subcellOrd, const shards::CellTopology &parentCell)
Retrieves the Cartesian coordinates of all vertices of a reference subcell.
static void getPhysicalSideNormals(ArraySideNormal &sideNormals, const ArrayJac &worksetJacobians, const int &worksetSideOrd, const shards::CellTopology &parentCell)
Computes non-normalized normal vectors to physical sides in a side workset .
static int checkPointsetInclusion(const ArrayPoint &points, const shards::CellTopology &cellTopo, const double &threshold=INTREPID_THRESHOLD)
Checks if a set of points belongs to a reference cell.
static int hasReferenceCell(const shards::CellTopology &cellTopo)
Checks if a cell topology has reference cell.
Header file for the Intrepid::HGRAD_TRI_C2_FEM class.
Intrepid utilities.
Header file for the abstract base class Intrepid::Basis.
Header file for the Intrepid::G_WEDGE_C2_FEM class.
static void mapToReferenceFrameInitGuess(ArrayRefPoint &refPoints, const ArrayInitGuess &initGuess, const ArrayPhysPoint &physPoints, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell=-1)
Computation of , the inverse of the reference-to-physical frame map using user-supplied initial guess...
static void setSubcellParametrization(FieldContainer< double > &subcellParametrization, const int subcellDim, const shards::CellTopology &parentCell)
Defines orientation-preserving parametrizations of reference edges and faces of cell topologies with ...
static void getReferenceSubcellNodes(ArraySubcellNode &subcellNodes, const int subcellDim, const int subcellOrd, const shards::CellTopology &parentCell)
Retrieves the Cartesian coordinates of all nodes of a reference subcell.
static int checkPointInclusion(const Scalar *point, const int pointDim, const shards::CellTopology &cellTopo, const double &threshold=INTREPID_THRESHOLD)
Checks if a point belongs to a reference cell.
static const double * getReferenceVertex(const shards::CellTopology &cell, const int vertexOrd)
Retrieves the Cartesian coordinates of a reference cell vertex.
static void printWorksetSubcell(const ArrayCell &cellWorkset, const shards::CellTopology &parentCell, const int &pCellOrd, const int &subcellDim, const int &subcellOrd, const int &fieldWidth=3)
Prints the nodes of a subcell from a cell workset.
static void validateArguments_checkPointwiseInclusion(ArrayIncl &inCell, const ArrayPoint &physPoints, const ArrayCell &cellWorkset, const int &whichCell, const shards::CellTopology &cell)
Validates arguments to Intrepid::CellTools::checkPointwiseInclusion.
static void validateArguments_setJacobianDetArgs(const ArrayJacDet &jacobianDet, const ArrayJac &jacobian)
Validates arguments to Intrepid::CellTools::setJacobianDet.
Header file for classes providing basic linear algebra functionality in 1D, 2D and 3D...
Header file for the Intrepid::HGRAD_HEX_C2_FEM class.
static void validateArguments_setJacobianInv(const ArrayJacInv &jacobianInv, const ArrayJac &jacobian)
Validates arguments to Intrepid::CellTools::setJacobianInv.
Header file for the Intrepid::HGRAD_TET_COMP12_FEM class.
static void validateArguments_mapToPhysicalFrame(const ArrayPhysPoint &physPoints, const ArrayRefPoint &refPoints, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell)
Validates arguments to Intrepid::CellTools::mapToPhysicalFrame.
static void checkPointwiseInclusion(ArrayIncl &inRefCell, const ArrayPoint &points, const shards::CellTopology &cellTopo, const double &threshold=INTREPID_THRESHOLD)
Checks every point in a set for inclusion in a reference cell.
static void validateArguments_setJacobian(const ArrayJac &jacobian, const ArrayPoint &points, const ArrayCell &cellWorkset, const int &whichCell, const shards::CellTopology &cellTopo)
Validates arguments to Intrepid::CellTools::setJacobian.
static void setJacobian(ArrayJac &jacobian, const ArrayPoint &points, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell=-1)
Computes the Jacobian matrix DF of the reference-to-physical frame map F.
static const FieldContainer< double > & getSubcellParametrization(const int subcellDim, const shards::CellTopology &parentCell)
Returns array with the coefficients of the parametrization maps for the edges or faces of a reference...
A stateless class for operations on cell data. Provides methods for:
static void setJacobianDet(ArrayJacDet &jacobianDet, const ArrayJac &jacobian)
Computes the determinant of the Jacobian matrix DF of the reference-to-physical frame map F...
CellTools()
Default constructor.
Header file for the Intrepid::HGRAD_LINE_C1_FEM class.
static void getPhysicalFaceTangents(ArrayFaceTangentU &faceTanU, ArrayFaceTangentV &faceTanV, const ArrayJac &worksetJacobians, const int &worksetFaceOrd, const shards::CellTopology &parentCell)
Computes non-normalized tangent vector pairs to physical faces in a face workset ; (see Subcell works...