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 DT, 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(
const typename DT::execution_space& space,
141 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
142 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
143 const Kokkos::DynRankView<vinvValueType, vinvProperties...> coeffs,
144 const EOperator operatorType) {
145 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
146 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
147 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
148 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
151 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
152 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
153 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
154 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
156 typedef typename inputPointViewType::value_type inputPointType;
158 const ordinal_type cardinality = outputValues.extent(0);
159 const ordinal_type spaceDim = 2;
161 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
162 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
164 switch (operatorType) {
165 case OPERATOR_VALUE: {
166 workViewType work(Kokkos::view_alloc(space,
"Basis_HCURL_TRI_In_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
167 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
168 OPERATOR_VALUE,numPtsPerEval> FunctorType;
169 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
172 case OPERATOR_CURL: {
173 workViewType work(Kokkos::view_alloc(space,
"Basis_HCURL_TRI_In_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
174 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
175 OPERATOR_CURL,numPtsPerEval> FunctorType;
176 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, coeffs, work) );
180 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
181 ">>> ERROR (Basis_HCURL_TRI_In_FEM): Operator type not implemented" );
188 template<
typename DT,
typename OT,
typename PT>
191 const EPointType pointType ) {
193 constexpr ordinal_type spaceDim = 2;
194 this->basisCardinality_ = CardinalityHCurlTri(order);
195 this->basisDegree_ = order;
196 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >() );
197 this->basisType_ = BASIS_FEM_LAGRANGIAN;
198 this->basisCoordinates_ = COORDINATES_CARTESIAN;
199 this->functionSpace_ = FUNCTION_SPACE_HCURL;
200 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
202 const ordinal_type card = this->basisCardinality_;
204 const ordinal_type cardPn = Intrepid2::getPnCardinality<spaceDim>(order);
205 const ordinal_type cardPnm1 = Intrepid2::getPnCardinality<spaceDim>(order-1);
206 const ordinal_type cardPnm2 = Intrepid2::getPnCardinality<spaceDim>(order-2);
207 const ordinal_type cardVecPn = spaceDim*cardPn;
208 const ordinal_type cardVecPnm1 = spaceDim*cardPnm1;
212 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
215 constexpr ordinal_type tagSize = 4;
217 ordinal_type tags[maxCard][tagSize];
220 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
221 dofCoords(
"Hcurl::Tri::In::dofCoords", card, spaceDim);
223 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
224 coeffs(
"Hcurl::Tri::In::coeffs", cardVecPn, card);
226 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
227 dofCoeffs(
"Hcurl::Tri::In::dofCoeffs", card, spaceDim);
233 const ordinal_type lwork = card*card;
234 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
235 V1(
"Hcurl::Tri::In::V1", cardVecPn, card);
246 for (ordinal_type i=0;i<cardPnm1;i++)
247 for (ordinal_type d=0;d<spaceDim;d++)
248 V1(d*cardPn+i,d*cardPnm1+i) = 1.0;
254 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> cubPoints(
"Hcurl::Tri::In::cubPoints", myCub.
getNumPoints() , spaceDim );
255 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> cubWeights(
"Hcurl::Tri::In::cubWeights", myCub.
getNumPoints() );
259 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> phisAtCubPoints(
"Hcurl::Tri::In::phisAtCubPoints", cardPn , myCub.
getNumPoints() );
260 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
267 for (ordinal_type i=0;i<order;i++) {
268 for (ordinal_type j=0;j<cardPn;j++) {
270 V1(j,cardVecPnm1+i) -=
271 cubWeights(k) * cubPoints(k,1)
272 * phisAtCubPoints(cardPnm2+i,k)
273 * phisAtCubPoints(j,k);
274 V1(j+cardPn,cardVecPnm1+i) +=
275 cubWeights(k) * cubPoints(k,0)
276 * phisAtCubPoints(cardPnm2+i,k)
277 * phisAtCubPoints(j,k);
283 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
284 V2(
"Hcurl::Tri::In::V2", card ,cardVecPn);
286 const ordinal_type numEdges = this->basisCellTopology_.getEdgeCount();
288 shards::CellTopology edgeTop(shards::getCellTopologyData<shards::Line<2> >() );
296 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> linePts(
"Hcurl::Tri::In::linePts", numPtsPerEdge , 1 );
299 const ordinal_type offset = 1;
306 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgePts(
"Hcurl::Tri::In::edgePts", numPtsPerEdge , spaceDim );
307 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> phisAtEdgePoints(
"Hcurl::Tri::In::phisAtEdgePoints", cardPn , numPtsPerEdge );
308 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace> edgeTan(
"Hcurl::Tri::In::edgeTan", spaceDim );
311 for (ordinal_type edge=0;edge<numEdges;edge++) {
314 this->basisCellTopology_ );
320 this->basisCellTopology_ );
322 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
329 for (ordinal_type j=0;j<numPtsPerEdge;j++) {
331 const ordinal_type i_card = numPtsPerEdge*edge+j;
334 for (ordinal_type k=0;k<cardPn;k++) {
335 V2(i_card,k) = edgeTan(0) * phisAtEdgePoints(k,j);
336 V2(i_card,k+cardPn) = edgeTan(1) * phisAtEdgePoints(k,j);
341 for(ordinal_type k=0; k<spaceDim; ++k) {
342 dofCoords(i_card,k) = edgePts(j,k);
343 dofCoeffs(i_card,k) = edgeTan(k);
347 tags[i_card][1] = edge;
349 tags[i_card][3] = numPtsPerEdge;
365 if (numPtsPerCell > 0) {
366 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
367 internalPoints(
"Hcurl::Tri::In::internalPoints", numPtsPerCell , spaceDim );
369 this->basisCellTopology_ ,
374 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
375 phisAtInternalPoints(
"Hcurl::Tri::In::phisAtInternalPoints", cardPn , numPtsPerCell );
376 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
377 phisAtInternalPoints,
383 for (ordinal_type j=0;j<numPtsPerCell;j++) {
385 const ordinal_type i_card = numEdges*order+spaceDim*j;
387 for (ordinal_type k=0;k<cardPn;k++) {
389 V2(i_card,k) = phisAtInternalPoints(k,j);
391 V2(i_card+1,cardPn+k) = phisAtInternalPoints(k,j);
395 for(ordinal_type d=0; d<spaceDim; ++d) {
396 for(ordinal_type dim=0; dim<spaceDim; ++dim) {
397 dofCoords(i_card+d,dim) = internalPoints(j,dim);
398 dofCoeffs(i_card+d,dim) = (d==dim);
401 tags[i_card+d][0] = spaceDim;
402 tags[i_card+d][1] = 0;
403 tags[i_card+d][2] = spaceDim*j+d;
404 tags[i_card+d][3] = spaceDim*numPtsPerCell;
411 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
412 vmat(
"Hcurl::Tri::In::vmat", card, card),
413 work(
"Hcurl::Tri::In::work", lwork),
414 ipiv(
"Hcurl::Tri::In::ipiv", card);
417 for(ordinal_type i=0; i< card; ++i) {
418 for(ordinal_type j=0; j< card; ++j) {
420 for(ordinal_type k=0; k< cardVecPn; ++k)
421 s += V2(i,k)*V1(k,j);
426 ordinal_type info = 0;
427 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
429 lapack.GETRF(card, card,
430 vmat.data(), vmat.stride_1(),
431 (ordinal_type*)ipiv.data(),
434 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
436 ">>> ERROR: (Intrepid2::Basis_HCURL_TRI_In_FEM) lapack.GETRF returns nonzero info." );
439 vmat.data(), vmat.stride_1(),
440 (ordinal_type*)ipiv.data(),
444 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
446 ">>> ERROR: (Intrepid2::Basis_HCURL_TRI_In_FEM) lapack.GETRI returns nonzero info." );
448 for (ordinal_type i=0;i<cardVecPn;++i)
449 for (ordinal_type j=0;j<card;++j){
451 for(ordinal_type k=0; k< card; ++k)
452 s += V1(i,k)*vmat(k,j);
456 this->coeffs_ = Kokkos::create_mirror_view(
typename DT::memory_space(), coeffs);
457 Kokkos::deep_copy(this->coeffs_ , coeffs);
459 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
460 Kokkos::deep_copy(this->dofCoords_, dofCoords);
462 this->dofCoeffs_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoeffs);
463 Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
469 const ordinal_type posScDim = 0;
470 const ordinal_type posScOrd = 1;
471 const ordinal_type posDfOrd = 2;
477 this->setOrdinalTagData(this->tagToOrdinal_,
480 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).
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Basis_HCURL_TRI_In_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
virtual ordinal_type getNumPoints() const override
Returns the number of cubature points.
Header file for the Intrepid2::CubatureDirectTrisymPos class.
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.