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;
235 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
237 const ordinal_type card = this->basisCardinality_;
240 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
241 dofCoords(
"Hgrad::Tet::Cn::dofCoords", card, spaceDim);
244 constexpr ordinal_type tagSize = 4;
245 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
246 ordinal_type tags[maxCard][tagSize];
250 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
251 const ordinal_type numFaces = this->basisCellTopology_.getFaceCount();
253 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
254 shards::CellTopology faceTop(shards::getCellTopologyData<shards::Triangle<3> >() );
272 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> vertexes(
"Hcurl::Tet::In::vertexes", numVertexes , spaceDim );
273 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tet::In::linePts", numPtsPerEdge , 1 );
274 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> triPts(
"Hcurl::Tet::In::triPts", numPtsPerFace , 2 );
277 const ordinal_type offset = 1;
281 this->basisCellTopology_ ,
296 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tet::In::edgePts", numPtsPerEdge , spaceDim );
297 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> facePts(
"Hcurl::Tet::In::facePts", numPtsPerFace , spaceDim );
299 for (ordinal_type i=0;i<numVertexes;i++) {
301 for(ordinal_type k=0; k<spaceDim; ++k)
302 dofCoords(i_card,k) = vertexes(i,k);
311 for (ordinal_type i=0;i<numEdges;i++) {
316 this->basisCellTopology_ );
320 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
322 const ordinal_type i_card = numVertexes + numPtsPerEdge*i+j;
325 for(ordinal_type k=0; k<spaceDim; ++k)
326 dofCoords(i_card,k) = edgePts(j,k);
331 tags[i_card][3] = numPtsPerEdge;
336 if(numPtsPerFace >0) {
338 for (ordinal_type i=0;i<numFaces;i++) {
344 this->basisCellTopology_ );
345 for (ordinal_type j=0;j<numPtsPerFace;j++) {
347 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numPtsPerFace*i+j;
350 for(ordinal_type k=0; k<spaceDim; ++k)
351 dofCoords(i_card,k) = facePts(j,k);
356 tags[i_card][3] = numPtsPerFace;
363 if (numPtsPerCell > 0) {
364 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
365 cellPoints(
"Hcurl::Tet::In::cellPoints", numPtsPerCell , spaceDim );
367 this->basisCellTopology_ ,
373 for (ordinal_type j=0;j<numPtsPerCell;j++) {
375 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numFaces*numPtsPerFace+j;
378 for(ordinal_type dim=0; dim<spaceDim; ++dim)
379 dofCoords(i_card,dim) = cellPoints(j,dim);
381 tags[i_card][0] = spaceDim;
384 tags[i_card][3] = numPtsPerCell;
388 this->dofCoords_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoords);
389 Kokkos::deep_copy(this->dofCoords_, dofCoords);
393 const ordinal_type lwork = card*card;
394 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
395 vmat(
"Hgrad::Tet::Cn::vmat", card, card),
396 work(
"Hgrad::Tet::Cn::work", lwork),
397 ipiv(
"Hgrad::Tet::Cn::ipiv", card);
399 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(vmat, dofCoords, order, OPERATOR_VALUE);
401 ordinal_type info = 0;
402 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
404 lapack.GETRF(card, card,
405 vmat.data(), vmat.stride_1(),
406 (ordinal_type*)ipiv.data(),
409 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
411 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
414 vmat.data(), vmat.stride_1(),
415 (ordinal_type*)ipiv.data(),
419 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
421 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
424 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
425 vinv(
"Hgrad::Line::Cn::vinv", card, card);
427 for (ordinal_type i=0;i<card;++i)
428 for (ordinal_type j=0;j<card;++j)
429 vinv(i,j) = vmat(j,i);
431 this->vinv_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), vinv);
432 Kokkos::deep_copy(this->vinv_ , vinv);
437 const ordinal_type posScDim = 0;
438 const ordinal_type posScOrd = 1;
439 const ordinal_type posDfOrd = 2;
445 this->setOrdinalTagData(this->tagToOrdinal_,
448 this->basisCardinality_,
Kokkos::View< ordinal_type *, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
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.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH class.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.