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
31 Basis_HGRAD_LINE_Cn_FEM::Serial<opType>::
32 getValues( OutputViewType output,
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;
46 auto vcprop = Kokkos::common_view_alloc_prop(input);
49 case OPERATOR_VALUE: {
50 ViewType phis(Kokkos::view_wrap(work.data(), vcprop), card, npts);
52 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
53 Serial<opType>::getValues(phis, input, order, alpha, beta);
55 for (ordinal_type i=0;i<card;++i)
56 for (ordinal_type j=0;j<npts;++j) {
57 output.access(i,j) = 0.0;
58 for (ordinal_type k=0;k<card;++k)
59 output.access(i,j) += vinv(k,i)*phis.access(k,j);
74 opDn = getOperatorOrder(opType);
77 const ordinal_type dkcard = 1;
78 ViewType phis(Kokkos::view_wrap(work.data(), vcprop), card, npts, dkcard);
79 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
80 Serial<opType>::getValues(phis, input, order, alpha, beta, opDn);
82 for (ordinal_type i=0;i<card;++i)
83 for (ordinal_type j=0;j<npts;++j)
84 for (ordinal_type k=0;k<dkcard;++k) {
85 output.access(i,j,k) = 0.0;
86 for (ordinal_type l=0;l<card;++l)
87 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
92 INTREPID2_TEST_FOR_ABORT(
true,
93 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM::Serial::getValues) operator is not supported." );
99 template<
typename DT, ordinal_type numPtsPerEval,
100 typename outputValueValueType,
class ...outputValueProperties,
101 typename inputPointValueType,
class ...inputPointProperties,
102 typename vinvValueType,
class ...vinvProperties>
104 Basis_HGRAD_LINE_Cn_FEM::
105 getValues(
const typename DT::execution_space& space,
106 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
107 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
108 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
109 const EOperator operatorType ) {
110 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
111 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
112 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
113 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
116 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
117 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
118 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
119 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
121 typedef typename inputPointViewType::value_type inputPointType;
123 const ordinal_type cardinality = outputValues.extent(0);
125 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
126 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
127 workViewType work(Kokkos::view_alloc(space,
"Basis_HGRAD_LINE_Cn_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
129 switch (operatorType) {
130 case OPERATOR_VALUE: {
131 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,workViewType,
132 OPERATOR_VALUE,numPtsPerEval> FunctorType;
133 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
147 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,workViewType,
148 OPERATOR_Dn,numPtsPerEval> FunctorType;
149 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
150 getOperatorOrder(operatorType)) );
154 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
155 ">>> ERROR (Basis_HGRAD_LINE_Cn_FEM): Operator type not implemented" );
163 template<
typename DT,
typename OT,
typename PT>
166 const EPointType pointType ) {
167 this->pointType_ = pointType;
168 this->basisCardinality_ = order+1;
169 this->basisDegree_ = order;
170 this->basisCellTopologyKey_ = shards::Line<2>::key;
171 this->basisType_ = BASIS_FEM_LAGRANGIAN;
172 this->basisCoordinates_ = COORDINATES_CARTESIAN;
173 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
175 const ordinal_type card = this->basisCardinality_;
178 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
179 dofCoords(
"Hgrad::Line::Cn::dofCoords", card, 1);
182 auto pointT = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
185 case POINTTYPE_EQUISPACED:
186 case POINTTYPE_WARPBLEND: {
189 shards::CellTopology cellTopo(shards::getCellTopologyData<shards::Line<2>>());
190 const ordinal_type offset = 0;
200 INTREPID2_TEST_FOR_EXCEPTION( !isValidPointType(pointT),
201 std::invalid_argument ,
202 ">>> ERROR: (Intrepid2::Basis_HGRAD_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(
"Hgrad::Line::Cn::vmat", card, card),
214 work(
"Hgrad::Line::Cn::work", lwork),
215 ipiv(
"Hgrad::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_HGRAD_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_HGRAD_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(
"Hgrad::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;
265 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
276 const ordinal_type iend = card - 2;
277 for (ordinal_type i=0;i<iend;++i) {
278 const auto e = i + 1;
285 const auto v1 = card -1;
319 this->setOrdinalTagData(this->tagToOrdinal_,
322 this->basisCardinality_,
330 template<
typename DT,
typename OT,
typename PT>
333 ordinal_type& perTeamSpaceSize,
334 ordinal_type& perThreadSpaceSize,
336 const EOperator operatorType)
const {
337 perTeamSpaceSize = 0;
338 perThreadSpaceSize = this->vinv_.extent(0)*get_dimension_scalar(inputPoints)*
sizeof(
typename BasisBase::scalarType);
341 template<
typename DT,
typename OT,
typename PT>
342 KOKKOS_INLINE_FUNCTION
345 OutputViewType outputValues,
346 const PointViewType inputPoints,
347 const EOperator operatorType,
348 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
349 const typename DT::execution_space::scratch_memory_space & scratchStorage,
350 const ordinal_type subcellDim,
351 const ordinal_type subcellOrdinal)
const {
353 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
354 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
356 const int numPoints = inputPoints.extent(0);
357 using ScalarType =
typename ScalarTraits<typename PointViewType::value_type>::scalar_type;
358 using WorkViewType = Kokkos::DynRankView< ScalarType,typename DT::execution_space::scratch_memory_space,Kokkos::MemoryTraits<Kokkos::Unmanaged> >;
359 ordinal_type sizePerPoint = this->vinv_.extent(0)*get_dimension_scalar(inputPoints);
360 WorkViewType workView(scratchStorage, sizePerPoint*team_member.team_size());
361 using range_type = Kokkos::pair<ordinal_type,ordinal_type>;
363 switch(operatorType) {
365 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
366 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type (pt,pt+1), Kokkos::ALL() );
367 const auto input = Kokkos::subview( inputPoints, range_type(pt, pt+1), Kokkos::ALL() );
368 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
373 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
374 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), range_type(pt,pt+1), Kokkos::ALL() );
375 const auto input = Kokkos::subview( inputPoints, range_type(pt,pt+1), Kokkos::ALL() );
376 WorkViewType work(workView.data() + sizePerPoint*team_member.team_rank(), sizePerPoint);
377 Impl::Basis_HGRAD_LINE_Cn_FEM::Serial<OPERATOR_GRAD>::getValues( output, input, work, this->vinv_ );
381 INTREPID2_TEST_FOR_ABORT(
true,
382 ">>> ERROR (Basis_HGRAD_LINE_Cn_FEM): getValues not implemented for this operator");
virtual void getValues(const ExecutionSpace &space, OutputViewType outputValues, const PointViewType inputPoints, const EOperator operatorType=OPERATOR_VALUE) const override
Evaluation of a FEM basis on a reference cell.
ScalarTraits< pointValueType >::scalar_type scalarType
Scalar type for point values.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
See Intrepid2::Basis_HGRAD_LINE_Cn_FEM.
Basis_HGRAD_LINE_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
virtual void getScratchSpaceSize(ordinal_type &perTeamSpaceSize, ordinal_type &perThreadSpaceSize, const PointViewType inputPointsconst, const EOperator operatorType=OPERATOR_VALUE) const override
Return the size of the scratch space, in bytes, needed for using the team-level implementation of get...