Intrepid
Intrepid_HGRAD_TET_COMP12_FEMDef.hpp
Go to the documentation of this file.
1 #ifndef INTREPID_HGRAD_TET_COMP12_FEMDEF_HPP
2 #define INTREPID_HGRAD_TET_COMP12_FEMDEF_HPP
3 // @HEADER
4 // ************************************************************************
5 //
6 // Intrepid Package
7 // Copyright (2007) Sandia Corporation
8 //
9 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10 // license for use of this work by or on behalf of the U.S. Government.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Pavel Bochev (pbboche@sandia.gov)
40 // Denis Ridzal (dridzal@sandia.gov), or
41 // Kara Peterson (kjpeter@sandia.gov)
42 //
43 // ************************************************************************
44 // @HEADER
45 
52 namespace Intrepid {
53 
54  template<class Scalar, class ArrayScalar>
56  {
57  this -> basisCardinality_ = 10;
58  this -> basisDegree_ = 1;
59  this -> basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Tetrahedron<11> >() );
60  this -> basisType_ = BASIS_FEM_DEFAULT;
61  this -> basisCoordinates_ = COORDINATES_CARTESIAN;
62  this -> basisTagsAreSet_ = false;
63  }
64 
65 
66 template<class Scalar, class ArrayScalar>
68 
69  // Basis-dependent intializations
70  int tagSize = 4; // size of DoF tag
71  int posScDim = 0; // position in the tag, counting from 0, of the subcell dim
72  int posScOrd = 1; // position in the tag, counting from 0, of the subcell ordinal
73  int posDfOrd = 2; // position in the tag, counting from 0, of DoF ordinal relative to the subcell
74 
75  // An array with local DoF tags assigned to basis functions, in the order of their local enumeration
76  int tags[] = { 0, 0, 0, 1,
77  0, 1, 0, 1,
78  0, 2, 0, 1,
79  0, 3, 0, 1,
80  1, 0, 0, 1,
81  1, 1, 0, 1,
82  1, 2, 0, 1,
83  1, 3, 0, 1,
84  1, 4, 0, 1,
85  1, 5, 0, 1,
86  };
87 
88  // Basis-independent function sets tag and enum data in tagToOrdinal_ and ordinalToTag_ arrays:
89  Intrepid::setOrdinalTagData(this -> tagToOrdinal_,
90  this -> ordinalToTag_,
91  tags,
92  this -> basisCardinality_,
93  tagSize,
94  posScDim,
95  posScOrd,
96  posDfOrd);
97 }
98 
99 
100 
101 template<class Scalar, class ArrayScalar>
103  const ArrayScalar & inputPoints,
104  const EOperator operatorType) const {
105 
106  // Verify arguments
107 #ifdef HAVE_INTREPID_DEBUG
108  Intrepid::getValues_HGRAD_Args<Scalar, ArrayScalar>(outputValues,
109  inputPoints,
110  operatorType,
111  this -> getBaseCellTopology(),
112  this -> getCardinality() );
113 #endif
114 
115  // Number of evaluation points = dim 0 of inputPoints
116  int dim0 = inputPoints.dimension(0);
117 
118  // Temporaries: (x,y,z) coordinates of the evaluation point
119  Scalar x = 0.0;
120  Scalar y = 0.0;
121  Scalar z = 0.0;
122 
123  // Temporary for the auxiliary node basis function
124  Scalar aux = 0.0;
125 
126  // Array to store all the subtets containing the given pt
127  Teuchos::Array<int> pt_tets;
128 
129  switch (operatorType) {
130 
131  case OPERATOR_VALUE:
132  for (int i0 = 0; i0 < dim0; i0++) {
133  x = inputPoints(i0, 0);
134  y = inputPoints(i0, 1);
135  z = inputPoints(i0, 2);
136 
137  pt_tets = getLocalSubTetrahedra(x,y,z);
138 
139  // idependent verification shows that a given point will produce
140  // the same shape functions for each tet that contains it, so
141  // we only need to use the first one returned.
142  //for (int pt = 0; pt < pt_tets.size(); ++pt)
143  int subtet = pt_tets[0]; //pt_tets[pt];
144  aux = 0.0;
145  // outputValues is a rank-2 array with dimensions (basisCardinality_, dim0)
146  switch (subtet) {
147  case 0:
148  outputValues(0, i0) = 1. - 2. * (x + y + z);
149  outputValues(4, i0) = 2. * x;
150  outputValues(6, i0) = 2. * y;
151  outputValues(7, i0) = 2. * z;
152  break;
153  case 1:
154  outputValues(1, i0) = 2. * x - 1.;
155  outputValues(4, i0) = 2. - 2. * (x + y + z);
156  outputValues(5, i0) = 2. * y;
157  outputValues(8, i0) = 2. * z;
158  break;
159  case 2:
160  outputValues(2, i0) = 2. * y - 1.;
161  outputValues(5, i0) = 2. * x;
162  outputValues(6, i0) = 2. - 2. * (x + y + z);
163  outputValues(9, i0) = 2. * z;
164  break;
165  case 3:
166  outputValues(3, i0) = 2. * z - 1.;
167  outputValues(7, i0) = 2. - 2. * (x + y + z);
168  outputValues(8, i0) = 2. * x;
169  outputValues(9, i0) = 2. * y;
170  break;
171  case 4:
172  outputValues(4, i0) = 1. - 2. * (y + z);
173  outputValues(5, i0) = 2. * (x + y) - 1.;
174  outputValues(8, i0) = 2. * (x + z) - 1.;
175  aux = 2. - 4. * x;
176  break;
177  case 5:
178  outputValues(5, i0) = 1. - 2. * (x + y);
179  outputValues(8, i0) = 1. - 2. * (x + z);
180  outputValues(9, i0) = 2. * (y + z) - 1.;
181  aux = 4. - 4. * (x + y + z);
182  break;
183  case 6:
184  outputValues(7, i0) = 1. - 2. * (x + y);
185  outputValues(8, i0) = 2. * (x + z) - 1.;
186  outputValues(9, i0) = 2. * (y + z) - 1.;
187  aux = 2. - 4. * z;
188  break;
189  case 7:
190  outputValues(4, i0) = 1. - 2. * (y + z);
191  outputValues(7, i0) = 1. - 2. * (x + y);
192  outputValues(8, i0) = 2. * (x + z) - 1.;
193  aux = 4. * y;
194  break;
195  case 8:
196  outputValues(4, i0) = 1. - 2. * (y + z);
197  outputValues(5, i0) = 2. * (x + y) - 1.;
198  outputValues(6, i0) = 1. - 2. * (x + z);
199  aux = 4. * z;
200  break;
201  case 9:
202  outputValues(5, i0) = 2. * (x + y) - 1.;
203  outputValues(6, i0) = 1. - 2. * (x + z);
204  outputValues(9, i0) = 2. * (y + z) - 1.;
205  aux = 2. - 4. * y;
206  break;
207  case 10:
208  outputValues(6, i0) = 1. - 2. * (x + z);
209  outputValues(7, i0) = 1. - 2. * (x + y);
210  outputValues(9, i0) = 2. * (y + z) - 1.;
211  aux = 4. * x;
212  break;
213  case 11:
214  outputValues(4, i0) = 1. - 2. * (y + z);
215  outputValues(6, i0) = 1. - 2. * (x + z);
216  outputValues(7, i0) = 1. - 2. * (x + y);
217  aux = 4. * (x + y + z) - 2.;
218  break;
219  }
220  outputValues(4, i0) += aux/6.0;
221  outputValues(5, i0) += aux/6.0;
222  outputValues(6, i0) += aux/6.0;
223  outputValues(7, i0) += aux/6.0;
224  outputValues(8, i0) += aux/6.0;
225  outputValues(9, i0) += aux/6.0;
226  //}
227  }
228  break;
229 
230  case OPERATOR_GRAD:
231  case OPERATOR_D1:
232  {
233  // initialize to 0.0 since we will be accumulating
234  outputValues.initialize(0.0);
235 
236  // local looping indices
237  // NOTE: bc is barycentric coord
238  int node, tet, pt, dim, bc1, bc2;
239 
240  // get 12 subtet gradients sized as 3, 11, 12
241  Intrepid::FieldContainer<Scalar> dx = getSubTetGrads();
242  // get subtet jacobian determinants (12)
243  Intrepid::FieldContainer<Scalar> xJ = getSubTetDetF();
244  // get integration weights (numPoints, 12)
245  Intrepid::FieldContainer<Scalar> w = getWeights(inputPoints);
246  // get Barycentric Coordinates of points
247  Intrepid::FieldContainer<Scalar> lambda = getBarycentricCoords(inputPoints);
248 
249  // declare FieldContainer for intermediate calcs
250  // a - for the 4x4 projection matrix
251  FieldContainer<Scalar> a(4, 4);
253 
254  // b - for the 3 x 4 x 10 integrated gradients
255  FieldContainer<Scalar> b(3,4,10);
256 
257  // c - product of inv(a) and b
258  FieldContainer<Scalar> c(4,3,10);
259 
260  // again initialize for safety
261  a.initialize(0.0);
262  b.initialize(0.0);
263  c.initialize(0.0);
264 
265  for (pt=0; pt < dim0; ++pt)
266  {
267  // compute a
268  for (tet=0; tet < 12; ++tet)
269  for (bc1=0; bc1 < 4; ++bc1)
270  for (bc2=0; bc2 < 4; ++bc2)
271  a(bc1,bc2) += xJ(tet) * w(pt,tet) * lambda(pt,bc1) * lambda(pt,bc2);
272 
273  // compute b
274  for (tet=0; tet < 12; ++tet)
275  {
276  for (node=0; node < 10; ++node)
277  for (bc1=0; bc1 < 4; ++bc1)
278  for (dim=0; dim < 3; ++dim)
279  b(dim,bc1,node) += xJ(tet) * w(pt,tet) * lambda(pt,bc1) * dx(dim,node,tet);
280 
281  // add in contribution from the auxiliary node, averaged over the 6 mid-edge ndoes
282  for (node=4; node < 10; ++node)
283  for (bc1=0; bc1 < 4; ++bc1)
284  for (dim=0; dim < 3; ++dim)
285  b(dim,bc1,node) += xJ(tet) * w(pt,tet) * lambda(pt,bc1) * dx(dim,10,tet)/6;
286  }
287  } // loop over pts
288 
289  // compute inverse of a (4x4 inverse)
290  ai = inverse44(a);
291 
292  // compute c
293  for (node=0; node < 10; ++node)
294  for (bc1=0; bc1 < 4; ++bc1)
295  for (bc2=0; bc2 < 4; ++bc2)
296  for (dim=0; dim < 3; ++dim)
297  c(bc1,dim,node) += ai(bc1,bc2) * b(dim,bc2,node);
298 
299  // fill in shape function derivatives
300  for (pt=0; pt < dim0; ++pt)
301  for (node=0; node < 10; ++node)
302  for (dim=0; dim < 3; ++dim)
303  for (bc1=0; bc1 < 4; ++bc1)
304  outputValues(node,pt,dim) += lambda(pt,bc1) * c(bc1,dim,node);
305  }
306  break;
307 
308  case OPERATOR_CURL:
309  TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_CURL), std::invalid_argument,
310  ">>> ERROR (Basis_HGRAD_TET_COMP12_FEM): CURL is invalid operator for rank-0 (scalar) functions in 3D");
311  break;
312 
313  case OPERATOR_DIV:
314  TEUCHOS_TEST_FOR_EXCEPTION( (operatorType == OPERATOR_DIV), std::invalid_argument,
315  ">>> ERROR (Basis_HGRAD_TET_COMP12_FEM): DIV is invalid operator for rank-0 (scalar) functions in 3D");
316  break;
317 
318  case OPERATOR_D2:
319  case OPERATOR_D3:
320  case OPERATOR_D4:
321  case OPERATOR_D5:
322  case OPERATOR_D6:
323  case OPERATOR_D7:
324  case OPERATOR_D8:
325  case OPERATOR_D9:
326  case OPERATOR_D10:
327  {
328  // outputValues is a rank-3 array with dimensions (basisCardinality_, dim0, DkCardinality)
329  int DkCardinality = Intrepid::getDkCardinality(operatorType,
330  this -> basisCellTopology_.getDimension() );
331  for(int dofOrd = 0; dofOrd < this -> basisCardinality_; dofOrd++) {
332  for (int i0 = 0; i0 < dim0; i0++) {
333  for(int dkOrd = 0; dkOrd < DkCardinality; dkOrd++){
334  outputValues(dofOrd, i0, dkOrd) = 0.0;
335  }
336  }
337  }
338  }
339  break;
340  default:
341  TEUCHOS_TEST_FOR_EXCEPTION( !( Intrepid::isValidOperator(operatorType) ), std::invalid_argument,
342  ">>> ERROR (Basis_HGRAD_TET_COMP12_FEM): Invalid operator type");
343  }
344 }
345 
346 
347 
348 template<class Scalar, class ArrayScalar>
350  const ArrayScalar & inputPoints,
351  const ArrayScalar & cellVertices,
352  const EOperator operatorType) const {
353  TEUCHOS_TEST_FOR_EXCEPTION( (true), std::logic_error,
354  ">>> ERROR (Basis_HGRAD_TET_COMP12_FEM): FEM Basis calling an FVD member function");
355 
356 }
357 
358 template<class Scalar, class ArrayScalar>
360 #ifdef HAVE_INTREPID_DEBUG
361  // Verify rank of output array.
362  TEUCHOS_TEST_FOR_EXCEPTION( !(DofCoords.rank() == 2), std::invalid_argument,
363  ">>> ERROR: (Intrepid::Basis_HGRAD_TET_COMP12_FEM::getDofCoords) rank = 2 required for DofCoords array");
364  // Verify 0th dimension of output array.
365  TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(0) == this -> basisCardinality_ ), std::invalid_argument,
366  ">>> ERROR: (Intrepid::Basis_HGRAD_TET_COMP12_FEM::getDofCoords) mismatch in number of DoF and 0th dimension of DofCoords array");
367  // Verify 1st dimension of output array.
368  TEUCHOS_TEST_FOR_EXCEPTION( !( DofCoords.dimension(1) == (int)(this -> basisCellTopology_.getDimension()) ), std::invalid_argument,
369  ">>> ERROR: (Intrepid::Basis_HGRAD_TET_COMP12_FEM::getDofCoords) incorrect reference cell (1st) dimension in DofCoords array");
370 #endif
371 
372  DofCoords(0,0) = 0.0; DofCoords(0,1) = 0.0; DofCoords(0,2) = 0.0;
373  DofCoords(1,0) = 1.0; DofCoords(1,1) = 0.0; DofCoords(1,2) = 0.0;
374  DofCoords(2,0) = 0.0; DofCoords(2,1) = 1.0; DofCoords(2,2) = 0.0;
375  DofCoords(3,0) = 0.0; DofCoords(3,1) = 0.0; DofCoords(3,2) = 1.0;
376  DofCoords(4,0) = 0.5; DofCoords(4,1) = 0.0; DofCoords(4,2) = 0.0;
377  DofCoords(5,0) = 0.5; DofCoords(5,1) = 0.5; DofCoords(5,2) = 0.0;
378  DofCoords(6,0) = 0.0; DofCoords(6,1) = 0.5; DofCoords(6,2) = 0.0;
379  DofCoords(7,0) = 0.0; DofCoords(7,1) = 0.0; DofCoords(7,2) = 0.5;
380  DofCoords(8,0) = 0.5; DofCoords(8,1) = 0.0; DofCoords(8,2) = 0.5;
381  DofCoords(9,0) = 0.0; DofCoords(9,1) = 0.5; DofCoords(9,2) = 0.5;
382 }
383 
384 template<class Scalar, class ArrayScalar>
385 Teuchos::Array<int>
387 {
388 
389  Teuchos::Array<int> subTets;
390 
391  // local coords
392  Scalar xyz = x + y + z;
393  Scalar xy = x + y;
394  Scalar xz = x + z;
395  Scalar yz = y + z;
396 
397  // cycle through each subdomain and push back if the point lies within
398 
399  // subtet #0 E0 := 0.0 <= r + s + t <= 0.5 && 0.0 <= r <= 0.5 && 0.0 <= s <= 0.5 && 0.0 <= t <= 0.5
400  if ( (0.0 <= xyz && xyz <= 0.5) && (0.0 <= x && x <= 0.5) && (0.0 <= y && y <= 0.5) && (0.0 <= z && z <= 0.5) )
401  subTets.push_back(0);
402 
403  // subtet #1 E1 := 0.5 <= r + s + t <= 1.0 && 0.5 <= r <= 1.0 && 0.0 <= s <= 0.5 && 0.0 <= t <= 0.5
404  if ( (0.5 <= xyz && xyz <= 1.0) && (0.5 <= x && x <= 1.0) && (0.0 <= y && y <= 0.5) && (0.0 <= z && z <= 0.5) )
405  subTets.push_back(1);
406 
407  // subtet #2 E2 := 0.5 <= r + s + t <= 1.0 && 0.0 <= r <= 0.5 && 0.5 <= s <= 1.0 && 0.0 <= t <= 0.5
408  if ( (0.5 <= xyz && xyz <= 1.0) && (0.0 <= x && x <= 0.5) && (0.5 <= y && y <= 1.0) && (0.0 <= z && z<= 0.5) )
409  subTets.push_back(2);
410 
411  // subtet #3 E3 := 0.5 <= r + s + t <= 1.0 && 0.0 <= r <= 0.5 && 0.0 <= s <= 0.5 && 0.5 <= t <= 1.0
412  if ( (0.5 <= xyz && xyz <= 1.0) && (0.0 <= x && x <= 0.5) && (0.0 <= y && y <= 0.5) && (0.5 <= z && z <= 1.0) )
413  subTets.push_back(3);
414 
415  // subtet #4 E4 := 0.0 <= s + t <= 0.5 && 0.5 <= r + s <= 1.0 && 0.5 <= r + t <= 1.0 && 0.0 <= r <= 0.5
416  if ( (0.0 <= yz && yz <= 0.5) && (0.5 <= xy && xy <= 1.0) && (0.5 <= xz && xz <= 1.0) && (0.0 <= x && x <= 0.5) )
417  subTets.push_back(4);
418 
419  // subtet #5 E5 := 0.5 <= r + s <= 1.0 && 0.5 <= s + t <= 1.0 && 0.5 <= r + t <= 1.0 && 0.75 <= r + s + t <= 1.0
420  if ( (0.5 <= xy && xy <= 1.0) && (0.5 <= yz && yz <= 1.0) && (0.5 <= xz && xz <= 1.0) && (0.75 <= xyz && xyz <= 1.0) )
421  subTets.push_back(5);
422 
423  // subtet #6 E6 := 0.5 <= s + t <= 1.0 && 0.0 <= r + s <= 0.5 && 0.5 <= r + t <= 1.0 && 0.0 <= t <= 0.5
424  if ( (0.5 <= yz && yz <= 1.0) && (0.0 <= xy && xy <= 0.5) && (0.5 <= xz && xz <= 1.0) && (0.0 <= z && z <= 0.5) )
425  subTets.push_back(6);
426 
427  // subtet #7 E7 := 0.0 <= s + t <= 0.5 && 0.0 <= r + s <= 0.5 && 0.5 <= r + t <= 1.0 && 0.0 <= s <= 0.25
428  if ( (0.0 <= yz && yz <= 0.5) && (0.0 <= xy && xy <= 0.5) && (0.5 <= xz && xz <= 1.0) && (0.0 <= y && y <= 0.25) )
429  subTets.push_back(7);
430 
431  // subtet #8 E8 := 0.0 <= r + t <= 0.5 && 0.0 <= s + t <= 0.5 && 0.5 <= r + s <= 1.0 && 0.0 <= t <= 0.25
432  if ( (0.0 <= xz && xz <= 0.5) && (0.0 <= yz && yz <= 0.5) && (0.5 <= xy && xy <= 1.0) && (0.0 <= z && z <= 0.5) )
433  subTets.push_back(8);
434 
435  // subtet #9 E9 := 0.0 <= r + t <= 0.5 && 0.5 <= r + s <= 1.0 && 0.5 <= s + t <= 1.0 && 0.0 <= s <= 0.5
436  if ( (0.0 <= xz && xz <= 0.5) && (0.5 <= xy && xy <= 1.0) && (0.5 <= yz && yz <= 1.0) && (0.0 <= y && y <= 0.5) )
437  subTets.push_back(9);
438 
439  // subtet #10 E10 := 0.0 <= r + t <= 0.5 && 0.5 <= s + t <= 1.0 && 0.0 <= r + s <= 0.5 && 0.0 <= r <= 0.25
440  if ( (0.0 <= xz && xz <= 0.5) && (0.5 <= yz && yz <= 1.0) && (0.0 <= xy && xy <= 0.5) && (0.0 <= x && x <= 0.25) )
441  subTets.push_back(10);
442 
443  // subtet #11 E11 := 0.5 <= r + s + t <= 0.75 && 0.0 <= r + t <= 0.5 && 0.0 <= s + t <= 0.5 && 0.0 <= r + s <= 0.5
444  if ( (0.5 <= xyz && xyz <= 0.75) && (0.0 <= xz && xz <= 0.5) && (0.0 <= yz && yz <= 0.5) && (0.0 <= xy && xy <= 0.5) )
445  subTets.push_back(11);
446 
447  return subTets;
448 }
449 
450 
451 template<class Scalar, class ArrayScalar>
454 {
455  int numPoints = inPts.dimension(0);
456  Intrepid::FieldContainer<Scalar> w(numPoints, 12);
457  w.initialize(0.0);
458  Teuchos::Array< Teuchos::Array<int> > pt_tets;
459 
460  for (int pt = 0; pt < numPoints; ++pt)
461  pt_tets.push_back(getLocalSubTetrahedra(inPts(pt,0), inPts(pt,1), inPts(pt,2)));
462 
463  Teuchos::Array<int> flat;
464  FieldContainer<int> count(12);
465 
466  for (int pt = 0; pt < numPoints; ++pt)
467  for (int i = 0; i < pt_tets[pt].size(); ++i)
468  flat.push_back(pt_tets[pt][i]);
469 
470  for (int i = 0; i < flat.size(); ++i)
471  count(flat[i])++;
472 
473  for (int pt = 0; pt < numPoints; ++pt)
474  for (int i = 0; i < pt_tets[pt].size(); ++i)
475  w(pt, pt_tets[pt][i]) = 1.0/count(pt_tets[pt][i]);
476 
477  return w;
478 }
479 
480 
481 
482 template<class Scalar, class ArrayScalar>
485 {
486  int numPoints = inPts.dimension(0);
487  Intrepid::FieldContainer<Scalar> lambda(numPoints, 4);
488 
489  for (int pt = 0; pt < numPoints; ++pt)
490  {
491  lambda(pt,0) = 1. - inPts(pt,0) - inPts(pt,1) - inPts(pt,2);
492  lambda(pt,1) = inPts(pt,0);
493  lambda(pt,2) = inPts(pt,1);
494  lambda(pt,3) = inPts(pt,2);
495  }
496 
497  return lambda;
498 }
499 
500 template<class Scalar, class ArrayScalar>
501 Scalar
503 {
504  Scalar det = a(0,3) * a(1,2) * a(2,1) * a(3,0)
505  - a(0,2) * a(1,3) * a(2,1) * a(3,0)
506  - a(0,3) * a(1,1) * a(2,2) * a(3,0)
507  + a(0,1) * a(1,3) * a(2,2) * a(3,0)
508  + a(0,2) * a(1,1) * a(2,3) * a(3,0)
509  - a(0,1) * a(1,2) * a(2,3) * a(3,0)
510  - a(0,3) * a(1,2) * a(2,0) * a(3,1)
511  + a(0,2) * a(1,3) * a(2,0) * a(3,1)
512  + a(0,3) * a(1,0) * a(2,2) * a(3,1)
513  - a(0,0) * a(1,3) * a(2,2) * a(3,1)
514  - a(0,2) * a(1,0) * a(2,3) * a(3,1)
515  + a(0,0) * a(1,2) * a(2,3) * a(3,1)
516  + a(0,3) * a(1,1) * a(2,0) * a(3,2)
517  - a(0,1) * a(1,3) * a(2,0) * a(3,2)
518  - a(0,3) * a(1,0) * a(2,1) * a(3,2)
519  + a(0,0) * a(1,3) * a(2,1) * a(3,2)
520  + a(0,1) * a(1,0) * a(2,3) * a(3,2)
521  - a(0,0) * a(1,1) * a(2,3) * a(3,2)
522  - a(0,2) * a(1,1) * a(2,0) * a(3,3)
523  + a(0,1) * a(1,2) * a(2,0) * a(3,3)
524  + a(0,2) * a(1,0) * a(2,1) * a(3,3)
525  - a(0,0) * a(1,2) * a(2,1) * a(3,3)
526  - a(0,1) * a(1,0) * a(2,2) * a(3,3)
527  + a(0,0) * a(1,1) * a(2,2) * a(3,3);
528 
529  return det;
530 }
531 
532 template<class Scalar, class ArrayScalar>
535 {
537  Scalar xj = det44(a);
538 
539  ai(0,0) = (1/xj) * (-a(1,3) * a(2,2) * a(3,1) + a(1,2) * a(2,3) * a(3,1) + a(1,3) * a(2,1) * a(3,2) - a(1,1) * a(2,3) * a(3,2) - a(1,2) * a(2,1) * a(3,3) + a(1,1) * a(2,2) * a(3,3));
540  ai(0,1) = (1/xj) * ( a(0,3) * a(2,2) * a(3,1) - a(0,2) * a(2,3) * a(3,1) - a(0,3) * a(2,1) * a(3,2) + a(0,1) * a(2,3) * a(3,2) + a(0,2) * a(2,1) * a(3,3) - a(0,1) * a(2,2) * a(3,3));
541  ai(0,2) = (1/xj) * (-a(0,3) * a(1,2) * a(3,1) + a(0,2) * a(1,3) * a(3,1) + a(0,3) * a(1,1) * a(3,2) - a(0,1) * a(1,3) * a(3,2) - a(0,2) * a(1,1) * a(3,3) + a(0,1) * a(1,2) * a(3,3));
542  ai(0,3) = (1/xj) * ( a(0,3) * a(1,2) * a(2,1) - a(0,2) * a(1,3) * a(2,1) - a(0,3) * a(1,1) * a(2,2) + a(0,1) * a(1,3) * a(2,2) + a(0,2) * a(1,1) * a(2,3) - a(0,1) * a(1,2) * a(2,3));
543 
544  ai(1,0) = (1/xj) * ( a(1,3) * a(2,2) * a(3,0) - a(1,2) * a(2,3) * a(3,0) - a(1,3) * a(2,0) * a(3,2) + a(1,0) * a(2,3) * a(3,2) + a(1,2) * a(2,0) * a(3,3) - a(1,0) * a(2,2) * a(3,3));
545  ai(1,1) = (1/xj) * (-a(0,3) * a(2,2) * a(3,0) + a(0,2) * a(2,3) * a(3,0) + a(0,3) * a(2,0) * a(3,2) - a(0,0) * a(2,3) * a(3,2) - a(0,2) * a(2,0) * a(3,3) + a(0,0) * a(2,2) * a(3,3));
546  ai(1,2) = (1/xj) * ( a(0,3) * a(1,2) * a(3,0) - a(0,2) * a(1,3) * a(3,0) - a(0,3) * a(1,0) * a(3,2) + a(0,0) * a(1,3) * a(3,2) + a(0,2) * a(1,0) * a(3,3) - a(0,0) * a(1,2) * a(3,3));
547  ai(1,3) = (1/xj) * (-a(0,3) * a(1,2) * a(2,0) + a(0,2) * a(1,3) * a(2,0) + a(0,3) * a(1,0) * a(2,2) - a(0,0) * a(1,3) * a(2,2) - a(0,2) * a(1,0) * a(2,3) + a(0,0) * a(1,2) * a(2,3));
548 
549  ai(2,0) = (1/xj) * (-a(1,3) * a(2,1) * a(3,0) + a(1,1) * a(2,3) * a(3,0) + a(1,3) * a(2,0) * a(3,1) - a(1,0) * a(2,3) * a(3,1) - a(1,1) * a(2,0) * a(3,3) + a(1,0) * a(2,1) * a(3,3));
550  ai(2,1) = (1/xj) * ( a(0,3) * a(2,1) * a(3,0) - a(0,1) * a(2,3) * a(3,0) - a(0,3) * a(2,0) * a(3,1) + a(0,0) * a(2,3) * a(3,1) + a(0,1) * a(2,0) * a(3,3) - a(0,0) * a(2,1) * a(3,3));
551  ai(2,2) = (1/xj) * (-a(0,3) * a(1,1) * a(3,0) + a(0,1) * a(1,3) * a(3,0) + a(0,3) * a(1,0) * a(3,1) - a(0,0) * a(1,3) * a(3,1) - a(0,1) * a(1,0) * a(3,3) + a(0,0) * a(1,1) * a(3,3));
552  ai(2,3) = (1/xj) * ( a(0,3) * a(1,1) * a(2,0) - a(0,1) * a(1,3) * a(2,0) - a(0,3) * a(1,0) * a(2,1) + a(0,0) * a(1,3) * a(2,1) + a(0,1) * a(1,0) * a(2,3) - a(0,0) * a(1,1) * a(2,3));
553 
554  ai(3,0) = (1/xj) * ( a(1,2) * a(2,1) * a(3,0) - a(1,1) * a(2,2) * a(3,0) - a(1,2) * a(2,0) * a(3,1) + a(1,0) * a(2,2) * a(3,1) + a(1,1) * a(2,0) * a(3,2) - a(1,0) * a(2,1) * a(3,2));
555  ai(3,1) = (1/xj) * (-a(0,2) * a(2,1) * a(3,0) + a(0,1) * a(2,2) * a(3,0) + a(0,2) * a(2,0) * a(3,1) - a(0,0) * a(2,2) * a(3,1) - a(0,1) * a(2,0) * a(3,2) + a(0,0) * a(2,1) * a(3,2));
556  ai(3,2) = (1/xj) * ( a(0,2) * a(1,1) * a(3,0) - a(0,1) * a(1,2) * a(3,0) - a(0,2) * a(1,0) * a(3,1) + a(0,0) * a(1,2) * a(3,1) + a(0,1) * a(1,0) * a(3,2) - a(0,0) * a(1,1) * a(3,2));
557  ai(3,3) = (1/xj) * (-a(0,2) * a(1,1) * a(2,0) + a(0,1) * a(1,2) * a(2,0) + a(0,2) * a(1,0) * a(2,1) - a(0,0) * a(1,2) * a(2,1) - a(0,1) * a(1,0) * a(2,2) + a(0,0) * a(1,1) * a(2,2));
558 
559  return ai;
560 }
561 
562 template<class Scalar, class ArrayScalar>
565 {
567  dx.initialize(0.0);
568  // fill in dx
569  dx(0,0,0) = -2.0;
570  dx(0,1,1) = 2.0;
571  dx(0,4,0) = 2.0;
572  dx(0,4,1) = -2.0;
573  dx(0,5,2) = 2.0;
574  dx(0,5,4) = 2.0;
575  dx(0,5,5) = 2.0;
576  dx(0,5,8) = 2.0;
577  dx(0,5,9) = 2.0;
578  dx(0,6,2) = -2.0;
579  dx(0,6,8) = -2.0;
580  dx(0,6,9) = -2.0;
581  dx(0,6,10) = -2.0;
582  dx(0,6,11) = -2.0;
583  dx(0,7,3) = -2.0;
584  dx(0,7,6) = -2.0;
585  dx(0,7,7) = -2.0;
586  dx(0,7,10) = -2.0;
587  dx(0,7,11) = -2.0;
588  dx(0,8,3) = 2.0;
589  dx(0,8,4) = 2.0;
590  dx(0,8,5) = 2.0;
591  dx(0,8,6) = 2.0;
592  dx(0,8,7) = 2.0;
593  dx(0,10,4) = -4.0;
594  dx(0,10,5) = -4.0;
595  dx(0,10,10) = 4.0;
596  dx(0,10,11) = 4.0;
597 
598  // fill in dy
599  dx(1,0,0) = -2.0;
600  dx(1,2,2) = 2.0;
601  dx(1,4,1) = -2.0;
602  dx(1,4,4) = -2.0;
603  dx(1,4,7) = -2.0;
604  dx(1,4,8) = -2.0;
605  dx(1,4,11) = -2.0;
606  dx(1,5,1) = 2.0;
607  dx(1,5,4) = 2.0;
608  dx(1,5,5) = 2.0;
609  dx(1,5,8) = 2.0;
610  dx(1,5,9) = 2.0;
611  dx(1,6,0) = 2.0;
612  dx(1,6,2) = -2.0;
613  dx(1,7,3) = -2.0;
614  dx(1,7,6) = -2.0;
615  dx(1,7,7) = -2.0;
616  dx(1,7,10) = -2.0;
617  dx(1,7,11) = -2.0;
618  dx(1,9,3) = 2.0;
619  dx(1,9,5) = 2.0;
620  dx(1,9,6) = 2.0;
621  dx(1,9,9) = 2.0;
622  dx(1,9,10) = 2.0;
623  dx(1,10,5) = -4.0;
624  dx(1,10,7) = 4.0;
625  dx(1,10,9) = -4.0;
626  dx(1,10,11) = 4.0;
627 
628  // fill in dz
629  dx(2,0,0) = -2.0;
630  dx(2,3,3) = 2.0;
631  dx(2,4,1) = -2.0;
632  dx(2,4,4) = -2.0;
633  dx(2,4,7) = -2.0;
634  dx(2,4,8) = -2.0;
635  dx(2,4,11) = -2.0;
636  dx(2,6,2) = -2.0;
637  dx(2,6,8) = -2.0;
638  dx(2,6,9) = -2.0;
639  dx(2,6,10) = -2.0;
640  dx(2,6,11) = -2.0;
641  dx(2,7,0) = 2.0;
642  dx(2,7,3) = -2.0;
643  dx(2,8,1) = 2.0;
644  dx(2,8,4) = 2.0;
645  dx(2,8,5) = 2.0;
646  dx(2,8,6) = 2.0;
647  dx(2,8,7) = 2.0;
648  dx(2,9,2) = 2.0;
649  dx(2,9,5) = 2.0;
650  dx(2,9,6) = 2.0;
651  dx(2,9,9) = 2.0;
652  dx(2,9,10) = 2.0;
653  dx(2,10,5) = -4.0;
654  dx(2,10,6) = -4.0;
655  dx(2,10,8) = 4.0;
656  dx(2,10,11) = 4.0;
657 
658  return dx;
659 }
660 
661 template<class Scalar, class ArrayScalar>
664 {
666  // set sub-elem jacobians
667  xJ(0) = 1./48.; xJ(1) = 1./48.; xJ(2) = 1./48.; xJ(3) = 1./48.;
668  xJ(4) = 1./96.; xJ(5) = 1./96.; xJ(6) = 1./96.; xJ(7) = 1./96.;
669  xJ(8) = 1./96.; xJ(9) = 1./96.; xJ(10) = 1./96.; xJ(11) = 1./96.;
670 
671  return xJ;
672 }
673 
674 
675 }// namespace Intrepid
676 #endif
int dimension(const int whichDim) const
Returns the specified dimension.
void setOrdinalTagData(std::vector< std::vector< std::vector< int > > > &tagToOrdinal, std::vector< std::vector< int > > &ordinalToTag, const int *tags, const int basisCard, const int tagSize, const int posScDim, const int posScOrd, const int posDfOrd)
Fills ordinalToTag_ and tagToOrdinal_ by basis-specific tag data.
EOperator
Enumeration of primitive operators available in Intrepid. Primitive operators act on reconstructed fu...
Intrepid::FieldContainer< Scalar > inverse44(const Intrepid::FieldContainer< Scalar >) const
Returns FieldContainer of Barycentric Coordinates for the input points.
void initializeTags()
Initializes tagToOrdinal_ and ordinalToTag_ lookup arrays.
Intrepid::FieldContainer< Scalar > getSubTetDetF() const
Returns FieldContainer of local sub-tet detF.
int getDkCardinality(const EOperator operatorType, const int spaceDim)
Returns cardinality of Dk, i.e., the number of all derivatives of order k.
void getValues(ArrayScalar &outputValues, const ArrayScalar &inputPoints, const EOperator operatorType) const
FEM basis evaluation on a reference Tetrahedron cell.
void initialize(const Scalar value=0)
Initializes a field container by assigning value to all its elements.
int isValidOperator(const EOperator operatorType)
Verifies validity of an operator enum.
Intrepid::FieldContainer< Scalar > getSubTetGrads() const
Returns FieldContainer of local sub-tet gradients.
Teuchos::Array< int > getLocalSubTetrahedra(Scalar, Scalar, Scalar) const
Returns array of local sub-tetrahdera that the given point resides in.
Scalar det44(const Intrepid::FieldContainer< Scalar >) const
Returns FieldContainer of Barycentric Coordinates for the input points.
Intrepid::FieldContainer< Scalar > getWeights(const ArrayScalar &) const
Returns FieldContainer of local integration weights.
void getDofCoords(ArrayScalar &DofCoords) const
Returns spatial locations (coordinates) of degrees of freedom on a reference Tetrahedron.
Intrepid::FieldContainer< Scalar > getBarycentricCoords(const ArrayScalar &) const
Returns FieldContainer of Barycentric Coordinates for the input points.