49 #ifndef __INTREPID2_CELLTOOLS_DEF_PHYS_TO_REF_HPP__
50 #define __INTREPID2_CELLTOOLS_DEF_PHYS_TO_REF_HPP__
53 #if defined (__clang__) && !defined (__INTEL_COMPILER)
54 #pragma clang system_header
66 template<
typename SpT>
67 template<
typename refPointValueType,
class ...refPointProperties,
68 typename physPointValueType,
class ...physPointProperties,
69 typename worksetCellValueType,
class ...worksetCellProperties>
73 const Kokkos::DynRankView<physPointValueType,physPointProperties...> physPoints,
74 const Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCell,
75 const shards::CellTopology cellTopo ) {
76 #ifdef HAVE_INTREPID2_DEBUG
77 CellTools_mapToReferenceFrameArgs(refPoints, physPoints, worksetCell, cellTopo);
80 typedef Kokkos::DynRankView<typename ScalarTraits<refPointValueType>::scalar_type,SpT> refPointViewSpType;
82 const auto spaceDim = cellTopo.getDimension();
84 cellCenter(
"CellTools::mapToReferenceFrame::cellCenter", spaceDim),
85 cellVertex(
"CellTools::mapToReferenceFrame::cellCenter", spaceDim);
86 getReferenceCellCenter(cellCenter, cellVertex, cellTopo);
89 const auto numCells = worksetCell.extent(0);
90 const auto numPoints = physPoints.extent(1);
93 using result_layout =
typename DeduceLayout< decltype(refPoints) >::result_layout;
94 using device_type =
typename decltype(refPoints)::device_type;
95 auto vcprop = Kokkos::common_view_alloc_prop(refPoints);
96 using common_value_type =
typename decltype(vcprop)::value_type;
97 Kokkos::DynRankView< common_value_type, result_layout, device_type > initGuess ( Kokkos::view_alloc(
"CellTools::mapToReferenceFrame::initGuess", vcprop), numCells, numPoints, spaceDim );
99 rst::clone(initGuess, cellCenter);
101 mapToReferenceFrameInitGuess(refPoints, initGuess, physPoints, worksetCell, cellTopo);
105 template<
typename SpT>
106 template<
typename refPointValueType,
class ...refPointProperties,
107 typename initGuessValueType,
class ...initGuessProperties,
108 typename physPointValueType,
class ...physPointProperties,
109 typename worksetCellValueType,
class ...worksetCellProperties,
110 typename HGradBasisPtrType>
114 const Kokkos::DynRankView<initGuessValueType,initGuessProperties...> initGuess,
115 const Kokkos::DynRankView<physPointValueType,physPointProperties...> physPoints,
116 const Kokkos::DynRankView<worksetCellValueType,worksetCellProperties...> worksetCell,
117 const HGradBasisPtrType basis ) {
118 #ifdef HAVE_INTREPID2_DEBUG
119 CellTools_mapToReferenceFrameInitGuessArgs(refPoints, initGuess, physPoints, worksetCell,
120 basis->getBaseCellTopology());
123 const auto cellTopo = basis->getBaseCellTopology();
124 const auto spaceDim = cellTopo.getDimension();
128 const auto numCells = worksetCell.extent(0);
129 const auto numPoints = physPoints.extent(1);
132 const auto tol = tolerence();
134 using result_layout =
typename DeduceLayout< decltype(refPoints) >::result_layout;
135 using device_type =
typename decltype(refPoints)::device_type;
136 auto vcprop = Kokkos::common_view_alloc_prop(refPoints);
137 typedef Kokkos::DynRankView<typename decltype(vcprop)::value_type, result_layout, device_type > viewType;
140 viewType xOld(Kokkos::view_alloc(
"CellTools::mapToReferenceFrameInitGuess::xOld", vcprop), numCells, numPoints, spaceDim);
141 viewType xTmp(Kokkos::view_alloc(
"CellTools::mapToReferenceFrameInitGuess::xTmp", vcprop), numCells, numPoints, spaceDim);
144 Kokkos::deep_copy(xOld, initGuess);
147 auto vcpropJ = Kokkos::common_view_alloc_prop(refPoints, worksetCell);
148 typedef Kokkos::DynRankView<typename decltype(vcpropJ)::value_type, result_layout, device_type > viewTypeJ;
149 viewTypeJ jacobian(Kokkos::view_alloc(
"CellTools::mapToReferenceFrameInitGuess::jacobian", vcpropJ), numCells, numPoints, spaceDim, spaceDim);
150 viewTypeJ jacobianInv(Kokkos::view_alloc(
"CellTools::mapToReferenceFrameInitGuess::jacobianInv", vcpropJ), numCells, numPoints, spaceDim, spaceDim);
152 typedef Kokkos::DynRankView<typename ScalarTraits<refPointValueType>::scalar_type,SpT> errorViewType;
154 xScalarTmp (
"CellTools::mapToReferenceFrameInitGuess::xScalarTmp", numCells, numPoints, spaceDim),
155 errorPointwise(
"CellTools::mapToReferenceFrameInitGuess::errorPointwise", numCells, numPoints),
156 errorCellwise (
"CellTools::mapToReferenceFrameInitGuess::errorCellwise", numCells);
166 setJacobian(jacobian, xOld, worksetCell, basis);
167 setJacobianInv(jacobianInv, jacobian);
170 mapToPhysicalFrame(xTmp, xOld, worksetCell, basis);
171 rst::subtract(xTmp, physPoints, xTmp);
172 rst::matvec(refPoints, jacobianInv, xTmp);
173 rst::add(refPoints, xOld);
176 rst::subtract(xTmp, xOld, refPoints);
179 rst::extractScalarValues(xScalarTmp, xTmp);
180 rst::vectorNorm(errorPointwise, xScalarTmp, NORM_TWO);
183 rst::vectorNorm(errorCellwise, errorPointwise, NORM_ONE);
184 const auto errorTotal = rst::Serial::vectorNorm(errorCellwise, NORM_ONE);
187 if (errorTotal < tol)
191 Kokkos::deep_copy(xOld, refPoints);
static constexpr ordinal_type MaxNewton
Maximum number of Newton iterations used internally in methods such as computing the action of the in...