15 #ifndef Intrepid2_ProjectedGeometry_h
16 #define Intrepid2_ProjectedGeometry_h
18 #include "Intrepid2_ScalarView.hpp"
32 template<
int spaceDim,
typename Po
intScalar,
typename DeviceType>
36 using ViewType = ScalarView< PointScalar, DeviceType>;
37 using ConstViewType = ScalarView<const PointScalar, DeviceType>;
38 using BasisPtr = Teuchos::RCP< Basis<DeviceType,PointScalar,PointScalar> >;
49 template<
class ExactGeometry,
class ExactGeometryGradient>
51 const ExactGeometry &exactGeometry,
const ExactGeometryGradient &exactGeometryGradient)
53 const ordinal_type numCells = flatCellGeometry.
extent_int(0);
55 INTREPID2_TEST_FOR_EXCEPTION(spaceDim != targetHGradBasis->getBaseCellTopology().getDimension(), std::invalid_argument,
"spaceDim must match the cell topology on which target basis is defined");
56 INTREPID2_TEST_FOR_EXCEPTION(projectedBasisNodes.rank() != 3, std::invalid_argument,
"projectedBasisNodes must have shape (C,F,D)");
57 INTREPID2_TEST_FOR_EXCEPTION(projectedBasisNodes.extent_int(0) != numCells, std::invalid_argument,
"cell counts must match in projectedBasisNodes and cellNodesToMap");
58 INTREPID2_TEST_FOR_EXCEPTION(projectedBasisNodes.extent_int(1) != targetHGradBasis->getCardinality(), std::invalid_argument,
"projectedBasisNodes must have shape (C,F,D)");
59 INTREPID2_TEST_FOR_EXCEPTION(projectedBasisNodes.extent_int(2) != spaceDim, std::invalid_argument,
"projectedBasisNodes must have shape (C,F,D)");
61 using ExecutionSpace =
typename DeviceType::execution_space;
66 ordinal_type targetQuadratureDegree(targetHGradBasis->getDegree()), targetDerivativeQuadratureDegree(targetHGradBasis->getDegree());
71 const ordinal_type numPoints = evaluationPointsRefSpace.extent(0);
72 const ordinal_type numGradPoints = evaluationGradPointsRefSpace.extent(0);
79 ViewType evaluationPoints (
"ProjectedGeometry evaluation points (value)", numCells, numPoints, spaceDim);
80 ViewType evaluationGradPoints(
"ProjectedGeometry evaluation points (gradient)", numCells, numGradPoints, spaceDim);
83 BasisPtr hgradLinearBasisForFlatGeometry = flatCellGeometry.
basisForNodes();
88 if (numGradPoints > 0)
96 auto policy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<2>>({0,0}, {numCells,numPoints});
97 auto gradPolicy = Kokkos::MDRangePolicy<ExecutionSpace,Kokkos::Rank<3>>({0,0,0},{numCells,numGradPoints,spaceDim});
99 ViewType evaluationValues (
"exact geometry values", numCells, numPoints);
100 ViewType evaluationGradients (
"exact geometry gradients", numCells, numGradPoints, spaceDim);
104 for (
int comp=0; comp<spaceDim; comp++)
106 Kokkos::parallel_for(
"evaluate geometry function for projection", policy,
107 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal) {
108 Kokkos::Array<PointScalar,spaceDim> point;
109 for (
int d=0; d<spaceDim; d++)
111 point[d] = evaluationPoints(cellOrdinal,pointOrdinal,d);
113 evaluationValues(cellOrdinal,pointOrdinal) = exactGeometry(point,comp);
123 flatCellGeometry.
setJacobian(gradPointsJacobians,evaluationGradPoints,refData);
125 Kokkos::parallel_for(
"evaluate geometry gradients for projection", gradPolicy,
126 KOKKOS_LAMBDA (
const int &cellOrdinal,
const int &pointOrdinal,
const int &d2) {
127 Kokkos::Array<PointScalar,spaceDim> point;
128 for (
int d=0; d<spaceDim; d++)
130 point[d] = evaluationGradPoints(cellOrdinal,pointOrdinal,d);
132 evaluationGradients(cellOrdinal,pointOrdinal,d2) = exactGeometryGradient(point,comp,d2);
139 transformedGradientData.storeMatVec(gradPointsJacobians,gradientData);
141 auto projectedBasisNodesForComp = Kokkos::subview(projectedBasisNodes,Kokkos::ALL(),Kokkos::ALL(),comp);
145 transformedGradientData.getUnderlyingView(),
147 targetHGradBasis.get(),
BasisPtr basisForNodes() const
H^1 Basis used in the reference-to-physical transformation. Linear for straight-edged geometry; highe...
CellGeometry provides the nodes for a set of cells; has options that support efficient definition of ...
static Data< DataScalar, DeviceType > allocateMatVecResult(const Data< DataScalar, DeviceType > &matData, const Data< DataScalar, DeviceType > &vecData, const bool transposeMatrix=false)
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...
Wrapper around a Kokkos::View that allows data that is constant or repeating in various logical dimen...
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...
Data< PointScalar, DeviceType > getJacobianRefData(const ScalarView< PointScalar, DeviceType > &points) const
Computes reference-space data for the specified points, to be used in setJacobian().
view_type getAllDerivEvalPoints(EvalPointsType type=TARGET) const
Returns all the evaluation points for basis/target derivatives in the cell.
view_type getAllEvalPoints(EvalPointsType type=TARGET) const
Returns the basis/target evaluation points in the cell.
Data< Orientation, DeviceType > getOrientations()
Returns the orientations for all cells. Calls initializeOrientations() if it has not previously been ...
Allows generation of geometry degrees of freedom based on a provided map from straight-edged mesh dom...
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 ...
Allows definition of cell geometry information, including uniform and curvilinear mesh definition...
Utility methods for Intrepid2 unit tests.
static void projectOntoHGRADBasis(ViewType projectedBasisNodes, BasisPtr targetHGradBasis, CellGeometry< PointScalar, spaceDim, DeviceType > flatCellGeometry, const ExactGeometry &exactGeometry, const ExactGeometryGradient &exactGeometryGradient)
Generate geometry degrees of freedom based on a provided map from straight-edged mesh domain to curvi...
void createHGradProjectionStruct(const BasisPtrType cellBasis, const ordinal_type targetCubDegree, const ordinal_type targetGradCubDegre)
Initialize the ProjectionStruct for HGRAD projections.
An helper class to compute the evaluation points and weights needed for performing projections...
Header file for the abstract base class Intrepid2::Basis.