16#ifndef __INTREPID2_HGRAD_LINE_CN_FEM_DEF_HPP__
17#define __INTREPID2_HGRAD_LINE_CN_FEM_DEF_HPP__
24 template<EOperator opType>
25 template<
typename OutputViewType,
26 typename InputViewType,
27 typename WorkViewType,
28 typename VinvViewType>
29 KOKKOS_INLINE_FUNCTION
33 const InputViewType input,
35 const VinvViewType vinv,
36 const ordinal_type operatorDn ) {
37 ordinal_type opDn = operatorDn;
39 const ordinal_type card = vinv.extent(0);
40 const ordinal_type npts = input.extent(0);
42 const ordinal_type order = card - 1;
43 const double alpha = 0.0, beta = 0.0;
45 typedef typename Kokkos::DynRankView<typename InputViewType::value_type, typename WorkViewType::memory_space> ViewType;
48 case OPERATOR_VALUE: {
51 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
52 Serial<opType>::getValues(phis, input, order, alpha, beta);
54 for (ordinal_type i=0;i<card;++i)
55 for (ordinal_type j=0;j<npts;++j) {
56 output.access(i,j) = 0.0;
57 for (ordinal_type k=0;k<card;++k)
58 output.access(i,j) += vinv(k,i)*phis.access(k,j);
76 const ordinal_type dkcard = 1;
78 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
79 Serial<opType>::getValues(phis, input, order, alpha, beta, opDn);
81 for (ordinal_type i=0;i<card;++i)
82 for (ordinal_type j=0;j<npts;++j)
83 for (ordinal_type k=0;k<dkcard;++k) {
84 output.access(i,j,k) = 0.0;
85 for (ordinal_type l=0;l<card;++l)
86 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
91 INTREPID2_TEST_FOR_ABORT(
true,
92 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM::Serial::getValues) operator is not supported." );
98 template<
typename DT, ordinal_type numPtsPerEval,
99 typename outputValueValueType,
class ...outputValueProperties,
100 typename inputPointValueType,
class ...inputPointProperties,
101 typename vinvValueType,
class ...vinvProperties>
103 Basis_HGRAD_LINE_Cn_FEM::
104 getValues(
const typename DT::execution_space& space,
105 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
106 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
107 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
108 const EOperator operatorType ) {
109 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
110 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
111 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
112 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
115 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
116 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
117 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
118 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
120 const ordinal_type cardinality = outputValues.extent(0);
122 auto work =
createMatchingDynRankView(inputPoints,
"Basis_HGRAD_LINE_Cn_FEM::getValues::work", cardinality, inputPoints.extent(0));
124 switch (operatorType) {
125 case OPERATOR_VALUE: {
126 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
127 OPERATOR_VALUE,numPtsPerEval> FunctorType;
128 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
142 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,
decltype(work),
143 OPERATOR_Dn,numPtsPerEval> FunctorType;
144 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
149 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
150 ">>> ERROR (Basis_HGRAD_LINE_Cn_FEM): Operator type not implemented" );
158 template<
typename DT,
typename OT,
typename PT>
161 const EPointType pointType ) {
162 this->pointType_ = pointType;
173 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
174 dofCoords(
"Hgrad::Line::Cn::dofCoords", card, 1);
177 auto pointT = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
180 case POINTTYPE_EQUISPACED:
181 case POINTTYPE_WARPBLEND: {
184 shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Line<2>>());
185 const ordinal_type offset = 0;
196 std::invalid_argument ,
197 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) invalid pointType." );
201 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
202 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
206 const ordinal_type lwork = card*card;
207 Kokkos::DynRankView<typename ScalarViewType::value_type,Kokkos::LayoutLeft,Kokkos::HostSpace>
208 vmat(
"Hgrad::Line::Cn::vmat", card, card),
209 work(
"Hgrad::Line::Cn::work", lwork),
210 ipiv(
"Hgrad::Line::Cn::ipiv", card);
212 const double alpha = 0.0, beta = 0.0;
213 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
214 getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>
215 (
typename Kokkos::HostSpace::execution_space{}, vmat, dofCoords, order, alpha, beta, OPERATOR_VALUE);
217 ordinal_type info = 0;
218 Teuchos::LAPACK<ordinal_type,typename ScalarViewType::value_type> lapack;
220 lapack.GETRF(card, card,
221 vmat.data(), vmat.stride(1),
222 (ordinal_type*)ipiv.data(),
225 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
227 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) lapack.GETRF returns nonzero info." );
230 vmat.data(), vmat.stride(1),
231 (ordinal_type*)ipiv.data(),
235 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
237 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) lapack.GETRI returns nonzero info." );
240 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
241 vinv(
"Hgrad::Line::Cn::vinv", card, card);
243 for (ordinal_type i=0;i<card;++i)
244 for (ordinal_type j=0;j<card;++j)
245 vinv(i,j) = vmat(j,i);
247 this->
vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
248 Kokkos::deep_copy(this->
vinv_ , vinv);
253 const ordinal_type tagSize = 4;
254 const ordinal_type posScDim = 0;
255 const ordinal_type posScOrd = 1;
256 const ordinal_type posDfOrd = 2;
260 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
271 const ordinal_type iend = card - 2;
272 for (ordinal_type i=0;i<iend;++i) {
273 const auto e = i + 1;
280 const auto v1 = card -1;
325 template<
typename DT,
typename OT,
typename PT>
327 Basis_HGRAD_LINE_Cn_FEM<DT,OT,PT>::getScratchSpaceSize(
328 ordinal_type& perTeamSpaceSize,
329 ordinal_type& perThreadSpaceSize,
331 const EOperator operatorType)
const {
332 perTeamSpaceSize = 0;
333 perThreadSpaceSize = this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
336 template<
typename DT,
typename OT,
typename PT>
337 KOKKOS_INLINE_FUNCTION
339 Basis_HGRAD_LINE_Cn_FEM<DT,OT,PT>::getValues(
340 OutputViewType outputValues,
341 const PointViewType inputPoints,
342 const EOperator operatorType,
343 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
344 const typename DT::execution_space::scratch_memory_space & scratchStorage,
345 const ordinal_type subcellDim,
346 const ordinal_type subcellOrdinal)
const {
348 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
349 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
351 const int numPoints = inputPoints.extent(0);
352 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
353 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
354 ordinal_type sizePerPoint = this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
355 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
356 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
358 switch(operatorType) {
360 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
361 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
362 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
363 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
364 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_VALUE>::getValues( output, input, work, vinv_ );
368 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=, &vinv_ = this->vinv_] (ordinal_type& pt) {
369 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
370 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
371 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
372 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_GRAD>::getValues( output, input, work, vinv_ );
376 INTREPID2_TEST_FOR_ABORT(
true,
377 ">>> ERROR (Basis_HGRAD_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...
Kokkos::DynRankView< typename ScalarViewType::value_type, DeviceType > vinv_
inverse of Generalized Vandermonde matrix, whose columns store the expansion coefficients of the noda...
Basis_HGRAD_LINE_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
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_HGRAD_LINE_Cn_FEM.
See Intrepid2::Basis_HGRAD_LINE_Cn_FEM.