49 #ifndef __INTREPID2_HGRAD_QUAD_C2_FEM_DEF_HPP__
50 #define __INTREPID2_HGRAD_QUAD_C2_FEM_DEF_HPP__
58 template<EOperator opType>
59 template<
typename OutputViewType,
60 typename inputViewType>
61 KOKKOS_INLINE_FUNCTION
63 Basis_HGRAD_QUAD_C2_FEM::Serial<opType>::
64 getValues( OutputViewType output,
65 const inputViewType input ) {
67 case OPERATOR_VALUE : {
68 const auto x = input(0);
69 const auto y = input(1);
72 output.access(0) = x*(x - 1.0)*y*(y - 1.0)/4.0;
73 output.access(1) = x*(x + 1.0)*y*(y - 1.0)/4.0;
74 output.access(2) = x*(x + 1.0)*y*(y + 1.0)/4.0;
75 output.access(3) = x*(x - 1.0)*y*(y + 1.0)/4.0;
77 output.access(4) = (1.0 - x)*(1.0 + x)*y*(y - 1.0)/2.0;
78 output.access(5) = x*(x + 1.0)*(1.0 - y)*(1.0 + y)/2.0;
79 output.access(6) = (1.0 - x)*(1.0 + x)*y*(y + 1.0)/2.0;
80 output.access(7) = x*(x - 1.0)*(1.0 - y)*(1.0 + y)/2.0;
82 output.access(8) = (1.0 - x)*(1.0 + x)*(1.0 - y)*(1.0 + y);
86 case OPERATOR_GRAD : {
87 const auto x = input(0);
88 const auto y = input(1);
91 output.access(0, 0) = (-0.25 + 0.5*x)*(-1. + y)*y;
92 output.access(0, 1) = (-1.0 + x)*x*(-0.25 + 0.5*y);
94 output.access(1, 0) = (0.25 + 0.5*x)*(-1. + y)*y;
95 output.access(1, 1) = x*(1. + x)*(-0.25 + 0.5*y);
97 output.access(2, 0) = (0.25 + 0.5*x)*y*(1. + y);
98 output.access(2, 1) = x*(1. + x)*(0.25 + 0.5*y);
100 output.access(3, 0) = (-0.25 + 0.5*x)*y*(1. + y);
101 output.access(3, 1) = (-1. + x)*x*(0.25 + 0.5*y);
103 output.access(4, 0) = x*(1.0 - y)*y;
104 output.access(4, 1) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y);
106 output.access(5, 0) = 0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x);
107 output.access(5, 1) =-x*(1.0 + x)*y;
109 output.access(6, 0) =-y*(1.0 + y)*x;
110 output.access(6, 1) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y);
112 output.access(7, 0) = 0.5*(1.0 - y)*(1.0+ y)*(-1.0 + 2.0*x);
113 output.access(7, 1) = (1.0 - x)*x*y;
115 output.access(8, 0) =-2.0*(1.0 - y)*(1.0 + y)*x;
116 output.access(8, 1) =-2.0*(1.0 - x)*(1.0 + x)*y;
119 case OPERATOR_CURL : {
120 const auto x = input(0);
121 const auto y = input(1);
125 output.access(0, 1) =-(-0.25 + 0.5*x)*(-1. + y)*y;
126 output.access(0, 0) = (-1.0 + x)*x*(-0.25 + 0.5*y);
128 output.access(1, 1) =-(0.25 + 0.5*x)*(-1. + y)*y;
129 output.access(1, 0) = x*(1. + x)*(-0.25 + 0.5*y);
131 output.access(2, 1) =-(0.25 + 0.5*x)*y*(1. + y);
132 output.access(2, 0) = x*(1. + x)*(0.25 + 0.5*y);
134 output.access(3, 1) =-(-0.25 + 0.5*x)*y*(1. + y);
135 output.access(3, 0) = (-1. + x)*x*(0.25 + 0.5*y);
137 output.access(4, 1) =-x*(1.0 - y)*y;
138 output.access(4, 0) = 0.5*(1.0 - x)*(1.0 + x)*(-1.0 + 2.0*y);
140 output.access(5, 1) =-0.5*(1.0 - y)*(1.0 + y)*(1.0 + 2.0*x);
141 output.access(5, 0) =-x*(1.0 + x)*y;
143 output.access(6, 1) = y*(1.0 + y)*x;
144 output.access(6, 0) = 0.5*(1.0 - x)*(1.0 + x)*(1.0 + 2.0*y);
146 output.access(7, 1) =-0.5*(1.0 - y)*(1.0 + y)*(-1.0 + 2.0*x);
147 output.access(7, 0) = (1.0 - x)*x*y;
149 output.access(8, 1) = 2.0*(1.0 - y)*(1.0 + y)*x;
150 output.access(8, 0) =-2.0*(1.0 - x)*(1.0 + x)*y;
154 const auto x = input(0);
155 const auto y = input(1);
157 output.access(0, 0) = 0.5*(-1.0 + y)*y;
158 output.access(0, 1) = 0.25 - 0.5*y + x*(-0.5 + 1.*y);
159 output.access(0, 2) = 0.5*(-1.0 + x)*x;
161 output.access(1, 0) = 0.5*(-1.0 + y)*y;
162 output.access(1, 1) =-0.25 + 0.5*y + x*(-0.5 + 1.*y);
163 output.access(1, 2) = 0.5*x*(1.0 + x);
165 output.access(2, 0) = 0.5*y*(1.0 + y);
166 output.access(2, 1) = 0.25 + 0.5*y + x*(0.5 + 1.*y);
167 output.access(2, 2) = 0.5*x*(1.0 + x);
169 output.access(3, 0) = 0.5*y*(1.0 + y);
170 output.access(3, 1) =-0.25 - 0.5*y + x*(0.5 + 1.*y);
171 output.access(3, 2) = 0.5*(-1.0 + x)*x;
173 output.access(4, 0) = (1.0 - y)*y;
174 output.access(4, 1) = x*(1. - 2.*y);
175 output.access(4, 2) = (1.0 - x)*(1.0 + x);
177 output.access(5, 0) = (1.0 - y)*(1.0 + y);
178 output.access(5, 1) = x*(0. - 2.*y) - 1.*y;
179 output.access(5, 2) =-x*(1.0 + x);
181 output.access(6, 0) =-y*(1.0 + y);
182 output.access(6, 1) = x*(-1. - 2.*y);
183 output.access(6, 2) = (1.0 - x)*(1.0 + x);
185 output.access(7, 0) = (1.0 - y)*(1.0 + y);
186 output.access(7, 1) = x*(0. - 2.*y) + 1.*y;
187 output.access(7, 2) = (1.0 - x)*x;
189 output.access(8, 0) =-2.0 + 2.0*y*y;
190 output.access(8, 1) = 4*x*y;
191 output.access(8, 2) =-2.0 + 2.0*x*x;
195 const auto x = input(0);
196 const auto y = input(1);
197 output.access(0, 0) = 0.0;
198 output.access(0, 1) =-0.5 + y;
199 output.access(0, 2) =-0.5 + x;
200 output.access(0, 3) = 0.0;
202 output.access(1, 0) = 0.0;
203 output.access(1, 1) =-0.5 + y;
204 output.access(1, 2) = 0.5 + x;
205 output.access(1, 3) = 0.0;
207 output.access(2, 0) = 0.0;
208 output.access(2, 1) = 0.5 + y;
209 output.access(2, 2) = 0.5 + x;
210 output.access(2, 3) = 0.0;
212 output.access(3, 0) = 0.0;
213 output.access(3, 1) = 0.5 + y;
214 output.access(3, 2) =-0.5 + x;
215 output.access(3, 3) = 0.0;
217 output.access(4, 0) = 0.0;
218 output.access(4, 1) = 1.0 - 2.0*y;
219 output.access(4, 2) =-2.0*x;
220 output.access(4, 3) = 0.0;
222 output.access(5, 0) = 0.0;
223 output.access(5, 1) =-2.0*y;
224 output.access(5, 2) =-1.0 - 2.0*x;
225 output.access(5, 3) = 0.0;
227 output.access(6, 0) = 0.0;
228 output.access(6, 1) =-1.0 - 2.0*y;
229 output.access(6, 2) =-2.0*x;
230 output.access(6, 3) = 0.0;
232 output.access(7, 0) = 0.0;
233 output.access(7, 1) =-2.0*y;
234 output.access(7, 2) = 1.0 - 2.0*x;
235 output.access(7, 3) = 0.0;
237 output.access(8, 0) = 0.0;
238 output.access(8, 1) = 4.0*y;
239 output.access(8, 2) = 4.0*x;
240 output.access(8, 3) = 0.0;
244 output.access(0, 0) = 0.0;
245 output.access(0, 1) = 0.0;
246 output.access(0, 2) = 1.0;
247 output.access(0, 3) = 0.0;
248 output.access(0, 4) = 0.0;
250 output.access(1, 0) = 0.0;
251 output.access(1, 1) = 0.0;
252 output.access(1, 2) = 1.0;
253 output.access(1, 3) = 0.0;
254 output.access(1, 4) = 0.0;
256 output.access(2, 0) = 0.0;
257 output.access(2, 1) = 0.0;
258 output.access(2, 2) = 1.0;
259 output.access(2, 3) = 0.0;
260 output.access(2, 4) = 0.0;
262 output.access(3, 0) = 0.0;
263 output.access(3, 1) = 0.0;
264 output.access(3, 2) = 1.0;
265 output.access(3, 3) = 0.0;
266 output.access(3, 4) = 0.0;
268 output.access(4, 0) = 0.0;
269 output.access(4, 1) = 0.0;
270 output.access(4, 2) =-2.0;
271 output.access(4, 3) = 0.0;
272 output.access(4, 4) = 0.0;
274 output.access(5, 0) = 0.0;
275 output.access(5, 1) = 0.0;
276 output.access(5, 2) =-2.0;
277 output.access(5, 3) = 0.0;
278 output.access(5, 4) = 0.0;
280 output.access(6, 0) = 0.0;
281 output.access(6, 1) = 0.0;
282 output.access(6, 2) =-2.0;
283 output.access(6, 3) = 0.0;
284 output.access(6, 4) = 0.0;
286 output.access(7, 0) = 0.0;
287 output.access(7, 1) = 0.0;
288 output.access(7, 2) =-2.0;
289 output.access(7, 3) = 0.0;
290 output.access(7, 4) = 0.0;
292 output.access(8, 0) = 0.0;
293 output.access(8, 1) = 0.0;
294 output.access(8, 2) = 4.0;
295 output.access(8, 3) = 0.0;
296 output.access(8, 4) = 0.0;
299 case OPERATOR_MAX : {
300 const ordinal_type jend = output.extent(1);
301 const ordinal_type iend = output.extent(0);
303 for (ordinal_type j=0;j<jend;++j)
304 for (ordinal_type i=0;i<iend;++i)
305 output.access(i, j) = 0.0;
309 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
310 opType != OPERATOR_GRAD &&
311 opType != OPERATOR_CURL &&
312 opType != OPERATOR_D1 &&
313 opType != OPERATOR_D2 &&
314 opType != OPERATOR_D3 &&
315 opType != OPERATOR_D4 &&
316 opType != OPERATOR_MAX,
317 ">>> ERROR: (Intrepid2::Basis_HGRAD_QUAD_C2_FEM::Serial::getValues) operator is not supported");
323 template<
typename SpT,
324 typename outputValueValueType,
class ...outputValueProperties,
325 typename inputPointValueType,
class ...inputPointProperties>
327 Basis_HGRAD_QUAD_C2_FEM::
328 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
329 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
330 const EOperator operatorType ) {
331 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
332 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
333 typedef typename ExecSpace<typename inputPointViewType::execution_space,SpT>::ExecSpaceType ExecSpaceType;
336 const auto loopSize = inputPoints.extent(0);
337 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
339 switch (operatorType) {
341 case OPERATOR_VALUE: {
342 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
343 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
348 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
349 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
352 case OPERATOR_CURL: {
353 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_CURL> FunctorType;
354 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
358 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
359 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): DIV is invalid operator for rank-0 (scalar) functions in 2D");
363 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D2> FunctorType;
364 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
369 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D3> FunctorType;
370 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
375 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D4> FunctorType;
376 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
385 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_MAX> FunctorType;
386 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
390 INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
391 ">>> ERROR (Basis_HGRAD_QUAD_C2_FEM): Invalid operator type");
403 template<
typename SpT,
typename OT,
typename PT>
406 this->basisCardinality_ = 9;
407 this->basisDegree_ = 2;
408 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >() );
409 this->basisType_ = BASIS_FEM_DEFAULT;
410 this->basisCoordinates_ = COORDINATES_CARTESIAN;
411 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
415 const ordinal_type tagSize = 4;
416 const ordinal_type posScDim = 0;
417 const ordinal_type posScOrd = 1;
418 const ordinal_type posDfOrd = 2;
421 ordinal_type tags[36] = { 0, 0, 0, 1,
437 this->setOrdinalTagData(this->tagToOrdinal_,
440 this->basisCardinality_,
448 Kokkos::DynRankView<typename ScalarViewType::value_type,typename SpT::array_layout,Kokkos::HostSpace>
449 dofCoords(
"dofCoordsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
451 dofCoords(0,0) = -1.0; dofCoords(0,1) = -1.0;
452 dofCoords(1,0) = 1.0; dofCoords(1,1) = -1.0;
453 dofCoords(2,0) = 1.0; dofCoords(2,1) = 1.0;
454 dofCoords(3,0) = -1.0; dofCoords(3,1) = 1.0;
456 dofCoords(4,0) = 0.0; dofCoords(4,1) = -1.0;
457 dofCoords(5,0) = 1.0; dofCoords(5,1) = 0.0;
458 dofCoords(6,0) = 0.0; dofCoords(6,1) = 1.0;
459 dofCoords(7,0) = -1.0; dofCoords(7,1) = 0.0;
461 dofCoords(8,0) = 0.0; dofCoords(8,1) = 0.0;
463 this->dofCoords_ = Kokkos::create_mirror_view(
typename SpT::memory_space(), dofCoords);
464 Kokkos::deep_copy(this->dofCoords_, dofCoords);
Kokkos::View< ordinal_type *, typename ExecSpaceType::array_layout, Kokkos::HostSpace > OrdinalTypeArray1DHost
View type for 1d host array.
Basis_HGRAD_QUAD_C2_FEM()
Constructor.