16#ifndef __INTREPID2_HGRAD_TRI_CN_FEM_DEF_HPP__
17#define __INTREPID2_HGRAD_TRI_CN_FEM_DEF_HPP__
26template<EOperator OpType>
27template<
typename OutputViewType,
28typename InputViewType,
35 const InputViewType input,
37 const VinvViewType vinv,
38 const ordinal_type order ) {
40 constexpr ordinal_type spaceDim = 2;
42 card = vinv.extent(0),
43 npts = input.extent(0);
45 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
46 auto ptr = work.data();
49 case OPERATOR_VALUE: {
53 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
54 Serial<OpType>::getValues(phis, input, dummyView, order);
56 for (ordinal_type i=0;i<card;++i)
57 for (ordinal_type j=0;j<npts;++j) {
58 output.access(i,j) = 0.0;
59 for (ordinal_type k=0;k<card;++k)
60 output.access(i,j) += vinv(k,i)*phis.access(k,j);
67 ptr += card*npts*spaceDim*get_dimension_scalar(input);
69 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
70 Serial<OpType>::getValues(phis, input, workView, order);
72 for (ordinal_type i=0;i<card;++i)
73 for (ordinal_type j=0;j<npts;++j)
74 for (ordinal_type k=0;k<spaceDim;++k) {
75 output.access(i,j,k) = 0.0;
76 for (ordinal_type l=0;l<card;++l)
77 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
90 const ordinal_type dkcard = getDkCardinality<OpType,spaceDim>();
94 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
95 Serial<OpType>::getValues(phis, input, dummyView, order);
97 for (ordinal_type i=0;i<card;++i)
98 for (ordinal_type j=0;j<npts;++j)
99 for (ordinal_type k=0;k<dkcard;++k) {
100 output.access(i,j,k) = 0.0;
101 for (ordinal_type l=0;l<card;++l)
102 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
106 case OPERATOR_CURL: {
108 ptr += card*npts*spaceDim*get_dimension_scalar(input);
112 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
113 Serial<OPERATOR_D1>::getValues(phis, input, workView, order);
115 for (ordinal_type i=0;i<card;++i)
116 for (ordinal_type j=0;j<npts;++j) {
117 output.access(i,j,0) = 0.0;
118 for (ordinal_type l=0;l<card;++l)
119 output.access(i,j,0) += vinv(l,i)*phis.access(l,j,1);
120 output.access(i,j,1) = 0.0;
121 for (ordinal_type l=0;l<card;++l)
122 output.access(i,j,1) -= vinv(l,i)*phis.access(l,j,0);
127 INTREPID2_TEST_FOR_ABORT(
true,
128 ">>> ERROR (Basis_HGRAD_TRI_Cn_FEM): Operator type not implemented");
133template<
typename DT, ordinal_type numPtsPerEval,
134typename outputValueValueType,
class ...outputValueProperties,
135typename inputPointValueType,
class ...inputPointProperties,
136typename vinvValueType,
class ...vinvProperties>
138Basis_HGRAD_TRI_Cn_FEM::
140 const typename DT::execution_space& space,
141 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
142 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
143 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
144 const ordinal_type order,
145 const EOperator operatorType) {
146 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
147 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
148 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
149 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
152 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
153 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
154 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
155 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
157 const ordinal_type cardinality = outputValues.extent(0);
158 const ordinal_type spaceDim = 2;
160 typedef typename DeduceDynRankView<inputPointViewType>::type workViewType;
162 switch (operatorType) {
163 case OPERATOR_VALUE: {
164 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", cardinality, inputPoints.extent(0));
165 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
166 OPERATOR_VALUE,numPtsPerEval> FunctorType;
167 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
172 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", cardinality*(2*spaceDim+1), inputPoints.extent(0));
173 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
174 OPERATOR_D1,numPtsPerEval> FunctorType;
175 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
178 case OPERATOR_CURL: {
179 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", cardinality*(2*spaceDim+1), inputPoints.extent(0));
180 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
181 OPERATOR_CURL,numPtsPerEval> FunctorType;
182 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
186 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
187 OPERATOR_D2,numPtsPerEval> FunctorType;
188 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", cardinality*outputValues.extent(2), inputPoints.extent(0));
189 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
193 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
194 ">>> ERROR (Basis_HGRAD_TRI_Cn_FEM): Operator type not implemented" );
201template<
typename DT,
typename OT,
typename PT>
204 const EPointType pointType ) {
205 constexpr ordinal_type spaceDim = 2;
214 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
218 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
219 dofCoords(
"Hgrad::Tri::Cn::dofCoords", card, spaceDim);
222 const shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Triangle<3>>());
223 const ordinal_type offset = 0;
229 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
230 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
234 const ordinal_type lwork = card*card;
235 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
236 vmat(
"Hgrad::Tri::Cn::vmat", card, card),
237 work(
"Hgrad::Tri::Cn::work", lwork),
238 ipiv(
"Hgrad::Tri::Cn::ipiv", card);
240 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
246 ordinal_type info = 0;
247 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
249 lapack.GETRF(card, card,
250 vmat.data(), vmat.stride(1),
251 (ordinal_type*)ipiv.data(),
254 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
256 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_Cn_FEM) lapack.GETRF returns nonzero info." );
259 vmat.data(), vmat.stride(1),
260 (ordinal_type*)ipiv.data(),
264 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
266 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_Cn_FEM) lapack.GETRI returns nonzero info." );
269 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
270 vinv(
"Hgrad::Line::Cn::vinv", card, card);
272 for (ordinal_type i=0;i<card;++i)
273 for (ordinal_type j=0;j<card;++j)
274 vinv(i,j) = vmat(j,i);
276 this->
vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
277 Kokkos::deep_copy(this->
vinv_ , vinv);
282 constexpr ordinal_type tagSize = 4;
283 const ordinal_type posScDim = 0;
284 const ordinal_type posScOrd = 1;
285 const ordinal_type posDfOrd = 2;
289 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
291 ordinal_type tags[maxCard][tagSize];
300 ordinal_type edgeId[3] = {}, elemId = 0;
301 for (ordinal_type i=0;i<card;++i) {
304 const auto x = dofCoords(i,0);
305 const auto y = dofCoords(i,1);
311 if ((1.0 - xi0) < eps) {
317 else if ((1.0 - xi1) < eps) {
323 else if ((1.0 - xi2) < eps) {
329 else if (xi2 < eps) {
332 tags[i][2] = edgeId[0]++;
333 tags[i][3] = numEdgeDof;
335 else if (xi0 < eps) {
338 tags[i][2] = edgeId[1]++;
339 tags[i][3] = numEdgeDof;
341 else if (xi1 < eps) {
344 tags[i][2] = edgeId[2]++;
345 tags[i][3] = numEdgeDof;
350 tags[i][2] = elemId++;
351 tags[i][3] = numElemDof;
370 template<
typename DT,
typename OT,
typename PT>
372 Basis_HGRAD_TRI_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
373 ordinal_type& perTeamSpaceSize,
374 ordinal_type& perThreadSpaceSize,
376 const EOperator operatorType)
const {
377 perTeamSpaceSize = 0;
378 perThreadSpaceSize = getWorkSizePerPoint(operatorType)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
381 template<
typename DT,
typename OT,
typename PT>
382 KOKKOS_INLINE_FUNCTION
384 Basis_HGRAD_TRI_Cn_FEM<DT,OT,PT>::getValues(
385 OutputViewType outputValues,
386 const PointViewType inputPoints,
387 const EOperator operatorType,
388 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
389 const typename DT::execution_space::scratch_memory_space & scratchStorage,
390 const ordinal_type subcellDim,
391 const ordinal_type subcellOrdinal)
const {
393 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
394 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
396 const int numPoints = inputPoints.extent(0);
397 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
398 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
399 constexpr ordinal_type spaceDim = 2;
400 auto sizePerPoint = (operatorType==OPERATOR_VALUE) ?
401 this->vinv_.extent(0)*get_dimension_scalar(inputPoints) :
402 (2*spaceDim+1)*this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
403 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
404 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
405 switch(operatorType) {
407 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
408 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
409 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
410 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
411 Impl::Basis_HGRAD_TRI_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_, basisDegree_);
415 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
416 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
417 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
418 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
419 Impl::Basis_HGRAD_TRI_Cn_FEM::Serial<OPERATOR_GRAD>::getValues( output, input, work, vinv_, basisDegree_);
423 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
424 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
425 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
426 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
427 Impl::Basis_HGRAD_TRI_Cn_FEM::Serial<OPERATOR_CURL>::getValues( output, input, work, vinv_, basisDegree_);
431 INTREPID2_TEST_FOR_ABORT(
true,
432 ">>> ERROR (Basis_HGRAD_TRI_Cn_FEM): getValues not implemented for this operator");
KOKKOS_INLINE_FUNCTION ordinal_type getPnCardinality(ordinal_type n)
Returns cardinality of Polynomials of order n (P^n).
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH class.
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_pointer_v< CtorProp > &&!std::is_convertible_v< CtorProp, constchar * >, OutViewType >::type createMatchingUnmanagedView(const InViewType &view, const CtorProp &data, const Dims... dims)
Creates an unmanaged view that matches the value_type of the provided view The type of the output vie...
Basis_HGRAD_TRI_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
EPointType pointType_
type of lattice used for creating the DoF coordinates
Kokkos::DynRankView< scalarType, DeviceType > vinv_
inverse of Generalized Vandermonde matrix, whose columns store the expansion coefficients of the noda...
ECoordinates basisCoordinates_
ordinal_type basisDegree_
void setOrdinalTagData(OrdinalTypeView3D &tagToOrdinal, OrdinalTypeView2D &ordinalToTag, const OrdinalTypeView1D tags, const ordinal_type basisCard, const ordinal_type tagSize, const ordinal_type posScDim, const ordinal_type posScOrd, const ordinal_type posDfOrd)
OrdinalTypeArray2DHost ordinalToTag_
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
ordinal_type basisCardinality_
OrdinalTypeArray3DHost tagToOrdinal_
ScalarTraits< double >::scalar_type scalarType
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
unsigned basisCellTopologyKey_
EFunctionSpace functionSpace_
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
See Intrepid2::Basis_HGRAD_TRI_Cn_FEM.
See Intrepid2::Basis_HGRAD_TRI_Cn_FEM work is a rank 1 view having the same value_type of inputPoints...