16 #ifndef __INTREPID2_HGRAD_TRI_C2_FEM_DEF_HPP__
17 #define __INTREPID2_HGRAD_TRI_C2_FEM_DEF_HPP__
25 template<EOperator opType>
26 template<
typename OutputViewType,
27 typename inputViewType>
28 KOKKOS_INLINE_FUNCTION
30 Basis_HGRAD_TRI_C2_FEM::Serial<opType>::
31 getValues( OutputViewType output,
32 const inputViewType input ) {
34 case OPERATOR_VALUE: {
35 const auto x = input(0);
36 const auto y = input(1);
39 output.access(0) = (x + y - 1.0)*(2.0*x + 2.0*y - 1.0);
40 output.access(1) = x*(2.0*x - 1.0);
41 output.access(2) = y*(2.0*y - 1.0);
42 output.access(3) = -4.0*x*(x + y - 1.0);
43 output.access(4) = 4.0*x*y;
44 output.access(5) = -4.0*y*(x + y - 1.0);
49 const auto x = input(0);
50 const auto y = input(1);
52 output.access(0, 0) = 4.0*x + 4.0*y - 3.0;
53 output.access(0, 1) = 4.0*x + 4.0*y - 3.0;
55 output.access(1, 0) = 4.0*x - 1.0;
56 output.access(1, 1) = 0.0;
58 output.access(2, 0) = 0.0;
59 output.access(2, 1) = 4.0*y - 1.0;
61 output.access(3, 0) = -4.0*(2.0*x + y - 1.0);
62 output.access(3, 1) = -4.0*x;
64 output.access(4, 0) = 4.0*y;
65 output.access(4, 1) = 4.0*x;
67 output.access(5, 0) = -4.0*y;
68 output.access(5, 1) = -4.0*(x + 2.0*y - 1.0);
72 const auto x = input(0);
73 const auto y = input(1);
75 output.access(0, 1) =-(4.0*x + 4.0*y - 3.0);
76 output.access(0, 0) = 4.0*x + 4.0*y - 3.0;
78 output.access(1, 1) =-(4.0*x - 1.0);
79 output.access(1, 0) = 0.0;
81 output.access(2, 1) = 0.0;
82 output.access(2, 0) = 4.0*y - 1.0;
84 output.access(3, 1) = 4.0*(2.0*x + y - 1.0);
85 output.access(3, 0) = -4.0*x;
87 output.access(4, 1) = -4.0*y;
88 output.access(4, 0) = 4.0*x;
90 output.access(5, 1) = 4.0*y;
91 output.access(5, 0) = -4.0*(x + 2.0*y - 1.0);
97 output.access(0, 0) = 4.0;
98 output.access(1, 0) = 4.0;
99 output.access(2, 0) = 0.0;
100 output.access(3, 0) =-8.0;
101 output.access(4, 0) = 0.0;
102 output.access(5, 0) = 0.0;
105 output.access(0, 1) = 4.0;
106 output.access(1, 1) = 0.0;
107 output.access(2, 1) = 0.0;
108 output.access(3, 1) =-4.0;
109 output.access(4, 1) = 4.0;
110 output.access(5, 1) =-4.0;
113 output.access(0, 2) = 4.0;
114 output.access(1, 2) = 0.0;
115 output.access(2, 2) = 4.0;
116 output.access(3, 2) = 0.0;
117 output.access(4, 2) = 0.0;
118 output.access(5, 2) =-8.0;
122 const ordinal_type jend = output.extent(1);
123 const ordinal_type iend = output.extent(0);
125 for (ordinal_type j=0;j<jend;++j)
126 for (ordinal_type i=0;i<iend;++i)
127 output.access(i, j) = 0.0;
131 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
132 opType != OPERATOR_GRAD &&
133 opType != OPERATOR_CURL &&
134 opType != OPERATOR_D1 &&
135 opType != OPERATOR_D2 &&
136 opType != OPERATOR_MAX,
137 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_C2_FEM::Serial::getValues) operator is not supported");
142 template<
typename DT,
143 typename outputValueValueType,
class ...outputValueProperties,
144 typename inputPointValueType,
class ...inputPointProperties>
146 Basis_HGRAD_TRI_C2_FEM::
147 getValues(
const typename DT::execution_space& space,
148 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
149 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
150 const EOperator operatorType ) {
151 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
152 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
153 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
156 const auto loopSize = inputPoints.extent(0);
157 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
159 switch (operatorType) {
161 case OPERATOR_VALUE: {
162 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
163 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
168 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
169 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
172 case OPERATOR_CURL: {
173 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_CURL> FunctorType;
174 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
178 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
179 ">>> ERROR (Basis_HGRAD_TRI_C2_FEM): DIV is invalid operator for rank-0 (scalar) fields in 2D.");
183 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D2> FunctorType;
184 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
195 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
196 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
200 INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
201 ">>> ERROR (Basis_HGRAD_TRI_C2_FEM): Invalid operator type");
210 template<
typename DT,
typename OT,
typename PT>
213 const ordinal_type spaceDim = 2;
214 this->basisCardinality_ = 6;
215 this->basisDegree_ = 2;
216 this->basisCellTopologyKey_ = shards::Triangle<3>::key;
217 this->basisType_ = BASIS_FEM_DEFAULT;
218 this->basisCoordinates_ = COORDINATES_CARTESIAN;
219 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
224 const ordinal_type tagSize = 4;
225 const ordinal_type posScDim = 0;
226 const ordinal_type posScOrd = 1;
227 const ordinal_type posDfOrd = 2;
230 ordinal_type tags[24] = { 0, 0, 0, 1,
241 this->setOrdinalTagData(this->tagToOrdinal_,
244 this->basisCardinality_,
252 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
253 dofCoords(
"dofCoordsHost", this->basisCardinality_,spaceDim);
255 dofCoords(0,0) = 0.0; dofCoords(0,1) = 0.0;
256 dofCoords(1,0) = 1.0; dofCoords(1,1) = 0.0;
257 dofCoords(2,0) = 0.0; dofCoords(2,1) = 1.0;
258 dofCoords(3,0) = 0.5; dofCoords(3,1) = 0.0;
259 dofCoords(4,0) = 0.5; dofCoords(4,1) = 0.5;
260 dofCoords(5,0) = 0.0; dofCoords(5,1) = 0.5;
262 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
263 Kokkos::deep_copy(this->dofCoords_, dofCoords);
266 template<
typename DT,
typename OT,
typename PT>
269 ordinal_type& perTeamSpaceSize,
270 ordinal_type& perThreadSpaceSize,
272 const EOperator operatorType)
const {
273 perTeamSpaceSize = 0;
274 perThreadSpaceSize = 0;
277 template<
typename DT,
typename OT,
typename PT>
278 KOKKOS_INLINE_FUNCTION
281 OutputViewType outputValues,
282 const PointViewType inputPoints,
283 const EOperator operatorType,
284 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
285 const typename DT::execution_space::scratch_memory_space & scratchStorage,
286 const ordinal_type subcellDim,
287 const ordinal_type subcellOrdinal)
const {
289 INTREPID2_TEST_FOR_ABORT( !((subcellDim <= 0) && (subcellOrdinal == -1)),
290 ">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_C2_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
292 (void) scratchStorage;
294 const int numPoints = inputPoints.extent(0);
296 switch(operatorType) {
298 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
299 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
300 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
305 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
306 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
307 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
308 Impl::Basis_HGRAD_TRI_C2_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
312 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
313 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
314 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
315 Impl::Basis_HGRAD_TRI_C2_FEM::Serial<OPERATOR_CURL>::getValues( output, input);
319 INTREPID2_TEST_FOR_ABORT(
true,
">>> ERROR: (Intrepid2::Basis_HGRAD_TRI_C2_FEM::getValues), Operator Type not supported.");
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.
See Intrepid2::Basis_HGRAD_TRI_C2_FEM.
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...
Basis_HGRAD_TRI_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.