48 #ifndef __INTREPID2_ORIENTATIONTOOLS_DEF_MODIFY_POINTS_HPP__
49 #define __INTREPID2_ORIENTATIONTOOLS_DEF_MODIFY_POINTS_HPP__
52 #if defined (__clang__) && !defined (__INTEL_COMPILER)
53 #pragma clang system_header
65 KOKKOS_INLINE_FUNCTION
70 const ordinal_type ort) {
71 #ifdef HAVE_INTREPID2_DEBUG
72 INTREPID2_TEST_FOR_ABORT( !( -1.0 <= pt && pt <= 1.0 ),
73 ">>> ERROR (Intrepid::OrientationTools::getModifiedLinePoint): "
74 "Input point is out of range [-1, 1].");
78 case 0: ot = pt;
break;
79 case 1: ot = -pt;
break;
81 INTREPID2_TEST_FOR_ABORT(
true,
82 ">>> ERROR (Intrepid2::OrientationTools::getModifiedLinePoint): "
83 "Orientation is invalid (0--1)." );
87 template<
typename JacobianViewType>
88 KOKKOS_INLINE_FUNCTION
92 #ifdef HAVE_INTREPID2_DEBUG
93 INTREPID2_TEST_FOR_ABORT( ort <0 || ort >1,
94 ">>> ERROR (Intrepid2::OrientationTools::getLineJacobian): " \
95 "Orientation is invalid (0--1)." );
98 ordinal_type jac[2] = { 1, -1 };
100 jacobian(0,0) = jac[ort];
103 template<
typename VT>
104 KOKKOS_INLINE_FUNCTION
111 const ordinal_type ort) {
112 const VT lambda[3] = { 1.0 - pt0 - pt1,
116 #ifdef HAVE_INTREPID2_DEBUG
119 INTREPID2_TEST_FOR_ABORT( !( -eps <= lambda[0] && lambda[0] <= 1.0+eps ),
120 ">>> ERROR (Intrepid::OrientationTools::getModifiedTrianglePoint): " \
121 "Computed bicentric coordinate (lamba[0]) is out of range [0, 1].");
123 INTREPID2_TEST_FOR_ABORT( !( -eps <= lambda[1] && lambda[1] <= 1.0+eps ),
124 ">>> ERROR (Intrepid::OrientationTools::getModifiedTrianglePoint): " \
125 "Computed bicentric coordinate (lamba[1]) is out of range [0, 1].");
127 INTREPID2_TEST_FOR_ABORT( !( -eps <= lambda[2] && lambda[2] <= 1.0+eps ),
128 ">>> ERROR (Intrepid::OrientationTools::getModifiedTrianglePoint): "
129 "Computed bicentric coordinate (lamba[2]) is out of range [0, 1].");
133 case 0: ot0 = lambda[1]; ot1 = lambda[2];
break;
134 case 1: ot0 = lambda[0]; ot1 = lambda[1];
break;
135 case 2: ot0 = lambda[2]; ot1 = lambda[0];
break;
137 case 3: ot0 = lambda[2]; ot1 = lambda[1];
break;
138 case 4: ot0 = lambda[0]; ot1 = lambda[2];
break;
139 case 5: ot0 = lambda[1]; ot1 = lambda[0];
break;
141 INTREPID2_TEST_FOR_ABORT(
true,
142 ">>> ERROR (Intrepid2::OrientationTools::getModifiedTrianglePoint): " \
143 "Orientation is invalid (0--5)." );
147 template<
typename JacobianViewType>
148 KOKKOS_INLINE_FUNCTION
152 #ifdef HAVE_INTREPID2_DEBUG
153 INTREPID2_TEST_FOR_ABORT( ort <0 || ort >5,
154 ">>> ERROR (Intrepid2::OrientationTools::getTriangleJacobian): " \
155 "Orientation is invalid (0--5)." );
158 ordinal_type jac[6][2][2] = { { { 1, 0 },
171 jacobian(0,0) = jac[ort][0][0];
172 jacobian(0,1) = jac[ort][0][1];
173 jacobian(1,0) = jac[ort][1][0];
174 jacobian(1,1) = jac[ort][1][1];
177 template<
typename VT>
178 KOKKOS_INLINE_FUNCTION
185 const ordinal_type ort) {
186 #ifdef HAVE_INTREPID2_DEBUG
187 INTREPID2_TEST_FOR_ABORT( !( -1.0 <= pt0 && pt0 <= 1.0 ),
188 ">>> ERROR (Intrepid::OrientationTools::getModifiedQuadrilateralPoint): " \
189 "Input point(0) is out of range [-1, 1].");
191 INTREPID2_TEST_FOR_ABORT( !( -1.0 <= pt1 && pt1 <= 1.0 ),
192 ">>> ERROR (Intrepid::OrientationTools::getModifiedQuadrilateralPoint): " \
193 "Input point(1) is out of range [-1, 1].");
196 const VT lambda[2][2] = { { pt0, -pt0 },
200 case 0: ot0 = lambda[0][0]; ot1 = lambda[1][0];
break;
201 case 1: ot0 = lambda[1][1]; ot1 = lambda[0][0];
break;
202 case 2: ot0 = lambda[0][1]; ot1 = lambda[1][1];
break;
203 case 3: ot0 = lambda[1][0]; ot1 = lambda[0][1];
break;
205 case 4: ot0 = lambda[1][0]; ot1 = lambda[0][0];
break;
206 case 5: ot0 = lambda[0][1]; ot1 = lambda[1][0];
break;
207 case 6: ot0 = lambda[1][1]; ot1 = lambda[0][1];
break;
208 case 7: ot0 = lambda[0][0]; ot1 = lambda[1][1];
break;
210 INTREPID2_TEST_FOR_ABORT(
true,
211 ">>> ERROR (Intrepid2::OrientationTools::getModifiedQuadrilateralPoint): " \
212 "Orientation is invalid (0--7)." );
216 template<
typename JacobianViewType>
217 KOKKOS_INLINE_FUNCTION
221 #ifdef HAVE_INTREPID2_DEBUG
222 INTREPID2_TEST_FOR_ABORT( ort <0 || ort >7,
223 ">>> ERROR (Intrepid2::OrientationTools::getQuadrilateralJacobian): " \
224 "Orientation is invalid (0--7)." );
227 ordinal_type jac[8][2][2] = { { { 1, 0 },
244 jacobian(0,0) = jac[ort][0][0];
245 jacobian(0,1) = jac[ort][0][1];
246 jacobian(1,0) = jac[ort][1][0];
247 jacobian(1,1) = jac[ort][1][1];
250 template<
typename outPointViewType,
251 typename refPointViewType>
256 const refPointViewType refPoints,
257 const shards::CellTopology cellTopo,
258 const ordinal_type cellOrt) {
259 #ifdef HAVE_INTREPID2_DEBUG
261 const auto cellDim = cellTopo.getDimension();
262 INTREPID2_TEST_FOR_EXCEPTION( !( (1 <= cellDim) && (cellDim <= 2 ) ), std::invalid_argument,
263 ">>> ERROR (Intrepid::OrientationTools::mapToModifiedReference): " \
264 "Method defined only for 1 and 2-dimensional subcells.");
266 INTREPID2_TEST_FOR_EXCEPTION( !( outPoints.extent(0) == refPoints.extent(0) ), std::invalid_argument,
267 ">>> ERROR (Intrepid::OrientationTools::mapToModifiedReference): " \
268 "Size of input and output point arrays does not match each other.");
276 template<
typename outPointViewType,
277 typename refPointViewType>
278 KOKKOS_INLINE_FUNCTION
282 const refPointViewType refPoints,
283 const unsigned cellTopoKey,
284 const ordinal_type cellOrt) {
286 const ordinal_type numPts = outPoints.extent(0);
287 switch (cellTopoKey) {
288 case shards::Line<>::key : {
289 for (ordinal_type pt=0;pt<numPts;++pt)
295 case shards::Triangle<>::key : {
296 for (ordinal_type pt=0;pt<numPts;++pt)
298 refPoints(pt, 0), refPoints(pt, 1),
302 case shards::Quadrilateral<>::key : {
303 for (ordinal_type pt=0;pt<numPts;++pt)
305 refPoints(pt, 0), refPoints(pt, 1),
310 INTREPID2_TEST_FOR_ABORT(
true,
311 ">>> ERROR (Intrepid2::OrientationTools::mapToModifiedReference): " \
312 "Invalid cell topology key." );
319 template<
typename outPo
intViewType>
324 const shards::CellTopology cellTopo,
325 const ordinal_type cellOrt) {
326 #ifdef HAVE_INTREPID2_DEBUG
328 const auto cellDim = cellTopo.getDimension();
329 INTREPID2_TEST_FOR_EXCEPTION( !( (1 <= cellDim) && (cellDim <= 2 ) ), std::invalid_argument,
330 ">>> ERROR (Intrepid::OrientationTools::getJacobianOfOrientationMap): " \
331 "Method defined only for 1 and 2-dimensional subcells.");
333 INTREPID2_TEST_FOR_ABORT( jacobian.rank() != 2,
334 ">>> ERROR (Intrepid2::OrientationTools::getJacobianOfOrientationMap): " \
335 "Jacobian should have rank 2" );
337 INTREPID2_TEST_FOR_EXCEPTION( ((jacobian.extent(0) != cellDim) || (jacobian.extent(1) != cellDim)), std::invalid_argument,
338 ">>> ERROR (Intrepid::OrientationTools::getJacobianOfOrientationMap): " \
339 "Size of jacobian is not compatible with cell topology.");
346 template<
typename outPo
intViewType>
347 KOKKOS_INLINE_FUNCTION
351 const unsigned cellTopoKey,
352 const ordinal_type cellOrt) {
353 switch (cellTopoKey) {
354 case shards::Line<>::key :
357 case shards::Triangle<>::key :
360 case shards::Quadrilateral<>::key :
364 INTREPID2_TEST_FOR_ABORT(
true,
365 ">>> ERROR (Intrepid2::OrientationTools::mapToModifiedReference): " \
366 "Invalid cell topology key." );
373 template<
typename TanViewType,
typename ParamViewType>
374 KOKKOS_INLINE_FUNCTION
377 const ParamViewType subcellParametrization,
378 const unsigned subcellTopoKey,
379 const ordinal_type subcellOrd,
380 const ordinal_type ort){
381 typename ParamViewType::non_const_value_type data[4];
382 typename ParamViewType::non_const_type jac(data, 2, 2);
384 ordinal_type cellDim = subcellParametrization.extent(1);
385 ordinal_type numTans = subcellParametrization.extent(2)-1;
388 for(ordinal_type d=0; d<cellDim; ++d)
389 for(ordinal_type j=0; j<numTans; ++j) {
391 for(ordinal_type k=0; k<numTans; ++k)
392 tangents(j,d) += subcellParametrization(subcellOrd,d,k+1)*jac(k,j);
397 template<
typename TanNormViewType,
typename ParamViewType>
398 KOKKOS_INLINE_FUNCTION
401 const ParamViewType subcellParametrization,
402 const unsigned subcellTopoKey,
403 const ordinal_type subcellOrd,
404 const ordinal_type ort){
405 ordinal_type cellDim = subcellParametrization.extent(1);
406 auto range = Kokkos::pair<ordinal_type, ordinal_type>(0,cellDim-1);
407 auto tangents = Kokkos::subview(tangentsAndNormal,range,Kokkos::ALL());
412 tangentsAndNormal(1,0) = tangents(0,1);
413 tangentsAndNormal(1,1) = -tangents(0,0);
416 tangentsAndNormal(2,0) = tangents(0,1)*tangents(1,2) - tangents(0,2)*tangents(1,1);
417 tangentsAndNormal(2,1) = tangents(0,2)*tangents(1,0) - tangents(0,0)*tangents(1,2);
418 tangentsAndNormal(2,2) = tangents(0,0)*tangents(1,1) - tangents(0,1)*tangents(1,0);
422 template<
typename coordsViewType,
typename subcellCoordsViewType,
typename ParamViewType>
423 KOKKOS_INLINE_FUNCTION
426 const subcellCoordsViewType subcellCoords,
427 const ParamViewType subcellParametrization,
428 const unsigned subcellTopoKey,
429 const ordinal_type subcellOrd,
430 const ordinal_type ort){
432 ordinal_type cellDim = subcellParametrization.extent(1);
433 ordinal_type numCoords = subcellCoords.extent(0);
434 ordinal_type subcellDim = subcellCoords.extent(1);
435 auto range = Kokkos::pair<ordinal_type, ordinal_type>(0,subcellDim);
436 auto modSubcellCoords = Kokkos::subview(cellCoords, Kokkos::ALL(),range);
438 typename coordsViewType::value_type subCoord[2];
440 for(ordinal_type i=0; i<numCoords; ++i) {
441 for(ordinal_type d=0; d<subcellDim; ++d)
442 subCoord[d] = modSubcellCoords(i,d);
444 for(ordinal_type d=0; d<cellDim; ++d) {
445 cellCoords(i,d) = subcellParametrization(subcellOrd, d, 0);
446 for(ordinal_type k=0; k<subcellDim; ++k)
447 cellCoords(i,d) += subcellParametrization(subcellOrd, d, k+1)*subCoord[k];