41 struct F_scaledResidualNormalComponent3d {
43 TanViewType workview_;
44 const TanViewType tangents_;
45 const InViewType residual_;
46 const typename OutViewType::value_type scaling_;
48 KOKKOS_INLINE_FUNCTION
49 F_scaledResidualNormalComponent3d( OutViewType result,
51 const TanViewType tangents,
52 const InViewType residual,
53 const typename OutViewType::value_type scaling)
54 : result_(result), workview_(workview), tangents_(tangents), residual_(residual), scaling_(scaling) {}
56 KOKKOS_INLINE_FUNCTION
57 void operator()(
const ordinal_type cell,
58 const ordinal_type point)
const {
60 auto t1 = Kokkos::subview( tangents_, cell, point, Kokkos::ALL(), 0);
61 auto t2 = Kokkos::subview( tangents_, cell, point, Kokkos::ALL(), 1);
62 auto n = Kokkos::subview( workview_, cell, point, Kokkos::ALL());
63 Kernels::Serial::vector_product_d3(n, t1, t2);
64 result_(cell,point) = (n(0)*residual_(cell,point,0) + n(1)*residual_(cell,point,1) + n(2)*residual_(cell,point,2))*scaling_/Kernels::Serial::norm(n, NORM_TWO);
150 mapToReferenceFrame( Kokkos::DynRankView<refPointValueType,refPointProperties...> refPoints,
151 const Kokkos::DynRankView<physPointValueType,physPointProperties...> physPoints,
152 const Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCell,
153 const shards::CellTopology cellTopo,
154 const physPointValueType shellThickness ) {
155 constexpr bool are_accessible =
156 Kokkos::SpaceAccessibility<MemSpaceType,
157 typename decltype(refPoints)::memory_space>::accessible &&
158 Kokkos::SpaceAccessibility<MemSpaceType,
159 typename decltype(physPoints)::memory_space>::accessible &&
160 Kokkos::SpaceAccessibility<MemSpaceType,
161 typename decltype(worksetCell)::memory_space>::accessible;
163 static_assert(are_accessible,
"CellTools<DeviceType>::mapToReferenceFrame(..): input/output views' memory spaces are not compatible with DeviceType");
165#ifdef HAVE_INTREPID2_DEBUG
168 using deviceType =
typename decltype(refPoints)::device_type;
171 typedef Kokkos::DynRankView<typename ScalarTraits<refPointValueType>::scalar_type,deviceType> refPointViewSpType;
173 const auto spaceDim = cellTopo.getDimension();
175 cellCenter(
"CellTools::mapToReferenceFrame::cellCenter", spaceDim);
179 rst::clone(refPoints, cellCenter);
192 mapToReferenceFrame( Kokkos::DynRankView<refPointValueType,refPointProperties...> refPoints,
193 const Kokkos::DynRankView<physPointValueType,physPointProperties...> physPoints,
194 const Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCell,
196 const physPointValueType shellThickness) {
197 constexpr bool are_accessible =
198 Kokkos::SpaceAccessibility<MemSpaceType,
199 typename decltype(refPoints)::memory_space>::accessible &&
200 Kokkos::SpaceAccessibility<MemSpaceType,
201 typename decltype(physPoints)::memory_space>::accessible &&
202 Kokkos::SpaceAccessibility<MemSpaceType,
203 typename decltype(worksetCell)::memory_space>::accessible;
205 static_assert(are_accessible,
"CellTools<DeviceType>::mapToReferenceFrameInitGuess(..): input/output views' memory spaces are not compatible with DeviceType");
207 const bool isShell = (shellThickness>0);
210 const ordinal_type refDim = basis->getDomainDimension();
211 const ordinal_type physDim = physPoints.extent_int(2);
215 const auto numCells = worksetCell.extent(0);
216 const auto numPoints = physPoints.extent(1);
219 auto refDimRange = Kokkos::pair<ordinal_type,ordinal_type>(0,refDim);
221 using result_layout =
typename DeduceLayout<
decltype(refPoints) >::result_layout;
228 Kokkos::deep_copy(xOld, Kokkos::subdynrankview(refPoints, Kokkos::ALL(), Kokkos::ALL(), refDimRange));
231 using valueTypeJ = std::common_type_t<
typename decltype(refPoints)::value_type,
typename decltype(worksetCell)::value_type>;
232 using viewTypeJ = Kokkos::DynRankView<valueTypeJ, result_layout, DeviceType >;
237 metric = view_factory::template create_view<viewTypeJ>(refPoints, worksetCell,
"CellTools::mapToReferenceFrameInitGuess::metric", numCells, numPoints, refDim, refDim);
238 viewTypeJ jacobian = view_factory::template create_view<viewTypeJ>(refPoints, worksetCell,
"CellTools::mapToReferenceFrameInitGuess::jacobian", numCells, numPoints, physDim, refDim);
241 viewTypeJ jacobianInv = view_factory::template create_view<viewTypeJ>(refPoints, worksetCell,
"CellTools::mapToReferenceFrameInitGuess::jacobianInv", numCells, numPoints, refDim, refDim);
244 using errorViewType = Kokkos::DynRankView<typename ScalarTraits<refPointValueType>::scalar_type, DeviceType>;
245 using errorType =
typename errorViewType::value_type;
247 xScalarTmp (
"CellTools::mapToReferenceFrameInitGuess::xScalarTmp", numCells, numPoints, physDim),
248 errorPointwise(
"CellTools::mapToReferenceFrameInitGuess::errorPointwise", numCells, numPoints);
251 const auto tol = tolerance<errorType>();
253 errorType error(0), physInfNorm(0);
255 rst::extractScalarValues(xScalarTmp, physPoints);
256 rst::vectorNorm(errorPointwise, xScalarTmp, NORM_TWO);
257 using range_policy_type = Kokkos::MDRangePolicy<typename DeviceType::execution_space, Kokkos::Rank<2>, Kokkos::IndexType<ordinal_type> >;
258 range_policy_type policy( { 0, 0 }, { numCells, numPoints } );
260 Kokkos::parallel_reduce(
"MaxReduction", policy, FunctorType(errorPointwise), Kokkos::Max<errorType>(physInfNorm));
262 auto refPts = Kokkos::subdynrankview(refPoints,Kokkos::ALL(), Kokkos::ALL(), refDimRange);
267 bool converged(
false);
272 rst::subtract(physTmp, physPoints, physTmp);
275 rst::extractScalarValues(xScalarTmp, physTmp);
276 rst::vectorNorm(errorPointwise, xScalarTmp, NORM_TWO);
279 Kokkos::parallel_reduce(
"MaxReduction", policy, FunctorType(errorPointwise), Kokkos::Max<errorType>(error));
281 if (error < tol*physInfNorm) {
292 if(refDim < physDim) {
293 rst::matvec(xTmp, jacobian, physTmp,
true);
294 rst::AtA(metric,jacobian);
296 rst::matvec(refPts, jacobianInv, xTmp);
300 rst::matvec(refPts, jacobianInv, physTmp);
304 rst::extractScalarValues(Kokkos::subdynrankview(xScalarTmp, Kokkos::ALL(), Kokkos::ALL(), refDimRange), refPts);
306 rst::add(refPts, xOld);
311 rst::vectorNorm(errorPointwise, Kokkos::subdynrankview(xScalarTmp, Kokkos::ALL(), Kokkos::ALL(), refDimRange), NORM_TWO);
312 Kokkos::parallel_reduce(
"MaxReduction", policy, FunctorType(errorPointwise), Kokkos::Max<errorType>(error));
320 rst::subtract(physTmp, physPoints, physTmp);
326 Kokkos::deep_copy(xOld, refPts);
336 Kokkos::subdynrankview(refPoints,Kokkos::ALL(), Kokkos::ALL(), refDim),