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
64 Basis_HGRAD_QUAD_DEG2_FEM<serendipity>::Serial<opType>::
65 getValues( OutputViewType output,
66 const inputViewType input ) {
68 case OPERATOR_VALUE : {
69 const auto x = input(0);
70 const auto y = input(1);
73 if constexpr (!serendipity) {
74 output.access(0) = x*(x - 1.0)*y*(y - 1.0)/4.0;
75 output.access(1) = x*(x + 1.0)*y*(y - 1.0)/4.0;
76 output.access(2) = x*(x + 1.0)*y*(y + 1.0)/4.0;
77 output.access(3) = x*(x - 1.0)*y*(y + 1.0)/4.0;
79 output.access(4) = (1.0 - x)*(1.0 + x)*y*(y - 1.0)/2.0;
80 output.access(5) = x*(x + 1.0)*(1.0 - y)*(1.0 + y)/2.0;
81 output.access(6) = (1.0 - x)*(1.0 + x)*y*(y + 1.0)/2.0;
82 output.access(7) = x*(x - 1.0)*(1.0 - y)*(1.0 + y)/2.0;
85 output.access(8) = (1.0 - x)*(1.0 + x)*(1.0 - y)*(1.0 + y);
89 output.access(0) = 0.25*(1.0 - x)*(1.0 - y)*(-x - y - 1.0);
90 output.access(1) = 0.25*(1.0 + x)*(1.0 - y)*( x - y - 1.0);
91 output.access(2) = 0.25*(1.0 + x)*(1.0 + y)*( x + y - 1.0);
92 output.access(3) = 0.25*(1.0 - x)*(1.0 + y)*(-x + y - 1.0);
94 output.access(4) = 0.5*(1.0 - x*x)*(1.0 - y);
95 output.access(5) = 0.5*(1.0 + x)*(1.0 - y*y);
96 output.access(6) = 0.5*(1.0 - x*x)*(1.0 + y);
97 output.access(7) = 0.5*(1.0 - x)*(1.0 - y*y);
103 case OPERATOR_GRAD : {
104 const auto x = input(0);
105 const auto y = input(1);
107 if constexpr (!serendipity) {
109 output.access(0, 0) = (-0.25 + 0.5*x)*(-1. + y)*y;
110 output.access(0, 1) = (-1.0 + x)*x*(-0.25 + 0.5*y);
112 output.access(1, 0) = (0.25 + 0.5*x)*(-1. + y)*y;
113 output.access(1, 1) = x*(1. + x)*(-0.25 + 0.5*y);
115 output.access(2, 0) = (0.25 + 0.5*x)*y*(1. + y);
116 output.access(2, 1) = x*(1. + x)*(0.25 + 0.5*y);
118 output.access(3, 0) = (-0.25 + 0.5*x)*y*(1. + y);
119 output.access(3, 1) = (-1. + x)*x*(0.25 + 0.5*y);
121 output.access(4, 0) = x*(1.0 - y)*y;
122 output.access(4, 1) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y);
124 output.access(5, 0) = 0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x);
125 output.access(5, 1) =-x*(1.0 + x)*y;
127 output.access(6, 0) =-y*(1.0 + y)*x;
128 output.access(6, 1) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y);
130 output.access(7, 0) = 0.5*(1.0 - y)*(1.0+ y)*(-1.0 + 2.0*x);
131 output.access(7, 1) = (1.0 - x)*x*y;
133 output.access(8, 0) =-2.0*(1.0 - y)*(1.0 + y)*x;
134 output.access(8, 1) =-2.0*(1.0 - x)*(1.0 + x)*y;
138 output.access(0, 0) = -0.25*(1.0-y)*(-x-y-1.0) - 0.25*(1.0-x)*(1.0-y);
139 output.access(0, 1) = -0.25*(1.0-x)*(-x-y-1.0) - 0.25*(1.0-x)*(1.0-y);
141 output.access(1, 0) = 0.25*(1.0-y)*( x-y-1.0) + 0.25*(1.0+x)*(1.0-y);
142 output.access(1, 1) = -0.25*(1.0+x)*( x-y-1.0) - 0.25*(1.0+x)*(1.0-y);
144 output.access(2, 0) = 0.25*(1.0+y)*( x+y-1.0) + 0.25*(1.0+x)*(1.0+y);
145 output.access(2, 1) = 0.25*(1.0+x)*( x+y-1.0) + 0.25*(1.0+x)*(1.0+y);
147 output.access(3, 0) = -0.25*(1.0+y)*(-x+y-1.0) - 0.25*(1.0-x)*(1.0+y);
148 output.access(3, 1) = 0.25*(1.0-x)*(-x+y-1.0) + 0.25*(1.0-x)*(1.0+y);
150 output.access(4, 0) = -x*(1.0-y);
151 output.access(4, 1) = -0.5*(1.0-x*x);
153 output.access(5, 0) = 0.5*(1.0-y*y);
154 output.access(5, 1) = -y*(1.0+x);
156 output.access(6, 0) = -x*(1.0+y);
157 output.access(6, 1) = 0.5*(1.0-x*x);
159 output.access(7, 0) = -0.5*(1.0-y*y);
160 output.access(7, 1) = -y*(1.0-x);
164 case OPERATOR_CURL : {
165 const auto x = input(0);
166 const auto y = input(1);
171 if constexpr (!serendipity) {
172 output.access(0, 1) =-(-0.25 + 0.5*x)*(-1. + y)*y;
173 output.access(0, 0) = (-1.0 + x)*x*(-0.25 + 0.5*y);
175 output.access(1, 1) =-(0.25 + 0.5*x)*(-1. + y)*y;
176 output.access(1, 0) = x*(1. + x)*(-0.25 + 0.5*y);
178 output.access(2, 1) =-(0.25 + 0.5*x)*y*(1. + y);
179 output.access(2, 0) = x*(1. + x)*(0.25 + 0.5*y);
181 output.access(3, 1) =-(-0.25 + 0.5*x)*y*(1. + y);
182 output.access(3, 0) = (-1. + x)*x*(0.25 + 0.5*y);
184 output.access(4, 1) =-x*(1.0 - y)*y;
185 output.access(4, 0) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y);
187 output.access(5, 1) =-0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x);
188 output.access(5, 0) =-x*(1.0 + x)*y;
190 output.access(6, 1) = y*(1.0 + y)*x;
191 output.access(6, 0) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y);
193 output.access(7, 1) =-0.5*(1.0 - y)*(1.0 + y)*(-1.0 + 2.0*x);
194 output.access(7, 0) = (1.0 - x)*x*y;
196 output.access(8, 1) = 2.0*(1.0 - y)*(1.0 + y)*x;
197 output.access(8, 0) =-2.0*(1.0 - x)*(1.0 + x)*y;
200 output.access(0, 1) = 0.25*(1.0-y)*(-x-y-1.0) + 0.25*(1.0-x)*(1.0-y);
201 output.access(0, 0) = -0.25*(1.0-x)*(-x-y-1.0) - 0.25*(1.0-x)*(1.0-y);
203 output.access(1, 1) = -0.25*(1.0-y)*( x-y-1.0) - 0.25*(1.0+x)*(1.0-y);
204 output.access(1, 0) = -0.25*(1.0+x)*( x-y-1.0) - 0.25*(1.0+x)*(1.0-y);
206 output.access(2, 1) = -0.25*(1.0+y)*( x+y-1.0) - 0.25*(1.0+x)*(1.0+y);
207 output.access(2, 0) = 0.25*(1.0+x)*( x+y-1.0) + 0.25*(1.0+x)*(1.0+y);
209 output.access(3, 1) = 0.25*(1.0+y)*(-x+y-1.0) + 0.25*(1.0-x)*(1.0+y);
210 output.access(3, 0) = 0.25*(1.0-x)*(-x+y-1.0) + 0.25*(1.0-x)*(1.0+y);
212 output.access(4, 1) = x*(1.0-y);
213 output.access(4, 0) = -0.5*(1.0-x*x);
215 output.access(5, 1) = -0.5*(1.0-y*y);
216 output.access(5, 0) = -y*(1.0+x);
218 output.access(6, 1) = x*(1.0+y);
219 output.access(6, 0) = 0.5*(1.0-x*x);
221 output.access(7, 1) = 0.5*(1.0-y*y);
222 output.access(7, 0) = -y*(1.0-x);
227 const auto x = input(0);
228 const auto y = input(1);
231 if constexpr (!serendipity) {
233 output.access(0, 0) = 0.5*(-1.0 + y)*y;
234 output.access(0, 1) = 0.25 - 0.5*y + x*(-0.5 + 1.*y);
235 output.access(0, 2) = 0.5*(-1.0 + x)*x;
237 output.access(1, 0) = 0.5*(-1.0 + y)*y;
238 output.access(1, 1) =-0.25 + 0.5*y + x*(-0.5 + 1.*y);
239 output.access(1, 2) = 0.5*x*(1.0 + x);
241 output.access(2, 0) = 0.5*y*(1.0 + y);
242 output.access(2, 1) = 0.25 + 0.5*y + x*(0.5 + 1.*y);
243 output.access(2, 2) = 0.5*x*(1.0 + x);
245 output.access(3, 0) = 0.5*y*(1.0 + y);
246 output.access(3, 1) =-0.25 - 0.5*y + x*(0.5 + 1.*y);
247 output.access(3, 2) = 0.5*(-1.0 + x)*x;
249 output.access(4, 0) = (1.0 - y)*y;
250 output.access(4, 1) = x*(1. - 2.*y);
251 output.access(4, 2) = (1.0 - x)*(1.0 + x);
253 output.access(5, 0) = (1.0 - y)*(1.0 + y);
254 output.access(5, 1) = x*(0. - 2.*y) - 1.*y;
255 output.access(5, 2) =-x*(1.0 + x);
257 output.access(6, 0) =-y*(1.0 + y);
258 output.access(6, 1) = x*(-1. - 2.*y);
259 output.access(6, 2) = (1.0 - x)*(1.0 + x);
261 output.access(7, 0) = (1.0 - y)*(1.0 + y);
262 output.access(7, 1) = x*(0. - 2.*y) + 1.*y;
263 output.access(7, 2) = (1.0 - x)*x;
265 output.access(8, 0) =-2.0 + 2.0*y*y;
266 output.access(8, 1) = 4*x*y;
267 output.access(8, 2) =-2.0 + 2.0*x*x;
271 output.access(0, 0) = 0.5*(1.0 - y);
272 output.access(0, 1) = 0.25*(1.0 - 2.0*x - 2.0*y);
273 output.access(0, 2) = 0.5*(1.0 - x);
275 output.access(1, 0) = 0.5*(1.0 - y);
276 output.access(1, 1) = -0.25*(1.0 + 2.0*x - 2.0*y);
277 output.access(1, 2) = 0.5*(1.0 + x);
279 output.access(2, 0) = 0.5*(1.0 + y);
280 output.access(2, 1) = 0.25*(1.0 + 2.0*x + 2.0*y);
281 output.access(2, 2) = 0.5*(1.0 + x);
283 output.access(3, 0) = 0.5*(1.0 + y);
284 output.access(3, 1) = -0.25*(1.0 - 2.0*x + 2.0*y);
285 output.access(3, 2) = 0.5*(1.0 - x);
287 output.access(4, 0) = -(1.0 - y);
288 output.access(4, 1) = x;
289 output.access(4, 2) = 0.0;
291 output.access(5, 0) = 0.0;
292 output.access(5, 1) = -y;
293 output.access(5, 2) = -(1.0 + x);
295 output.access(6, 0) = -(1.0 + y);
296 output.access(6, 1) = -x;
297 output.access(6, 2) = 0.0;
299 output.access(7, 0) = 0.0;
300 output.access(7, 1) = y;
301 output.access(7, 2) = -(1.0 - x);
307 if constexpr (!serendipity) {
308 const auto x = input(0);
309 const auto y = input(1);
310 output.access(0, 0) = 0.0;
311 output.access(0, 1) =-0.5 + y;
312 output.access(0, 2) =-0.5 + x;
313 output.access(0, 3) = 0.0;
315 output.access(1, 0) = 0.0;
316 output.access(1, 1) =-0.5 + y;
317 output.access(1, 2) = 0.5 + x;
318 output.access(1, 3) = 0.0;
320 output.access(2, 0) = 0.0;
321 output.access(2, 1) = 0.5 + y;
322 output.access(2, 2) = 0.5 + x;
323 output.access(2, 3) = 0.0;
325 output.access(3, 0) = 0.0;
326 output.access(3, 1) = 0.5 + y;
327 output.access(3, 2) =-0.5 + x;
328 output.access(3, 3) = 0.0;
330 output.access(4, 0) = 0.0;
331 output.access(4, 1) = 1.0 - 2.0*y;
332 output.access(4, 2) =-2.0*x;
333 output.access(4, 3) = 0.0;
335 output.access(5, 0) = 0.0;
336 output.access(5, 1) =-2.0*y;
337 output.access(5, 2) =-1.0 - 2.0*x;
338 output.access(5, 3) = 0.0;
340 output.access(6, 0) = 0.0;
341 output.access(6, 1) =-1.0 - 2.0*y;
342 output.access(6, 2) =-2.0*x;
343 output.access(6, 3) = 0.0;
345 output.access(7, 0) = 0.0;
346 output.access(7, 1) =-2.0*y;
347 output.access(7, 2) = 1.0 - 2.0*x;
348 output.access(7, 3) = 0.0;
350 output.access(8, 0) = 0.0;
351 output.access(8, 1) = 4.0*y;
352 output.access(8, 2) = 4.0*x;
353 output.access(8, 3) = 0.0;
357 output.access(0, 0) = 0.0;
358 output.access(0, 1) =-0.5;
359 output.access(0, 2) =-0.5;
360 output.access(0, 3) = 0.0;
362 output.access(1, 0) = 0.0;
363 output.access(1, 1) =-0.5;
364 output.access(1, 2) = 0.5;
365 output.access(1, 3) = 0.0;
367 output.access(2, 0) = 0.0;
368 output.access(2, 1) = 0.5;
369 output.access(2, 2) = 0.5;
370 output.access(2, 3) = 0.0;
372 output.access(3, 0) = 0.0;
373 output.access(3, 1) = 0.5;
374 output.access(3, 2) =-0.5;
375 output.access(3, 3) = 0.0;
377 output.access(4, 0) = 0.0;
378 output.access(4, 1) = 1.0;
379 output.access(4, 2) = 0.0;
380 output.access(4, 3) = 0.0;
382 output.access(5, 0) = 0.0;
383 output.access(5, 1) = 0.0;
384 output.access(5, 2) =-1.0;
385 output.access(5, 3) = 0.0;
387 output.access(6, 0) = 0.0;
388 output.access(6, 1) =-1.0;
389 output.access(6, 2) = 0.0;
390 output.access(6, 3) = 0.0;
392 output.access(7, 0) = 0.0;
393 output.access(7, 1) = 0.0;
394 output.access(7, 2) = 1.0;
395 output.access(7, 3) = 0.0;
401 const ordinal_type jend = output.extent(1);
402 const ordinal_type iend = output.extent(0);
404 for (ordinal_type j=0;j<jend;++j)
405 for (ordinal_type i=0;i<iend;++i)
406 output.access(i, j) = 0.0;
408 if constexpr (!serendipity) {
409 output.access(0, 2) = 1.0;
410 output.access(1, 2) = 1.0;
411 output.access(2, 2) = 1.0;
412 output.access(3, 2) = 1.0;
414 output.access(4, 2) =-2.0;
415 output.access(5, 2) =-2.0;
416 output.access(6, 2) =-2.0;
417 output.access(7, 2) =-2.0;
419 output.access(8, 2) = 4.0;
423 case OPERATOR_MAX : {
424 const ordinal_type jend = output.extent(1);
425 const ordinal_type iend = output.extent(0);
427 for (ordinal_type j=0;j<jend;++j)
428 for (ordinal_type i=0;i<iend;++i)
429 output.access(i, j) = 0.0;
433 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
434 opType != OPERATOR_GRAD &&
435 opType != OPERATOR_CURL &&
436 opType != OPERATOR_D1 &&
437 opType != OPERATOR_D2 &&
438 opType != OPERATOR_D3 &&
439 opType != OPERATOR_D4 &&
440 opType != OPERATOR_MAX,
441 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_C2_FEM::Serial::getValues) operator is not supported");
447 template<
bool serendipity>
448 template<
typename DT,
449 typename outputValueValueType,
class ...outputValueProperties,
450 typename inputPointValueType,
class ...inputPointProperties>
452 Basis_HGRAD_QUAD_DEG2_FEM<serendipity>::
453 getValues(
const typename DT::execution_space& space,
454 Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
455 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
456 const EOperator operatorType ) {
457 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
458 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
459 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
462 const auto loopSize = inputPoints.extent(0);
463 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(space, 0, loopSize);
465 switch (operatorType) {
467 case OPERATOR_VALUE: {
468 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
469 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
474 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
475 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
478 case OPERATOR_CURL: {
479 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_CURL> FunctorType;
480 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
484 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
485 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): DIV is invalid operator for rank-0 (scalar) functions in 2D");
489 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D2> FunctorType;
490 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
495 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D3> FunctorType;
496 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
501 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D4> FunctorType;
502 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
511 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
512 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
516 INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
517 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): Invalid operator type");
526 template<
bool serendipity,
typename DT,
typename OT,
typename PT>
529 this->basisCardinality_ = serendipity ? 8 : 9;
530 this->basisDegree_ = 2;
531 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >() );
532 this->basisType_ = BASIS_FEM_DEFAULT;
533 this->basisCoordinates_ = COORDINATES_CARTESIAN;
534 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
538 const ordinal_type tagSize = 4;
539 const ordinal_type posScDim = 0;
540 const ordinal_type posScOrd = 1;
541 const ordinal_type posDfOrd = 2;
544 ordinal_type tags[36] = { 0, 0, 0, 1,
560 this->setOrdinalTagData(this->tagToOrdinal_,
563 this->basisCardinality_,
571 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
572 dofCoords(
"dofCoordsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
574 dofCoords(0,0) = -1.0; dofCoords(0,1) = -1.0;
575 dofCoords(1,0) = 1.0; dofCoords(1,1) = -1.0;
576 dofCoords(2,0) = 1.0; dofCoords(2,1) = 1.0;
577 dofCoords(3,0) = -1.0; dofCoords(3,1) = 1.0;
579 dofCoords(4,0) = 0.0; dofCoords(4,1) = -1.0;
580 dofCoords(5,0) = 1.0; dofCoords(5,1) = 0.0;
581 dofCoords(6,0) = 0.0; dofCoords(6,1) = 1.0;
582 dofCoords(7,0) = -1.0; dofCoords(7,1) = 0.0;
584 if constexpr (!serendipity) {
585 dofCoords(8,0) = 0.0; dofCoords(8,1) = 0.0;
588 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
589 Kokkos::deep_copy(this->dofCoords_, dofCoords);
Kokkos::View< ordinal_type *, typename ExecutionSpace::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Basis_HGRAD_QUAD_DEG2_FEM()
Constructor.