49#ifndef __INTREPID2_HGRAD_LINE_CN_FEM_DEF_HPP__
50#define __INTREPID2_HGRAD_LINE_CN_FEM_DEF_HPP__
57 template<EOperator opType>
58 template<
typename OutputViewType,
59 typename inputViewType,
60 typename workViewType,
61 typename vinvViewType>
62 KOKKOS_INLINE_FUNCTION
64 Basis_HGRAD_LINE_Cn_FEM::Serial<opType>::
65 getValues( OutputViewType output,
66 const inputViewType input,
68 const vinvViewType vinv,
69 const ordinal_type operatorDn ) {
70 ordinal_type opDn = operatorDn;
72 const ordinal_type card = vinv.extent(0);
73 const ordinal_type npts = input.extent(0);
75 const ordinal_type order = card - 1;
76 const double alpha = 0.0, beta = 0.0;
78 typedef typename Kokkos::DynRankView<typename workViewType::value_type, typename workViewType::memory_space> viewType;
79 auto vcprop = Kokkos::common_view_alloc_prop(work);
82 case OPERATOR_VALUE: {
83 viewType phis(Kokkos::view_wrap(work.data(), vcprop), card, npts);
85 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
86 Serial<opType>::getValues(phis, input, order, alpha, beta);
88 for (ordinal_type i=0;i<card;++i)
89 for (ordinal_type j=0;j<npts;++j) {
90 output.access(i,j) = 0.0;
91 for (ordinal_type k=0;k<card;++k)
92 output.access(i,j) += vinv(k,i)*phis.access(k,j);
110 const ordinal_type dkcard = 1;
111 viewType phis(Kokkos::view_wrap(work.data(), vcprop), card, npts, dkcard);
112 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
113 Serial<opType>::getValues(phis, input, order, alpha, beta, opDn);
115 for (ordinal_type i=0;i<card;++i)
116 for (ordinal_type j=0;j<npts;++j)
117 for (ordinal_type k=0;k<dkcard;++k) {
118 output.access(i,j,k) = 0.0;
119 for (ordinal_type l=0;l<card;++l)
120 output.access(i,j,k) += vinv(l,i)*phis.access(l,j,k);
125 INTREPID2_TEST_FOR_ABORT(
true,
126 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM::Serial::getValues) operator is not supported." );
132 template<
typename DT, ordinal_type numPtsPerEval,
133 typename outputValueValueType,
class ...outputValueProperties,
134 typename inputPointValueType,
class ...inputPointProperties,
135 typename vinvValueType,
class ...vinvProperties>
137 Basis_HGRAD_LINE_Cn_FEM::
138 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
139 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
140 const Kokkos::DynRankView<vinvValueType, vinvProperties...> vinv,
141 const EOperator operatorType ) {
142 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
143 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
144 typedef Kokkos::DynRankView<vinvValueType, vinvProperties...> vinvViewType;
145 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
148 const auto loopSizeTmp1 = (inputPoints.extent(0)/numPtsPerEval);
149 const auto loopSizeTmp2 = (inputPoints.extent(0)%numPtsPerEval != 0);
150 const auto loopSize = loopSizeTmp1 + loopSizeTmp2;
151 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
153 typedef typename inputPointViewType::value_type inputPointType;
155 const ordinal_type cardinality = outputValues.extent(0);
157 auto vcprop = Kokkos::common_view_alloc_prop(inputPoints);
158 typedef typename Kokkos::DynRankView< inputPointType, typename inputPointViewType::memory_space> workViewType;
159 workViewType work(Kokkos::view_alloc(
"Basis_HGRAD_LINE_Cn_FEM::getValues::work", vcprop), cardinality, inputPoints.extent(0));
161 switch (operatorType) {
162 case OPERATOR_VALUE: {
163 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,workViewType,
164 OPERATOR_VALUE,numPtsPerEval> FunctorType;
165 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work) );
179 typedef Functor<outputValueViewType,inputPointViewType,vinvViewType,workViewType,
180 OPERATOR_Dn,numPtsPerEval> FunctorType;
181 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints, vinv, work,
186 INTREPID2_TEST_FOR_EXCEPTION(
true , std::invalid_argument,
187 ">>> ERROR (Basis_HGRAD_LINE_Cn_FEM): Operator type not implemented" );
195 template<
typename DT,
typename OT,
typename PT>
198 const EPointType pointType ) {
199 this->pointType_ = pointType;
200 this->basisCardinality_ = order+1;
201 this->basisDegree_ = order;
202 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Line<2> >() );
203 this->basisType_ = BASIS_FEM_LAGRANGIAN;
204 this->basisCoordinates_ = COORDINATES_CARTESIAN;
205 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
207 const ordinal_type card = this->basisCardinality_;
210 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
211 dofCoords(
"Hgrad::Line::Cn::dofCoords", card, 1);
214 auto pointT = (pointType == POINTTYPE_DEFAULT) ? POINTTYPE_EQUISPACED : pointType;
217 case POINTTYPE_EQUISPACED:
218 case POINTTYPE_WARPBLEND: {
221 const ordinal_type offset = 0;
223 this->basisCellTopology_,
232 std::invalid_argument ,
233 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) invalid pointType." );
237 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
238 Kokkos::deep_copy(this->dofCoords_, dofCoords);
242 const ordinal_type lwork = card*card;
243 Kokkos::DynRankView<typename ScalarViewType::value_type,Kokkos::LayoutLeft,Kokkos::HostSpace>
244 vmat(
"Hgrad::Line::Cn::vmat", card, card),
245 work(
"Hgrad::Line::Cn::work", lwork),
246 ipiv(
"Hgrad::Line::Cn::ipiv", card);
248 const double alpha = 0.0, beta = 0.0;
249 Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI::
250 getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval>
251 (vmat, dofCoords, order, alpha, beta, OPERATOR_VALUE);
253 ordinal_type info = 0;
254 Teuchos::LAPACK<ordinal_type,typename ScalarViewType::value_type> lapack;
256 lapack.GETRF(card, card,
257 vmat.data(), vmat.stride_1(),
258 (ordinal_type*)ipiv.data(),
261 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
263 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) lapack.GETRF returns nonzero info." );
266 vmat.data(), vmat.stride_1(),
267 (ordinal_type*)ipiv.data(),
271 INTREPID2_TEST_FOR_EXCEPTION( info != 0,
273 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) lapack.GETRI returns nonzero info." );
276 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
277 vinv(
"Hgrad::Line::Cn::vinv", card, card);
279 for (ordinal_type i=0;i<card;++i)
280 for (ordinal_type j=0;j<card;++j)
281 vinv(i,j) = vmat(j,i);
283 this->vinv_ = Kokkos::create_mirror_view(
typename DT::memory_space(), vinv);
284 Kokkos::deep_copy(this->vinv_ , vinv);
289 const ordinal_type tagSize = 4;
290 const ordinal_type posScDim = 0;
291 const ordinal_type posScOrd = 1;
292 const ordinal_type posDfOrd = 2;
296 INTREPID2_TEST_FOR_EXCEPTION( order >
Parameters::MaxOrder, std::invalid_argument,
"polynomial order exceeds the max supported by this class");
307 const ordinal_type iend = card - 2;
308 for (ordinal_type i=0;i<iend;++i) {
309 const auto e = i + 1;
316 const auto v1 = card -1;
346 OrdinalTypeArray1DHost tagView(&tags[0][0], card*4);
350 this->setOrdinalTagData(this->tagToOrdinal_,
353 this->basisCardinality_,
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.
Basis_HGRAD_LINE_Cn_FEM(const ordinal_type order, const EPointType pointType=POINTTYPE_EQUISPACED)
Constructor.
static constexpr ordinal_type MaxOrder
The maximum reconstruction order.