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 DT, ordinal_type numPtsPerEval,
157 typename outputValueValueType,
class ...outputValueProperties,
158 typename inputPointValueType,
class ...inputPointProperties,
159 typename vinvValueType,
class ...vinvProperties>
161 Basis_HGRAD_TET_Cn_FEM::
163 const typename DT::execution_space& space,
164 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
165 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
166 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
167 const EOperator operatorType) {
168 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
169 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
170 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
171 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
174 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
175 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
176 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
177 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
179 typedef typename inputPointViewType::value_type inputPointType;
181 const ordinal_type cardinality = outputValues.extent(0);
182 const ordinal_type spaceDim = 3;
184 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
185 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
187 switch (operatorType) {
188 case OPERATOR_VALUE: {
189 workViewType work(Kokkos::view_alloc(space,
"Basis_HGRAD_TET_Cn_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
190 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
191 OPERATOR_VALUE,numPtsPerEval> FunctorType;
192 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
197 workViewType work(Kokkos::view_alloc(space,
"Basis_HGRAD_TET_Cn_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
198 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
199 OPERATOR_D1,numPtsPerEval> FunctorType;
200 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
204 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
205 OPERATOR_D2,numPtsPerEval> FunctorType;
206 workViewType work(Kokkos::view_alloc(space,
"Basis_HGRAD_TET_Cn_FEM::getValues::work", vcprop), cardinality*outputValues.extent(2), inputPoints.extent(0));
207 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
218 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
219 ">>> ERROR (Basis_HGRAD_TET_Cn_FEM): Operator type not implemented" );
226 template<
typename DT,
typename OT,
typename PT>
229 const EPointType pointType ) {
230 constexpr ordinal_type spaceDim = 3;
232 this->basisCardinality_ = Intrepid2::getPnCardinality<spaceDim>(order);
233 this->basisDegree_ = order;
234 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
235 this->basisType_ = BASIS_FEM_LAGRANGIAN;
236 this->basisCoordinates_ = COORDINATES_CARTESIAN;
237 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
238 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
240 const ordinal_type card = this->basisCardinality_;
243 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
244 dofCoords(
"Hgrad::Tet::Cn::dofCoords", card, spaceDim);
248 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
251 constexpr ordinal_type tagSize = 4;
252 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
253 ordinal_type tags[maxCard][tagSize];
257 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
258 const ordinal_type numFaces = this->basisCellTopology_.getFaceCount();
260 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
261 shards::CellTopology faceTop(shards::getCellTopologyData<shards::Triangle<3> >() );
279 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> vertexes(
"Hcurl::Tet::In::vertexes", numVertexes , spaceDim );
280 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tet::In::linePts", numPtsPerEdge , 1 );
281 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> triPts(
"Hcurl::Tet::In::triPts", numPtsPerFace , 2 );
284 const ordinal_type offset = 1;
288 this->basisCellTopology_ ,
303 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tet::In::edgePts", numPtsPerEdge , spaceDim );
304 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> facePts(
"Hcurl::Tet::In::facePts", numPtsPerFace , spaceDim );
306 for (ordinal_type i=0;i<numVertexes;i++) {
308 for(ordinal_type k=0; k<spaceDim; ++k)
309 dofCoords(i_card,k) = vertexes(i,k);
318 for (ordinal_type i=0;i<numEdges;i++) {
323 this->basisCellTopology_ );
327 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
329 const ordinal_type i_card = numVertexes + numPtsPerEdge*i+j;
332 for(ordinal_type k=0; k<spaceDim; ++k)
333 dofCoords(i_card,k) = edgePts(j,k);
338 tags[i_card][3] = numPtsPerEdge;
343 if(numPtsPerFace >0) {
345 for (ordinal_type i=0;i<numFaces;i++) {
351 this->basisCellTopology_ );
352 for (ordinal_type j=0;j<numPtsPerFace;j++) {
354 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numPtsPerFace*i+j;
357 for(ordinal_type k=0; k<spaceDim; ++k)
358 dofCoords(i_card,k) = facePts(j,k);
363 tags[i_card][3] = numPtsPerFace;
370 if (numPtsPerCell > 0) {
371 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
372 cellPoints(
"Hcurl::Tet::In::cellPoints", numPtsPerCell , spaceDim );
374 this->basisCellTopology_ ,
380 for (ordinal_type j=0;j<numPtsPerCell;j++) {
382 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numFaces*numPtsPerFace+j;
385 for(ordinal_type dim=0; dim<spaceDim; ++dim)
386 dofCoords(i_card,dim) = cellPoints(j,dim);
388 tags[i_card][0] = spaceDim;
391 tags[i_card][3] = numPtsPerCell;
395 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
396 Kokkos::deep_copy(this->dofCoords_, dofCoords);
400 const ordinal_type lwork = card*card;
401 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
402 vmat(
"Hgrad::Tet::Cn::vmat", card, card),
403 work(
"Hgrad::Tet::Cn::work", lwork),
404 ipiv(
"Hgrad::Tet::Cn::ipiv", card);
406 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
412 ordinal_type info = 0;
413 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
415 lapack.GETRF(card, card,
416 vmat.data(), vmat.stride_1(),
417 (ordinal_type*)ipiv.data(),
420 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
422 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
425 vmat.data(), vmat.stride_1(),
426 (ordinal_type*)ipiv.data(),
430 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
432 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
435 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
436 vinv(
"Hgrad::Line::Cn::vinv", card, card);
438 for (ordinal_type i=0;i<card;++i)
439 for (ordinal_type j=0;j<card;++j)
440 vinv(i,j) = vmat(j,i);
442 this->vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
443 Kokkos::deep_copy(this->vinv_ , vinv);
448 const ordinal_type posScDim = 0;
449 const ordinal_type posScOrd = 1;
450 const ordinal_type posDfOrd = 2;
456 this->setOrdinalTagData(this->tagToOrdinal_,
459 this->basisCardinality_,
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM class.
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_ORTH class.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.