15#ifndef __INTREPID2_HVOL_LINE_CN_FEM_DEF_HPP__
16#define __INTREPID2_HVOL_LINE_CN_FEM_DEF_HPP__
23 template<EOperator opType>
24 template<
typename OutputViewType,
25 typename InputViewType,
26 typename WorkViewType,
27 typename VinvViewType>
28 KOKKOS_INLINE_FUNCTION
32 const InputViewType input,
34 const VinvViewType vinv,
35 const ordinal_type operatorDn ) {
36 ordinal_type opDn = operatorDn;
38 const ordinal_type card = vinv.extent(0);
39 const ordinal_type npts = input.extent(0);
41 const ordinal_type order = card - 1;
42 const double alpha = 0.0, beta = 0.0;
44 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
47 case OPERATOR_VALUE: {
50 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
51 Serial<opType>::getValues(phis, input, order, alpha, beta);
53 for (ordinal_type i=0;i<card;++i)
54 for (ordinal_type j=0;j<npts;++j) {
55 output.access(i,j) = 0.0;
56 for (ordinal_type k=0;k<card;++k)
57 output.access(i,j) += vinv(k,i)*phis.access(k,j);
75 const ordinal_type dkcard = 1;
77 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
78 Serial<opType>::getValues(phis, input, order, alpha, beta, opDn);
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<dkcard;++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);
90 INTREPID2_TEST_FOR_ABORT(
true,
91 ">>> ERROR: (Intrepid2::Basis_HVOL_LINE_Cn_FEM::Serial::getValues) operator is not supported." );
97 template<
typename DT, ordinal_type numPtsPerEval,
98 typename outputValueValueType,
class ...outputValueProperties,
99 typename inputPointValueType,
class ...inputPointProperties,
100 typename vinvValueType,
class ...vinvProperties>
102 Basis_HVOL_LINE_Cn_FEM::
103 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
104 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
105 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
106 const EOperator operatorType ) {
107 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
108 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
109 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
110 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
113 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
114 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
115 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
116 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
118 const ordinal_type cardinality = outputValues.extent(0);
120 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HVOL_LINE_Cn_FEM::getValues::work", cardinality, inputPoints.extent(0));
122 switch (operatorType) {
123 case OPERATOR_VALUE: {
124 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
125 OPERATOR_VALUE,numPtsPerEval> FunctorType;
126 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
140 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
141 OPERATOR_Dn,numPtsPerEval> FunctorType;
142 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
147 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
148 ">>> ERROR (Basis_HVOL_LINE_Cn_FEM): Operator type not implemented" );
157 template<
typename DT,
typename OT,
typename PT>
160 const EPointType pointType ) {
161 this->pointType_ = pointType;
172 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
173 dofCoords(
"HVOL::Line::Cn::dofCoords", card, 1);
176 auto pointT = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
179 case POINTTYPE_EQUISPACED:
180 case POINTTYPE_WARPBLEND: {
183 const shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Line<2> >());
184 const ordinal_type offset = 1;
187 order+1+offset, offset,
193 case POINTTYPE_GAUSS: {
201 std::invalid_argument ,
202 ">>> ERROR: (Intrepid2::Basis_HVOL_LINE_Cn_FEM) invalid pointType." );
206 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
207 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
211 const ordinal_type lwork = card*card;
212 Kokkos::DynRankView<typename ScalarViewType::value_type,Kokkos::LayoutLeft,Kokkos::HostSpace>
213 vmat(
"HVOL::Line::Cn::vmat", card, card),
214 work(
"HVOL::Line::Cn::work", lwork),
215 ipiv(
"HVOL::Line::Cn::ipiv", card);
217 const double alpha = 0.0, beta = 0.0;
218 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
219 getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>
220 (
typename Kokkos::HostSpace::execution_space{}, vmat, dofCoords, order, alpha, beta, OPERATOR_VALUE);
222 ordinal_type info = 0;
223 Teuchos::LAPACK<ordinal_type,typename ScalarViewType::value_type> lapack;
225 lapack.GETRF(card, card,
226 vmat.data(), vmat.stride(1),
227 (ordinal_type*)ipiv.data(),
230 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
232 ">>> ERROR: (Intrepid2::Basis_HVOL_LINE_Cn_FEM) lapack.GETRF returns nonzero info." );
235 vmat.data(), vmat.stride(1),
236 (ordinal_type*)ipiv.data(),
240 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
242 ">>> ERROR: (Intrepid2::Basis_HVOL_LINE_Cn_FEM) lapack.GETRI returns nonzero info." );
245 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
246 vinv(
"HVOL::Line::Cn::vinv", card, card);
248 for (ordinal_type i=0;i<card;++i)
249 for (ordinal_type j=0;j<card;++j)
250 vinv(i,j) = vmat(j,i);
252 this->
vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
253 Kokkos::deep_copy(this->
vinv_ , vinv);
258 const ordinal_type tagSize = 4;
259 const ordinal_type posScDim = 0;
260 const ordinal_type posScOrd = 1;
261 const ordinal_type posDfOrd = 2;
266 for (ordinal_type i=0;i<card;++i) {
288 template<
typename DT,
typename OT,
typename PT>
290 Basis_HVOL_LINE_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
291 ordinal_type& perTeamSpaceSize,
292 ordinal_type& perThreadSpaceSize,
294 const EOperator operatorType)
const {
295 perTeamSpaceSize = 0;
296 perThreadSpaceSize = this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
299 template<
typename DT,
typename OT,
typename PT>
300 KOKKOS_INLINE_FUNCTION
302 Basis_HVOL_LINE_Cn_FEM<DT,OT,PT>::getValues(
303 OutputViewType outputValues,
304 const PointViewType inputPoints,
305 const EOperator operatorType,
306 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
307 const typename DT::execution_space::scratch_memory_space & scratchStorage,
308 const ordinal_type subcellDim,
309 const ordinal_type subcellOrdinal)
const {
311 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
312 ">>> ERROR: (Intrepid2::Basis_HVOL_LINE_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
314 const int numPoints = inputPoints.extent(0);
315 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
316 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
317 ordinal_type sizePerPoint = this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
318 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
319 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
321 switch(operatorType) {
323 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
324 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
325 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
326 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
327 Impl::Basis_HVOL_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_ );
331 INTREPID2_TEST_FOR_ABORT(
true,
332 ">>> ERROR (Basis_HVOL_LINE_Cn_FEM): getValues not implemented for this operator");
KOKKOS_INLINE_FUNCTION ordinal_type getOperatorOrder(const EOperator operatorType)
Returns order of an operator.
KOKKOS_FORCEINLINE_FUNCTION bool isValidPointType(const EPointType pointType)
Verifies validity of a point type enum.
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...
DeduceDynRankView< InViewType >::type createMatchingDynRankView(const InViewType &view, const CtorProp &prop, const Dims... dims)
Creates and returns a view that matches the value_type of the provided view The output view type is d...
Basis_HVOL_LINE_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
Kokkos::DynRankView< typename ScalarViewType::value_type, 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_LINE_Cn_FEM.
See Intrepid2::Basis_HVOL_LINE_Cn_FEM.