16 #ifndef __INTREPID2_HGRAD_PYR_C1_FEM_DEF_HPP__
17 #define __INTREPID2_HGRAD_PYR_C1_FEM_DEF_HPP__
25 template<EOperator opType>
26 template<
typename OutputViewType,
27 typename inputViewType>
28 KOKKOS_INLINE_FUNCTION
30 Basis_HGRAD_PYR_C1_FEM::Serial<opType>::
31 getValues( OutputViewType output,
32 const inputViewType input ) {
33 const auto eps = epsilon();
35 static_assert(std::is_same<
36 typename OutputViewType::value_type,
37 typename inputViewType::value_type>::value,
"Input/output view has different value types");
39 typedef typename OutputViewType::value_type value_type;
41 const value_type x = input(0);
42 const value_type y = input(1);
43 const value_type ztmp = input(2);
46 const value_type z = ( (value_type(1.0) - ztmp) < value_type(eps) ? value_type(1.0 - eps) : ztmp );
50 case OPERATOR_VALUE: {
51 const value_type factor = 0.25/(1.0 - z);
54 output.access(0) = (1.0 - x - z) * (1.0 - y - z) * factor;
55 output.access(1) = (1.0 + x - z) * (1.0 - y - z) * factor;
56 output.access(2) = (1.0 + x - z) * (1.0 + y - z) * factor;
57 output.access(3) = (1.0 - x - z) * (1.0 + y - z) * factor;
62 const value_type factor = 0.25/(1.0 - z);
63 const value_type factor2 = 4.0 * factor * factor;
66 output.access(0, 0) = (y + z - 1.0) * factor;
67 output.access(0, 1) = (x + z - 1.0) * factor;
68 output.access(0, 2) = x * y * factor2 - 0.25;
70 output.access(1, 0) = (1.0 - y - z) * factor;
71 output.access(1, 1) = (z - x - 1.0) * factor;
72 output.access(1, 2) = - x*y * factor2 - 0.25;
74 output.access(2, 0) = (1.0 + y - z) * factor;
75 output.access(2, 1) = (1.0 + x - z) * factor;
76 output.access(2, 2) = x * y * factor2 - 0.25;
78 output.access(3, 0) = (z - y - 1.0) * factor;
79 output.access(3, 1) = (1.0 - x - z) * factor;
80 output.access(3, 2) = - x*y * factor2 - 0.25;
82 output.access(4, 0) = 0.0;
83 output.access(4, 1) = 0.0;
84 output.access(4, 2) = 1;
88 const value_type factor = 0.25/(1.0 - z);
89 const value_type factor2 = 4.0 * factor * factor;
90 const value_type factor3 = 8.0 * factor * factor2;
93 output.access(0, 0) = 0.0;
94 output.access(0, 1) = factor;
95 output.access(0, 2) = y*factor2;
96 output.access(0, 3) = 0.0;
97 output.access(0, 4) = x*factor2;
98 output.access(0, 5) = x*y*factor3;
100 output.access(1, 0) = 0.0;
101 output.access(1, 1) = -factor;
102 output.access(1, 2) = -y*factor2;
103 output.access(1, 3) = 0.0;
104 output.access(1, 4) = -x*factor2;
105 output.access(1, 5) = -x*y*factor3;
107 output.access(2, 0) = 0.0;
108 output.access(2, 1) = factor;
109 output.access(2, 2) = y*factor2;
110 output.access(2, 3) = 0.0;
111 output.access(2, 4) = x*factor2;
112 output.access(2, 5) = x*y*factor3;
114 output.access(3, 0) = 0.0;
115 output.access(3, 1) = -factor;
116 output.access(3, 2) = -y*factor2;
117 output.access(3, 3) = 0.0;
118 output.access(3, 4) = -x*factor2;
119 output.access(3, 5) = -x*y*factor3;
121 output.access(4, 0) = 0.0;
122 output.access(4, 1) = 0.0;
123 output.access(4, 2) = 0.0;
124 output.access(4, 3) = 0.0;
125 output.access(4, 4) = 0.0;
126 output.access(4, 5) = 0.0;
130 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
131 opType != OPERATOR_GRAD &&
132 opType != OPERATOR_D2,
133 ">>> ERROR: (Intrepid2::Basis_HGRAD_PYR_C1_FEM::Serial::getValues) operator is not supported");
138 template<
typename DT,
139 typename outputValueValueType,
class ...outputValueProperties,
140 typename inputPointValueType,
class ...inputPointProperties>
142 Basis_HGRAD_PYR_C1_FEM::
143 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
144 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
145 const EOperator operatorType ) {
146 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
147 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
148 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
151 const auto loopSize = inputPoints.extent(0);
152 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
154 switch (operatorType) {
156 case OPERATOR_VALUE: {
157 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
158 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
163 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_GRAD> FunctorType;
164 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
167 case OPERATOR_CURL: {
168 INTREPID2_TEST_FOR_EXCEPTION( operatorType == OPERATOR_CURL, std::invalid_argument,
169 ">>> ERROR (Basis_HGRAD_PYR_C1_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D");
173 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
174 ">>> ERROR (Basis_HGRAD_PYR_C1_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D");
178 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_D2> FunctorType;
179 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
190 INTREPID2_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
191 ">>> ERROR (Basis_HGRAD_PYR_C1_FEM): Operator not implemented yet");
195 INTREPID2_TEST_FOR_EXCEPTION( !( Intrepid2::isValidOperator(operatorType) ), std::invalid_argument,
196 ">>> ERROR (Basis_HGRAD_PYR_C1_FEM): Invalid operator type");
204 template<
typename DT,
typename OT,
typename PT>
207 const ordinal_type spaceDim = 3;
208 this->basisCardinality_ = 5;
209 this->basisDegree_ = 1;
210 this->basisCellTopologyKey_ = shards::Pyramid<5>::key;
211 this->basisType_ = BASIS_FEM_DEFAULT;
212 this->basisCoordinates_ = COORDINATES_CARTESIAN;
213 this->functionSpace_ = FUNCTION_SPACE_HGRAD;
218 const ordinal_type tagSize = 4;
219 const ordinal_type posScDim = 0;
220 const ordinal_type posScOrd = 1;
221 const ordinal_type posDfOrd = 2;
224 ordinal_type tags[20] = { 0, 0, 0, 1,
232 OrdinalTypeArray1DHost tagView(&tags[0], 20);
235 this->setOrdinalTagData(this->tagToOrdinal_,
238 this->basisCardinality_,
246 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
247 dofCoords(
"dofCoordsHost", this->basisCardinality_,spaceDim);
249 dofCoords(0,0) = -1.0; dofCoords(0,1) = -1.0; dofCoords(0,2) = 0.0;
250 dofCoords(1,0) = 1.0; dofCoords(1,1) = -1.0; dofCoords(1,2) = 0.0;
251 dofCoords(2,0) = 1.0; dofCoords(2,1) = 1.0; dofCoords(2,2) = 0.0;
252 dofCoords(3,0) = -1.0; dofCoords(3,1) = 1.0; dofCoords(3,2) = 0.0;
253 dofCoords(4,0) = 0.0; dofCoords(4,1) = 0.0; dofCoords(4,2) = 1.0;
255 this->dofCoords_ = Kokkos::create_mirror_view(
typename DT::memory_space(), dofCoords);
256 Kokkos::deep_copy(this->dofCoords_, dofCoords);
259 template<
typename DT,
typename OT,
typename PT>
262 ordinal_type& perTeamSpaceSize,
263 ordinal_type& perThreadSpaceSize,
264 const PointViewType inputPoints,
265 const EOperator operatorType)
const {
266 perTeamSpaceSize = 0;
267 perThreadSpaceSize = 0;
270 template<
typename DT,
typename OT,
typename PT>
271 KOKKOS_INLINE_FUNCTION
273 Basis_HGRAD_PYR_C1_FEM<DT,OT,PT>::getValues(
274 OutputViewType outputValues,
275 const PointViewType inputPoints,
276 const EOperator operatorType,
277 const typename Kokkos::TeamPolicy<typename DT::execution_space>::member_type& team_member,
278 const typename DT::execution_space::scratch_memory_space & scratchStorage,
279 const ordinal_type subcellDim,
280 const ordinal_type subcellOrdinal)
const {
282 INTREPID2_TEST_FOR_ABORT( !((subcellDim <= 0) && (subcellOrdinal == -1)),
283 ">>> ERROR: (Intrepid2::Basis_HGRAD_PYR_C1_FEM::getValues), The capability of selecting subsets of basis functions has not been implemented yet.");
285 (void) scratchStorage;
287 const int numPoints = inputPoints.extent(0);
289 switch(operatorType) {
291 Kokkos::parallel_for (Kokkos::TeamThreadRange (team_member, numPoints), [=] (ordinal_type& pt) {
292 auto output = Kokkos::subview( outputValues, Kokkos::ALL(), pt, Kokkos::ALL() );
293 const auto input = Kokkos::subview( inputPoints, pt, Kokkos::ALL() );
294 Impl::Basis_HGRAD_PYR_C1_FEM::Serial<OPERATOR_VALUE>::getValues( output, input);
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() );
301 Impl::Basis_HGRAD_PYR_C1_FEM::Serial<OPERATOR_GRAD>::getValues( output, input);
Implementation of the default H(grad)-compatible FEM basis of degree 1 on Pyramid cell...
Basis_HGRAD_PYR_C1_FEM()
Constructor.