49 #ifndef __INTREPID2_HGRAD_TRI_CN_FEM_DEF_HPP__ 50 #define __INTREPID2_HGRAD_TRI_CN_FEM_DEF_HPP__ 59 template<EOperator opType>
60 template<
typename OutputViewType,
61 typename inputViewType,
62 typename workViewType,
63 typename vinvViewType>
64 KOKKOS_INLINE_FUNCTION
66 Basis_HGRAD_TRI_Cn_FEM::Serial<opType>::
67 getValues( OutputViewType output,
68 const inputViewType input,
70 const vinvViewType vinv ) {
72 constexpr ordinal_type spaceDim = 2;
74 card = vinv.extent(0),
75 npts = input.extent(0);
78 ordinal_type order = 0;
80 if (card == Intrepid2::getPnCardinality<spaceDim>(p) ) {
86 typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
87 auto vcprop = Kokkos::common_view_alloc_prop(work);
88 auto ptr = work.data();
91 case OPERATOR_VALUE: {
92 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
95 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
96 Serial<opType>::getValues(phis, input, dummyView, order);
98 for (ordinal_type i=0;i<card;++i)
99 for (ordinal_type j=0;j<npts;++j) {
100 output.access(i,j) = 0.0;
101 for (ordinal_type k=0;k<card;++k)
102 output.access(i,j) += vinv(k,i)*phis.access(k,j);
108 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
109 ptr += card*npts*spaceDim*get_dimension_scalar(work);
110 const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
111 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
112 Serial<opType>::getValues(phis, input, workView, order);
114 for (ordinal_type i=0;i<card;++i)
115 for (ordinal_type j=0;j<npts;++j)
116 for (ordinal_type k=0;k<spaceDim;++k) {
117 output.access(i,j,k) = 0.0;
118 for (ordinal_type l=0;l<card;++l)
119 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
132 const ordinal_type dkcard = getDkCardinality<opType,spaceDim>();
133 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, dkcard);
136 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
137 Serial<opType>::getValues(phis, input, dummyView, order);
139 for (ordinal_type i=0;i<card;++i)
140 for (ordinal_type j=0;j<npts;++j)
141 for (ordinal_type k=0;k<dkcard;++k) {
142 output.access(i,j,k) = 0.0;
143 for (ordinal_type l=0;l<card;++l)
144 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
148 case OPERATOR_CURL: {
149 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
150 ptr += card*npts*spaceDim*get_dimension_scalar(work);
151 const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
154 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
155 Serial<OPERATOR_D1>::getValues(phis, input, workView, order);
157 for (ordinal_type i=0;i<card;++i)
158 for (ordinal_type j=0;j<npts;++j) {
159 output.access(i,j,0) = 0.0;
160 for (ordinal_type l=0;l<card;++l)
161 output.access(i,j,0) += vinv(l,i)*phis.access(l,j,1);
162 output.access(i,j,1) = 0.0;
163 for (ordinal_type l=0;l<card;++l)
164 output.access(i,j,1) -= vinv(l,i)*phis.access(l,j,0);
169 INTREPID2_TEST_FOR_ABORT(
true,
170 ">>> ERROR (Basis_HGRAD_TRI_Cn_FEM): Operator type not implemented");
175 template<
typename DT, ordinal_type numPtsPerEval,
176 typename outputValueValueType,
class ...outputValueProperties,
177 typename inputPointValueType,
class ...inputPointProperties,
178 typename vinvValueType,
class ...vinvProperties>
180 Basis_HGRAD_TRI_Cn_FEM::
181 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
182 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
183 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
184 const EOperator operatorType) {
185 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
186 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
187 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
188 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
191 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
192 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
193 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
194 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
196 typedef typename inputPointViewType::value_type inputPointType;
198 const ordinal_type cardinality = outputValues.extent(0);
199 const ordinal_type spaceDim = 2;
201 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
202 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
204 switch (operatorType) {
205 case OPERATOR_VALUE: {
206 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
207 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
208 OPERATOR_VALUE,numPtsPerEval> FunctorType;
209 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
214 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
215 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
216 OPERATOR_D1,numPtsPerEval> FunctorType;
217 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
220 case OPERATOR_CURL: {
221 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
222 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
223 OPERATOR_CURL,numPtsPerEval> FunctorType;
224 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
228 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
229 OPERATOR_D2,numPtsPerEval> FunctorType;
230 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_TRI_Cn_FEM::getValues::work", vcprop), cardinality*outputValues.extent(2), inputPoints.extent(0));
231 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
242 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
243 ">>> ERROR (Basis_HGRAD_TRI_Cn_FEM): Operator type not implemented" );
250 template<
typename DT,
typename OT,
typename PT>
254 constexpr ordinal_type spaceDim = 2;
256 this->basisCardinality_ = Intrepid2::getPnCardinality<spaceDim>(order);
257 this->basisDegree_ = order;
258 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >() );
259 this->basisType_ = BASIS_FEM_LAGRANGIAN;
260 this->basisCoordinates_ = COORDINATES_CARTESIAN;
261 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
263 pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
264 const ordinal_type card = this->basisCardinality_;
267 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
268 dofCoords(
"Hgrad::Tri::Cn::dofCoords", card, spaceDim);
271 const ordinal_type offset = 0;
273 this->basisCellTopology_,
277 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
278 Kokkos::deep_copy(this->dofCoords_, dofCoords);
282 const ordinal_type lwork = card*card;
283 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
284 vmat(
"Hgrad::Tri::Cn::vmat", card, card),
285 work(
"Hgrad::Tri::Cn::work", lwork),
286 ipiv(
"Hgrad::Tri::Cn::ipiv", card);
288 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(vmat, dofCoords, order, OPERATOR_VALUE);
290 ordinal_type info = 0;
291 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
293 lapack.GETRF(card, card,
294 vmat.data(), vmat.stride_1(),
295 (ordinal_type*)ipiv.data(),
298 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
300 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_Cn_FEM) lapack.GETRF returns nonzero info." );
303 vmat.data(), vmat.stride_1(),
304 (ordinal_type*)ipiv.data(),
308 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
310 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_Cn_FEM) lapack.GETRI returns nonzero info." );
313 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
314 vinv(
"Hgrad::Line::Cn::vinv", card, card);
316 for (ordinal_type i=0;i<card;++i)
317 for (ordinal_type j=0;j<card;++j)
318 vinv(i,j) = vmat(j,i);
320 this->vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
321 Kokkos::deep_copy(this->vinv_ , vinv);
326 constexpr ordinal_type tagSize = 4;
327 const ordinal_type posScDim = 0;
328 const ordinal_type posScOrd = 1;
329 const ordinal_type posDfOrd = 2;
331 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
332 ordinal_type tags[maxCard][tagSize];
335 numEdgeDof = Intrepid2::getPnCardinality<1>(order-2),
336 numElemDof = (order > 2 ? Intrepid2::getPnCardinality<2>(order-3) : 0);
338 scalarType xi0, xi1, xi2;
339 const scalarType eps = threshold();
341 ordinal_type edgeId[3] = {}, elemId = 0;
342 for (ordinal_type i=0;i<card;++i) {
345 const auto x = dofCoords(i,0);
346 const auto y = dofCoords(i,1);
352 if ((1.0 - xi0) < eps) {
358 else if ((1.0 - xi1) < eps) {
364 else if ((1.0 - xi2) < eps) {
370 else if (xi2 < eps) {
373 tags[i][2] = edgeId[0]++;
374 tags[i][3] = numEdgeDof;
376 else if (xi0 < eps) {
379 tags[i][2] = edgeId[1]++;
380 tags[i][3] = numEdgeDof;
382 else if (xi1 < eps) {
385 tags[i][2] = edgeId[2]++;
386 tags[i][3] = numEdgeDof;
391 tags[i][2] = elemId++;
392 tags[i][3] = numElemDof;
396 OrdinalTypeArray1DHost tagView(&tags[0][0], card*tagSize);
400 this->setOrdinalTagData(this->tagToOrdinal_,
403 this->basisCardinality_,
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH class.
EPointType
Enumeration of types of point distributions in Intrepid.
Basis_HGRAD_TRI_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.