49 #ifndef __INTREPID2_HCURL_TRI_IN_FEM_DEF_HPP__
50 #define __INTREPID2_HCURL_TRI_IN_FEM_DEF_HPP__
61 template<EOperator opType>
62 template<
typename outputViewType,
63 typename inputViewType,
64 typename workViewType,
65 typename vinvViewType>
66 KOKKOS_INLINE_FUNCTION
68 Basis_HCURL_TRI_In_FEM::Serial<opType>::
69 getValues( outputViewType output,
70 const inputViewType input,
72 const vinvViewType coeffs ) {
74 constexpr ordinal_type spaceDim = 2;
76 cardPn = coeffs.extent(0)/spaceDim,
77 card = coeffs.extent(1),
78 npts = input.extent(0);
81 ordinal_type order = 0;
83 if (card == CardinalityHCurlTri(p)) {
89 typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
90 auto vcprop = Kokkos::common_view_alloc_prop(work);
91 auto ptr = work.data();
94 case OPERATOR_VALUE: {
95 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
96 workViewType dummyView;
98 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
99 Serial<opType>::getValues(phis, input, dummyView, order);
101 for (ordinal_type i=0;i<card;++i)
102 for (ordinal_type j=0;j<npts;++j)
103 for (ordinal_type d=0;d<spaceDim;++d) {
104 output.access(i,j,d) = 0.0;
105 for (ordinal_type k=0;k<cardPn;++k)
106 output.access(i,j,d) += coeffs(k+d*cardPn,i) * phis(k,j);
110 case OPERATOR_CURL: {
111 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
112 ptr += card*npts*spaceDim*get_dimension_scalar(work);
113 const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
115 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
116 Serial<OPERATOR_GRAD>::getValues(phis, input, workView, order);
118 for (ordinal_type i=0;i<card;++i)
119 for (ordinal_type j=0;j<npts;++j) {
120 output.access(i,j) = 0.0;
121 for (ordinal_type k=0; k<cardPn; ++k)
122 output.access(i,j) += - coeffs(k,i)*phis(k,j,1)
123 + coeffs(k+cardPn,i)*phis(k,j,0);
128 INTREPID2_TEST_FOR_ABORT(
true,
129 ">>> ERROR (Basis_HCURL_TRI_In_FEM): Operator type not implemented");
134 template<
typename SpT, ordinal_type numPtsPerEval,
135 typename outputValueValueType,
class ...outputValueProperties,
136 typename inputPointValueType,
class ...inputPointProperties,
137 typename vinvValueType,
class ...vinvProperties>
139 Basis_HCURL_TRI_In_FEM::
140 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
141 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
142 const Kokkos::DynRankView<vinvValueType, vinvProperties...> coeffs,
143 const EOperator operatorType) {
144 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
145 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
146 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
147 typedef typename ExecSpace<typename inputPointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
150 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
151 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
152 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
153 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
155 typedef typename inputPointViewType::value_type inputPointType;
157 const ordinal_type cardinality = outputValues.extent(0);
158 const ordinal_type spaceDim = 2;
160 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
161 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
163 switch (operatorType) {
164 case OPERATOR_VALUE: {
165 workViewType work(Kokkos::view_alloc(
"Basis_HCURL_TRI_In_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
166 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
167 OPERATOR_VALUE,numPtsPerEval> FunctorType;
168 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
171 case OPERATOR_CURL: {
172 workViewType work(Kokkos::view_alloc(
"Basis_HCURL_TRI_In_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
173 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
174 OPERATOR_CURL,numPtsPerEval> FunctorType;
175 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
179 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
180 ">>> ERROR (Basis_HCURL_TRI_In_FEM): Operator type not implemented" );
187 template<
typename SpT,
typename OT,
typename PT>
190 const EPointType pointType ) {
192 constexpr ordinal_type spaceDim = 2;
193 this->basisCardinality_ = CardinalityHCurlTri(order);
194 this->basisDegree_ = order;
195 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >() );
196 this->basisType_ = BASIS_FEM_FIAT;
197 this->basisCoordinates_ = COORDINATES_CARTESIAN;
199 const ordinal_type card = this->basisCardinality_;
201 const ordinal_type cardPn = Intrepid2::getPnCardinality<spaceDim>(order);
202 const ordinal_type cardPnm1 = Intrepid2::getPnCardinality<spaceDim>(order-1);
203 const ordinal_type cardPnm2 = Intrepid2::getPnCardinality<spaceDim>(order-2);
204 const ordinal_type cardVecPn = spaceDim*cardPn;
205 const ordinal_type cardVecPnm1 = spaceDim*cardPnm1;
209 constexpr ordinal_type tagSize = 4;
211 ordinal_type tags[maxCard][tagSize];
214 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
215 dofCoords(
"Hcurl::Tri::In::dofCoords", card, spaceDim);
217 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
218 coeffs(
"Hcurl::Tri::In::coeffs", cardVecPn, card);
220 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
221 dofCoeffs(
"Hcurl::Tri::In::dofCoeffs", card, spaceDim);
227 const ordinal_type lwork = card*card;
228 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
229 V1(
"Hcurl::Tri::In::V1", cardVecPn, card);
240 for (ordinal_type i=0;i<cardPnm1;i++)
241 for (ordinal_type d=0;d<spaceDim;d++)
242 V1(d*cardPn+i,d*cardPnm1+i) = 1.0;
248 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> cubPoints(
"Hcurl::Tri::In::cubPoints", myCub.
getNumPoints() , spaceDim );
249 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> cubWeights(
"Hcurl::Tri::In::cubWeights", myCub.
getNumPoints() );
253 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> phisAtCubPoints(
"Hcurl::Tri::In::phisAtCubPoints", cardPn , myCub.
getNumPoints() );
254 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(phisAtCubPoints, cubPoints, order, OPERATOR_VALUE);
257 for (ordinal_type i=0;i<order;i++) {
258 for (ordinal_type j=0;j<cardPn;j++) {
260 V1(j,cardVecPnm1+i) -=
261 cubWeights(k) * cubPoints(k,1)
262 * phisAtCubPoints(cardPnm2+i,k)
263 * phisAtCubPoints(j,k);
264 V1(j+cardPn,cardVecPnm1+i) +=
265 cubWeights(k) * cubPoints(k,0)
266 * phisAtCubPoints(cardPnm2+i,k)
267 * phisAtCubPoints(j,k);
273 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
274 V2(
"Hcurl::Tri::In::V2", card ,cardVecPn);
276 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
278 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
286 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tri::In::linePts", numPtsPerEdge , 1 );
289 const ordinal_type offset = 1;
296 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tri::In::edgePts", numPtsPerEdge , spaceDim );
297 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> phisAtEdgePoints(
"Hcurl::Tri::In::phisAtEdgePoints", cardPn , numPtsPerEdge );
298 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace> edgeTan(
"Hcurl::Tri::In::edgeTan", spaceDim );
301 for (ordinal_type edge=0;edge<numEdges;edge++) {
304 this->basisCellTopology_ );
306 const scalarType refEdgeMeasure = 2.0;
307 for (ordinal_type j=0;j<spaceDim;j++)
308 edgeTan(j) *= refEdgeMeasure;
314 this->basisCellTopology_ );
316 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(phisAtEdgePoints , edgePts, order, OPERATOR_VALUE);
319 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
321 const ordinal_type i_card = numPtsPerEdge*edge+j;
324 for (ordinal_type k=0;k<cardPn;k++) {
325 V2(i_card,k) = edgeTan(0) * phisAtEdgePoints(k,j);
326 V2(i_card,k+cardPn) = edgeTan(1) * phisAtEdgePoints(k,j);
331 for(ordinal_type k=0; k<spaceDim; ++k) {
332 dofCoords(i_card,k) = edgePts(j,k);
333 dofCoeffs(i_card,k) = edgeTan(k);
337 tags[i_card][1] = edge;
339 tags[i_card][3] = numPtsPerEdge;
355 if (numPtsPerCell > 0) {
356 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
357 internalPoints(
"Hcurl::Tri::In::internalPoints", numPtsPerCell , spaceDim );
359 this->basisCellTopology_ ,
364 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
365 phisAtInternalPoints(
"Hcurl::Tri::In::phisAtInternalPoints", cardPn , numPtsPerCell );
366 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>( phisAtInternalPoints , internalPoints , order, OPERATOR_VALUE );
369 for (ordinal_type j=0;j<numPtsPerCell;j++) {
371 const ordinal_type i_card = numEdges*order+spaceDim*j;
373 for (ordinal_type k=0;k<cardPn;k++) {
375 V2(i_card,k) = phisAtInternalPoints(k,j);
377 V2(i_card+1,cardPn+k) = phisAtInternalPoints(k,j);
381 for(ordinal_type d=0; d<spaceDim; ++d) {
382 for(ordinal_type dim=0; dim<spaceDim; ++dim) {
383 dofCoords(i_card+d,dim) = internalPoints(j,dim);
384 dofCoeffs(i_card+d,dim) = (d==dim);
387 tags[i_card+d][0] = spaceDim;
388 tags[i_card+d][1] = 0;
389 tags[i_card+d][2] = spaceDim*j+d;
390 tags[i_card+d][3] = spaceDim*numPtsPerCell;
397 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
398 vmat(
"Hcurl::Tri::In::vmat", card, card),
399 work(
"Hcurl::Tri::In::work", lwork),
400 ipiv(
"Hcurl::Tri::In::ipiv", card);
403 for(ordinal_type i=0; i< card; ++i) {
404 for(ordinal_type j=0; j< card; ++j) {
406 for(ordinal_type k=0; k< cardVecPn; ++k)
407 s += V2(i,k)*V1(k,j);
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_HCURL_TRI_In_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_HCURL_TRI_In_FEM) lapack.GETRI returns nonzero info." );
434 for (ordinal_type i=0;i<cardVecPn;++i)
435 for (ordinal_type j=0;j<card;++j){
437 for(ordinal_type k=0; k< card; ++k)
438 s += V1(i,k)*vmat(k,j);
442 this->coeffs_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), coeffs);
443 Kokkos::deep_copy(this->coeffs_ , coeffs);
445 this->dofCoords_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoords);
446 Kokkos::deep_copy(this->dofCoords_, dofCoords);
448 this->dofCoeffs_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoeffs);
449 Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
455 const ordinal_type posScDim = 0;
456 const ordinal_type posScOrd = 1;
457 const ordinal_type posDfOrd = 2;
463 this->setOrdinalTagData(this->tagToOrdinal_,
466 this->basisCardinality_,
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH class.
Header file for the Intrepid2::CubatureDirectTriDefault class.
Defines direct integration rules on a triangle.
Basis_HCURL_TRI_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::View< ordinal_type *,typename ExecSpaceType::array_layout, Kokkos::HostSpace > ordinal_type_array_1d_host
View type for 1d host array.
virtual void getCubature(pointViewType cubPoints, weightViewType cubWeights) const
Returns cubature points and weights (return arrays must be pre-sized/pre-allocated).
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
virtual ordinal_type getNumPoints() const
Returns the number of cubature points.