49 #ifndef __INTREPID2_HGRAD_TET_CN_FEM_DEF_HPP__
50 #define __INTREPID2_HGRAD_TET_CN_FEM_DEF_HPP__
60 template<EOperator opType>
61 template<
typename outputViewType,
62 typename inputViewType,
63 typename workViewType,
64 typename vinvViewType>
65 KOKKOS_INLINE_FUNCTION
67 Basis_HGRAD_TET_Cn_FEM::Serial<opType>::
68 getValues( outputViewType output,
69 const inputViewType input,
71 const vinvViewType vinv ) {
73 constexpr ordinal_type spaceDim = 3;
75 card = vinv.extent(0),
76 npts = input.extent(0);
79 ordinal_type order = 0;
81 if (card == Intrepid2::getPnCardinality<spaceDim>(p)) {
87 typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
88 auto vcprop = Kokkos::common_view_alloc_prop(work);
89 auto ptr = work.data();
92 case OPERATOR_VALUE: {
93 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
96 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
97 Serial<opType>::getValues(phis, input, dummyView, order);
99 for (ordinal_type i=0;i<card;++i)
100 for (ordinal_type j=0;j<npts;++j) {
101 output.access(i,j) = 0.0;
102 for (ordinal_type k=0;k<card;++k)
103 output.access(i,j) += vinv(k,i)*phis.access(k,j);
109 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
110 ptr += card*npts*spaceDim*get_dimension_scalar(work);
111 const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
112 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
113 Serial<opType>::getValues(phis, input, workView, order);
115 for (ordinal_type i=0;i<card;++i)
116 for (ordinal_type j=0;j<npts;++j)
117 for (ordinal_type k=0;k<spaceDim;++k) {
118 output.access(i,j,k) = 0.0;
119 for (ordinal_type l=0;l<card;++l)
120 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
133 const ordinal_type dkcard = getDkCardinality<opType,spaceDim>();
134 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, dkcard);
137 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
138 Serial<opType>::getValues(phis, input, dummyView, order);
140 for (ordinal_type i=0;i<card;++i)
141 for (ordinal_type j=0;j<npts;++j)
142 for (ordinal_type k=0;k<dkcard;++k) {
143 output.access(i,j,k) = 0.0;
144 for (ordinal_type l=0;l<card;++l)
145 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
150 INTREPID2_TEST_FOR_ABORT(
true,
151 ">>> ERROR (Basis_HGRAD_TET_Cn_FEM): Operator type not implemented");
156 template<
typename SpT, ordinal_type numPtsPerEval,
157 typename outputValueValueType,
class ...outputValueProperties,
158 typename inputPointValueType,
class ...inputPointProperties,
159 typename vinvValueType,
class ...vinvProperties>
161 Basis_HGRAD_TET_Cn_FEM::
162 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
163 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
164 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
165 const EOperator operatorType) {
166 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
167 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
168 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
169 typedef typename ExecSpace<typename inputPointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
172 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
173 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
174 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
175 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
177 typedef typename inputPointViewType::value_type inputPointType;
179 const ordinal_type cardinality = outputValues.extent(0);
180 const ordinal_type spaceDim = 3;
182 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
183 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
185 switch (operatorType) {
186 case OPERATOR_VALUE: {
187 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TET_Cn_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
188 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
189 OPERATOR_VALUE,numPtsPerEval> FunctorType;
190 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
195 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TET_Cn_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
196 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
197 OPERATOR_D1,numPtsPerEval> FunctorType;
198 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
202 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
203 OPERATOR_D2,numPtsPerEval> FunctorType;
204 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TET_Cn_FEM::getValues::work", vcprop), cardinality*outputValues.extent(2), inputPoints.extent(0));
205 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
216 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
217 ">>> ERROR (Basis_HGRAD_TET_Cn_FEM): Operator type not implemented" );
224 template<
typename SpT,
typename OT,
typename PT>
227 const EPointType pointType ) {
228 constexpr ordinal_type spaceDim = 3;
230 this->basisCardinality_ = Intrepid2::getPnCardinality<spaceDim>(order);
231 this->basisDegree_ = order;
232 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
233 this->basisType_ = BASIS_FEM_FIAT;
234 this->basisCoordinates_ = COORDINATES_CARTESIAN;
236 const ordinal_type card = this->basisCardinality_;
239 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
240 dofCoords(
"Hgrad::Tet::Cn::dofCoords", card, spaceDim);
243 constexpr ordinal_type tagSize = 4;
244 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
245 ordinal_type tags[maxCard][tagSize];
249 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
250 const ordinal_type numFaces = this->basisCellTopology_.getFaceCount();
252 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
253 shards::CellTopology faceTop(shards::getCellTopologyData<shards::Triangle<3> >() );
271 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> vertexes(
"Hcurl::Tet::In::vertexes", numVertexes , spaceDim );
272 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tet::In::linePts", numPtsPerEdge , 1 );
273 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> triPts(
"Hcurl::Tet::In::triPts", numPtsPerFace , 2 );
276 const ordinal_type offset = 1;
280 this->basisCellTopology_ ,
295 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tet::In::edgePts", numPtsPerEdge , spaceDim );
296 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> facePts(
"Hcurl::Tet::In::facePts", numPtsPerFace , spaceDim );
298 for (ordinal_type i=0;i<numVertexes;i++) {
300 for(ordinal_type k=0; k<spaceDim; ++k)
301 dofCoords(i_card,k) = vertexes(i,k);
310 for (ordinal_type i=0;i<numEdges;i++) {
315 this->basisCellTopology_ );
319 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
321 const ordinal_type i_card = numVertexes + numPtsPerEdge*i+j;
324 for(ordinal_type k=0; k<spaceDim; ++k)
325 dofCoords(i_card,k) = edgePts(j,k);
330 tags[i_card][3] = numPtsPerEdge;
335 if(numPtsPerFace >0) {
337 for (ordinal_type i=0;i<numFaces;i++) {
343 this->basisCellTopology_ );
344 for (ordinal_type j=0;j<numPtsPerFace;j++) {
346 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numPtsPerFace*i+j;
349 for(ordinal_type k=0; k<spaceDim; ++k)
350 dofCoords(i_card,k) = facePts(j,k);
355 tags[i_card][3] = numPtsPerFace;
362 if (numPtsPerCell > 0) {
363 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
364 cellPoints(
"Hcurl::Tet::In::cellPoints", numPtsPerCell , spaceDim );
366 this->basisCellTopology_ ,
372 for (ordinal_type j=0;j<numPtsPerCell;j++) {
374 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numFaces*numPtsPerFace+j;
377 for(ordinal_type dim=0; dim<spaceDim; ++dim)
378 dofCoords(i_card,dim) = cellPoints(j,dim);
380 tags[i_card][0] = spaceDim;
383 tags[i_card][3] = numPtsPerCell;
387 this->dofCoords_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoords);
388 Kokkos::deep_copy(this->dofCoords_, dofCoords);
392 const ordinal_type lwork = card*card;
393 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
394 vmat(
"Hgrad::Tet::Cn::vmat", card, card),
395 work(
"Hgrad::Tet::Cn::work", lwork),
396 ipiv(
"Hgrad::Tet::Cn::ipiv", card);
398 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(vmat, dofCoords, order, OPERATOR_VALUE);
400 ordinal_type info = 0;
401 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
403 lapack.GETRF(card, card,
404 vmat.data(), vmat.stride_1(),
405 (ordinal_type*)ipiv.data(),
408 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
410 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
413 vmat.data(), vmat.stride_1(),
414 (ordinal_type*)ipiv.data(),
418 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
420 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
423 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
424 vinv(
"Hgrad::Line::Cn::vinv", card, card);
426 for (ordinal_type i=0;i<card;++i)
427 for (ordinal_type j=0;j<card;++j)
428 vinv(i,j) = vmat(j,i);
430 this->vinv_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), vinv);
431 Kokkos::deep_copy(this->vinv_ , vinv);
436 const ordinal_type posScDim = 0;
437 const ordinal_type posScOrd = 1;
438 const ordinal_type posDfOrd = 2;
444 this->setOrdinalTagData(this->tagToOrdinal_,
447 this->basisCardinality_,
Basis_HGRAD_TET_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM class.
Kokkos::View< ordinal_type *,typename ExecSpaceType::array_layout, Kokkos::HostSpace > ordinal_type_array_1d_host
View type for 1d host array.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH class.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.