15#ifndef __INTREPID2_HVOL_TET_CN_FEM_DEF_HPP__
16#define __INTREPID2_HVOL_TET_CN_FEM_DEF_HPP__
26 template<EOperator OpType>
27 template<
typename OutputViewType,
28 typename InputViewType,
29 typename WorkViewType,
30 typename VinvViewType>
31 KOKKOS_INLINE_FUNCTION
35 const InputViewType input,
37 const VinvViewType vinv ) {
39 constexpr ordinal_type spaceDim = 3;
41 card = vinv.extent(0),
42 npts = input.extent(0);
45 ordinal_type order = 0;
47 if (card == Intrepid2::getPnCardinality<spaceDim>(p)) {
53 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
54 auto ptr = work.data();
57 case OPERATOR_VALUE: {
61 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
62 Serial<OpType>::getValues(phis, input, dummyView, order);
64 for (ordinal_type i=0;i<card;++i)
65 for (ordinal_type j=0;j<npts;++j) {
66 output.access(i,j) = 0.0;
67 for (ordinal_type k=0;k<card;++k)
68 output.access(i,j) += vinv(k,i)*phis.access(k,j);
75 ptr += card*npts*spaceDim*get_dimension_scalar(input);
77 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
78 Serial<OpType>::getValues(phis, input, workView, order);
80 for (ordinal_type i=0;i<card;++i)
81 for (ordinal_type j=0;j<npts;++j)
82 for (ordinal_type k=0;k<spaceDim;++k) {
83 output.access(i,j,k) = 0.0;
84 for (ordinal_type l=0;l<card;++l)
85 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
98 const ordinal_type dkcard = getDkCardinality<OpType,spaceDim>();
103 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::
104 Serial<OpType>::getValues(phis, input, dummyView, order);
106 for (ordinal_type i=0;i<card;++i)
107 for (ordinal_type j=0;j<npts;++j)
108 for (ordinal_type k=0;k<dkcard;++k) {
109 output.access(i,j,k) = 0.0;
110 for (ordinal_type l=0;l<card;++l)
111 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
116 INTREPID2_TEST_FOR_ABORT(
true,
117 ">>> ERROR (Basis_HVOL_TET_Cn_FEM): Operator type not implemented");
122 template<
typename DT, ordinal_type numPtsPerEval,
123 typename outputValueValueType,
class ...outputValueProperties,
124 typename inputPointValueType,
class ...inputPointProperties,
125 typename vinvValueType,
class ...vinvProperties>
127 Basis_HVOL_TET_Cn_FEM::
128 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
129 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
130 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
131 const EOperator operatorType) {
132 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
133 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
134 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
135 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
138 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
139 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
140 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
141 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
143 const ordinal_type cardinality = outputValues.extent(0);
144 const ordinal_type spaceDim = 3;
146 ordinal_type order = 0;
147 while((Intrepid2::getPnCardinality<spaceDim>(++order) != cardinality) && (order !=
Parameters::MaxOrder));
149 typedef typename DeduceDynRankView<inputPointViewType>::type workViewType;
151 switch (operatorType) {
152 case OPERATOR_VALUE: {
153 auto bufferSize = Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_VALUE>::getWorkSizePerPoint(order);
154 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HVOL_TET_Cn_FEM::getValues::work", bufferSize, inputPoints.extent(0));
155 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
156 OPERATOR_VALUE,numPtsPerEval> FunctorType;
157 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
162 auto bufferSize = Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_D1>::getWorkSizePerPoint(order);
163 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HVOL_TET_Cn_FEM::getValues::work", bufferSize, inputPoints.extent(0));
164 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
165 OPERATOR_D1,numPtsPerEval> FunctorType;
166 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
170 auto bufferSize = Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_D2>::getWorkSizePerPoint(order);
171 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType, workViewType,
172 OPERATOR_D2,numPtsPerEval> FunctorType;
173 workViewType work = createMatchingView<workViewType>(inputPoints,
"Basis_HVOL_TET_Cn_FEM::getValues::work", bufferSize, inputPoints.extent(0));
174 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
185 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
186 ">>> ERROR (Basis_HVOL_TET_Cn_FEM): Operator type not implemented" );
193 template<
typename DT,
typename OT,
typename PT>
196 const EPointType pointType ) {
197 constexpr ordinal_type spaceDim = 3;
199 this->pointType_ = pointType;
210 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
211 dofCoords(
"HVOL::Tet::Cn::dofCoords", card, spaceDim);
214 const ordinal_type offset = 1;
215 const shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Tetrahedron<4> >());
218 order+spaceDim+offset, offset,
221 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
222 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
226 const ordinal_type lwork = card*card;
227 Kokkos::DynRankView<scalarType,Kokkos::LayoutLeft,Kokkos::HostSpace>
228 vmat(
"HVOL::Tet::Cn::vmat", card, card),
229 work(
"HVOL::Tet::Cn::work", lwork),
230 ipiv(
"HVOL::Tet::Cn::ipiv", card);
232 Impl::Basis_HGRAD_TET_Cn_FEM_ORTH::getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>(
typename Kokkos::HostSpace::execution_space{},
238 ordinal_type info = 0;
239 Teuchos::LAPACK<ordinal_type,scalarType> lapack;
241 lapack.GETRF(card, card,
242 vmat.data(), vmat.stride(1),
243 (ordinal_type*)ipiv.data(),
246 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
248 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM) lapack.GETRF returns nonzero info." );
251 vmat.data(), vmat.stride(1),
252 (ordinal_type*)ipiv.data(),
256 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
258 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM) lapack.GETRI returns nonzero info." );
261 Kokkos::DynRankView<scalarType,typename DT::execution_space::array_layout,Kokkos::HostSpace>
262 vinv(
"HVOL::Line::Cn::vinv", card, card);
264 for (ordinal_type i=0;i<card;++i)
265 for (ordinal_type j=0;j<card;++j)
266 vinv(i,j) = vmat(j,i);
268 this->
vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
269 Kokkos::deep_copy(this->
vinv_ , vinv);
274 constexpr ordinal_type tagSize = 4;
275 const ordinal_type posScDim = 0;
276 const ordinal_type posScOrd = 1;
277 const ordinal_type posDfOrd = 2;
280 ordinal_type tags[maxCard][tagSize];
286 ordinal_type elemId = 0;
289 tags[i][0] = spaceDim;
291 tags[i][2] = elemId++;
292 tags[i][3] = numElemDof;
302 this->basisCardinality_,
310 template<
typename DT,
typename OT,
typename PT>
312 Basis_HVOL_TET_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
313 ordinal_type& perTeamSpaceSize,
314 ordinal_type& perThreadSpaceSize,
316 const EOperator operatorType)
const {
317 perTeamSpaceSize = 0;
318 perThreadSpaceSize = this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
321 template<
typename DT,
typename OT,
typename PT>
322 KOKKOS_INLINE_FUNCTION
324 Basis_HVOL_TET_Cn_FEM<DT,OT,PT>::getValues(
325 OutputViewType outputValues,
326 const PointViewType inputPoints,
327 const EOperator operatorType,
328 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
329 const typename DT::execution_space::scratch_memory_space & scratchStorage,
330 const ordinal_type subcellDim,
331 const ordinal_type subcellOrdinal)
const {
333 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
334 ">>> ERROR: (Intrepid2::Basis_HVOL_TET_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
336 const int numPoints = inputPoints.extent(0);
337 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
338 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
339 auto sizePerPoint = this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
340 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
341 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
342 switch(operatorType) {
344 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
345 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
346 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
347 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
348 Impl::Basis_HVOL_TET_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_);
352 INTREPID2_TEST_FOR_ABORT(
true,
353 ">>> ERROR (Basis_HVOL_TET_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_TET_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_TET_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_TET_Cn_FEM.
See Intrepid2::Basis_HVOL_TET_Cn_FEM.