15 #ifndef __INTREPID2_CELLTOOLS_SERIAL_HPP__
16 #define __INTREPID2_CELLTOOLS_SERIAL_HPP__
18 #include "Intrepid2_ConfigDefs.hpp"
20 #include "Shards_CellTopology.hpp"
46 template<
typename jacobianViewType,
47 typename basisGradViewType,
48 typename nodeViewType>
49 KOKKOS_INLINE_FUNCTION
51 computeJacobian(
const jacobianViewType &jacobian,
52 const basisGradViewType &grads,
53 const nodeViewType &nodes) {
54 const auto numNodes = nodes.extent(0);
56 const auto physDim = jacobian.extent(0);
57 const auto refDim = jacobian.extent(1);
59 INTREPID2_TEST_FOR_ABORT( numNodes != grads.extent(0),
"grad dimension_0 does not match to cardinality.");
60 INTREPID2_TEST_FOR_ABORT(refDim != grads.extent(1),
"grad dimension_1 does not match to space dim.");
61 INTREPID2_TEST_FOR_ABORT( physDim != nodes.extent(1),
"node dimension_1 does not match to space dim.");
63 Kernels::Serial::gemm_trans_notrans(1.0, nodes, grads, 0.0, jacobian);
71 template<
typename PointViewType,
72 typename basisValViewType,
73 typename nodeViewType>
74 KOKKOS_INLINE_FUNCTION
76 mapToPhysicalFrame(
const PointViewType &point,
77 const basisValViewType &vals,
78 const nodeViewType &nodes) {
79 const auto numNodes = vals.extent(0);
80 const auto physDim = point.extent(0);
82 INTREPID2_TEST_FOR_ABORT(numNodes != nodes.extent(0),
"nodes dimension_0 does not match to vals dimension_0.");
83 INTREPID2_TEST_FOR_ABORT(physDim != nodes.extent(1),
"node dimension_1 does not match to space dim.");
85 Kernels::Serial::gemv_trans(1.0, nodes, vals, 0.0, point);
113 template<
typename implBasisType,
114 typename refPointViewType,
115 typename phyPointViewType,
116 typename nodeViewType>
117 KOKKOS_INLINE_FUNCTION
120 const phyPointViewType &physPoint,
121 const nodeViewType &nodes,
122 const double tol = tolerence()) {
123 const ordinal_type refDim = refPoint.extent(0);
124 const ordinal_type physDim = physPoint.extent(0);
125 const ordinal_type numNodes = nodes.extent(0);
127 INTREPID2_TEST_FOR_ABORT(refDim > physDim,
"the dimension of the reference cell is greater than physical cell dimension.");
128 INTREPID2_TEST_FOR_ABORT(physDim != static_cast<ordinal_type>(nodes.extent(1)),
"physPoint dimension_0 does not match to space dim.");
129 INTREPID2_TEST_FOR_ABORT(numNodes > 27,
"function hard-coded to support at most mappings with 27 Dofs");
131 typedef typename refPointViewType::non_const_value_type value_type;
135 value_type buf[27*3 + 27 + 9 + 9 + 9 + 9 + 3 + 3] = {}, *ptr = &buf[0];
136 Kokkos::DynRankView<value_type,
137 Kokkos::AnonymousSpace,
138 Kokkos::MemoryUnmanaged> grads(ptr, numNodes, refDim); ptr += numNodes*refDim;
140 Kokkos::DynRankView<value_type,
141 Kokkos::AnonymousSpace,
142 Kokkos::MemoryUnmanaged> vals(ptr, numNodes); ptr += numNodes;
144 Kokkos::DynRankView<value_type,
145 Kokkos::AnonymousSpace,
146 Kokkos::MemoryUnmanaged> jac(ptr, physDim, refDim); ptr += physDim*refDim;
148 Kokkos::DynRankView<value_type,
149 Kokkos::AnonymousSpace,
150 Kokkos::MemoryUnmanaged> metric(ptr, refDim, refDim); ptr += refDim*refDim;
152 Kokkos::DynRankView<value_type,
153 Kokkos::AnonymousSpace,
154 Kokkos::MemoryUnmanaged> invMetric(ptr, refDim, refDim); ptr += refDim*refDim;
156 Kokkos::DynRankView<value_type,
157 Kokkos::AnonymousSpace,
158 Kokkos::MemoryUnmanaged> invDf(ptr, refDim, physDim); ptr += refDim*physDim;
160 Kokkos::DynRankView<value_type,
161 Kokkos::AnonymousSpace,
162 Kokkos::MemoryUnmanaged> tmpPhysPoint(ptr, physDim); ptr += physDim;
164 Kokkos::DynRankView<value_type,
165 Kokkos::AnonymousSpace,
166 Kokkos::MemoryUnmanaged> oldRefPoint(ptr, refDim); ptr += refDim;
169 for (ordinal_type j=0;j<refDim;++j) oldRefPoint(j) = 0;
171 double xphyNorm = Kernels::Serial::norm(physPoint, NORM_ONE);
173 bool converged =
false;
177 mapToPhysicalFrame(tmpPhysPoint, vals, nodes);
178 Kernels::Serial::z_is_axby(tmpPhysPoint, 1.0, physPoint, -1.0, tmpPhysPoint);
179 double residualNorm = Kernels::Serial::norm(tmpPhysPoint, NORM_ONE);
180 if (residualNorm < tol*xphyNorm) {
187 CellTools::Serial::computeJacobian(jac, grads, nodes);
189 if(physDim == refDim) {
190 Kernels::Serial::inverse(invDf, jac);
192 Kernels::Serial::gemm_trans_notrans(1.0, jac, jac, 0.0, metric);
193 Kernels::Serial::inverse(invMetric, metric);
194 Kernels::Serial::gemm_notrans_trans(1.0, invMetric, jac, 0.0, invDf);
198 Kernels::Serial::gemv_notrans(1.0, invDf, tmpPhysPoint, 0.0, refPoint);
199 Kernels::Serial::z_is_axby(refPoint, 1.0, oldRefPoint, 1.0, refPoint);
202 Kernels::Serial::z_is_axby(oldRefPoint, 1.0, oldRefPoint, -1.0, refPoint);
204 double err = Kernels::Serial::norm(oldRefPoint, NORM_ONE);
210 Kernels::Serial::copy(oldRefPoint, refPoint);
215 template<
typename refEdgeTanViewType,
typename ParamViewType>
216 KOKKOS_INLINE_FUNCTION
218 getReferenceEdgeTangent(
const refEdgeTanViewType refEdgeTangent,
219 const ParamViewType edgeParametrization,
220 const ordinal_type edgeOrdinal ) {
222 ordinal_type dim = edgeParametrization.extent(1);
223 for(ordinal_type i = 0; i < dim; ++i) {
224 refEdgeTangent(i) = edgeParametrization(edgeOrdinal, i, 1);
228 template<
typename refFaceTanViewType,
typename ParamViewType>
229 KOKKOS_INLINE_FUNCTION
231 getReferenceFaceTangent(
const refFaceTanViewType refFaceTanU,
232 const refFaceTanViewType refFaceTanV,
233 const ParamViewType faceParametrization,
234 const ordinal_type faceOrdinal) {
238 ordinal_type dim = faceParametrization.extent(1);
239 for(ordinal_type i = 0; i < dim; ++i) {
240 refFaceTanU(i) = faceParametrization(faceOrdinal, i, 1);
241 refFaceTanV(i) = faceParametrization(faceOrdinal, i, 2);
245 template<
typename edgeTangentViewType,
typename ParamViewType,
typename jacobianViewType>
246 KOKKOS_INLINE_FUNCTION
248 getPhysicalEdgeTangent(
const edgeTangentViewType edgeTangent,
249 const ParamViewType edgeParametrization,
250 const jacobianViewType jacobian,
251 const ordinal_type edgeOrdinal) {
252 typedef typename ParamViewType::non_const_value_type value_type;
253 const ordinal_type dim = edgeParametrization.extent(1);
255 Kokkos::DynRankView<value_type, Kokkos::AnonymousSpace,
256 Kokkos::MemoryUnmanaged> refEdgeTangent(&buf[0], dim);
258 getReferenceEdgeTangent(refEdgeTangent, edgeParametrization, edgeOrdinal);
259 Kernels::Serial::matvec_product(edgeTangent, jacobian, refEdgeTangent);
262 template<
typename faceTanViewType,
typename ParamViewType,
typename jacobianViewType>
263 KOKKOS_INLINE_FUNCTION
265 getPhysicalFaceTangents( faceTanViewType faceTanU,
266 faceTanViewType faceTanV,
267 const ParamViewType faceParametrization,
268 const jacobianViewType jacobian,
269 const ordinal_type faceOrdinal) {
270 typedef typename ParamViewType::non_const_value_type value_type;
271 const ordinal_type dim = faceParametrization.extent(1);
272 INTREPID2_TEST_FOR_ABORT(dim != 3,
273 "computing face tangents requires dimension 3.");
275 Kokkos::DynRankView<value_type,
276 Kokkos::AnonymousSpace,
277 Kokkos::MemoryUnmanaged> refFaceTanU(&buf[0], dim), refFaceTanV(&buf[3], dim);
279 getReferenceFaceTangent(refFaceTanU,
284 Kernels::Serial::matvec_product_d3(faceTanU, jacobian, refFaceTanU);
285 Kernels::Serial::matvec_product_d3(faceTanV, jacobian, refFaceTanV);
289 template<
typename faceNormalViewType,
typename ParamViewType,
typename jacobianViewType>
290 KOKKOS_INLINE_FUNCTION
292 getPhysicalFaceNormal(
const faceNormalViewType faceNormal,
293 const ParamViewType faceParametrization,
294 const jacobianViewType jacobian,
295 const ordinal_type faceOrdinal) {
296 typedef typename ParamViewType::non_const_value_type value_type;
297 const ordinal_type dim = faceParametrization.extent(1);
298 INTREPID2_TEST_FOR_ABORT(dim != 3,
299 "computing face normal requires dimension 3.");
301 Kokkos::DynRankView<value_type,
302 Kokkos::AnonymousSpace,
303 Kokkos::MemoryUnmanaged> faceTanU(&buf[0], dim), faceTanV(&buf[3], dim);
305 getPhysicalFaceTangents(faceTanU, faceTanV,
309 Kernels::Serial::vector_product_d3(faceNormal, faceTanU, faceTanV);
312 template<
typename s
ideNormalViewType,
typename ParamViewType,
typename jacobianViewType>
313 KOKKOS_INLINE_FUNCTION
315 getPhysicalSideNormal(
const sideNormalViewType sideNormal,
316 const ParamViewType sideParametrization,
317 const jacobianViewType jacobian,
318 const ordinal_type sideOrdinal) {
319 const ordinal_type dim = sideParametrization.extent(1);
320 typedef typename ParamViewType::non_const_value_type value_type;
324 Kokkos::DynRankView<value_type,
325 Kokkos::AnonymousSpace,
326 Kokkos::MemoryUnmanaged> edgeTangent(&buf[0], dim);
327 getPhysicalEdgeTangent(edgeTangent, sideParametrization, jacobian, sideOrdinal);
328 sideNormal(0) = edgeTangent(1);
329 sideNormal(1) = -edgeTangent(0);
333 getPhysicalFaceNormal(sideNormal, sideParametrization, jacobian, sideOrdinal);
337 INTREPID2_TEST_FOR_ABORT(
true,
"cell dimension is out of range.");
Header function for Intrepid2::Util class and other utility functions.
static constexpr ordinal_type MaxNewton
Maximum number of Newton iterations used internally in methods such as computing the action of the in...
Header file for the classes: Intrepid2::RefSubcellParametrization, Intrepid2::RefCellNodes, Intrepid2::RefCellCenter.
Contains definitions of custom data types in Intrepid2.
Header file for small functions used in Intrepid2.