49#ifndef __INTREPID2_HGRAD_TET_CN_FEM_DEF_HPP__
50#define __INTREPID2_HGRAD_TET_CN_FEM_DEF_HPP__
60template<EOperator opType>
61template<
typename OutputViewType,
62typename inputViewType,
67Basis_HGRAD_TET_Cn_FEM::Serial<opType>::
68getValues( 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");
156template<
typename DT, ordinal_type numPtsPerEval,
157typename outputValueValueType,
class ...outputValueProperties,
158typename inputPointValueType,
class ...inputPointProperties,
159typename vinvValueType,
class ...vinvProperties>
161Basis_HGRAD_TET_Cn_FEM::
162getValues( 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,typename DT::execution_space>::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" );
224template<
typename DT,
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_LAGRANGIAN;
234 this->basisCoordinates_ = COORDINATES_CARTESIAN;
235 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
236 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
238 const ordinal_type card = this->basisCardinality_;
241 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
242 dofCoords(
"Hgrad::Tet::Cn::dofCoords", card, spaceDim);
246 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
249 constexpr ordinal_type tagSize = 4;
250 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
251 ordinal_type tags[maxCard][tagSize];
255 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
256 const ordinal_type numFaces = this->basisCellTopology_.getFaceCount();
258 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
259 shards::CellTopology faceTop(shards::getCellTopologyData<shards::Triangle<3> >() );
277 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> vertexes(
"Hcurl::Tet::In::vertexes", numVertexes , spaceDim );
278 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tet::In::linePts", numPtsPerEdge , 1 );
279 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> triPts(
"Hcurl::Tet::In::triPts", numPtsPerFace , 2 );
282 const ordinal_type offset = 1;
286 this->basisCellTopology_ ,
301 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tet::In::edgePts", numPtsPerEdge , spaceDim );
302 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> facePts(
"Hcurl::Tet::In::facePts", numPtsPerFace , spaceDim );
304 for (ordinal_type i=0;i<numVertexes;i++) {
306 for(ordinal_type k=0; k<spaceDim; ++k)
307 dofCoords(i_card,k) = vertexes(i,k);
316 for (ordinal_type i=0;i<numEdges;i++) {
321 this->basisCellTopology_ );
325 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
327 const ordinal_type i_card = numVertexes + numPtsPerEdge*i+j;
330 for(ordinal_type k=0; k<spaceDim; ++k)
331 dofCoords(i_card,k) = edgePts(j,k);
336 tags[i_card][3] = numPtsPerEdge;
341 if(numPtsPerFace >0) {
343 for (ordinal_type i=0;i<numFaces;i++) {
349 this->basisCellTopology_ );
350 for (ordinal_type j=0;j<numPtsPerFace;j++) {
352 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numPtsPerFace*i+j;
355 for(ordinal_type k=0; k<spaceDim; ++k)
356 dofCoords(i_card,k) = facePts(j,k);
361 tags[i_card][3] = numPtsPerFace;
368 if (numPtsPerCell > 0) {
369 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
370 cellPoints(
"Hcurl::Tet::In::cellPoints", numPtsPerCell , spaceDim );
372 this->basisCellTopology_ ,
378 for (ordinal_type j=0;j<numPtsPerCell;j++) {
380 const ordinal_type i_card = numVertexes+numEdges*numPtsPerEdge+numFaces*numPtsPerFace+j;
383 for(ordinal_type dim=0; dim<spaceDim; ++dim)
384 dofCoords(i_card,dim) = cellPoints(j,dim);
386 tags[i_card][0] = spaceDim;
389 tags[i_card][3] = numPtsPerCell;
393 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
394 Kokkos::deep_copy(this->dofCoords_, dofCoords);
398 const ordinal_type lwork = card*card;
399 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
400 vmat(
"Hgrad::Tet::Cn::vmat", card, card),
401 work(
"Hgrad::Tet::Cn::work", lwork),
402 ipiv(
"Hgrad::Tet::Cn::ipiv", card);
404 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::device_type,Parameters::MaxNumPtsPerBasisEval>(vmat, dofCoords, order, OPERATOR_VALUE);
406 ordinal_type info = 0;
407 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
409 lapack.GETRF(card, card,
410 vmat.data(), vmat.stride_1(),
411 (ordinal_type*)ipiv.data(),
414 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
416 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
419 vmat.data(), vmat.stride_1(),
420 (ordinal_type*)ipiv.data(),
424 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
426 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
429 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
430 vinv(
"Hgrad::Line::Cn::vinv", card, card);
432 for (ordinal_type i=0;i<card;++i)
433 for (ordinal_type j=0;j<card;++j)
434 vinv(i,j) = vmat(j,i);
436 this->vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
437 Kokkos::deep_copy(this->vinv_ , vinv);
442 const ordinal_type posScDim = 0;
443 const ordinal_type posScOrd = 1;
444 const ordinal_type posDfOrd = 2;
446 OrdinalTypeArray1DHost tagView(&tags[0][0], card*tagSize);
450 this->setOrdinalTagData(this->tagToOrdinal_,
453 this->basisCardinality_,
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM class.
Header file for the Intrepid2::Basis_HGRAD_TET_Cn_FEM_ORTH class.
Basis_HGRAD_TET_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.