48 #ifndef __INTREPID2_ORIENTATIONTOOLS_DEF_MODIFY_BASIS_HPP__ 49 #define __INTREPID2_ORIENTATIONTOOLS_DEF_MODIFY_BASIS_HPP__ 52 #if defined (__clang__) && !defined (__INTEL_COMPILER) 53 #pragma clang system_header 61 template<
typename elemOrtValueType,
class ...elemOrtProperties,
62 typename elemNodeValueType,
class ...elemNodeProperties>
65 getOrientation( Kokkos::DynRankView<elemOrtValueType,elemOrtProperties...> elemOrts,
66 const Kokkos::DynRankView<elemNodeValueType,elemNodeProperties...> elemNodes,
67 const shards::CellTopology cellTopo) {
69 auto elemOrtsHost = Kokkos::create_mirror_view(elemOrts);
70 auto elemNodesHost = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), elemNodes);
72 const ordinal_type numCells = elemNodes.extent(0);
73 for (
auto cell=0;cell<numCells;++cell) {
74 const auto nodes = Kokkos::subview(elemNodesHost, cell, Kokkos::ALL());
75 elemOrtsHost(cell) = Orientation::getOrientation(cellTopo, nodes);
78 Kokkos::deep_copy(elemOrts, elemOrtsHost);
81 template<
typename ortViewType,
82 typename OutputViewType,
83 typename inputViewType,
86 typename dataViewType>
89 OutputViewType output;
91 o2tViewType ordinalToTag;
92 t2oViewType tagToOrdinal;
94 const dataViewType matData;
95 const ordinal_type cellDim, numVerts, numEdges, numFaces, numPoints, dimBasis;
98 OutputViewType output_,
100 o2tViewType ordinalToTag_,
101 t2oViewType tagToOrdinal_,
102 const dataViewType matData_,
103 const ordinal_type cellDim_,
104 const ordinal_type numVerts_,
105 const ordinal_type numEdges_,
106 const ordinal_type numFaces_,
107 const ordinal_type numPoints_,
108 const ordinal_type dimBasis_)
112 ordinalToTag(ordinalToTag_),
113 tagToOrdinal(tagToOrdinal_),
119 numPoints(numPoints_),
123 KOKKOS_INLINE_FUNCTION
124 void operator()(
const ordinal_type cell)
const {
125 typedef typename inputViewType::non_const_value_type input_value_type;
127 auto out = Kokkos::subview(output, cell, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
128 auto in = (input.rank() == output.rank()) ?
129 Kokkos::subview(input, cell, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL())
130 : Kokkos::subview(input, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());
133 for (ordinal_type vertId=0;vertId<numVerts;++vertId) {
134 const ordinal_type i = (
static_cast<size_type
>(vertId) < tagToOrdinal.extent(1) ? tagToOrdinal(0, vertId, 0) : -1);
136 for (ordinal_type j=0;j<numPoints;++j)
137 for (ordinal_type k=0;k<dimBasis;++k)
138 out(i, j, k) = in(i, j, k);
143 const ordinal_type ordIntr = (
static_cast<size_type
>(cellDim) < tagToOrdinal.extent(0) ? tagToOrdinal(cellDim, 0, 0) : -1);
145 const ordinal_type ndofIntr = ordinalToTag(ordIntr, 3);
146 for (ordinal_type i=0;i<ndofIntr;++i) {
147 const ordinal_type ii = tagToOrdinal(cellDim, 0, i);
148 for (ordinal_type j=0;j<numPoints;++j)
149 for (ordinal_type k=0;k<dimBasis;++k)
150 out(ii, j, k) = in(ii, j, k);
156 ordinal_type existEdgeDofs = 0;
158 ordinal_type ortEdges[12];
159 orts(cell).getEdgeOrientation(ortEdges, numEdges);
162 for (ordinal_type edgeId=0;edgeId<numEdges;++edgeId) {
163 const ordinal_type ordEdge = (1 < tagToOrdinal.extent(0) ? (
static_cast<size_type
>(edgeId) < tagToOrdinal.extent(1) ? tagToOrdinal(1, edgeId, 0) : -1) : -1);
167 const ordinal_type ndofEdge = ordinalToTag(ordEdge, 3);
168 const auto mat = Kokkos::subview(matData,
169 edgeId, ortEdges[edgeId],
170 Kokkos::ALL(), Kokkos::ALL());
172 for (ordinal_type j=0;j<numPoints;++j)
173 for (ordinal_type i=0;i<ndofEdge;++i) {
174 const ordinal_type ii = tagToOrdinal(1, edgeId, i);
176 for (ordinal_type k=0;k<dimBasis;++k) {
177 input_value_type temp = 0.0;
178 for (ordinal_type l=0;l<ndofEdge;++l) {
179 const ordinal_type ll = tagToOrdinal(1, edgeId, l);
180 temp += mat(i,l)*in(ll, j, k);
182 out(ii, j, k) = temp;
191 ordinal_type ortFaces[12];
192 orts(cell).getFaceOrientation(ortFaces, numFaces);
195 for (ordinal_type faceId=0;faceId<numFaces;++faceId) {
196 const ordinal_type ordFace = (2 < tagToOrdinal.extent(0) ? (
static_cast<size_type
>(faceId) < tagToOrdinal.extent(1) ? tagToOrdinal(2, faceId, 0) : -1) : -1);
199 const ordinal_type ndofFace = ordinalToTag(ordFace, 3);
200 const auto mat = Kokkos::subview(matData,
201 numEdges*existEdgeDofs+faceId, ortFaces[faceId],
202 Kokkos::ALL(), Kokkos::ALL());
204 for (ordinal_type j=0;j<numPoints;++j)
205 for (ordinal_type i=0;i<ndofFace;++i) {
206 const ordinal_type ii = tagToOrdinal(2, faceId, i);
208 for (ordinal_type k=0;k<dimBasis;++k) {
209 input_value_type temp = 0.0;
210 for (ordinal_type l=0;l<ndofFace;++l) {
211 const ordinal_type ll = tagToOrdinal(2, faceId, l);
212 temp += mat(i,l)*in(ll, j, k);
214 out(ii, j, k) = temp;
223 template<
typename DT>
224 template<
typename outputValueType,
class ...outputProperties,
225 typename inputValueType,
class ...inputProperties,
226 typename OrientationViewType,
231 const Kokkos::DynRankView<inputValueType, inputProperties...> input,
232 const OrientationViewType orts,
233 const BasisType* basis ) {
234 #ifdef HAVE_INTREPID2_DEBUG 236 if (input.rank() == output.rank())
238 for (size_type i=0;i<input.rank();++i)
239 INTREPID2_TEST_FOR_EXCEPTION( input.extent(i) != output.extent(i), std::invalid_argument,
240 ">>> ERROR (OrientationTools::modifyBasisByOrientation): Input and output dimension does not match.");
242 else if (input.rank() == output.rank() - 1)
244 for (size_type i=0;i<input.rank();++i)
245 INTREPID2_TEST_FOR_EXCEPTION( input.extent(i) != output.extent(i+1), std::invalid_argument,
246 ">>> ERROR (OrientationTools::modifyBasisByOrientation): Input dimensions must match output dimensions exactly, or else match all but the first dimension (in the case that input does not have a 'cell' dimension).");
250 INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
251 ">>> ERROR (OrientationTools::modifyBasisByOrientation): input and output ranks must either match, or input rank must be one less than that of output.")
254 INTREPID2_TEST_FOR_EXCEPTION( static_cast<ordinal_type>(output.extent(1)) != basis->getCardinality(), std::invalid_argument,
255 ">>> ERROR (OrientationTools::modifyBasisByOrientation): Field dimension of input/output does not match to basis cardinality.");
259 if (basis->requireOrientation()) {
260 auto ordinalToTag = Kokkos::create_mirror_view_and_copy(
typename DT::memory_space(), basis->getAllDofTags());
261 auto tagToOrdinal = Kokkos::create_mirror_view_and_copy(
typename DT::memory_space(), basis->getAllDofOrdinal());
264 numCells = output.extent(0),
266 numPoints = output.extent(2),
267 dimBasis = output.extent(3);
270 const shards::CellTopology cellTopo = basis->getBaseCellTopology();
273 cellDim = cellTopo.getDimension(),
274 numVerts = cellTopo.getVertexCount()*ordinal_type(basis->getDofCount(0, 0) > 0),
275 numEdges = cellTopo.getEdgeCount()*ordinal_type(basis->getDofCount(1, 0) > 0),
276 numFaces = cellTopo.getFaceCount();
278 const Kokkos::RangePolicy<typename DT::execution_space> policy(0, numCells);
281 decltype(output),decltype(input),
282 decltype(ordinalToTag),decltype(tagToOrdinal),
283 decltype(matData)> FunctorType;
288 ordinalToTag, tagToOrdinal,
290 cellDim, numVerts, numEdges, numFaces,
291 numPoints, dimBasis));
293 Kokkos::deep_copy(output, input);
Header file for the Intrepid2::Orientation class.