Intrepid2
Intrepid2_HCURL_TET_I1_FEMDef.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Intrepid2 Package
5// Copyright (2007) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Kyungjoo Kim (kyukim@sandia.gov), or
38// Mauro Perego (mperego@sandia.gov)
39//
40// ************************************************************************
41// @HEADER
42
49#ifndef __INTREPID2_HCURL_TET_I1_FEM_DEF_HPP__
50#define __INTREPID2_HCURL_TET_I1_FEM_DEF_HPP__
51
52namespace Intrepid2 {
53
54 // -------------------------------------------------------------------------------------
55 namespace Impl {
56
57 template<EOperator opType>
58 template<typename OutputViewType,
59 typename inputViewType>
60 KOKKOS_INLINE_FUNCTION
61 void
62 Basis_HCURL_TET_I1_FEM::Serial<opType>::
63 getValues( OutputViewType output,
64 const inputViewType input ) {
65 switch (opType) {
66 case OPERATOR_VALUE: {
67 const auto x = input(0);
68 const auto y = input(1);
69 const auto z = input(2);
70
71 // output is subview of a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim), dim0 is iteration from range
72 output.access(0, 0) = 2.0*(1.0 - y - z);
73 output.access(0, 1) = 2.0*x;
74 output.access(0, 2) = 2.0*x;
75
76 output.access(1, 0) =-2.0*y;
77 output.access(1, 1) = 2.0*x;
78 output.access(1, 2) = 0.0;
79
80 output.access(2, 0) = -2.0*y;
81 output.access(2, 1) = 2.0*(-1.0 + x + z);
82 output.access(2, 2) = -2.0*y;
83
84 output.access(3, 0) = 2.0*z;
85 output.access(3, 1) = 2.0*z;
86 output.access(3, 2) = 2.0*(1.0 - x - y);
87
88 output.access(4, 0) =-2.0*z;
89 output.access(4, 1) = 0.0;
90 output.access(4, 2) = 2.0*x;
91
92 output.access(5, 0) = 0.0;
93 output.access(5, 1) =-2.0*z;
94 output.access(5, 2) = 2.0*y;
95 break;
96 }
97 case OPERATOR_CURL: {
98 // output is subview of a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim), dim0 is iteration from range
99 output.access(0, 0) = 0.0;
100 output.access(0, 1) =-4.0;
101 output.access(0, 2) = 4.0;
102
103 output.access(1, 0) = 0.0;
104 output.access(1, 1) = 0.0;
105 output.access(1, 2) = 4.0;
106
107 output.access(2, 0) =-4.0;
108 output.access(2, 1) = 0.0;
109 output.access(2, 2) = 4.0;
110
111 output.access(3, 0) =-4.0;
112 output.access(3, 1) = 4.0;
113 output.access(3, 2) = 0.0;
114
115 output.access(4, 0) = 0.0;
116 output.access(4, 1) =-4.0;
117 output.access(4, 2) = 0.0;
118
119 output.access(5, 0) = 4.0;
120 output.access(5, 1) = 0.0;
121 output.access(5, 2) = 0.0;
122 break;
123 }
124 default: {
125 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
126 opType != OPERATOR_CURL,
127 ">>> ERROR: (Intrepid2::Basis_HCURL_TET_I1_FEM::Serial::getValues) operator is not supported");
128 }
129 }
130 }
131
132 template<typename DT,
133 typename outputValueValueType, class ...outputValueProperties,
134 typename inputPointValueType, class ...inputPointProperties>
135 void
136 Basis_HCURL_TET_I1_FEM::
137 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
138 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
139 const EOperator operatorType ) {
140 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
141 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
142 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
143
144 // Number of evaluation points = dim 0 of inputPoints
145 const auto loopSize = inputPoints.extent(0);
146 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
147
148 switch (operatorType) {
149
150 case OPERATOR_VALUE: {
151 typedef Functor<outputValueViewType, inputPointViewType, OPERATOR_VALUE> FunctorType;
152 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
153 break;
154 }
155 case OPERATOR_CURL: {
156 typedef Functor<outputValueViewType, inputPointViewType, OPERATOR_CURL> FunctorType;
157 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
158 break;
159 }
160 case OPERATOR_DIV: {
161 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
162 ">>> ERROR (Basis_HCURL_TET_I1_FEM): DIV is invalid operator for HCURL Basis Functions");
163 break;
164 }
165 case OPERATOR_GRAD: {
166 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_GRAD), std::invalid_argument,
167 ">>> ERROR (Basis_HCURL_TET_I1_FEM): GRAD is invalid operator for HCURL Basis Functions");
168 break;
169 }
170 case OPERATOR_D1:
171 case OPERATOR_D2:
172 case OPERATOR_D3:
173 case OPERATOR_D4:
174 case OPERATOR_D5:
175 case OPERATOR_D6:
176 case OPERATOR_D7:
177 case OPERATOR_D8:
178 case OPERATOR_D9:
179 case OPERATOR_D10: {
180 INTREPID2_TEST_FOR_EXCEPTION( ( (operatorType == OPERATOR_D1) ||
181 (operatorType == OPERATOR_D2) ||
182 (operatorType == OPERATOR_D3) ||
183 (operatorType == OPERATOR_D4) ||
184 (operatorType == OPERATOR_D5) ||
185 (operatorType == OPERATOR_D6) ||
186 (operatorType == OPERATOR_D7) ||
187 (operatorType == OPERATOR_D8) ||
188 (operatorType == OPERATOR_D9) ||
189 (operatorType == OPERATOR_D10) ),
190 std::invalid_argument,
191 ">>> ERROR (Basis_HCURL_TET_I1_FEM): Invalid operator type");
192 break;
193 }
194 default: {
195 INTREPID2_TEST_FOR_EXCEPTION( ( (operatorType != OPERATOR_VALUE) &&
196 (operatorType != OPERATOR_GRAD) &&
197 (operatorType != OPERATOR_CURL) &&
198 (operatorType != OPERATOR_DIV) &&
199 (operatorType != OPERATOR_D1) &&
200 (operatorType != OPERATOR_D2) &&
201 (operatorType != OPERATOR_D3) &&
202 (operatorType != OPERATOR_D4) &&
203 (operatorType != OPERATOR_D5) &&
204 (operatorType != OPERATOR_D6) &&
205 (operatorType != OPERATOR_D7) &&
206 (operatorType != OPERATOR_D8) &&
207 (operatorType != OPERATOR_D9) &&
208 (operatorType != OPERATOR_D10) ),
209 std::invalid_argument,
210 ">>> ERROR (Basis_HCURL_TET_I1_FEM): Invalid operator type");
211 }
212 }
213 }
214 }
215
216
217 // -------------------------------------------------------------------------------------
218
219 template< typename DT, typename OT, typename PT >
222 this->basisCardinality_ = 6;
223 this->basisDegree_ = 1;
224 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<4> >() );
225 this->basisType_ = BASIS_FEM_DEFAULT;
226 this->basisCoordinates_ = COORDINATES_CARTESIAN;
227 this->functionSpace_ = FUNCTION_SPACE_HCURL;
228
229 // initialize tags
230 {
231 // Basis-dependent intializations
232 const ordinal_type tagSize = 4; // size of DoF tag
233 const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
234 const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
235 const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
236
237 // An array with local DoF tags assigned to basis functions, in the order of their local enumeration
238 ordinal_type tags[24] = {
239 1, 0, 0, 1,
240 1, 1, 0, 1,
241 1, 2, 0, 1,
242 1, 3, 0, 1,
243 1, 4, 0, 1,
244 1, 5, 0, 1 };
245
246 //host tags
247 OrdinalTypeArray1DHost tagView(&tags[0], 24);
248
249 // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
250 this->setOrdinalTagData(this->tagToOrdinal_,
251 this->ordinalToTag_,
252 tagView,
253 this->basisCardinality_,
254 tagSize,
255 posScDim,
256 posScOrd,
257 posDfOrd);
258 }
259 // dofCoords on host and create its mirror view to device
260 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
261 dofCoords("dofCoordsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
262
263 dofCoords(0,0) = 0.5; dofCoords(0,1) = 0.0; dofCoords(0,2) = 0.0;
264 dofCoords(1,0) = 0.5; dofCoords(1,1) = 0.5; dofCoords(1,2) = 0.0;
265 dofCoords(2,0) = 0.0; dofCoords(2,1) = 0.5; dofCoords(2,2) = 0.0;
266 dofCoords(3,0) = 0.0; dofCoords(3,1) = 0.0; dofCoords(3,2) = 0.5;
267 dofCoords(4,0) = 0.5; dofCoords(4,1) = 0.0; dofCoords(4,2) = 0.5;
268 dofCoords(5,0) = 0.0; dofCoords(5,1) = 0.5; dofCoords(5,2) = 0.5;
269
270 this->dofCoords_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoords);
271 Kokkos::deep_copy(this->dofCoords_, dofCoords);
272
273 // dofCoeffs on host and create its mirror view to device
274 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
275 dofCoeffs("dofCoeffsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
276
277 dofCoeffs(0,0) = 0.5; dofCoeffs(0,1) = 0.0; dofCoeffs(0,2) = 0.0;
278 dofCoeffs(1,0) = -0.5; dofCoeffs(1,1) = 0.5; dofCoeffs(1,2) = 0.0;
279 dofCoeffs(2,0) = 0.0; dofCoeffs(2,1) = -0.5; dofCoeffs(2,2) = 0.0;
280 dofCoeffs(3,0) = 0.0; dofCoeffs(3,1) = 0.0; dofCoeffs(3,2) = 0.5;
281 dofCoeffs(4,0) = -0.5; dofCoeffs(4,1) = 0.0; dofCoeffs(4,2) = 0.5;
282 dofCoeffs(5,0) = 0.0; dofCoeffs(5,1) = -0.5; dofCoeffs(5,2) = 0.5;
283
284 this->dofCoeffs_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoeffs);
285 Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
286
287 }
288
289
290}// namespace Intrepid2
291#endif