49 #ifndef __INTREPID2_HDIV_TRI_IN_FEM_DEF_HPP__
50 #define __INTREPID2_HDIV_TRI_IN_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_HDIV_TRI_In_FEM::Serial<opType>::
68 getValues( OutputViewType output,
69 const inputViewType input,
71 const vinvViewType coeffs ) {
73 constexpr ordinal_type spaceDim = 2;
75 cardPn = coeffs.extent(0)/spaceDim,
76 card = coeffs.extent(1),
77 npts = input.extent(0);
80 ordinal_type order = 0;
82 if (card == CardinalityHDivTri(p)) {
88 typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
89 auto vcprop = Kokkos::common_view_alloc_prop(work);
90 auto ptr = work.data();
93 case OPERATOR_VALUE: {
94 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
95 workViewType dummyView;
97 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
98 Serial<opType>::getValues(phis, input, dummyView, order);
100 for (ordinal_type i=0;i<card;++i)
101 for (ordinal_type j=0;j<npts;++j)
102 for (ordinal_type d=0;d<spaceDim;++d) {
103 output.access(i,j,d) = 0.0;
104 for (ordinal_type k=0;k<cardPn;++k)
105 output.access(i,j,d) += coeffs(k+d*cardPn,i) * phis.access(k,j);
110 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
111 ptr += card*npts*spaceDim*get_dimension_scalar(work);
112 const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
114 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
115 Serial<OPERATOR_GRAD>::getValues(phis, input, workView, order);
117 for (ordinal_type i=0;i<card;++i)
118 for (ordinal_type j=0;j<npts;++j) {
119 output.access(i,j) = 0.0;
120 for (ordinal_type k=0; k<cardPn; ++k)
121 for (ordinal_type d=0; d<spaceDim; ++d)
122 output.access(i,j) += coeffs(k+d*cardPn,i)*phis.access(k,j,d);
127 INTREPID2_TEST_FOR_ABORT(
true,
128 ">>> ERROR (Basis_HDIV_TRI_In_FEM): Operator type not implemented");
133 template<
typename DT, ordinal_type numPtsPerEval,
134 typename outputValueValueType,
class ...outputValueProperties,
135 typename inputPointValueType,
class ...inputPointProperties,
136 typename vinvValueType,
class ...vinvProperties>
138 Basis_HDIV_TRI_In_FEM::
139 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
140 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
141 const Kokkos::DynRankView<vinvValueType, vinvProperties...> coeffs,
142 const EOperator operatorType) {
143 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
144 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
145 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
146 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
149 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
150 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
151 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
152 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
154 typedef typename inputPointViewType::value_type inputPointType;
156 const ordinal_type cardinality = outputValues.extent(0);
157 const ordinal_type spaceDim = 2;
159 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
160 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
162 switch (operatorType) {
163 case OPERATOR_VALUE: {
164 workViewType work(Kokkos::view_alloc(
"Basis_HDIV_TRI_In_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
165 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
166 OPERATOR_VALUE,numPtsPerEval> FunctorType;
167 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
171 workViewType work(Kokkos::view_alloc(
"Basis_HDIV_TRI_In_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
172 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
173 OPERATOR_DIV,numPtsPerEval> FunctorType;
174 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
178 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
179 ">>> ERROR (Basis_HDIV_TRI_In_FEM): Operator type not implemented" );
186 template<
typename DT,
typename OT,
typename PT>
189 const EPointType pointType ) {
192 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
194 constexpr ordinal_type spaceDim = 2;
195 this->basisCardinality_ = CardinalityHDivTri(order);
196 this->basisDegree_ = order;
197 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >() );
198 this->basisType_ = BASIS_FEM_LAGRANGIAN;
199 this->basisCoordinates_ = COORDINATES_CARTESIAN;
200 this->functionSpace_ = FUNCTION_SPACE_HDIV;
201 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
203 const ordinal_type card = this->basisCardinality_;
205 const ordinal_type cardPn = Intrepid2::getPnCardinality<spaceDim>(order);
206 const ordinal_type cardPnm1 = Intrepid2::getPnCardinality<spaceDim>(order-1);
207 const ordinal_type cardPnm2 = Intrepid2::getPnCardinality<spaceDim>(order-2);
208 const ordinal_type cardVecPn = spaceDim*cardPn;
209 const ordinal_type cardVecPnm1 = spaceDim*cardPnm1;
213 constexpr ordinal_type tagSize = 4;
215 ordinal_type tags[maxCard][tagSize];
218 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
219 dofCoords(
"Hdiv::Tri::In::dofCoords", card, spaceDim);
221 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
222 dofCoeffs(
"Hdiv::Tri::In::dofCoeffs", card, spaceDim);
224 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
225 coeffs(
"Hdiv::Tri::In::coeffs", cardVecPn, card);
231 const ordinal_type lwork = card*card;
232 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
233 V1(
"Hdiv::Tri::In::V1", cardVecPn, card);
243 for (ordinal_type i=0;i<cardPnm1;i++) {
245 V1(cardPn+i,cardPnm1+i) = 1.0;
251 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> cubPoints(
"Hdiv::Tri::In::cubPoints", myCub.
getNumPoints() , spaceDim );
252 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> cubWeights(
"Hdiv::Tri::In::cubWeights", myCub.
getNumPoints() );
256 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> phisAtCubPoints(
"Hdiv::Tri::In::phisAtCubPoints", cardPn , myCub.
getNumPoints() );
257 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
264 for (ordinal_type i=0;i<order;i++) {
265 for (ordinal_type j=0;j<cardPn;j++) {
266 V1(j,cardVecPnm1+i) = 0.0;
267 for (ordinal_type d=0; d< spaceDim; ++d)
269 V1(j+d*cardPn,cardVecPnm1+i) +=
270 cubWeights(k) * cubPoints(k,d)
271 * phisAtCubPoints(cardPnm2+i,k)
272 * phisAtCubPoints(j,k);
278 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
279 V2(
"Hdiv::Tri::In::V2", card ,cardVecPn);
281 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
283 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
291 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> linePts(
"Hdiv::Tri::In::linePts", numPtsPerEdge , 1 );
294 const ordinal_type offset = 1;
301 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgePts(
"Hdiv::Tri::In::edgePts", numPtsPerEdge , spaceDim );
302 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> phisAtEdgePoints(
"Hdiv::Tri::In::phisAtEdgePoints", cardPn , numPtsPerEdge );
303 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgeNormal(
"Hcurl::Tri::In::edgeNormal", spaceDim );
306 for (ordinal_type edge=0;edge<numEdges;edge++) {
309 this->basisCellTopology_ );
315 this->basisCellTopology_ );
317 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
324 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
326 const ordinal_type i_card = numPtsPerEdge*edge+j;
329 for (ordinal_type k=0;k<cardPn;k++) {
331 for (ordinal_type l=0; l<spaceDim; l++)
332 V2(i_card,k+l*cardPn) = edgeNormal(l) * phisAtEdgePoints(k,j);
337 for(ordinal_type l=0; l<spaceDim; ++l) {
338 dofCoords(i_card,l) = edgePts(j,l);
339 dofCoeffs(i_card,l) = edgeNormal(l);
343 tags[i_card][1] = edge;
345 tags[i_card][3] = numPtsPerEdge;
362 if (numPtsPerCell > 0) {
363 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
364 internalPoints(
"Hdiv::Tri::In::internalPoints", numPtsPerCell , spaceDim );
366 this->basisCellTopology_ ,
371 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
372 phisAtInternalPoints(
"Hdiv::Tri::In::phisAtInternalPoints", cardPn , numPtsPerCell );
373 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
374 phisAtInternalPoints,
380 for (ordinal_type j=0;j<numPtsPerCell;j++) {
382 const ordinal_type i_card = numEdges*order+spaceDim*j;
384 for (ordinal_type k=0;k<cardPn;k++) {
385 for (ordinal_type l=0;l<spaceDim;l++) {
386 V2(i_card+l,l*cardPn+k) = phisAtInternalPoints(k,j);
391 for(ordinal_type d=0; d<spaceDim; ++d) {
392 for(ordinal_type l=0; l<spaceDim; ++l) {
393 dofCoords(i_card+d,l) = internalPoints(j,l);
394 dofCoeffs(i_card+d,l) = (l==d);
397 tags[i_card+d][0] = spaceDim;
398 tags[i_card+d][1] = 0;
399 tags[i_card+d][2] = spaceDim*j+d;
400 tags[i_card+d][3] = spaceDim*numPtsPerCell;
407 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
408 vmat(
"Hdiv::Tri::In::vmat", card, card),
409 work(
"Hdiv::Tri::In::work", lwork),
410 ipiv(
"Hdiv::Tri::In::ipiv", card);
413 for(ordinal_type i=0; i< card; ++i) {
414 for(ordinal_type j=0; j< card; ++j) {
416 for(ordinal_type k=0; k< cardVecPn; ++k)
417 s += V2(i,k)*V1(k,j);
422 ordinal_type info = 0;
423 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
425 lapack.GETRF(card, card,
426 vmat.data(), vmat.stride_1(),
427 (ordinal_type*)ipiv.data(),
430 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
432 ">>> ERROR: (Intrepid2::Basis_HDIV_TRI_In_FEM) lapack.GETRF returns nonzero info." );
435 vmat.data(), vmat.stride_1(),
436 (ordinal_type*)ipiv.data(),
440 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
442 ">>> ERROR: (Intrepid2::Basis_HDIV_TRI_In_FEM) lapack.GETRI returns nonzero info." );
444 for (ordinal_type i=0;i<cardVecPn;++i)
445 for (ordinal_type j=0;j<card;++j){
447 for(ordinal_type k=0; k< card; ++k)
448 s += V1(i,k)*vmat(k,j);
452 this->coeffs_ = Kokkos::create_mirror_view(
typename DT::memory_space(), coeffs);
453 Kokkos::deep_copy(this->coeffs_ , coeffs);
455 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
456 Kokkos::deep_copy(this->dofCoords_, dofCoords);
458 this->dofCoeffs_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoeffs);
459 Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
465 const ordinal_type posScDim = 0;
466 const ordinal_type posScOrd = 1;
467 const ordinal_type posDfOrd = 2;
469 OrdinalTypeArray1DHost tagView(&tags[0][0], card*tagSize);
473 this->setOrdinalTagData(this->tagToOrdinal_,
476 this->basisCardinality_,
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH class.
virtual void getCubature(PointViewType cubPoints, weightViewType cubWeights) const override
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
virtual ordinal_type getNumPoints() const override
Returns the number of cubature points.
Header file for the Intrepid2::CubatureDirectTrisymPos class.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
Basis_HDIV_TRI_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.