16 #ifndef __INTREPID2_HGRAD_TET_C2_FEM_DEF_HPP__
17 #define __INTREPID2_HGRAD_TET_C2_FEM_DEF_HPP__
25 template<EOperator opType>
26 template<
typename OutputViewType,
27 typename inputViewType>
28 KOKKOS_INLINE_FUNCTION
30 Basis_HGRAD_TET_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);
37 const auto z = input(2);
40 output.access(0) = (-1. + x + y + z)*(-1. + 2.*x + 2.*y + 2.*z);
41 output.access(1) = x*(-1. + 2.*x);
42 output.access(2) = y*(-1. + 2.*y);
43 output.access(3) = z*(-1. + 2.*z);
45 output.access(4) = -4.*x*(-1. + x + y + z);
46 output.access(5) = 4.*x*y;
47 output.access(6) = -4.*y*(-1. + x + y + z);
48 output.access(7) = -4.*z*(-1. + x + y + z);
49 output.access(8) = 4.*x*z;
50 output.access(9) = 4.*y*z;
55 const auto x = input(0);
56 const auto y = input(1);
57 const auto z = input(2);
60 output.access(0, 0) = -3.+ 4.*x + 4.*y + 4.*z;
61 output.access(0, 1) = -3.+ 4.*x + 4.*y + 4.*z;
62 output.access(0, 2) = -3.+ 4.*x + 4.*y + 4.*z;
64 output.access(1, 0) = -1.+ 4.*x;
65 output.access(1, 1) = 0.;
66 output.access(1, 2) = 0.;
68 output.access(2, 0) = 0.;
69 output.access(2, 1) = -1.+ 4.*y;
70 output.access(2, 2) = 0.;
72 output.access(3, 0) = 0.;
73 output.access(3, 1) = 0.;
74 output.access(3, 2) = -1.+ 4.*z;
77 output.access(4, 0) = -4.*(-1.+ 2*x + y + z);
78 output.access(4, 1) = -4.*x;
79 output.access(4, 2) = -4.*x;
81 output.access(5, 0) = 4.*y;
82 output.access(5, 1) = 4.*x;
83 output.access(5, 2) = 0.;
85 output.access(6, 0) = -4.*y;
86 output.access(6, 1) = -4.*(-1.+ x + 2*y + z);
87 output.access(6, 2) = -4.*y;
89 output.access(7, 0) = -4.*z;
90 output.access(7, 1) = -4.*z;
91 output.access(7, 2) = -4.*(-1.+ x + y + 2*z);
93 output.access(8, 0) = 4.*z;
94 output.access(8, 1) = 0.;
95 output.access(8, 2) = 4.*x;
97 output.access(9, 0) = 0.;
98 output.access(9, 1) = 4.*z;
99 output.access(9, 2) = 4.*y;
103 output.access(0, 0) = 4.;
104 output.access(0, 1) = 4.;
105 output.access(0, 2) = 4.;
106 output.access(0, 3) = 4.;
107 output.access(0, 4) = 4.;
108 output.access(0, 5) = 4.;
110 output.access(1, 0) = 4.;
111 output.access(1, 1) = 0.;
112 output.access(1, 2) = 0.;
113 output.access(1, 3) = 0.;
114 output.access(1, 4) = 0.;
115 output.access(1, 5) = 0.;
117 output.access(2, 0) = 0.;
118 output.access(2, 1) = 0.;
119 output.access(2, 2) = 0.;
120 output.access(2, 3) = 4.;
121 output.access(2, 4) = 0.;
122 output.access(2, 5) = 0.;
124 output.access(3, 0) = 0.;
125 output.access(3, 1) = 0.;
126 output.access(3, 2) = 0.;
127 output.access(3, 3) = 0.;
128 output.access(3, 4) = 0.;
129 output.access(3, 5) = 4.;
131 output.access(4, 0) = -8.;
132 output.access(4, 1) = -4.;
133 output.access(4, 2) = -4.;
134 output.access(4, 3) = 0.;
135 output.access(4, 4) = 0.;
136 output.access(4, 5) = 0.;
138 output.access(5, 0) = 0.;
139 output.access(5, 1) = 4.;
140 output.access(5, 2) = 0.;
141 output.access(5, 3) = 0.;
142 output.access(5, 4) = 0.;
143 output.access(5, 5) = 0.;
145 output.access(6, 0) = 0.;
146 output.access(6, 1) = -4.;
147 output.access(6, 2) = 0.;
148 output.access(6, 3) = -8.;
149 output.access(6, 4) = -4.;
150 output.access(6, 5) = 0;
152 output.access(7, 0) = 0.;
153 output.access(7, 1) = 0.;
154 output.access(7, 2) = -4.;
155 output.access(7, 3) = 0.;
156 output.access(7, 4) = -4.;
157 output.access(7, 5) = -8.;
159 output.access(8, 0) = 0.;
160 output.access(8, 1) = 0.;
161 output.access(8, 2) = 4.;
162 output.access(8, 3) = 0.;
163 output.access(8, 4) = 0.;
164 output.access(8, 5) = 0.;
166 output.access(9, 0) = 0.;
167 output.access(9, 1) = 0.;
168 output.access(9, 2) = 0.;
169 output.access(9, 3) = 0.;
170 output.access(9, 4) = 4.;
171 output.access(9, 5) = 0.;
175 const ordinal_type jend = output.extent(1);
176 const ordinal_type iend = output.extent(0);
178 for (ordinal_type j=0;j<jend;++j)
179 for (ordinal_type i=0;i<iend;++i)
180 output.access(i, j) = 0.0;
184 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
185 opType != OPERATOR_GRAD &&
186 opType != OPERATOR_D1 &&
187 opType != OPERATOR_D2 &&
188 opType != OPERATOR_MAX,
189 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_C2_FEM::Serial::getValues) operator is not supported");
194 template<
typename DT,
195 typename outputValueValueType,
class ...outputValueProperties,
196 typename inputPointValueType,
class ...inputPointProperties>
198 Basis_HGRAD_TET_C2_FEM::
199 getValues(
const typename DT::execution_space& space,
200 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
201 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
202 const EOperator operatorType ) {
203 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
204 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
205 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
208 const auto loopSize = inputPoints.extent(0);
209 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
211 switch (operatorType) {
213 case OPERATOR_VALUE: {
214 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
215 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
220 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
221 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
224 case OPERATOR_CURL: {
225 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument,
226 ">>> ERROR (Basis_HGRAD_TET_C2_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D");
230 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
231 ">>> ERROR (Basis_HGRAD_TET_C2_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D");
235 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D2> FunctorType;
236 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
247 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
248 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
252 INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
253 ">>> ERROR (Basis_HGRAD_TET_C2_FEM): Invalid operator type");
260 template<
typename DT,
typename OT,
typename PT>
263 const ordinal_type spaceDim = 3;
264 this->basisCardinality_ = 10;
265 this->basisDegree_ = 2;
266 this->basisCellTopologyKey_ = shards::Tetrahedron<4>::key;
267 this->basisType_ = BASIS_FEM_DEFAULT;
268 this->basisCoordinates_ = COORDINATES_CARTESIAN;
269 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
274 const ordinal_type tagSize = 4;
275 const ordinal_type posScDim = 0;
276 const ordinal_type posScOrd = 1;
277 const ordinal_type posDfOrd = 2;
280 ordinal_type tags[40] = { 0, 0, 0, 1,
296 this->setOrdinalTagData(this->tagToOrdinal_,
299 this->basisCardinality_,
307 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
308 dofCoords(
"dofCoordsHost", this->basisCardinality_,spaceDim);
310 dofCoords(0,0) = 0.0; dofCoords(0,1) = 0.0; dofCoords(0,2) = 0.0;
311 dofCoords(1,0) = 1.0; dofCoords(1,1) = 0.0; dofCoords(1,2) = 0.0;
312 dofCoords(2,0) = 0.0; dofCoords(2,1) = 1.0; dofCoords(2,2) = 0.0;
313 dofCoords(3,0) = 0.0; dofCoords(3,1) = 0.0; dofCoords(3,2) = 1.0;
315 dofCoords(4,0) = 0.5; dofCoords(4,1) = 0.0; dofCoords(4,2) = 0.0;
316 dofCoords(5,0) = 0.5; dofCoords(5,1) = 0.5; dofCoords(5,2) = 0.0;
317 dofCoords(6,0) = 0.0; dofCoords(6,1) = 0.5; dofCoords(6,2) = 0.0;
318 dofCoords(7,0) = 0.0; dofCoords(7,1) = 0.0; dofCoords(7,2) = 0.5;
319 dofCoords(8,0) = 0.5; dofCoords(8,1) = 0.0; dofCoords(8,2) = 0.5;
320 dofCoords(9,0) = 0.0; dofCoords(9,1) = 0.5; dofCoords(9,2) = 0.5;
322 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
323 Kokkos::deep_copy(this->dofCoords_, dofCoords);
326 template<
typename DT,
typename OT,
typename PT>
329 ordinal_type& perTeamSpaceSize,
330 ordinal_type& perThreadSpaceSize,
332 const EOperator operatorType)
const {
333 perTeamSpaceSize = 0;
334 perThreadSpaceSize = 0;
337 template<
typename DT,
typename OT,
typename PT>
338 KOKKOS_INLINE_FUNCTION
341 OutputViewType outputValues,
342 const PointViewType inputPoints,
343 const EOperator operatorType,
344 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
345 const typename DT::execution_space::scratch_memory_space & scratchStorage,
346 const ordinal_type subcellDim,
347 const ordinal_type subcellOrdinal)
const {
349 INTREPID2_TEST_FOR_ABORT( !((subcellDim <= 0) && (subcellOrdinal == -1)),
350 ">>> ERROR: (Intrepid2::Basis_HGRAD_TET_C2_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
352 (void) scratchStorage;
354 const int numPoints = inputPoints.extent(0);
356 switch(operatorType) {
358 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
359 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
360 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
365 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
366 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
367 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
368 Impl::Basis_HGRAD_TET_C2_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
Basis_HGRAD_TET_C2_FEM()
Constructor.
See Intrepid2::Basis_HGRAD_TET_C2_FEM.
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::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Kokkos::DynRankView< PointValueType, Kokkos::LayoutStride, DeviceType > PointViewType
View type for input points.
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...