16#ifndef Intrepid2_CellGeometryDef_h
17#define Intrepid2_CellGeometryDef_h
26 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
29 using BasisPtr = Teuchos::RCP<Intrepid2::Basis<DeviceType,PointScalar,PointScalar> >;
33 static std::map<const CellGeometryType *, shards::CellTopology> cellTopology_;
34 static std::map<const CellGeometryType *, BasisPtr> basisForNodes_;
37 static void constructorCalled(
const CellGeometryType *cellGeometry,
const shards::CellTopology &cellTopo, BasisPtr basisForNodes)
39 cellTopology_[cellGeometry] = cellTopo;
40 basisForNodes_[cellGeometry] = basisForNodes;
43 static void destructorCalled(
const CellGeometryType *cellGeometry)
45 cellTopology_.erase(cellGeometry);
46 basisForNodes_.erase(cellGeometry);
49 static BasisPtr getBasis(
const CellGeometryType *cellGeometry)
51 return basisForNodes_[cellGeometry];
54 static const shards::CellTopology & getCellTopology(
const CellGeometryType *cellGeometry)
56 return cellTopology_[cellGeometry];
61 template<
class Po
intScalar,
int spaceDim,
typename DeviceType >
typename std::map<const CellGeometry<PointScalar,spaceDim,DeviceType> *, shards::CellTopology> CellGeometryHostMembers< PointScalar,spaceDim,DeviceType>::cellTopology_;
63 template<
class Po
intScalar,
int spaceDim,
typename DeviceType >
typename std::map<const CellGeometry<PointScalar,spaceDim,DeviceType> *, Teuchos::RCP<Intrepid2::Basis<DeviceType,PointScalar,PointScalar> >> CellGeometryHostMembers< PointScalar,spaceDim,DeviceType>::basisForNodes_;
67 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
68 class CellMeasureFunctor
70 Kokkos::View<PointScalar**, DeviceType> cellMeasures_;
71 Kokkos::View<PointScalar**, DeviceType> detData_;
74 CellMeasureFunctor(Kokkos::View<PointScalar**, DeviceType> cellMeasures,
77 cellMeasures_(cellMeasures),
79 cubatureWeights_(cubatureWeights)
82 KOKKOS_INLINE_FUNCTION
void
83 operator () (
const ordinal_type cellOrdinal,
const ordinal_type pointOrdinal)
const
85 cellMeasures_(cellOrdinal,pointOrdinal) = detData_(cellOrdinal,pointOrdinal) * cubatureWeights_(pointOrdinal);
90 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
91 KOKKOS_INLINE_FUNCTION
94 nodeOrdering_(cellGeometry.nodeOrdering_),
95 cellGeometryType_(cellGeometry.cellGeometryType_),
96 subdivisionStrategy_(cellGeometry.subdivisionStrategy_),
97 affine_(cellGeometry.affine_),
98 orientations_(cellGeometry.orientations_),
99 origin_(cellGeometry.origin_),
100 domainExtents_(cellGeometry.domainExtents_),
101 gridCellCounts_(cellGeometry.gridCellCounts_),
102 tensorVertices_(cellGeometry.tensorVertices_),
103 cellToNodes_(cellGeometry.cellToNodes_),
104 nodes_(cellGeometry.nodes_),
105 numCells_(cellGeometry.numCells_),
106 numNodesPerCell_(cellGeometry.numNodesPerCell_)
109#ifndef INTREPID2_COMPILE_DEVICE_CODE
110 shards::CellTopology cellTopo = cellGeometry.
cellTopology();
113 HostMemberLookup::constructorCalled(
this, cellTopo,
basisForNodes);
117 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
118 KOKKOS_INLINE_FUNCTION
122#ifndef INTREPID2_COMPILE_DEVICE_CODE
124 HostMemberLookup::destructorCalled(
this);
128 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
129 KOKKOS_INLINE_FUNCTION
132 switch (subdivisionStrategy) {
149 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
153 ScalarView<PointScalar,DeviceType> data;
155 const int CELL_DIM = 0;
156 const int POINT_DIM = 1;
157 const int D1_DIM = 2;
158 const int D2_DIM = 3;
160 const int numCellsWorkset = (endCell == -1) ? (numCells_ - startCell) : (endCell - startCell);
162 Kokkos::Array<int,7> extents { numCellsWorkset, pointsPerCell, spaceDim, spaceDim, 1, 1, 1 };
165 int blockPlusDiagonalLastNonDiagonal = -1;
171 variationType[CELL_DIM] =
MODULAR;
172 variationType[POINT_DIM] =
CONSTANT;
173 variationType[D1_DIM] =
GENERAL;
174 variationType[D2_DIM] =
GENERAL;
185 blockPlusDiagonalLastNonDiagonal = -1;
196 const bool simplex = (spaceDim + 1 == cellToNodes_.extent_int(1));
199 variationType[CELL_DIM] =
GENERAL;
200 variationType[POINT_DIM] =
CONSTANT;
201 variationType[D1_DIM] =
GENERAL;
202 variationType[D2_DIM] =
GENERAL;
208 variationType[CELL_DIM] =
GENERAL;
209 variationType[D1_DIM] =
GENERAL;
210 variationType[D2_DIM] =
GENERAL;
214 variationType[POINT_DIM] =
CONSTANT;
219 variationType[POINT_DIM] =
GENERAL;
227 variationType[CELL_DIM] =
GENERAL;
228 variationType[POINT_DIM] =
GENERAL;
229 variationType[D1_DIM] =
GENERAL;
230 variationType[D2_DIM] =
GENERAL;
242 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
245 const int startCell,
const int endCell)
const
247 const int numCellsWorkset = (endCell == -1) ? (numCells_ - startCell) : (endCell - startCell);
256 auto dataHost = Kokkos::create_mirror_view(dataView3);
258 const int startCellType = startCell % cellTypeModulus;
259 const int endCellType = (numCellsWorkset >= cellTypeModulus) ? startCellType + cellTypeModulus : startCellType + numCellsWorkset;
260 const int gridCellOrdinal = 0;
261 for (
int cellType=startCellType; cellType<endCellType; cellType++)
263 const int subdivisionOrdinal = cellType % cellTypeModulus;
264 const int nodeZero = 0;
266 for (
int i=0; i<spaceDim; i++)
268 for (
int j=0; j<spaceDim; j++)
270 const int node = j+1;
273 dataHost(cellType,i,j) = J_ij;
278 Kokkos::deep_copy(dataView3,dataHost);
284 const auto domainExtents = domainExtents_;
285 const auto gridCellCounts = gridCellCounts_;
287 using ExecutionSpace =
typename DeviceType::execution_space;
288 auto policy = Kokkos::RangePolicy<>(ExecutionSpace(),0,spaceDim);
289 Kokkos::parallel_for(
"fill jacobian", policy, KOKKOS_LAMBDA(
const int d1)
292 const double REF_SPACE_EXTENT = 2.0;
293 dataView1(d1) = (domainExtents[d1] / REF_SPACE_EXTENT) / gridCellCounts[d1];
295 ExecutionSpace().fence();
304 const bool simplex = (spaceDim + 1 == cellToNodes_.extent_int(1));
310 auto cellToNodes = cellToNodes_;
313 using ExecutionSpace =
typename DeviceType::execution_space;
314 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<3>>({startCell,0,0},{numCellsWorkset,spaceDim,spaceDim});
316 Kokkos::parallel_for(
"compute first-order simplex Jacobians", policy,
317 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &d1,
const int &d2) {
318 const int nodeZero = 0;
319 const int node = d2+1;
320 const auto & nodeCoord = nodes(cellToNodes(cellOrdinal,node), d1);
321 const auto & nodeZeroCoord = nodes(cellToNodes(cellOrdinal,nodeZero), d1);
322 const PointScalar J_ij = nodeCoord - nodeZeroCoord;
323 dataView3(cellOrdinal,d1,d2) = (spaceDim != 1) ? J_ij : J_ij * 0.5;
337 const int onePoint = 1;
339 auto tempData =
Impl::createMatchingDynRankView(dataView3,
"CellGeometryProvider: temporary Jacobian data", numCellsWorkset, onePoint, spaceDim, spaceDim);
341 Kokkos::deep_copy(testPointView, 0.0);
345 auto tempDataSubview = Kokkos::subview(tempData, Kokkos::ALL(), 0, Kokkos::ALL(), Kokkos::ALL());
346 Kokkos::deep_copy(dataView3, tempDataSubview);
351 TEUCHOS_TEST_FOR_EXCEPTION(
basisForNodes == Teuchos::null, std::invalid_argument,
"basisForNodes must not be null");
352 TEUCHOS_TEST_FOR_EXCEPTION(dataView.size() == 0, std::invalid_argument,
"underlying view is not valid");
357 if (refData.
rank() == 3)
383 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
385 const Kokkos::Array<PointScalar,spaceDim> &domainExtents,
386 const Kokkos::Array<int,spaceDim> &gridCellCounts,
390 nodeOrdering_(nodeOrdering),
392 subdivisionStrategy_(subdivisionStrategy),
395 domainExtents_(domainExtents),
396 gridCellCounts_(gridCellCounts)
399 for (
int d=0; d<spaceDim; d++)
401 numCells_ *= gridCellCounts_[d];
405 shards::CellTopology cellTopo;
406 using BasisFamily = DerivedNodalBasisFamily<DeviceType,PointScalar,PointScalar>;
407 const int linearPolyOrder = 1;
412 numNodesPerCell_ = 1 << spaceDim;
416 cellTopo = shards::CellTopology(shards::getCellTopologyData<shards::Line<> >());
419 else if (spaceDim == 2)
421 cellTopo = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<> >());
424 else if (spaceDim == 3)
426 cellTopo = shards::CellTopology(shards::getCellTopologyData<shards::Hexahedron<> >());
432 "Classic Shards node ordering is only defined for hypercubes through space dimension 3");
443 numNodesPerCell_ = spaceDim + 1;
446 cellTopo = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<> >());
449 else if (spaceDim == 3)
451 cellTopo = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<> >());
456 INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
457 "Uniform-grid simplex subdivision is only supported in space dimensions 2 and 3");
465 if (cellTopo.getKey() == shards::Quadrilateral<>::key)
469 else if (cellTopo.getKey() == shards::Hexahedron<>::key)
476 HostMemberLookup::constructorCalled(
this, cellTopo,
basisForNodes);
482 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
484 ScalarView<int,DeviceType> cellToNodes,
485 ScalarView<PointScalar,DeviceType> nodes,
486 const bool claimAffine,
489 nodeOrdering_(nodeOrdering),
491 cellToNodes_(cellToNodes),
494 if(cellToNodes.is_allocated())
496 numCells_ = cellToNodes.extent_int(0);
497 numNodesPerCell_ = cellToNodes.extent_int(1);
498 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(numNodesPerCell_ != cellTopo.getNodeCount(), std::invalid_argument,
"cellToNodes.extent(1) does not match the cell topology node count");
502 numCells_ = nodes.extent_int(0);
503 numNodesPerCell_ = nodes.extent_int(1);
504 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(numNodesPerCell_ != cellTopo.getNodeCount(), std::invalid_argument,
"nodes.extent(1) does not match the cell topology node count");
511 const bool simplicialTopo = (cellTopo.getNodeCount() == cellTopo.getDimension() + 1);
512 affine_ = simplicialTopo;
519 using BasisFamily = DerivedNodalBasisFamily<DeviceType,PointScalar,PointScalar>;
520 const int linearPolyOrder = 1;
527 if (cellTopo.getKey() == shards::Quadrilateral<>::key)
531 else if (cellTopo.getKey() == shards::Hexahedron<>::key)
538 HostMemberLookup::constructorCalled(
this, cellTopo,
basisForNodes);
542 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
544 ScalarView<PointScalar,DeviceType> cellNodes)
550 numCells_ = cellNodes.extent_int(0);
551 numNodesPerCell_ = cellNodes.extent_int(1);
554 const bool firstOrderGeometry = (
basisForNodes->getDegree() == 1);
557 shards::CellTopology cellTopo =
basisForNodes->getBaseCellTopology();
559 if (firstOrderGeometry && (cellTopo.getNodeCount() == spaceDim + 1))
568 HostMemberLookup::constructorCalled(
this, cellTopo,
basisForNodes);
571 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
572 KOKKOS_INLINE_FUNCTION
578 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
587 INTREPID2_TEST_FOR_EXCEPTION(cubatureWeights.
rank() != 1, std::invalid_argument,
"cubatureWeights container must have shape (P)");
590 std::vector< Data<PointScalar,DeviceType> > tensorComponents(numTensorComponents);
594 const int cellExtent = jacobianDet.
extent_int(0);
597 Kokkos::Array<int,7> cellExtents{cellExtent,1,1,1,1,1,1};
599 ScalarView<PointScalar,DeviceType> detDataView (
"cell relative volumes", cellDataDim);
602 for (
int cubTensorComponent=0; cubTensorComponent<numTensorComponents-1; cubTensorComponent++)
605 const auto cubatureExtents = cubatureComponent.
getExtents();
606 const auto cubatureVariationTypes = cubatureComponent.getVariationTypes();
607 const int numPoints = cubatureComponent.getDataExtent(0);
608 ScalarView<PointScalar,DeviceType> cubatureWeightView (
"cubature component weights", numPoints);
609 const int pointComponentRank = 1;
610 tensorComponents[cubTensorComponent+1] =
Data<PointScalar,DeviceType>(cubatureWeightView,pointComponentRank,cubatureExtents,cubatureVariationTypes);
615 const int cellExtent = jacobianDet.
extent_int(0);
619 const int numPoints = cubatureWeights.
extent_int(0);
620 Kokkos::Array<int,7> extents{cellExtent,numPoints,1,1,1,1,1};
622 ScalarView<PointScalar,DeviceType> cubatureWeightView;
625 cubatureWeightView = ScalarView<PointScalar,DeviceType>(
"cell measure", cellDataDim, numPoints);
629 cubatureWeightView = ScalarView<PointScalar,DeviceType>(
"cell measure", numPoints);
631 const int cellMeasureRank = 2;
634 const bool separateFirstComponent = (numTensorComponents > 1);
638 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
648 "cellMeasure must either have a tensor component count of 1 or a tensor component count that is one higher than that of cubatureWeights");
650 INTREPID2_TEST_FOR_EXCEPTION(cubatureWeights.
rank() != 1, std::invalid_argument,
"cubatureWeights container must have shape (P)");
657 for (
int i=1; i<numTensorDimensions+1; i++)
666 const bool detCellVaries = detVaries[0] !=
CONSTANT;
667 const bool detPointVaries = detVaries[1] !=
CONSTANT;
669 if (detCellVaries && detPointVaries)
673 const int numCells = detData.extent_int(0);
674 const int numPoints = detData.extent_int(1);
675 INTREPID2_TEST_FOR_EXCEPTION(
numCells != cellMeasureData.extent_int(0), std::invalid_argument,
"cellMeasureData doesn't match jacobianDet in cell dimension");
676 INTREPID2_TEST_FOR_EXCEPTION(numPoints != cellMeasureData.extent_int(1), std::invalid_argument,
"cellMeasureData doesn't match jacobianDet in point dimension");
681 using ExecutionSpace =
typename DeviceType::execution_space;
682 Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<2>> rangePolicy({0,0},{
numCells,numPoints});
683 Kokkos::parallel_for(rangePolicy, cellMeasureFunctor);
685 else if (detCellVaries && !detPointVaries)
689 using ExecutionSpace =
typename DeviceType::execution_space;
690 Kokkos::parallel_for(
691 Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<2>>({0,0},{detData.extent_int(0),cubatureWeights.
extent_int(0)}),
692 KOKKOS_LAMBDA (
int cellOrdinal,
int pointOrdinal) {
693 cellMeasureData(cellOrdinal,pointOrdinal) = detData(cellOrdinal) * cubatureWeights(pointOrdinal);
702 using ExecutionSpace =
typename DeviceType::execution_space;
703 Kokkos::parallel_for(Kokkos::RangePolicy<ExecutionSpace>(0,cellMeasureData.extent_int(0)),
704 KOKKOS_LAMBDA (
const int &pointOrdinal) {
705 cellMeasureData(pointOrdinal) = detData(0) * cubatureWeights(pointOrdinal);
711 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
712 typename CellGeometry<PointScalar,spaceDim,DeviceType>::BasisPtr
716 return HostMemberLookup::getBasis(
this);
719 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
723 return HostMemberLookup::getCellTopology(
this);
726 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
727 KOKKOS_INLINE_FUNCTION
730 if (cellToNodes_.is_allocated())
732 return cellToNodes_(cell,node);
737 const ordinal_type gridCell = cell / numSubdivisions;
738 const ordinal_type subdivisionOrdinal = cell % numSubdivisions;
740 Kokkos::Array<ordinal_type,spaceDim> gridCellCoords;
741 ordinal_type gridCellDivided = gridCell;
742 ordinal_type numGridNodes = 1;
743 ordinal_type numGridCells = 1;
744 for (
int d=0; d<spaceDim; d++)
746 gridCellCoords[d] = gridCellDivided % gridCellCounts_[d];
747 gridCellDivided = gridCellDivided / gridCellCounts_[d];
748 numGridCells *= gridCellCounts_[d];
749 numGridNodes *= (gridCellCounts_[d] + 1);
756 const ordinal_type numInteriorNodes = ((subdivisionStrategy_ ==
FOUR_TRIANGLES) || (subdivisionStrategy_ ==
SIX_PYRAMIDS)) ? 1 : 0;
759 const ordinal_type gridNodeNumberingOffset = numInteriorNodes * numGridCells;
761 const ordinal_type numNodesPerGridCell = 1 << spaceDim;
762 if (gridCellNode >= numNodesPerGridCell)
764 const ordinal_type interiorGridNodeOffset = gridCellNode - numNodesPerGridCell;
765 return numNodesPerGridCell * gridCell + interiorGridNodeOffset;
771 ordinal_type d_index_stride = 1;
772 ordinal_type cartesianNodeNumber = 0;
773 for (
int d=0; d<spaceDim; d++)
776 cartesianNodeNumber += d_index * d_index_stride;
777 d_index_stride *= (gridCellCounts_[d] + 1);
779 return cartesianNodeNumber + gridNodeNumberingOffset;
789 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
790 KOKKOS_INLINE_FUNCTION
796 if (numSubdivisions == 1)
808 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
824 const bool simplex = (spaceDim + 1 == cellToNodes_.extent_int(1));
843 if (points.rank() == 2)
850 const int numCells = points.extent_int(0);
851 const int numPoints = points.extent_int(1);
857 for (
int cellOrdinal=0; cellOrdinal<
numCells; cellOrdinal++)
859 auto refPointsForCell = Kokkos::subview(points, cellOrdinal, Kokkos::ALL(), Kokkos::ALL());
860 basisForNodes->getValues(basisGradientsView, refPointsForCell, OPERATOR_GRAD);
867 using ExecutionSpace =
typename DeviceType::execution_space;
868 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<3>>({0,0,0},{numFields,numPoints,spaceDim});
870 Kokkos::parallel_for(
"copy basis gradients", policy,
871 KOKKOS_LAMBDA (
const int &fieldOrdinal,
const int &pointOrdinal,
const int &d) {
872 cellBasisGradientsView(cellOrdinal,fieldOrdinal,pointOrdinal,d) = basisGradientsView(fieldOrdinal,pointOrdinal,d);
874 ExecutionSpace().fence();
892 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
908 const bool simplex = (spaceDim + 1 == cellToNodes_.extent_int(1));
925 auto basisGradients =
basisForNodes->allocateBasisValues(points, OPERATOR_GRAD);
926 basisForNodes->getValues(basisGradients, points, OPERATOR_GRAD);
937 auto basisGradientsView =
Impl::createMatchingDynRankView(firstPointComponentView,
"CellGeometryProvider: temporary basisGradients", numFields, numPoints, spaceDim);
939 using ExecutionSpace =
typename DeviceType::execution_space;
940 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<3>>({0,0,0},{numFields,numPoints,spaceDim});
942 Kokkos::parallel_for(
"copy basis gradients", policy,
943 KOKKOS_LAMBDA (
const int &fieldOrdinal,
const int &pointOrdinal,
const int &d) {
944 basisGradientsView(fieldOrdinal,pointOrdinal,d) = basisGradients(fieldOrdinal,pointOrdinal,d);
946 ExecutionSpace().fence();
961 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
962 KOKKOS_INLINE_FUNCTION
971 if ((hypercubeNodeNumber % 4 == 1) || (hypercubeNodeNumber % 4 == 2))
978 if ((hypercubeNodeNumber % 4 == 2) || (hypercubeNodeNumber % 4 == 3))
985 const int nodesForPriorDimensions = 1 << d;
986 if ((hypercubeNodeNumber / nodesForPriorDimensions) % 2 == 1)
992 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
995 using HostExecSpace = Kokkos::DefaultHostExecutionSpace;
996 INTREPID2_TEST_FOR_EXCEPTION(this->
cellTopology().getCellTopologyData() ==
nullptr, std::invalid_argument,
997 "CellGeometry: orientations require a cell topology, which is not defined for space dimensions above 3");
1004 ScalarView<Orientation, DeviceType> orientationsView(
"orientations", numOrientations);
1005 auto orientationsHost = Kokkos::create_mirror_view(
typename HostExecSpace::memory_space(), orientationsView);
1014 ScalarView<PointScalar, HostExecSpace> cellNodesHost(
"cellNodesHost",numOrientations,nodesPerCell);
1016#if defined(INTREPID2_COMPILE_DEVICE_CODE)
1019 const int gridCellOrdinal = 0;
1020 auto hostPolicy = Kokkos::MDRangePolicy<HostExecSpace,Kokkos::Rank<2>>({0,0},{numSubdivisions,nodesPerCell});
1021 Kokkos::parallel_for(
"fill cellNodesHost", hostPolicy,
1022 [
this,gridCellOrdinal,cellNodesHost] (
const int &subdivisionOrdinal,
const int &nodeInCell) {
1024 cellNodesHost(subdivisionOrdinal,nodeInCell) = node;
1033 auto cellNodesHost = Kokkos::create_mirror_view_and_copy(
typename HostExecSpace::memory_space(), cellToNodes_);
1036 Kokkos::deep_copy(orientationsView,orientationsHost);
1038 const int orientationsRank = 1;
1039 const Kokkos::Array<int,7> orientationExtents {
static_cast<int>(numCells_),1,1,1,1,1,1};
1044 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1045 KOKKOS_INLINE_FUNCTION
1053 return numNodesPerCell_;
1065 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1066 template <
typename iType>
1067 KOKKOS_INLINE_FUNCTION
1068 typename std::enable_if<std::is_integral<iType>::value,
int>::type
1071 return static_cast<int>(
extent(r));
1074 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1075 KOKKOS_INLINE_FUNCTION
1079 return nodeOrdering_;
1082 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1083 KOKKOS_INLINE_FUNCTION
1089 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1090 KOKKOS_INLINE_FUNCTION
1095 return gridCellCounts_[dim];
1099 return tensorVertices_.extent_int(dim);
1107 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1108 KOKKOS_INLINE_FUNCTION
1111 return numNodesPerCell_;
1114 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1115 KOKKOS_INLINE_FUNCTION
1119 return orientations_(cellNumber);
1122 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1125 if (!orientations_.isValid())
1129 return orientations_;
1132 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1133 KOKKOS_INLINE_FUNCTION
1137 int cellCountForPriorDimensions = 1;
1138 for (
int d=0; d<dim; d++)
1142 const int componentGridCellOrdinal = (gridCellOrdinal / cellCountForPriorDimensions) %
numCellsInDimension(dim);
1143 const int vertexOrdinal = componentGridCellOrdinal + componentNode;
1146 return origin_[dim] + (vertexOrdinal * domainExtents_[dim]) / gridCellCounts_[dim];
1150 Kokkos::Array<int,spaceDim> pointOrdinalComponents;
1151 for (
int d=0; d<spaceDim; d++)
1153 pointOrdinalComponents[d] = 0;
1155 pointOrdinalComponents[dim] = vertexOrdinal;
1156 return tensorVertices_(pointOrdinalComponents,dim);
1165 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1166 KOKKOS_INLINE_FUNCTION
1172 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1173 KOKKOS_INLINE_FUNCTION
1175 const int &subdivisionNodeNumber)
const
1178 switch (subdivisionStrategy_)
1181 return subdivisionNodeNumber;
1186 Kokkos::Array<int,3> nodeLookup;
1189 if (subdivisionOrdinal == 0)
1192 nodeLookup = {0,1,2};
1194 else if (subdivisionOrdinal == 1)
1199 nodeLookup = {2,3,0};
1208 if (subdivisionOrdinal == 0)
1214 nodeLookup = {3,0,1};
1216 else if (subdivisionOrdinal == 1)
1221 nodeLookup = {2,3,0};
1237 if (subdivisionNodeNumber == 1)
1244 nodeLookup = {(subdivisionOrdinal + 1) % 4, -1, subdivisionOrdinal};
1247 const int gridCellNodeNumber = nodeLookup[subdivisionNodeNumber];
1248 return gridCellNodeNumber;
1253 Kokkos::Array<int,4> nodeLookup;
1284 switch (subdivisionOrdinal) {
1286 nodeLookup = {1,3,4,6};
1289 nodeLookup = {0,1,3,4};
1292 nodeLookup = {1,2,3,6};
1295 nodeLookup = {1,4,5,6};
1298 nodeLookup = {3,4,6,7};
1309 const int gridCellNodeNumber = nodeLookup[subdivisionNodeNumber];
1310 return gridCellNodeNumber;
1314 Kokkos::Array<int,5> nodeLookup;
1318 switch (subdivisionOrdinal)
1321 nodeLookup = {0,1,2,3,8};
1324 nodeLookup = {4,5,6,7,8};
1327 nodeLookup = {0,1,5,4,8};
1330 nodeLookup = {3,2,6,7,8};
1333 nodeLookup = {1,2,6,5,8};
1336 nodeLookup = {0,3,7,4,8};
1344 switch (subdivisionOrdinal)
1347 nodeLookup = {0,1,3,2,8};
1350 nodeLookup = {4,5,7,6,8};
1353 nodeLookup = {0,1,5,4,8};
1356 nodeLookup = {2,3,7,6,8};
1359 nodeLookup = {1,3,7,5,8};
1362 nodeLookup = {0,2,6,4,8};
1368 const int gridCellNodeNumber = nodeLookup[subdivisionNodeNumber];
1369 return gridCellNodeNumber;
1378 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1379 KOKKOS_INLINE_FUNCTION
1381 const int &subdivisionNodeNumber,
const int &d)
const
1388 if (gridCellNode == 4)
1392 const int gridVertex0 = 0;
1393 const int gridVertex1 = (d == 0) ? 1 : 3;
1400 if (gridCellNode == 8)
1404 const int gridVertex0 = 0;
1412 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1413 KOKKOS_INLINE_FUNCTION
1419 if (numSubdivisions == 1)
1426 const int subdivisionOrdinal = cell % numSubdivisions;
1427 const int gridCellOrdinal = cell / numSubdivisions;
1433#ifdef HAVE_INTREPID2_DEBUG
1441 if (cellToNodes_.is_allocated())
1443 const int nodeNumber = cellToNodes_(cell,node);
1444 return nodes_(nodeNumber,dim);
1448 return nodes_(cell,node,dim);
1453 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1457 const int numCellsWorkset = (endCell == -1) ? (numCells_ - startCell) : (endCell - startCell);
1459 using ExecutionSpace =
typename DeviceType::execution_space;
1460 auto policy = Kokkos::RangePolicy<ExecutionSpace>(ExecutionSpace(),0,numCellsWorkset);
1461 Kokkos::parallel_for(
"copy orientations", policy, KOKKOS_LAMBDA(
const int cellOrdinal)
1463 orientationsView(cellOrdinal) = orientationsData(cellOrdinal);
1465 ExecutionSpace().fence();
1468 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1469 KOKKOS_INLINE_FUNCTION
1482 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1485 const int pointsPerCell = points.
extent_int(0);
1489 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1493 const int pointDimension = (points.rank() == 3) ? 1 : 0;
1494 const int pointsPerCell = points.
extent_int(pointDimension);
1498 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1503 ScalarView<PointScalar,DeviceType> emptyPoints;
1507 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1511 const int pointsPerCell = points.
extent_int(0);
1515 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
1520 const int pointDimension = (points.rank() == 3) ? 1 : 0;
1521 const int pointsPerCell = points.extent_int(pointDimension);
1525 template<
class Po
intScalar,
int spaceDim,
typename DeviceType>
@ GENERAL
arbitrary variation
@ BLOCK_PLUS_DIAGONAL
one of two dimensions in a matrix; bottom-right part of matrix is diagonal
@ MODULAR
varies according to modulus of the index
static BasisFamily::BasisPtr getHypercubeBasis_HGRAD(int polyOrder, int spaceDim, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic HGRAD bases on a hypercube for the given family. Note that this will ret...
static BasisFamily::BasisPtr getBasis(const shards::CellTopology &cellTopo, Intrepid2::EFunctionSpace fs, int polyOrder, const EPointType pointType=POINTTYPE_DEFAULT)
Factory method for isotropic bases in the given family on the specified cell topology.
DeduceDynRankView< InViewType >::type createMatchingDynRankView(const InViewType &view, const CtorProp &prop, const Dims... dims)
Creates and returns a view that matches the value_type of the provided view The output view type is d...
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
Implementation of the default H(grad)-compatible FEM basis of degree 1 on Hexahedron cell.
Implementation of the default H(grad)-compatible FEM basis of degree 1 on Quadrilateral cell.
An abstract base class that defines interface for concrete basis implementations for Finite Element (...
CellGeometry provides the nodes for a set of cells; has options that support efficient definition of ...
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.
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...
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 ...
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 ...
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 ...
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 int numCells() const
Returns the number of cells.
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...
Data< PointScalar, DeviceType > getJacobianRefData(const ScalarView< PointScalar, DeviceType > &points) const
Computes reference-space data for the specified points, to be used in setJacobian().
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...
KOKKOS_INLINE_FUNCTION Orientation getOrientation(int &cellNumber) const
Returns the orientation for the specified cell. Requires that initializeOrientations() has been calle...
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
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.
void initializeOrientations()
Initialize the internal orientations_ member with the orientations of each member cell....
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 DataVariationType cellVariationType() const
KOKKOS_INLINE_FUNCTION int hypercubeComponentNodeNumber(int hypercubeNodeNumber, int d) const
For hypercube vertex number hypercubeNodeNumber, returns the component node number in specified dimen...
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
@ TWO_TRIANGLES_RIGHT
square --> two triangles, with a hypotenuse of slope 1
@ SIX_PYRAMIDS
cube --> six pyramids
@ NO_SUBDIVISION
no subdivision
@ SIX_TETRAHEDRA
cube --> six tetrahedra
@ FIVE_TETRAHEDRA
cube --> five tetrahedra
@ TWO_TRIANGLES_LEFT
square --> two triangles, with a hypotenuse of slope -1
@ FOUR_TRIANGLES
square --> four triangles, with a new vertex at center
KOKKOS_INLINE_FUNCTION unsigned rank() const
Returns the logical rank of this container. This is always 3.
@ UNIFORM_GRID
each grid division has the same dimensions
@ FIRST_ORDER
geometry expressible in terms of vertices of the cell
@ HIGHER_ORDER
geometry expressible in terms of a higher-order basis (must be specified)
@ TENSOR_GRID
grid expressed as a Cartesian product of 1D grids (could be a Shishkin mesh, e.g.)
KOKKOS_INLINE_FUNCTION bool affine() const
Returns true if Jacobian is constant within each cell.
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...
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.
@ HYPERCUBE_NODE_ORDER_CLASSIC_SHARDS
classic shards ordering
@ HYPERCUBE_NODE_ORDER_TENSOR
a more natural tensor ordering
KOKKOS_INLINE_FUNCTION ~CellGeometry()
Destructor.
KOKKOS_INLINE_FUNCTION HypercubeNodeOrdering nodeOrderingForHypercubes() const
Returns the node ordering used for hypercubes.
Data< Orientation, DeviceType > getOrientations()
Returns the orientations for all cells. Calls initializeOrientations() if it has not previously been ...
KOKKOS_INLINE_FUNCTION int uniformJacobianModulus() const
Returns an integer indicating the number of distinct cell types vis-a-vis Jacobians.
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
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 PointScalar operator()(const int &cell, const int &node, const int &dim) const
Return the coordinate (weight) of the specified node. For straight-edged geometry,...
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....
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...
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
KOKKOS_INLINE_FUNCTION enable_if_t< rank==1, const Kokkos::View< typename RankExpander< DataScalar, rank >::value_type, DeviceType > & > getUnderlyingView() const
Returns the underlying view. Throws an exception if the underlying view is not rank 1.
KOKKOS_INLINE_FUNCTION int extent_int(const int &r) const
Returns the logical extent in the specified dimension.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar **, DeviceType > & getUnderlyingView2() const
returns the View that stores the unique data. For rank-2 underlying containers.
KOKKOS_INLINE_FUNCTION constexpr bool isValid() const
returns true for containers that have data; false for those that don't (namely, those that have been ...
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar ***, DeviceType > & getUnderlyingView3() const
returns the View that stores the unique data. For rank-3 underlying containers.
KOKKOS_INLINE_FUNCTION const Kokkos::Array< DataVariationType, 7 > & getVariationTypes() const
Returns an array with the variation types in each logical dimension.
KOKKOS_INLINE_FUNCTION const Kokkos::View< DataScalar *, DeviceType > & getUnderlyingView1() const
returns the View that stores the unique data. For rank-1 underlying containers.
KOKKOS_INLINE_FUNCTION int getDataExtent(const ordinal_type &d) const
returns the true extent of the data corresponding to the logical dimension provided; if the data does...
KOKKOS_INLINE_FUNCTION Kokkos::Array< int, 7 > getExtents() const
Returns an array containing the logical extents in each dimension.
KOKKOS_INLINE_FUNCTION unsigned rank() const
Returns the logical rank of the Data container.
Store host-only "members" of CellGeometry using a static map indexed on the CellGeometry pointer....
Functor for full (C,P) Jacobian determinant container. CUDA compiler issues led us to avoid lambdas f...
Orientation encoding and decoding.
View-like interface to tensor data; tensor components are stored separately and multiplied together a...
KOKKOS_INLINE_FUNCTION const Data< Scalar, DeviceType > & getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.
KOKKOS_INLINE_FUNCTION ordinal_type rank() const
Returns the rank of the container.
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_integral< iType >::value, ordinal_type >::type extent_int(const iType &d) const
Returns the logical extent in the requested dimension.
KOKKOS_INLINE_FUNCTION ordinal_type numTensorComponents() const
Return the number of tensorial components.
View-like interface to tensor points; point components are stored separately; the appropriate coordin...
KOKKOS_INLINE_FUNCTION ScalarView< PointScalar, DeviceType > getTensorComponent(const ordinal_type &r) const
Returns the requested tensor component.
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_integral< iType >::value, int >::type extent_int(const iType &r) const
Returns the logical extent in the requested dimension.