Intrepid2
Intrepid2_HDIV_QUAD_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_HDIV_QUAD_I1_FEM_DEF_HPP__
50#define __INTREPID2_HDIV_QUAD_I1_FEM_DEF_HPP__
51
52
53namespace Intrepid2 {
54
55 // -------------------------------------------------------------------------------------
56 namespace Impl {
57
58 template<EOperator opType>
59 template<typename OutputViewType,
60 typename inputViewType>
61 KOKKOS_INLINE_FUNCTION
62 void
63 Basis_HDIV_QUAD_I1_FEM::Serial<opType>::
64 getValues( OutputViewType output,
65 const inputViewType input ) {
66 switch (opType) {
67 case OPERATOR_VALUE : { // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
68 const auto x = input(0);
69 const auto y = input(1);
70
71 output.access(0, 0) = 0.0;
72 output.access(0, 1) = 0.5*(y - 1.0);
73
74 output.access(1, 0) = 0.5*(1.0 + x);
75 output.access(1, 1) = 0.0;
76
77 output.access(2, 0) = 0.0;
78 output.access(2, 1) = 0.5*(1.0 + y);
79
80 output.access(3, 0) = 0.5*(x - 1.0);
81 output.access(3, 1) = 0.0;
82 break;
83 }
84 case OPERATOR_DIV: {
85 output.access(0) = 0.5;
86 output.access(1) = 0.5;
87 output.access(2) = 0.5;
88 output.access(3) = 0.5;
89 break;
90 }
91 default: {
92 INTREPID2_TEST_FOR_ABORT( opType != OPERATOR_VALUE &&
93 opType != OPERATOR_DIV,
94 ">>> ERROR: (Intrepid2::Basis_HDIV_QUAD_C1_FEM::Serial::getValues) operator is not supported");
95
96 }
97 }
98 }
99
100 template<typename DT,
101 typename outputValueValueType, class ...outputValueProperties,
102 typename inputPointValueType, class ...inputPointProperties>
103 void
104 Basis_HDIV_QUAD_I1_FEM::
105 getValues( Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValues,
106 const Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPoints,
107 const EOperator operatorType ) {
108 typedef Kokkos::DynRankView<outputValueValueType,outputValueProperties...> outputValueViewType;
109 typedef Kokkos::DynRankView<inputPointValueType, inputPointProperties...> inputPointViewType;
110 typedef typename ExecSpace<typename inputPointViewType::execution_space,typename DT::execution_space>::ExecSpaceType ExecSpaceType;
111
112
113 // Number of evaluation points = dim 0 of inputPoints
114 const auto loopSize = inputPoints.extent(0);
115 Kokkos::RangePolicy<ExecSpaceType,Kokkos::Schedule<Kokkos::Static> > policy(0, loopSize);
116
117 switch (operatorType) {
118 case OPERATOR_VALUE: {
119 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_VALUE> FunctorType;
120 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
121 break;
122 }
123 case OPERATOR_DIV: {
124 typedef Functor<outputValueViewType,inputPointViewType,OPERATOR_DIV> FunctorType;
125 Kokkos::parallel_for( policy, FunctorType(outputValues, inputPoints) );
126 break;
127 }
128 case OPERATOR_CURL: {
129 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument,
130 ">>> ERROR (Basis_HDIV_QUAD_I1_FEM): CURL is invalid operator for HDIV Basis Functions");
131 break;
132 }
133 case OPERATOR_GRAD: {
134 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_GRAD), std::invalid_argument,
135 ">>> ERROR (Basis_HDIV_QUAD_I1_FEM): GRAD is invalid operator for HDIV Basis Functions");
136 break;
137 }
138 case OPERATOR_D1:
139 case OPERATOR_D2:
140 case OPERATOR_D3:
141 case OPERATOR_D4:
142 case OPERATOR_D5:
143 case OPERATOR_D6:
144 case OPERATOR_D7:
145 case OPERATOR_D8:
146 case OPERATOR_D9:
147 case OPERATOR_D10: {
148 INTREPID2_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_D1) ||
149 (operatorType == OPERATOR_D2) ||
150 (operatorType == OPERATOR_D3) ||
151 (operatorType == OPERATOR_D4) ||
152 (operatorType == OPERATOR_D5) ||
153 (operatorType == OPERATOR_D6) ||
154 (operatorType == OPERATOR_D7) ||
155 (operatorType == OPERATOR_D8) ||
156 (operatorType == OPERATOR_D9) ||
157 (operatorType == OPERATOR_D10),
158 std::invalid_argument,
159 ">>> ERROR (Basis_HDIV_QUAD_I1_FEM): Invalid operator type");
160 break;
161 }
162 default: {
163 INTREPID2_TEST_FOR_EXCEPTION( (operatorType != OPERATOR_VALUE) &&
164 (operatorType != OPERATOR_GRAD) &&
165 (operatorType != OPERATOR_CURL) &&
166 (operatorType != OPERATOR_DIV) &&
167 (operatorType != OPERATOR_D1) &&
168 (operatorType != OPERATOR_D2) &&
169 (operatorType != OPERATOR_D3) &&
170 (operatorType != OPERATOR_D4) &&
171 (operatorType != OPERATOR_D5) &&
172 (operatorType != OPERATOR_D6) &&
173 (operatorType != OPERATOR_D7) &&
174 (operatorType != OPERATOR_D8) &&
175 (operatorType != OPERATOR_D9) &&
176 (operatorType != OPERATOR_D10),
177 std::invalid_argument,
178 ">>> ERROR (Basis_HDIV_QUAD_I1_FEM): Invalid operator type");
179 }
180 }
181 }
182
183
184 }
185
186 template<typename DT, typename OT, typename PT>
189 this->basisCardinality_ = 4;
190 this->basisDegree_ = 1;
191 this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Quadrilateral<4> >() );
192 this->basisType_ = BASIS_FEM_DEFAULT;
193 this->basisCoordinates_ = COORDINATES_CARTESIAN;
194 this->functionSpace_ = FUNCTION_SPACE_HDIV;
195
196 // initialize tags
197 {
198 // Basis-dependent intializations
199 const ordinal_type tagSize = 4; // size of DoF tag
200 const ordinal_type posScDim = 0; // position in the tag, counting from 0, of the subcell dim
201 const ordinal_type posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
202 const ordinal_type posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
203
204 // An array with local DoF tags assigned to basis functions, in the order of their local enumeration
205 ordinal_type tags[16] = { 1, 0, 0, 1,
206 1, 1, 0, 1,
207 1, 2, 0, 1,
208 1, 3, 0, 1 };
209
210
211 // when exec space is device, this wrapping relies on uvm.
212 OrdinalTypeArray1DHost tagView(&tags[0], 16);
213
214 // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
215 this->setOrdinalTagData(this->tagToOrdinal_,
216 this->ordinalToTag_,
217 tagView,
218 this->basisCardinality_,
219 tagSize,
220 posScDim,
221 posScOrd,
222 posDfOrd);
223 }
224 // dofCoords on host and create its mirror view to device
225 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
226 dofCoords("dofCoordsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
227
228 dofCoords(0,0) = 0.0; dofCoords(0,1) = -1.0;
229 dofCoords(1,0) = 1.0; dofCoords(1,1) = 0.0;
230 dofCoords(2,0) = 0.0; dofCoords(2,1) = 1.0;
231 dofCoords(3,0) = -1.0; dofCoords(3,1) = 0.0;
232
233 this->dofCoords_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoords);
234 Kokkos::deep_copy(this->dofCoords_, dofCoords);
235
236 // dofCoeffs on host and create its mirror view to device
237 Kokkos::DynRankView<typename ScalarViewType::value_type,typename DT::execution_space::array_layout,Kokkos::HostSpace>
238 dofCoeffs("dofCoeffsHost", this->basisCardinality_,this->basisCellTopology_.getDimension());
239
240 // for HDIV_QUAD_I1 dofCoeffs are the normals on the quadrilateral edges (with normals magnitude equal to edges' lengths)
241 dofCoeffs(0,0) = 0.0; dofCoeffs(0,1) = -1.0;
242 dofCoeffs(1,0) = 1.0; dofCoeffs(1,1) = 0.0;
243 dofCoeffs(2,0) = 0.0; dofCoeffs(2,1) = 1.0;
244 dofCoeffs(3,0) = -1.0; dofCoeffs(3,1) = 0.0;
245
246 this->dofCoeffs_ = Kokkos::create_mirror_view(typename DT::memory_space(), dofCoeffs);
247 Kokkos::deep_copy(this->dofCoeffs_, dofCoeffs);
248
249 }
250
251
252}// namespace Intrepid2
253
254#endif