14 #ifndef __INTREPID2_HGRAD_LINE_C2_FEM_DEF_HPP__
15 #define __INTREPID2_HGRAD_LINE_C2_FEM_DEF_HPP__
23 template<EOperator opType>
24 template<
typename OutputViewType,
25 typename inputViewType>
26 KOKKOS_INLINE_FUNCTION
28 Basis_HGRAD_LINE_C2_FEM::Serial<opType>::
29 getValues( OutputViewType output,
30 const inputViewType input ) {
32 case OPERATOR_VALUE : {
33 const auto x = input(0);
35 output.access(0) = (x - 1.0)*x/2.0;
36 output.access(1) = (1.0 + x)*x/2.0;
37 output.access(2) = (1.0 + x)*(1.0 - x);
40 case OPERATOR_GRAD : {
41 const auto x = input(0);
43 output.access(0, 0) = x-0.5;
44 output.access(1, 0) = x+0.5;
45 output.access(2, 0) = -2.0*x;
49 const ordinal_type jend = output.extent(1);
50 const ordinal_type iend = output.extent(0);
52 for (ordinal_type j=0;j<jend;++j)
53 for (ordinal_type i=0;i<iend;++i)
54 output.access(i, j) = 0.0;
58 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
59 opType != OPERATOR_GRAD &&
60 opType != OPERATOR_MAX,
61 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_C2_FEM::Serial::getValues) operator is not supported");
68 typename outputValueValueType,
class ...outputValueProperties,
69 typename inputPointValueType,
class ...inputPointProperties>
71 Basis_HGRAD_LINE_C2_FEM::
72 getValues(
const typename DT::execution_space& space,
73 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
74 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
75 const EOperator operatorType ) {
76 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
77 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
78 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
81 const auto loopSize = inputPoints.extent(0);
82 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
84 switch (operatorType) {
86 case OPERATOR_VALUE: {
87 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
88 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
95 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
96 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
108 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
109 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
113 INTREPID2_TEST_FOR_EXCEPTION( !Intrepid2::isValidOperator(operatorType), std::invalid_argument,
114 ">>> ERROR (Basis_HGRAD_LINE_C2_FEM): Invalid operator type");
125 template<
typename DT,
typename OT,
typename PT>
128 const ordinal_type spaceDim = 1;
129 this->basisCardinality_ = 3;
130 this->basisDegree_ = 2;
131 this->basisCellTopologyKey_ = shards::Line<2>::key;
132 this->basisType_ = BASIS_FEM_DEFAULT;
133 this->basisCoordinates_ = COORDINATES_CARTESIAN;
134 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
139 const ordinal_type tagSize = 4;
140 const ordinal_type posScDim = 0;
141 const ordinal_type posScOrd = 1;
142 const ordinal_type posDfOrd = 2;
145 ordinal_type tags[12] = { 0, 0, 0, 1,
154 this->setOrdinalTagData(this->tagToOrdinal_,
157 this->basisCardinality_,
165 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
166 dofCoords(
"dofCoordsHost", this->basisCardinality_,spaceDim);
168 dofCoords(0,0) = -1.0;
169 dofCoords(1,0) = 1.0;
170 dofCoords(2,0) = 0.0;
172 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
173 Kokkos::deep_copy(this->dofCoords_, dofCoords);
176 template<
typename DT,
typename OT,
typename PT>
179 ordinal_type& perTeamSpaceSize,
180 ordinal_type& perThreadSpaceSize,
182 const EOperator operatorType)
const {
183 perTeamSpaceSize = 0;
184 perThreadSpaceSize = 0;
187 template<
typename DT,
typename OT,
typename PT>
188 KOKKOS_INLINE_FUNCTION
191 OutputViewType outputValues,
192 const PointViewType inputPoints,
193 const EOperator operatorType,
194 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
195 const typename DT::execution_space::scratch_memory_space & scratchStorage,
196 const ordinal_type subcellDim,
197 const ordinal_type subcellOrdinal)
const {
199 INTREPID2_TEST_FOR_ABORT( !((subcellDim == -1) && (subcellOrdinal == -1)),
200 ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_C2_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
202 (void) scratchStorage;
204 const int numPoints = inputPoints.extent(0);
206 switch(operatorType) {
208 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
209 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
210 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
215 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
216 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
217 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
218 Impl::Basis_HGRAD_LINE_C2_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
Basis_HGRAD_LINE_C2_FEM()
Constructor.
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.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
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...
See Intrepid2::Basis_HGRAD_LINE_C2_FEM.