16#ifndef __INTREPID2_HGRAD_TET_CN_FEM_DEF_HPP__
17#define __INTREPID2_HGRAD_TET_CN_FEM_DEF_HPP__
27template<EOperator OpType>
28template<
typename OutputViewType,
29typename InputViewType,
36 const InputViewType input,
38 const VinvViewType vinv,
39 const ordinal_type order ) {
41 constexpr ordinal_type spaceDim = 3;
43 card = vinv.extent(0),
44 npts = input.extent(0);
46 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
47 auto ptr = work.data();
50 case OPERATOR_VALUE: {
54 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
55 Serial<OpType>::getValues(phis, input, dummyView, order);
57 for (ordinal_type i=0;i<card;++i)
58 for (ordinal_type j=0;j<npts;++j) {
59 output.access(i,j) = 0.0;
60 for (ordinal_type k=0;k<card;++k)
61 output.access(i,j) += vinv(k,i)*phis.access(k,j);
68 ptr += card*npts*spaceDim*get_dimension_scalar(input);
70 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
71 Serial<OpType>::getValues(phis, input, workView, order);
75 for (ordinal_type j=0;j<npts;++j)
76 for (ordinal_type k=0;k<spaceDim;++k)
77 for (ordinal_type i=0;i<card;++i)
79 output.access(i,j,k) = 0.0;
80 for (ordinal_type l=0;l<card;++l)
81 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
94 const ordinal_type dkcard = getDkCardinality<OpType,spaceDim>();
98 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
99 Serial<OpType>::getValues(phis, input, dummyView, order);
101 for (ordinal_type i=0;i<card;++i)
102 for (ordinal_type j=0;j<npts;++j)
103 for (ordinal_type k=0;k<dkcard;++k) {
104 output.access(i,j,k) = 0.0;
105 for (ordinal_type l=0;l<card;++l)
106 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
111 INTREPID2_TEST_FOR_ABORT(
true,
112 ">>> ERROR (Basis_HGRAD_TET_Cn_FEM): Operator type not implemented");
117template<
typename DT, ordinal_type numPtsPerEval,
118typename outputValueValueType,
class ...outputValueProperties,
119typename inputPointValueType,
class ...inputPointProperties,
120typename vinvValueType,
class ...vinvProperties>
122Basis_HGRAD_TET_Cn_FEM::
124 const typename DT::execution_space& space,
125 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
126 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
127 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
128 const ordinal_type order,
129 const EOperator operatorType) {
130 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
131 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
132 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
133 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
136 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
137 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
138 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
139 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
141 const ordinal_type cardinality = outputValues.extent(0);
142 const ordinal_type spaceDim = 3;
144 typedef typename DeduceDynRankView<inputPointViewType>::type workViewType;
146 switch (operatorType) {
147 case OPERATOR_VALUE: {
148 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TET_Cn_FEM::getValues::work", cardinality, inputPoints.extent(0));
149 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
150 OPERATOR_VALUE,numPtsPerEval> FunctorType;
151 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
156 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TET_Cn_FEM::getValues::work", cardinality*(2*spaceDim+1), inputPoints.extent(0));
157 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
158 OPERATOR_D1,numPtsPerEval> FunctorType;
159 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
163 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
164 OPERATOR_D2,numPtsPerEval> FunctorType;
165 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HGRAD_TET_Cn_FEM::getValues::work", cardinality*outputValues.extent(2), inputPoints.extent(0));
166 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work, order) );
170 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
171 ">>> ERROR (Basis_HGRAD_TET_Cn_FEM): Operator type not implemented" );
178template<
typename DT,
typename OT,
typename PT>
181 const EPointType pointType ) {
182 constexpr ordinal_type spaceDim = 3;
190 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
195 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
196 dofCoords(
"Hgrad::Tet::Cn::dofCoords", card, spaceDim);
200 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
203 constexpr ordinal_type tagSize = 4;
205 ordinal_type tags[maxCard][tagSize];
209 shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
210 const ordinal_type numEdges = cellTopo.getEdgeCount();
211 const ordinal_type numFaces = cellTopo.getFaceCount();
213 shards::CellTopology edgeTopo(shards::getCellTopologyData<shards::Line<2> >() );
214 shards::CellTopology faceTopo(shards::getCellTopologyData<shards::Triangle<3> >() );
232 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> vertexes(
"Hcurl::Tet::In::vertexes", numVertexes , spaceDim );
233 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tet::In::linePts", numPtsPerEdge , 1 );
234 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> triPts(
"Hcurl::Tet::In::triPts", numPtsPerFace , 2 );
237 const ordinal_type offset = 1;
256 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tet::In::edgePts", numPtsPerEdge , spaceDim );
257 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> facePts(
"Hcurl::Tet::In::facePts", numPtsPerFace , spaceDim );
259 for (ordinal_type i=0;i<numVertexes;i++) {
261 for(ordinal_type k=0; k<spaceDim; ++k)
262 dofCoords(i_card,k) = vertexes(i,k);
271 for (ordinal_type i=0;i<numEdges;i++) {
280 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
282 const ordinal_type i_card = numVertexes + numPtsPerEdge*i+j;
285 for(ordinal_type k=0; k<spaceDim; ++k)
286 dofCoords(i_card,k) = edgePts(j,k);
291 tags[i_card][3] = numPtsPerEdge;
296 if(numPtsPerFace >0) {
298 for (ordinal_type i=0;i<numFaces;i++) {
305 for (ordinal_type j=0;j<numPtsPerFace;j++) {
307 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numPtsPerFace*i+j;
310 for(ordinal_type k=0; k<spaceDim; ++k)
311 dofCoords(i_card,k) = facePts(j,k);
316 tags[i_card][3] = numPtsPerFace;
323 if (numPtsPerCell > 0) {
324 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
325 cellPoints(
"Hcurl::Tet::In::cellPoints", numPtsPerCell , spaceDim );
333 for (ordinal_type j=0;j<numPtsPerCell;j++) {
335 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numFaces*numPtsPerFace+j;
338 for(ordinal_type dim=0; dim<spaceDim; ++dim)
339 dofCoords(i_card,dim) = cellPoints(j,dim);
341 tags[i_card][0] = spaceDim;
344 tags[i_card][3] = numPtsPerCell;
348 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
349 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
353 const ordinal_type lwork = card*card;
354 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
355 vmat(
"Hgrad::Tet::Cn::vmat", card, card),
356 work(
"Hgrad::Tet::Cn::work", lwork),
357 ipiv(
"Hgrad::Tet::Cn::ipiv", card);
359 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
365 ordinal_type info = 0;
366 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
368 lapack.GETRF(card, card,
369 vmat.data(), vmat.stride(1),
370 (ordinal_type*)ipiv.data(),
373 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
375 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
378 vmat.data(), vmat.stride(1),
379 (ordinal_type*)ipiv.data(),
383 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
385 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
388 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
389 vinv(
"Hgrad::Line::Cn::vinv", card, card);
391 for (ordinal_type i=0;i<card;++i)
392 for (ordinal_type j=0;j<card;++j)
393 vinv(i,j) = vmat(j,i);
395 this->
vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
396 Kokkos::deep_copy(this->
vinv_ , vinv);
401 const ordinal_type posScDim = 0;
402 const ordinal_type posScOrd = 1;
403 const ordinal_type posDfOrd = 2;
420 template<
typename DT,
typename OT,
typename PT>
422 Basis_HGRAD_TET_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
423 ordinal_type& perTeamSpaceSize,
424 ordinal_type& perThreadSpaceSize,
426 const EOperator operatorType)
const {
427 perTeamSpaceSize = 0;
428 perThreadSpaceSize = getWorkSizePerPoint(operatorType)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
431 template<
typename DT,
typename OT,
typename PT>
432 KOKKOS_INLINE_FUNCTION
434 Basis_HGRAD_TET_Cn_FEM<DT,OT,PT>::getValues(
435 OutputViewType outputValues,
436 const PointViewType inputPoints,
437 const EOperator operatorType,
438 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
439 const typename DT::execution_space::scratch_memory_space & scratchStorage,
440 const ordinal_type subcellDim,
441 const ordinal_type subcellOrdinal)
const {
443 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
444 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
446 const int numPoints = inputPoints.extent(0);
447 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
448 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
449 constexpr ordinal_type spaceDim = 3;
450 auto sizePerPoint = (operatorType==OPERATOR_VALUE) ?
451 this->vinv_.extent(0)*get_dimension_scalar(inputPoints) :
452 (2*spaceDim+1)*this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
453 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
454 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
455 switch(operatorType) {
457 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
458 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
459 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
460 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
461 Impl::Basis_HGRAD_TET_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_, basisDegree_);
465 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_, basisDegree_ = this->basisDegree_] (ordinal_type& pt) {
466 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
467 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
468 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
469 Impl::Basis_HGRAD_TET_Cn_FEM::Serial<OPERATOR_GRAD>::getValues( output, input, work, vinv_, basisDegree_);
473 INTREPID2_TEST_FOR_ABORT(
true,
474 ">>> ERROR (Basis_HGRAD_TET_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_TET_Cn_FEM class.
Header file for the Intrepid2::Basis_HGRAD_TET_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...
Kokkos::DynRankView< scalarType, DeviceType > vinv_
inverse of Generalized Vandermonde matrix, whose columns store the expansion coefficients of the noda...
EPointType pointType_
type of lattice used for creating the DoF coordinates
Basis_HGRAD_TET_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
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_
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_TET_Cn_FEM.
See Intrepid2::Basis_HGRAD_TET_Cn_FEM.