48 #ifndef __INTREPID2_HVOL_TRI_CN_FEM_DEF_HPP__
49 #define __INTREPID2_HVOL_TRI_CN_FEM_DEF_HPP__
58 template<EOperator opType>
59 template<
typename OutputViewType,
60 typename inputViewType,
61 typename workViewType,
62 typename vinvViewType>
63 KOKKOS_INLINE_FUNCTION
65 Basis_HVOL_TRI_Cn_FEM::Serial<opType>::
66 getValues( OutputViewType output,
67 const inputViewType input,
69 const vinvViewType vinv ) {
71 constexpr ordinal_type spaceDim = 2;
73 card = vinv.extent(0),
74 npts = input.extent(0);
77 ordinal_type order = 0;
79 if (card == Intrepid2::getPnCardinality<spaceDim>(p) ) {
85 typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
86 auto vcprop = Kokkos::common_view_alloc_prop(work);
87 auto ptr = work.data();
90 case OPERATOR_VALUE: {
91 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts);
92 workViewType dummyView;
94 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
95 Serial<opType>::getValues(phis, input, dummyView, order);
97 for (ordinal_type i=0;i<card;++i)
98 for (ordinal_type j=0;j<npts;++j) {
99 output.access(i,j) = 0.0;
100 for (ordinal_type k=0;k<card;++k)
101 output.access(i,j) += vinv(k,i)*phis.access(k,j);
107 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim);
108 ptr += card*npts*spaceDim*get_dimension_scalar(work);
109 const viewType workView(Kokkos::view_wrap(ptr, vcprop), card, npts, spaceDim+1);
110 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
111 Serial<opType>::getValues(phis, input, workView, order);
113 for (ordinal_type i=0;i<card;++i)
114 for (ordinal_type j=0;j<npts;++j)
115 for (ordinal_type k=0;k<spaceDim;++k) {
116 output.access(i,j,k) = 0.0;
117 for (ordinal_type l=0;l<card;++l)
118 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
131 const ordinal_type dkcard = getDkCardinality<opType,spaceDim>();
132 const viewType phis(Kokkos::view_wrap(ptr, vcprop), card, npts, dkcard);
133 workViewType dummyView;
135 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
136 Serial<opType>::getValues(phis, input, dummyView, order);
138 for (ordinal_type i=0;i<card;++i)
139 for (ordinal_type j=0;j<npts;++j)
140 for (ordinal_type k=0;k<dkcard;++k) {
141 output.access(i,j,k) = 0.0;
142 for (ordinal_type l=0;l<card;++l)
143 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
148 INTREPID2_TEST_FOR_ABORT(
true,
149 ">>> ERROR (Basis_HVOL_TRI_Cn_FEM): Operator type not implemented");
154 template<
typename SpT, ordinal_type numPtsPerEval,
155 typename outputValueValueType,
class ...outputValueProperties,
156 typename inputPointValueType,
class ...inputPointProperties,
157 typename vinvValueType,
class ...vinvProperties>
159 Basis_HVOL_TRI_Cn_FEM::
160 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
161 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
162 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
163 const EOperator operatorType) {
164 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
165 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
166 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
167 typedef typename ExecSpace<typename inputPointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
170 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
171 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
172 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
173 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
175 typedef typename inputPointViewType::value_type inputPointType;
177 const ordinal_type cardinality = outputValues.extent(0);
178 const ordinal_type spaceDim = 2;
180 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
181 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
183 switch (operatorType) {
184 case OPERATOR_VALUE: {
185 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_TRI_Cn_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
186 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
187 OPERATOR_VALUE,numPtsPerEval> FunctorType;
188 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
193 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_TRI_Cn_FEM::getValues::work", vcprop), cardinality*(2*spaceDim+1), inputPoints.extent(0));
194 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
195 OPERATOR_D1,numPtsPerEval> FunctorType;
196 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
200 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
201 OPERATOR_D2,numPtsPerEval> FunctorType;
202 workViewType work(Kokkos::view_alloc(
"Basis_HVOL_TRI_Cn_FEM::getValues::work", vcprop), cardinality*outputValues.extent(2), inputPoints.extent(0));
203 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
214 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
215 ">>> ERROR (Basis_HVOL_TRI_Cn_FEM): Operator type not implemented" );
222 template<
typename SpT,
typename OT,
typename PT>
225 const EPointType pointType ) {
227 constexpr ordinal_type spaceDim = 2;
229 this->basisCardinality_ = Intrepid2::getPnCardinality<spaceDim>(order);
230 this->basisDegree_ = order;
231 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Triangle<3> >() );
232 this->basisType_ = BASIS_FEM_FIAT;
233 this->basisCoordinates_ = COORDINATES_CARTESIAN;
234 this->functionSpace_ = FUNCTION_SPACE_HVOL;
236 const ordinal_type card = this->basisCardinality_;
239 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
240 dofCoords(
"HVOL::Tri::Cn::dofCoords", card, spaceDim);
243 const ordinal_type offset = 1;
245 this->basisCellTopology_,
246 order+spaceDim+offset, offset,
249 this->dofCoords_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoords);
250 Kokkos::deep_copy(this->dofCoords_, dofCoords);
254 const ordinal_type lwork = card*card;
255 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
256 vmat(
"HVOL::Tri::Cn::vmat", card, card),
257 work(
"HVOL::Tri::Cn::work", lwork),
258 ipiv(
"HVOL::Tri::Cn::ipiv", card);
260 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(vmat, dofCoords, order, OPERATOR_VALUE);
262 ordinal_type info = 0;
263 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
265 lapack.GETRF(card, card,
266 vmat.data(), vmat.stride_1(),
267 (ordinal_type*)ipiv.data(),
270 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
272 ">>> ERROR: (Intrepid2::Basis_HVOL_TRI_Cn_FEM) lapack.GETRF returns nonzero info." );
275 vmat.data(), vmat.stride_1(),
276 (ordinal_type*)ipiv.data(),
280 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
282 ">>> ERROR: (Intrepid2::Basis_HVOL_TRI_Cn_FEM) lapack.GETRI returns nonzero info." );
285 Kokkos::DynRankView<scalarType,typename SpT::array_layout,Kokkos::HostSpace>
286 vinv(
"HVOL::Line::Cn::vinv", card, card);
288 for (ordinal_type i=0;i<card;++i)
289 for (ordinal_type j=0;j<card;++j)
290 vinv(i,j) = vmat(j,i);
292 this->vinv_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), vinv);
293 Kokkos::deep_copy(this->vinv_ , vinv);
298 constexpr ordinal_type tagSize = 4;
299 const ordinal_type posScDim = 0;
300 const ordinal_type posScOrd = 1;
301 const ordinal_type posDfOrd = 2;
303 constexpr ordinal_type maxCard = Intrepid2::getPnCardinality<spaceDim, Parameters::MaxOrder>();
304 ordinal_type tags[maxCard][tagSize];
307 numElemDof = this->basisCardinality_;
309 ordinal_type elemId = 0;
310 for (ordinal_type i=0;i<this->basisCardinality_;++i) {
312 tags[i][0] = spaceDim;
314 tags[i][2] = elemId++;
315 tags[i][3] = numElemDof;
322 this->setOrdinalTagData(this->tagToOrdinal_,
325 this->basisCardinality_,
Kokkos::View< ordinal_type *, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH class.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
Basis_HVOL_TRI_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.