Intrepid2
Intrepid2_CellGeometry.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid2 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 Kyungjoo Kim (kyukim@sandia.gov),
38 // Mauro Perego (mperego@sandia.gov), or
39 // Nate Roberts (nvrober@sandia.gov),
40 //
41 // ************************************************************************
42 // @HEADER
43 
50 #ifndef Intrepid2_CellGeometry_h
51 #define Intrepid2_CellGeometry_h
52 
53 #include "Intrepid2_Basis.hpp"
54 #include "Intrepid2_CellTools.hpp"
55 #include "Intrepid2_Data.hpp"
59 #include "Intrepid2_TensorData.hpp"
62 #include "Intrepid2_Utils.hpp"
63 #include "Intrepid2_VectorData.hpp"
64 
65 #include "Intrepid2_ScalarView.hpp"
66 
67 namespace Intrepid2
68 {
79  template<class PointScalar, int spaceDim, typename DeviceType>
81  {
82  public:
90  };
91 
94  {
102  };
103 
106  {
109  };
110 
115  KOKKOS_INLINE_FUNCTION
116  int numCellsPerGridCell(SubdivisionStrategy subdivisionStrategy) const;
117 
118  public:
126  Data<PointScalar,DeviceType> allocateJacobianDataPrivate(const ScalarView<PointScalar,DeviceType> &pointComponentView, const int &pointsPerCell, const int startCell, const int endCell) const;
127 
135  void setJacobianDataPrivate(Data<PointScalar,DeviceType> &jacobianData, const int &pointsPerCell, const Data<PointScalar,DeviceType> &refData, const int startCell, const int endCell) const;
136  protected:
137  HypercubeNodeOrdering nodeOrdering_;
138  CellGeometryType cellGeometryType_;
139  SubdivisionStrategy subdivisionStrategy_ = NO_SUBDIVISION;
140  bool affine_; // if true, each cell has constant Jacobian across the cell
141  Data<Orientation, DeviceType> orientations_; // for grid types, this could have either a single entry or one matching numCellsPerGridCell(). For other types, it has as many entries as there are cells.
142 
143  // uniform grid data -- used for UNIFORM_GRID type
144  Kokkos::Array<PointScalar,spaceDim> origin_; // point specifying a corner of the mesh
145  Kokkos::Array<PointScalar,spaceDim> domainExtents_; // how far the domain extends in each dimension
146  Kokkos::Array<int,spaceDim> gridCellCounts_; // how many grid cells wide the mesh is in each dimension
147 
148  // tensor grid data -- only used for TENSOR_GRID type
150 
151  // arbitrary cell node data, used for both higher-order and first-order
152  // (here, nodes are understood as geometry degrees of freedom)
153  ScalarView<int,DeviceType> cellToNodes_; // (C,N) -- N is the number of nodes per cell; values are global node ordinals
154  ScalarView<PointScalar,DeviceType> nodes_; // (GN,D) or (C,N,D) -- GN is the number of global nodes; (C,N,D) used only if cellToNodes_ is empty.
155  using BasisPtr = Teuchos::RCP< Basis<DeviceType,PointScalar,PointScalar> >;
156 
157  unsigned numCells_ = 0;
158  unsigned numNodesPerCell_ = 0;
159  public:
167  CellGeometry(const Kokkos::Array<PointScalar,spaceDim> &origin,
168  const Kokkos::Array<PointScalar,spaceDim> &domainExtents,
169  const Kokkos::Array<int,spaceDim> &gridCellCounts,
170  SubdivisionStrategy subdivisionStrategy = NO_SUBDIVISION,
172 
180  CellGeometry(const shards::CellTopology &cellTopo,
181  ScalarView<int,DeviceType> cellToNodes,
182  ScalarView<PointScalar,DeviceType> nodes,
183  const bool claimAffine = false,
185 
191  ScalarView<PointScalar,DeviceType> cellNodes);
192 
196  KOKKOS_INLINE_FUNCTION CellGeometry(const CellGeometry &cellGeometry);
197 
200  KOKKOS_INLINE_FUNCTION ~CellGeometry();
201 
203  KOKKOS_INLINE_FUNCTION
204  bool affine() const;
205 
212 
218  void computeCellMeasure( TensorData<PointScalar,DeviceType> &cellMeasure, const Data<PointScalar,DeviceType> & jacobianDet, const TensorData<PointScalar,DeviceType> & cubatureWeights ) const;
219 
221  BasisPtr basisForNodes() const;
222 
224  const shards::CellTopology & cellTopology() const;
225 
227  KOKKOS_INLINE_FUNCTION
228  ordinal_type cellToNode(ordinal_type cellIndex, ordinal_type cellNodeNumber) const;
229 
232  KOKKOS_INLINE_FUNCTION
233  DataVariationType cellVariationType() const;
234 
236  KOKKOS_INLINE_FUNCTION
237  int hypercubeComponentNodeNumber(int hypercubeNodeNumber, int d) const;
238 
240  void initializeOrientations();
241 
243  KOKKOS_INLINE_FUNCTION
244  size_t extent(const int& r) const;
245 
247  template <typename iType>
248  KOKKOS_INLINE_FUNCTION
249  typename std::enable_if<std::is_integral<iType>::value, int>::type
250  extent_int(const iType& r) const;
251 
253  KOKKOS_INLINE_FUNCTION
255 
257  KOKKOS_INLINE_FUNCTION
258  int numCells() const;
259 
261  KOKKOS_INLINE_FUNCTION
262  int numCellsInDimension(const int &dim) const;
263 
265  KOKKOS_INLINE_FUNCTION
266  int numNodesPerCell() const;
267 
269  KOKKOS_INLINE_FUNCTION
270  Orientation getOrientation(int &cellNumber) const;
271 
274 
279  void orientations(ScalarView<Orientation,DeviceType> orientationsView, const int &startCell = 0, const int &endCell = -1);
280 
282  KOKKOS_INLINE_FUNCTION
283  PointScalar gridCellCoordinate(const int &gridCellOrdinal, const int &localNodeNumber, const int &dim) const;
284 
286  KOKKOS_INLINE_FUNCTION
287  unsigned rank() const;
288 
290  KOKKOS_INLINE_FUNCTION
291  int gridCellNodeForSubdivisionNode(const int &gridCellOrdinal, const int &subdivisionOrdinal,
292  const int &subdivisionNodeNumber) const;
293 
295  KOKKOS_INLINE_FUNCTION
296  PointScalar subdivisionCoordinate(const int &gridCellOrdinal, const int &subdivisionOrdinal,
297  const int &subdivisionNodeNumber, const int &d) const;
298 
300  KOKKOS_INLINE_FUNCTION
301  PointScalar
302  operator()(const int& cell, const int& node, const int& dim) const;
303 
305  KOKKOS_INLINE_FUNCTION
306  int uniformJacobianModulus() const;
307 
314  Data<PointScalar,DeviceType> allocateJacobianData(const TensorPoints<PointScalar,DeviceType> &points, const int startCell=0, const int endCell=-1) const;
315 
322  Data<PointScalar,DeviceType> allocateJacobianData(const ScalarView<PointScalar,DeviceType> &points, const int startCell=0, const int endCell=-1) const;
323 
330  Data<PointScalar,DeviceType> allocateJacobianData(const int &numPoints, const int startCell=0, const int endCell=-1) const;
331 
336  Data<PointScalar,DeviceType> getJacobianRefData(const ScalarView<PointScalar,DeviceType> &points) const;
337 
343 
352  const int startCell=0, const int endCell=-1) const;
353 
361  void setJacobian(Data<PointScalar,DeviceType> &jacobianData, const ScalarView<PointScalar,DeviceType> &points, const Data<PointScalar,DeviceType> &refData,
362  const int startCell=0, const int endCell=-1) const;
363 
370  void setJacobian(Data<PointScalar,DeviceType> &jacobianData, const int &numPoints, const int startCell=0, const int endCell=-1) const;
371  };
372 } // namespace Intrepid2
373 
374 #include <Intrepid2_CellGeometryDef.hpp>
375 
376 #endif /* Intrepid2_CellGeometry_h */
void setJacobianDataPrivate(Data< PointScalar, DeviceType > &jacobianData, const int &pointsPerCell, const Data< PointScalar, DeviceType > &refData, const int startCell, const int endCell) const
Notionally-private method that provides a common interface for multiple public-facing setJacobianData...
geometry expressible in terms of vertices of the cell
BasisPtr basisForNodes() const
H^1 Basis used in the reference-to-physical transformation. Linear for straight-edged geometry; highe...
KOKKOS_INLINE_FUNCTION int numCellsPerGridCell(SubdivisionStrategy subdivisionStrategy) const
Helper method that returns the number of cells into which each grid cell will be subdivided based on ...
Data< PointScalar, DeviceType > allocateJacobianDataPrivate(const ScalarView< PointScalar, DeviceType > &pointComponentView, const int &pointsPerCell, const int startCell, const int endCell) const
Notionally-private method that provides a common interface for multiple public-facing allocateJacobia...
KOKKOS_INLINE_FUNCTION PointScalar subdivisionCoordinate(const int &gridCellOrdinal, const int &subdivisionOrdinal, const int &subdivisionNodeNumber, const int &d) const
returns coordinate in dimension d for the indicated subdivision of the indicated grid cell ...
CellGeometry provides the nodes for a set of cells; has options that support efficient definition of ...
View-like interface to tensor points; point components are stored separately; the appropriate coordin...
each grid division has the same dimensions
const shards::CellTopology & cellTopology() const
The shards CellTopology for each cell within the CellGeometry object. Note that this is always a lowe...
KOKKOS_INLINE_FUNCTION ordinal_type cellToNode(ordinal_type cellIndex, ordinal_type cellNodeNumber) const
Returns a global node number corresponding to the specified (cell, node) combination. If uniform grid (possibly subdivided), this number is computed dynamically; for more general meshes, this simply returns the result of a lookup in the cellToNodes container provided at construction.
KOKKOS_INLINE_FUNCTION PointScalar operator()(const int &cell, const int &node, const int &dim) const
Return the coordinate (weight) of the specified node. For straight-edged geometry, this is simply the physical coordinate of the vertex. For all geometries, this can be understood as a weight on the corresponding H^1 basis function used in the reference-to-physical map.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
void orientations(ScalarView< Orientation, DeviceType > orientationsView, const int &startCell=0, const int &endCell=-1)
Fills the provided container with the orientations for the specified cell range. Calls getOrientation...
View-like interface to tensor points; point components are stored separately; the appropriate coordin...
Defines the Data class, a wrapper around a Kokkos::View that allows data that is constant or repeatin...
CellGeometry(const Kokkos::Array< PointScalar, spaceDim > &origin, const Kokkos::Array< PointScalar, spaceDim > &domainExtents, const Kokkos::Array< int, spaceDim > &gridCellCounts, SubdivisionStrategy subdivisionStrategy=NO_SUBDIVISION, HypercubeNodeOrdering nodeOrdering=HYPERCUBE_NODE_ORDER_TENSOR)
Uniform grid constructor, with optional subdivision into simplices.
KOKKOS_INLINE_FUNCTION unsigned rank() const
Returns the logical rank of this container. This is always 3.
KOKKOS_INLINE_FUNCTION int hypercubeComponentNodeNumber(int hypercubeNodeNumber, int d) const
For hypercube vertex number hypercubeNodeNumber, returns the component node number in specified dimen...
Data< PointScalar, DeviceType > allocateJacobianData(const TensorPoints< PointScalar, DeviceType > &points, const int startCell=0, const int endCell=-1) const
Allocate a container into which Jacobians of the reference-to-physical mapping can be placed...
KOKKOS_INLINE_FUNCTION bool affine() const
Returns true if Jacobian is constant within each cell.
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
KOKKOS_INLINE_FUNCTION HypercubeNodeOrdering nodeOrderingForHypercubes() const
Returns the node ordering used for hypercubes.
Header function for Intrepid2::Util class and other utility functions.
Header file for the Intrepid2::Orientation class.
KOKKOS_INLINE_FUNCTION int gridCellNodeForSubdivisionNode(const int &gridCellOrdinal, const int &subdivisionOrdinal, const int &subdivisionNodeNumber) const
returns coordinate in dimension d for the indicated subdivision of the indicated grid cell ...
TensorData< PointScalar, DeviceType > allocateCellMeasure(const Data< PointScalar, DeviceType > &jacobianDet, const TensorData< PointScalar, DeviceType > &cubatureWeights) const
Allocate a TensorData object appropriate for passing to computeCellMeasure().
KOKKOS_INLINE_FUNCTION PointScalar gridCellCoordinate(const int &gridCellOrdinal, const int &localNodeNumber, const int &dim) const
returns coordinate in dimension dim of the indicated node in the indicated grid cell ...
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_integral< iType >::value, int >::type extent_int(const iType &r) const
Returns the logical extent of the container in the specified dimension as an int; the shape of CellGe...
lower-dimensional geometry that is orthogonally extruded in higher dimensions
KOKKOS_INLINE_FUNCTION int uniformJacobianModulus() const
Returns an integer indicating the number of distinct cell types vis-a-vis Jacobians.
Data< PointScalar, DeviceType > getJacobianRefData(const ScalarView< PointScalar, DeviceType > &points) const
Computes reference-space data for the specified points, to be used in setJacobian().
Orientation encoding and decoding.
Header file for the Intrepid2::OrientationTools and Intrepid2::Impl::OrientationTools classes...
geometry expressible in terms of a higher-order basis (must be specified)
Reference-space field values for a basis, designed to support typical vector-valued bases...
grid expressed as a Cartesian product of 1D grids (could be a Shishkin mesh, e.g.) ...
void initializeOrientations()
Initialize the internal orientations_ member with the orientations of each member cell...
square –&gt; four triangles, with a new vertex at center
Data< Orientation, DeviceType > getOrientations()
Returns the orientations for all cells. Calls initializeOrientations() if it has not previously been ...
KOKKOS_INLINE_FUNCTION Orientation getOrientation(int &cellNumber) const
Returns the orientation for the specified cell. Requires that initializeOrientations() has been calle...
KOKKOS_INLINE_FUNCTION DataVariationType cellVariationType() const
KOKKOS_INLINE_FUNCTION int numNodesPerCell() const
Returns the number of nodes per cell; may be more than the number of vertices in the corresponding Ce...
KOKKOS_INLINE_FUNCTION int numCellsInDimension(const int &dim) const
For uniform grid and tensor grid CellGeometry, returns the number of cells in the specified component...
void setJacobian(Data< PointScalar, DeviceType > &jacobianData, const TensorPoints< PointScalar, DeviceType > &points, const Data< PointScalar, DeviceType > &refData, const int startCell=0, const int endCell=-1) const
Compute Jacobian values for the reference-to-physical transformation, and place them in the provided ...
Structure-preserving representation of transformed basis values; reference space values and transform...
square –&gt; two triangles, with a hypotenuse of slope -1
square –&gt; two triangles, with a hypotenuse of slope 1
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
KOKKOS_INLINE_FUNCTION int numCells() const
Returns the number of cells.
KOKKOS_INLINE_FUNCTION ~CellGeometry()
Destructor.
KOKKOS_INLINE_FUNCTION size_t extent(const int &r) const
Returns the logical extent of the container in the specified dimension; the shape of CellGeometry is ...
Header file for the Intrepid2::CellTools class.
Stateless class that acts as a factory for a family of nodal bases (hypercube topologies only at this...
Header file for the abstract base class Intrepid2::Basis.
void computeCellMeasure(TensorData< PointScalar, DeviceType > &cellMeasure, const Data< PointScalar, DeviceType > &jacobianDet, const TensorData< PointScalar, DeviceType > &cubatureWeights) const
Compute cell measures that correspond to provided Jacobian determinants and.