15#ifndef __INTREPID2_HVOL_TRI_CN_FEM_DEF_HPP__
16#define __INTREPID2_HVOL_TRI_CN_FEM_DEF_HPP__
25 template<EOperator OpType>
26 template<
typename OutputViewType,
27 typename InputViewType,
28 typename WorkViewType,
29 typename VinvViewType>
30 KOKKOS_INLINE_FUNCTION
34 const InputViewType input,
36 const VinvViewType vinv ) {
38 constexpr ordinal_type spaceDim = 2;
40 card = vinv.extent(0),
41 npts = input.extent(0);
44 ordinal_type order = 0;
46 if (card == Intrepid2::getPnCardinality<spaceDim>(p) ) {
52 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
53 auto ptr = work.data();
56 case OPERATOR_VALUE: {
60 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
61 Serial<OpType>::getValues(phis, input, dummyView, order);
63 for (ordinal_type i=0;i<card;++i)
64 for (ordinal_type j=0;j<npts;++j) {
65 output.access(i,j) = 0.0;
66 for (ordinal_type k=0;k<card;++k)
67 output.access(i,j) += vinv(k,i)*phis.access(k,j);
74 ptr += card*npts*spaceDim*get_dimension_scalar(input);
76 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
77 Serial<OpType>::getValues(phis, input, workView, order);
79 for (ordinal_type i=0;i<card;++i)
80 for (ordinal_type j=0;j<npts;++j)
81 for (ordinal_type k=0;k<spaceDim;++k) {
82 output.access(i,j,k) = 0.0;
83 for (ordinal_type l=0;l<card;++l)
84 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
97 const ordinal_type dkcard = getDkCardinality<OpType,spaceDim>();
101 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::
102 Serial<OpType>::getValues(phis, input, dummyView, order);
104 for (ordinal_type i=0;i<card;++i)
105 for (ordinal_type j=0;j<npts;++j)
106 for (ordinal_type k=0;k<dkcard;++k) {
107 output.access(i,j,k) = 0.0;
108 for (ordinal_type l=0;l<card;++l)
109 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
114 INTREPID2_TEST_FOR_ABORT(
true,
115 ">>> ERROR (Basis_HVOL_TRI_Cn_FEM): Operator type not implemented");
120template<
typename DT, ordinal_type numPtsPerEval,
121typename outputValueValueType,
class ...outputValueProperties,
122typename inputPointValueType,
class ...inputPointProperties,
123typename vinvValueType,
class ...vinvProperties>
125Basis_HVOL_TRI_Cn_FEM::
126getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
127 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
128 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
129 const EOperator operatorType) {
130 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
131 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
132 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
133 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
136 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
137 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
138 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
139 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
141 const ordinal_type cardinality = outputValues.extent(0);
142 const ordinal_type spaceDim = 2;
144 typedef typename DeduceDynRankView<inputPointViewType>::type workViewType;
146 switch (operatorType) {
147 case OPERATOR_VALUE: {
148 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HVOL_TRI_Cn_FEM::getValues::work", cardinality, inputPoints.extent(0));
149 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
150 OPERATOR_VALUE,numPtsPerEval> FunctorType;
151 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
156 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HVOL_TRI_Cn_FEM::getValues::work", cardinality*(2*spaceDim+1), inputPoints.extent(0));
157 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
158 OPERATOR_D1,numPtsPerEval> FunctorType;
159 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
163 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
164 OPERATOR_D2,numPtsPerEval> FunctorType;
165 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HVOL_TRI_Cn_FEM::getValues::work", cardinality*outputValues.extent(2), inputPoints.extent(0));
166 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
177 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
178 ">>> ERROR (Basis_HVOL_TRI_Cn_FEM): Operator type not implemented" );
185template<
typename DT,
typename OT,
typename PT>
188 const EPointType pointType ) {
190 constexpr ordinal_type spaceDim = 2;
192 this->pointType_ = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
203 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
204 dofCoords(
"HVOL::Tri::Cn::dofCoords", card, spaceDim);
207 const ordinal_type offset = 1;
208 const shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Triangle<3> >());
211 order+spaceDim+offset, offset,
214 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
215 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
219 const ordinal_type lwork = card*card;
220 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
221 vmat(
"HVOL::Tri::Cn::vmat", card, card),
222 work(
"HVOL::Tri::Cn::work", lwork),
223 ipiv(
"HVOL::Tri::Cn::ipiv", card);
225 Impl::Basis_HGRAD_TRI_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
231 ordinal_type info = 0;
232 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
234 lapack.GETRF(card, card,
235 vmat.data(), vmat.stride(1),
236 (ordinal_type*)ipiv.data(),
239 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
241 ">>> ERROR: (Intrepid2::Basis_HVOL_TRI_Cn_FEM) lapack.GETRF returns nonzero info." );
244 vmat.data(), vmat.stride(1),
245 (ordinal_type*)ipiv.data(),
249 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
251 ">>> ERROR: (Intrepid2::Basis_HVOL_TRI_Cn_FEM) lapack.GETRI returns nonzero info." );
254 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
255 vinv(
"HVOL::Line::Cn::vinv", card, card);
257 for (ordinal_type i=0;i<card;++i)
258 for (ordinal_type j=0;j<card;++j)
259 vinv(i,j) = vmat(j,i);
261 this->
vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
262 Kokkos::deep_copy(this->
vinv_ , vinv);
267 constexpr ordinal_type tagSize = 4;
268 const ordinal_type posScDim = 0;
269 const ordinal_type posScOrd = 1;
270 const ordinal_type posDfOrd = 2;
273 ordinal_type tags[maxCard][tagSize];
278 ordinal_type elemId = 0;
281 tags[i][0] = spaceDim;
283 tags[i][2] = elemId++;
284 tags[i][3] = numElemDof;
294 this->basisCardinality_,
302 template<
typename DT,
typename OT,
typename PT>
304 Basis_HVOL_TRI_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
305 ordinal_type& perTeamSpaceSize,
306 ordinal_type& perThreadSpaceSize,
308 const EOperator operatorType)
const {
309 perTeamSpaceSize = 0;
310 perThreadSpaceSize = this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
313 template<
typename DT,
typename OT,
typename PT>
314 KOKKOS_INLINE_FUNCTION
316 Basis_HVOL_TRI_Cn_FEM<DT,OT,PT>::getValues(
317 OutputViewType outputValues,
318 const PointViewType inputPoints,
319 const EOperator operatorType,
320 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
321 const typename DT::execution_space::scratch_memory_space & scratchStorage,
322 const ordinal_type subcellDim,
323 const ordinal_type subcellOrdinal)
const {
325 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
326 ">>> ERROR: (Intrepid2::Basis_HVOL_TRI_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
328 const int numPoints = inputPoints.extent(0);
329 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
330 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
331 auto sizePerPoint = this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
332 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
333 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
334 switch(operatorType) {
336 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
337 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
338 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
339 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
340 Impl::Basis_HVOL_TRI_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_);
344 INTREPID2_TEST_FOR_ABORT(
true,
345 ">>> ERROR (Basis_HVOL_TRI_Cn_FEM): getValues not implemented for this operator");
KOKKOS_INLINE_FUNCTION ordinal_type getPnCardinality(ordinal_type n)
Returns cardinality of Polynomials of order n (P^n).
Header file for the Intrepid2::Basis_HGRAD_TRI_Cn_FEM_ORTH class.
KOKKOS_INLINE_FUNCTION std::enable_if< std::is_pointer_v< CtorProp > &&!std::is_convertible_v< CtorProp, constchar * >, OutViewType >::type createMatchingUnmanagedView(const InViewType &view, const CtorProp &data, const Dims... dims)
Creates an unmanaged view that matches the value_type of the provided view The type of the output vie...
Basis_HVOL_TRI_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::DynRankView< scalarType, DeviceType > vinv_
inverse of Generalized Vandermonde matrix, whose columns store the expansion coefficients of the noda...
ECoordinates basisCoordinates_
ordinal_type basisDegree_
void setOrdinalTagData(OrdinalTypeView3D &tagToOrdinal, OrdinalTypeView2D &ordinalToTag, const OrdinalTypeView1D tags, const ordinal_type basisCard, const ordinal_type tagSize, const ordinal_type posScDim, const ordinal_type posScOrd, const ordinal_type posDfOrd)
OrdinalTypeArray2DHost ordinalToTag_
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
ordinal_type basisCardinality_
OrdinalTypeArray3DHost tagToOrdinal_
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
unsigned basisCellTopologyKey_
EFunctionSpace functionSpace_
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
See Intrepid2::Basis_HVOL_TRI_Cn_FEM.
See Intrepid2::Basis_HVOL_TRI_Cn_FEM.