Intrepid
Intrepid_HDIV_HEX_I1_FEMDef.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Intrepid 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 Pavel Bochev (pbboche@sandia.gov)
38 // Denis Ridzal (dridzal@sandia.gov), or
39 // Kara Peterson (kjpeter@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
49 namespace Intrepid {
50 
51 template<class Scalar, class ArrayScalar>
53  {
54  this -> basisCardinality_ = 6;
55  this -> basisDegree_ = 1;
56  this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Hexahedron<8> >() );
57  this -> basisType_ = BASIS_FEM_DEFAULT;
58  this -> basisCoordinates_ = COORDINATES_CARTESIAN;
59  this -> basisTagsAreSet_ = false;
60  }
61 
62 template<class Scalar, class ArrayScalar>
64 
65  // Basis-dependent intializations
66  int tagSize = 4; // size of DoF tag
67  int posScDim = 0; // position in the tag, counting from 0, of the subcell dim
68  int posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
69  int posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
70 
71  // An array with local DoF tags assigned to basis functions, in the order of their local enumeration
72  int tags[] = {
73  2, 0, 0, 1,
74  2, 1, 0, 1,
75  2, 2, 0, 1,
76  2, 3, 0, 1,
77  2, 4, 0, 1,
78  2, 5, 0, 1,
79  };
80 
81  // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
82  Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
83  this -> ordinalToTag_,
84  tags,
85  this -> basisCardinality_,
86  tagSize,
87  posScDim,
88  posScOrd,
89  posDfOrd);
90 }
91 
92 
93 
94 template<class Scalar, class ArrayScalar>
96  const ArrayScalar & inputPoints,
97  const EOperator operatorType) const {
98 
99 // Verify arguments
100 #ifdef HAVE_INTREPID_DEBUG
101  Intrepid::getValues_HDIV_Args<Scalar, ArrayScalar>(outputValues,
102  inputPoints,
103  operatorType,
104  this -> getBaseCellTopology(),
105  this -> getCardinality() );
106 #endif
107 
108  // Number of evaluation points = dim 0 of inputPoints
109  int dim0 = inputPoints.dimension(0);
110 
111  // Temporaries: (x,y,z) coordinates of the evaluation point
112  Scalar x = 0.0;
113  Scalar y = 0.0;
114  Scalar z = 0.0;
115 
116  switch (operatorType) {
117  case OPERATOR_VALUE:
118  for (int i0 = 0; i0 < dim0; i0++) {
119  x = inputPoints(i0, 0);
120  y = inputPoints(i0, 1);
121  z = inputPoints(i0, 2);
122 
123  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, spaceDim)
124  outputValues(0, i0, 0) = 0.0;
125  outputValues(0, i0, 1) = (y - 1.0)/8.0;
126  outputValues(0, i0, 2) = 0.0;
127 
128  outputValues(1, i0, 0) = (1.0 + x)/8.0;
129  outputValues(1, i0, 1) = 0.0;
130  outputValues(1, i0, 2) = 0.0;
131 
132  outputValues(2, i0, 0) = 0.0;
133  outputValues(2, i0, 1) = (1.0 + y)/8.0;
134  outputValues(2, i0, 2) = 0.0;
135 
136  outputValues(3, i0, 0) = (x - 1.0)/8.0;
137  outputValues(3, i0, 1) = 0.0;
138  outputValues(3, i0, 2) = 0.0;
139 
140  outputValues(4, i0, 0) = 0.0;
141  outputValues(4, i0, 1) = 0.0;
142  outputValues(4, i0, 2) = (z - 1.0)/8.0;
143 
144  outputValues(5, i0, 0) = 0.0;
145  outputValues(5, i0, 1) = 0.0;
146  outputValues(5, i0, 2) = (1.0 + z)/8.0;
147  }
148  break;
149 
150  case OPERATOR_DIV:
151  // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
152  for (int i0 = 0; i0 < dim0; i0++) {
153  outputValues(0, i0) = 0.125;
154  outputValues(1, i0) = 0.125;
155  outputValues(2, i0) = 0.125;
156  outputValues(3, i0) = 0.125;
157  outputValues(4, i0) = 0.125;
158  outputValues(5, i0) = 0.125;
159  }
160  break;
161 
162  case OPERATOR_CURL:
163  TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument,
164  ">>> ERROR (Basis_HDIV_HEX_I1_FEM): CURL is invalid operator for HDIV Basis Functions");
165  break;
166 
167  case OPERATOR_GRAD:
168  TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_GRAD), std::invalid_argument,
169  ">>> ERROR (Basis_HDIV_HEX_I1_FEM): GRAD is invalid operator for HDIV Basis Functions");
170  break;
171 
172  case OPERATOR_D1:
173  case OPERATOR_D2:
174  case OPERATOR_D3:
175  case OPERATOR_D4:
176  case OPERATOR_D5:
177  case OPERATOR_D6:
178  case OPERATOR_D7:
179  case OPERATOR_D8:
180  case OPERATOR_D9:
181  case OPERATOR_D10:
182  TEUCHOS_TEST_FOR_EXCEPTION( ( (operatorType == OPERATOR_D1) ||
183  (operatorType == OPERATOR_D2) ||
184  (operatorType == OPERATOR_D3) ||
185  (operatorType == OPERATOR_D4) ||
186  (operatorType == OPERATOR_D5) ||
187  (operatorType == OPERATOR_D6) ||
188  (operatorType == OPERATOR_D7) ||
189  (operatorType == OPERATOR_D8) ||
190  (operatorType == OPERATOR_D9) ||
191  (operatorType == OPERATOR_D10) ),
192  std::invalid_argument,
193  ">>> ERROR (Basis_HDIV_HEX_I1_FEM): Invalid operator type");
194  break;
195 
196  default:
197  TEUCHOS_TEST_FOR_EXCEPTION( ( (operatorType != OPERATOR_VALUE) &&
198  (operatorType != OPERATOR_GRAD) &&
199  (operatorType != OPERATOR_CURL) &&
200  (operatorType != OPERATOR_DIV) &&
201  (operatorType != OPERATOR_D1) &&
202  (operatorType != OPERATOR_D2) &&
203  (operatorType != OPERATOR_D3) &&
204  (operatorType != OPERATOR_D4) &&
205  (operatorType != OPERATOR_D5) &&
206  (operatorType != OPERATOR_D6) &&
207  (operatorType != OPERATOR_D7) &&
208  (operatorType != OPERATOR_D8) &&
209  (operatorType != OPERATOR_D9) &&
210  (operatorType != OPERATOR_D10) ),
211  std::invalid_argument,
212  ">>> ERROR (Basis_HDIV_HEX_I1_FEM): Invalid operator type");
213  }
214 }
215 
216 
217 
218 template<class Scalar, class ArrayScalar>
220  const ArrayScalar & inputPoints,
221  const ArrayScalar & cellVertices,
222  const EOperator operatorType) const {
223  TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error,
224  ">>> ERROR (Basis_HDIV_HEX_I1_FEM): FEM Basis calling an FVD member function");
225 }
226 
227 template<class Scalar, class ArrayScalar>
228 void Basis_HDIV_HEX_I1_FEM<Scalar, ArrayScalar>::getDofCoords(ArrayScalar & DofCoords) const {
229 #ifdef HAVE_INTREPID_DEBUG
230  // Verify rank of output array.
231  TEUCHOS_TEST_FOR_EXCEPTION( !(DofCoords.rank() == 2), std::invalid_argument,
232  ">>> ERROR: (Intrepid::Basis_HDIV_HEX_I1_FEM::getDofCoords) rank = 2 required for DofCoords array");
233  // Verify 0th dimension of output array.
234  TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(0) == this -> basisCardinality_ ), std::invalid_argument,
235  ">>> ERROR: (Intrepid::Basis_HDIV_HEX_I1_FEM::getDofCoords) mismatch in number of DoF and 0th dimension of DofCoords array");
236  // Verify 1st dimension of output array.
237  TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(1) == (int)(this -> basisCellTopology_.getDimension()) ), std::invalid_argument,
238  ">>> ERROR: (Intrepid::Basis_HDIV_HEX_I1_FEM::getDofCoords) incorrect reference cell (1st) dimension in DofCoords array");
239 #endif
240 
241  DofCoords(0,0) = 0.0; DofCoords(0,1) = -1.0; DofCoords(0,2) = 0.0;
242  DofCoords(1,0) = 1.0; DofCoords(1,1) = 0.0; DofCoords(1,2) = 0.0;
243  DofCoords(2,0) = 0.0; DofCoords(2,1) = 1.0; DofCoords(2,2) = 0.0;
244  DofCoords(3,0) = -1.0; DofCoords(3,1) = 0.0; DofCoords(3,2) = 0.0;
245  DofCoords(4,0) = 0.0; DofCoords(4,1) = 0.0; DofCoords(4,2) = -1.0;
246  DofCoords(5,0) = 0.0; DofCoords(5,1) = 0.0; DofCoords(5,2) = 1.0;
247 }
248 
249 }// namespace Intrepid
250 
251 #if defined(Intrepid_SHOW_DEPRECATED_WARNINGS)
252 #ifdef __GNUC__
253 #warning "The Intrepid package is deprecated"
254 #endif
255 #endif
256 
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
Evaluation of a FEM basis on a reference Hexahedron cell.
void getDofCoords(ArrayScalar &DofCoords) const
Returns spatial locations (coordinates) of degrees of freedom on a reference Quadrilateral.
void initializeTags()
Initializes tagToOrdinal_ and ordinalToTag_ lookup arrays.