49#ifndef __INTREPID2_HGRAD_QUAD_C2_FEM_DEF_HPP__
50#define __INTREPID2_HGRAD_QUAD_C2_FEM_DEF_HPP__
58 template<
bool serendipity>
59 template<EOperator opType>
60 template<
typename OutputViewType,
61 typename inputViewType>
62 KOKKOS_INLINE_FUNCTION
66 const inputViewType input ) {
68 case OPERATOR_VALUE : {
69 const auto x = input(0);
70 const auto y = input(1);
73 output.access(0) = x*(x - 1.0)*y*(y - 1.0)/4.0;
74 output.access(1) = x*(x + 1.0)*y*(y - 1.0)/4.0;
75 output.access(2) = x*(x + 1.0)*y*(y + 1.0)/4.0;
76 output.access(3) = x*(x - 1.0)*y*(y + 1.0)/4.0;
78 output.access(4) = (1.0 - x)*(1.0 + x)*y*(y - 1.0)/2.0;
79 output.access(5) = x*(x + 1.0)*(1.0 - y)*(1.0 + y)/2.0;
80 output.access(6) = (1.0 - x)*(1.0 + x)*y*(y + 1.0)/2.0;
81 output.access(7) = x*(x - 1.0)*(1.0 - y)*(1.0 + y)/2.0;
84 if constexpr (!serendipity) {
85 output.access(8) = (1.0 - x)*(1.0 + x)*(1.0 - y)*(1.0 + y);
90 case OPERATOR_GRAD : {
91 const auto x = input(0);
92 const auto y = input(1);
95 output.access(0, 0) = (-0.25 + 0.5*x)*(-1. + y)*y;
96 output.access(0, 1) = (-1.0 + x)*x*(-0.25 + 0.5*y);
98 output.access(1, 0) = (0.25 + 0.5*x)*(-1. + y)*y;
99 output.access(1, 1) = x*(1. + x)*(-0.25 + 0.5*y);
101 output.access(2, 0) = (0.25 + 0.5*x)*y*(1. + y);
102 output.access(2, 1) = x*(1. + x)*(0.25 + 0.5*y);
104 output.access(3, 0) = (-0.25 + 0.5*x)*y*(1. + y);
105 output.access(3, 1) = (-1. + x)*x*(0.25 + 0.5*y);
107 output.access(4, 0) = x*(1.0 - y)*y;
108 output.access(4, 1) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y);
110 output.access(5, 0) = 0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x);
111 output.access(5, 1) =-x*(1.0 + x)*y;
113 output.access(6, 0) =-y*(1.0 + y)*x;
114 output.access(6, 1) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y);
116 output.access(7, 0) = 0.5*(1.0 - y)*(1.0+ y)*(-1.0 + 2.0*x);
117 output.access(7, 1) = (1.0 - x)*x*y;
119 if constexpr (!serendipity) {
120 output.access(8, 0) =-2.0*(1.0 - y)*(1.0 + y)*x;
121 output.access(8, 1) =-2.0*(1.0 - x)*(1.0 + x)*y;
125 case OPERATOR_CURL : {
126 const auto x = input(0);
127 const auto y = input(1);
131 output.access(0, 1) =-(-0.25 + 0.5*x)*(-1. + y)*y;
132 output.access(0, 0) = (-1.0 + x)*x*(-0.25 + 0.5*y);
134 output.access(1, 1) =-(0.25 + 0.5*x)*(-1. + y)*y;
135 output.access(1, 0) = x*(1. + x)*(-0.25 + 0.5*y);
137 output.access(2, 1) =-(0.25 + 0.5*x)*y*(1. + y);
138 output.access(2, 0) = x*(1. + x)*(0.25 + 0.5*y);
140 output.access(3, 1) =-(-0.25 + 0.5*x)*y*(1. + y);
141 output.access(3, 0) = (-1. + x)*x*(0.25 + 0.5*y);
143 output.access(4, 1) =-x*(1.0 - y)*y;
144 output.access(4, 0) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y);
146 output.access(5, 1) =-0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x);
147 output.access(5, 0) =-x*(1.0 + x)*y;
149 output.access(6, 1) = y*(1.0 + y)*x;
150 output.access(6, 0) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y);
152 output.access(7, 1) =-0.5*(1.0 - y)*(1.0 + y)*(-1.0 + 2.0*x);
153 output.access(7, 0) = (1.0 - x)*x*y;
155 if constexpr (!serendipity) {
156 output.access(8, 1) = 2.0*(1.0 - y)*(1.0 + y)*x;
157 output.access(8, 0) =-2.0*(1.0 - x)*(1.0 + x)*y;
162 const auto x = input(0);
163 const auto y = input(1);
165 output.access(0, 0) = 0.5*(-1.0 + y)*y;
166 output.access(0, 1) = 0.25 - 0.5*y + x*(-0.5 + 1.*y);
167 output.access(0, 2) = 0.5*(-1.0 + x)*x;
169 output.access(1, 0) = 0.5*(-1.0 + y)*y;
170 output.access(1, 1) =-0.25 + 0.5*y + x*(-0.5 + 1.*y);
171 output.access(1, 2) = 0.5*x*(1.0 + x);
173 output.access(2, 0) = 0.5*y*(1.0 + y);
174 output.access(2, 1) = 0.25 + 0.5*y + x*(0.5 + 1.*y);
175 output.access(2, 2) = 0.5*x*(1.0 + x);
177 output.access(3, 0) = 0.5*y*(1.0 + y);
178 output.access(3, 1) =-0.25 - 0.5*y + x*(0.5 + 1.*y);
179 output.access(3, 2) = 0.5*(-1.0 + x)*x;
181 output.access(4, 0) = (1.0 - y)*y;
182 output.access(4, 1) = x*(1. - 2.*y);
183 output.access(4, 2) = (1.0 - x)*(1.0 + x);
185 output.access(5, 0) = (1.0 - y)*(1.0 + y);
186 output.access(5, 1) = x*(0. - 2.*y) - 1.*y;
187 output.access(5, 2) =-x*(1.0 + x);
189 output.access(6, 0) =-y*(1.0 + y);
190 output.access(6, 1) = x*(-1. - 2.*y);
191 output.access(6, 2) = (1.0 - x)*(1.0 + x);
193 output.access(7, 0) = (1.0 - y)*(1.0 + y);
194 output.access(7, 1) = x*(0. - 2.*y) + 1.*y;
195 output.access(7, 2) = (1.0 - x)*x;
197 if constexpr (!serendipity) {
198 output.access(8, 0) =-2.0 + 2.0*y*y;
199 output.access(8, 1) = 4*x*y;
200 output.access(8, 2) =-2.0 + 2.0*x*x;
205 const auto x = input(0);
206 const auto y = input(1);
207 output.access(0, 0) = 0.0;
208 output.access(0, 1) =-0.5 + y;
209 output.access(0, 2) =-0.5 + x;
210 output.access(0, 3) = 0.0;
212 output.access(1, 0) = 0.0;
213 output.access(1, 1) =-0.5 + y;
214 output.access(1, 2) = 0.5 + x;
215 output.access(1, 3) = 0.0;
217 output.access(2, 0) = 0.0;
218 output.access(2, 1) = 0.5 + y;
219 output.access(2, 2) = 0.5 + x;
220 output.access(2, 3) = 0.0;
222 output.access(3, 0) = 0.0;
223 output.access(3, 1) = 0.5 + y;
224 output.access(3, 2) =-0.5 + x;
225 output.access(3, 3) = 0.0;
227 output.access(4, 0) = 0.0;
228 output.access(4, 1) = 1.0 - 2.0*y;
229 output.access(4, 2) =-2.0*x;
230 output.access(4, 3) = 0.0;
232 output.access(5, 0) = 0.0;
233 output.access(5, 1) =-2.0*y;
234 output.access(5, 2) =-1.0 - 2.0*x;
235 output.access(5, 3) = 0.0;
237 output.access(6, 0) = 0.0;
238 output.access(6, 1) =-1.0 - 2.0*y;
239 output.access(6, 2) =-2.0*x;
240 output.access(6, 3) = 0.0;
242 output.access(7, 0) = 0.0;
243 output.access(7, 1) =-2.0*y;
244 output.access(7, 2) = 1.0 - 2.0*x;
245 output.access(7, 3) = 0.0;
247 if constexpr (!serendipity) {
248 output.access(8, 0) = 0.0;
249 output.access(8, 1) = 4.0*y;
250 output.access(8, 2) = 4.0*x;
251 output.access(8, 3) = 0.0;
256 output.access(0, 0) = 0.0;
257 output.access(0, 1) = 0.0;
258 output.access(0, 2) = 1.0;
259 output.access(0, 3) = 0.0;
260 output.access(0, 4) = 0.0;
262 output.access(1, 0) = 0.0;
263 output.access(1, 1) = 0.0;
264 output.access(1, 2) = 1.0;
265 output.access(1, 3) = 0.0;
266 output.access(1, 4) = 0.0;
268 output.access(2, 0) = 0.0;
269 output.access(2, 1) = 0.0;
270 output.access(2, 2) = 1.0;
271 output.access(2, 3) = 0.0;
272 output.access(2, 4) = 0.0;
274 output.access(3, 0) = 0.0;
275 output.access(3, 1) = 0.0;
276 output.access(3, 2) = 1.0;
277 output.access(3, 3) = 0.0;
278 output.access(3, 4) = 0.0;
280 output.access(4, 0) = 0.0;
281 output.access(4, 1) = 0.0;
282 output.access(4, 2) =-2.0;
283 output.access(4, 3) = 0.0;
284 output.access(4, 4) = 0.0;
286 output.access(5, 0) = 0.0;
287 output.access(5, 1) = 0.0;
288 output.access(5, 2) =-2.0;
289 output.access(5, 3) = 0.0;
290 output.access(5, 4) = 0.0;
292 output.access(6, 0) = 0.0;
293 output.access(6, 1) = 0.0;
294 output.access(6, 2) =-2.0;
295 output.access(6, 3) = 0.0;
296 output.access(6, 4) = 0.0;
298 output.access(7, 0) = 0.0;
299 output.access(7, 1) = 0.0;
300 output.access(7, 2) =-2.0;
301 output.access(7, 3) = 0.0;
302 output.access(7, 4) = 0.0;
304 if constexpr (!serendipity) {
305 output.access(8, 0) = 0.0;
306 output.access(8, 1) = 0.0;
307 output.access(8, 2) = 4.0;
308 output.access(8, 3) = 0.0;
309 output.access(8, 4) = 0.0;
313 case OPERATOR_MAX : {
314 const ordinal_type jend = output.extent(1);
315 const ordinal_type iend = output.extent(0);
317 for (ordinal_type j=0;j<jend;++j)
318 for (ordinal_type i=0;i<iend;++i)
319 output.access(i, j) = 0.0;
323 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
324 opType != OPERATOR_GRAD &&
325 opType != OPERATOR_CURL &&
326 opType != OPERATOR_D1 &&
327 opType != OPERATOR_D2 &&
328 opType != OPERATOR_D3 &&
329 opType != OPERATOR_D4 &&
330 opType != OPERATOR_MAX,
331 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_C2_FEM::Serial::getValues) operator is not supported");
337 template<
bool serendipity>
338 template<
typename DT,
339 typename outputValueValueType,
class ...outputValueProperties,
340 typename inputPointValueType,
class ...inputPointProperties>
343 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
344 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
345 const EOperator operatorType ) {
346 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
347 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
348 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
351 const auto loopSize = inputPoints.extent(0);
352 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
354 switch (operatorType) {
356 case OPERATOR_VALUE: {
357 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
358 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
363 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
364 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
367 case OPERATOR_CURL: {
368 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_CURL> FunctorType;
369 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
373 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
374 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): DIV is invalid operator for rank-0 (scalar) functions in 2D");
378 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D2> FunctorType;
379 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
384 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D3> FunctorType;
385 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
390 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D4> FunctorType;
391 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
400 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
401 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
405 INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
406 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): Invalid operator type");
415 template<
bool serendipity,
typename DT,
typename OT,
typename PT>
420 this->
basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >() );
427 const ordinal_type tagSize = 4;
428 const ordinal_type posScDim = 0;
429 const ordinal_type posScOrd = 1;
430 const ordinal_type posDfOrd = 2;
433 ordinal_type tags[36] = { 0, 0, 0, 1,
446 OrdinalTypeArray1DHost tagView(&tags[0], serendipity ? 32 : 36);
460 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
463 dofCoords(0,0) = -1.0; dofCoords(0,1) = -1.0;
464 dofCoords(1,0) = 1.0; dofCoords(1,1) = -1.0;
465 dofCoords(2,0) = 1.0; dofCoords(2,1) = 1.0;
466 dofCoords(3,0) = -1.0; dofCoords(3,1) = 1.0;
468 dofCoords(4,0) = 0.0; dofCoords(4,1) = -1.0;
469 dofCoords(5,0) = 1.0; dofCoords(5,1) = 0.0;
470 dofCoords(6,0) = 0.0; dofCoords(6,1) = 1.0;
471 dofCoords(7,0) = -1.0; dofCoords(7,1) = 0.0;
473 if constexpr (!serendipity) {
474 dofCoords(8,0) = 0.0; dofCoords(8,1) = 0.0;
477 this->
dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
478 Kokkos::deep_copy(this->
dofCoords_, dofCoords);
Basis_HGRAD_QUAD_DEG2_FEM()
Constructor.
ECoordinates basisCoordinates_
ordinal_type basisDegree_
void setOrdinalTagData(OrdinalTypeView3D &tagToOrdinal, OrdinalTypeView2D &ordinalToTag, const OrdinalTypeView1D tags, const ordinal_type basisCard, const ordinal_type tagSize, const ordinal_type posScDim, const ordinal_type posScOrd, const ordinal_type posDfOrd)
OrdinalTypeArray2DHost ordinalToTag_
Kokkos::DynRankView< scalarType, DeviceType > dofCoords_
ordinal_type basisCardinality_
OrdinalTypeArray3DHost tagToOrdinal_
shards::CellTopology basisCellTopology_
EFunctionSpace functionSpace_
See Intrepid2::Basis_HGRAD_QUAD_DEG2_FEM.