Intrepid
Intrepid_PointToolsDef.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 
48 #ifdef _MSC_VER
49 #include "winmath.h"
50 #endif
51 
52 
53 namespace Intrepid {
54 
55  template<class Scalar, class ArrayType>
56  void PointTools::getLattice(ArrayType &pts ,
57  const shards::CellTopology& cellType ,
58  const int order ,
59  const int offset ,
60  const EPointType pointType )
61  {
62  switch (pointType) {
63  case POINTTYPE_EQUISPACED:
64  getEquispacedLattice<Scalar,ArrayType>( cellType , pts , order , offset );
65  break;
66  case POINTTYPE_WARPBLEND:
67  getWarpBlendLattice<Scalar,ArrayType>( cellType , pts , order , offset );
68  break;
69  default:
70  TEUCHOS_TEST_FOR_EXCEPTION( true ,
71  std::invalid_argument ,
72  "PointTools::getLattice: invalid EPointType" );
73  }
74  return;
75  }
76 
77  template<class Scalar, class ArrayType>
78  void PointTools::getGaussPoints( ArrayType &pts ,
79  const int order )
80  {
81 
82  Scalar *z = new Scalar[order+1];
83  Scalar *w = new Scalar[order+1];
84 
85  IntrepidPolylib::zwgj( z , w , order + 1 , 0.0 , 0.0 );
86  for (int i=0;i<order+1;i++) {
87  pts(i,0) = z[i];
88  }
89 
90  delete []z;
91  delete []w;
92  }
93 
94 
95  template<class Scalar, class ArrayType>
96  void PointTools::getEquispacedLattice(const shards::CellTopology& cellType ,
97  ArrayType &points ,
98  const int order ,
99  const int offset )
100 
101  {
102  switch (cellType.getKey()) {
103  case shards::Tetrahedron<4>::key:
104  case shards::Tetrahedron<8>::key:
105  case shards::Tetrahedron<10>::key:
106  TEUCHOS_TEST_FOR_EXCEPTION( ( points.dimension(0) != getLatticeSize( cellType , order , offset ) )
107  || points.dimension(1) != 3 ,
108  std::invalid_argument ,
109  ">>> ERROR(PointTools::getEquispacedLattice): points argument is ill-sized." );
110  getEquispacedLatticeTetrahedron<Scalar,ArrayType>( points , order , offset );
111  break;
112  case shards::Triangle<3>::key:
113  case shards::Triangle<4>::key:
114  case shards::Triangle<6>::key:
115  TEUCHOS_TEST_FOR_EXCEPTION( ( points.dimension(0) != getLatticeSize( cellType , order , offset ) )
116  || points.dimension(1) != 2 ,
117  std::invalid_argument ,
118  ">>> ERROR(PointTools::getEquispacedLattice): points argument is ill-sized." );
119  getEquispacedLatticeTriangle<Scalar,ArrayType>( points , order , offset );
120  break;
121  case shards::Line<2>::key:
122  case shards::Line<3>::key:
123  TEUCHOS_TEST_FOR_EXCEPTION( ( points.dimension(0) != getLatticeSize( cellType , order , offset ) )
124  || points.dimension(1) != 1 ,
125  std::invalid_argument ,
126  ">>> ERROR(PointTools::getEquispacedLattice): points argument is ill-sized." );
127  getEquispacedLatticeLine<Scalar,ArrayType>( points , order , offset );
128  break;
129  default:
130  TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
131  ">>> ERROR (Intrepid::PointTools::getEquispacedLattice): Illegal cell type" );
132  }
133 
134  }
135 
136  template<class Scalar, class ArrayType>
137  void PointTools::getWarpBlendLattice( const shards::CellTopology& cellType ,
138  ArrayType &points ,
139  const int order ,
140  const int offset )
141 
142  {
143  switch (cellType.getKey()) {
144  case shards::Tetrahedron<4>::key:
145  case shards::Tetrahedron<8>::key:
146  case shards::Tetrahedron<10>::key:
147  TEUCHOS_TEST_FOR_EXCEPTION( ( points.dimension(0) != getLatticeSize( cellType , order , offset ) )
148  || points.dimension(1) != 3 ,
149  std::invalid_argument ,
150  ">>> ERROR(PointTools::getWarpBlendLattice): points argument is ill-sized." );
151  getWarpBlendLatticeTetrahedron<Scalar,ArrayType>( points , order , offset );
152  break;
153  case shards::Triangle<3>::key:
154  case shards::Triangle<4>::key:
155  case shards::Triangle<6>::key:
156  TEUCHOS_TEST_FOR_EXCEPTION( ( points.dimension(0) != getLatticeSize( cellType , order , offset ) )
157  || points.dimension(1) != 2 ,
158  std::invalid_argument ,
159  ">>> ERROR(PointTools::getWarpBlendLattice): points argument is ill-sized." );
160  getWarpBlendLatticeTriangle<Scalar,ArrayType>( points , order , offset );
161  break;
162  case shards::Line<2>::key:
163  case shards::Line<3>::key:
164  TEUCHOS_TEST_FOR_EXCEPTION( ( points.dimension(0) != getLatticeSize( cellType , order , offset ) )
165  || points.dimension(1) != 1 ,
166  std::invalid_argument ,
167  ">>> ERROR(PointTools::getWarpBlendLattice): points argument is ill-sized." );
168  getWarpBlendLatticeLine<Scalar,ArrayType>( points , order , offset );
169  break;
170  default:
171  TEUCHOS_TEST_FOR_EXCEPTION( true , std::invalid_argument ,
172  ">>> ERROR (Intrepid::PointTools::getWarpBlendLattice): Illegal cell type" );
173  }
174 
175  }
176 
177  template<class Scalar, class ArrayType>
178  void PointTools::getEquispacedLatticeLine( ArrayType &points ,
179  const int order ,
180  const int offset )
181  {
182  TEUCHOS_TEST_FOR_EXCEPTION( order < 0 ,
183  std::invalid_argument ,
184  ">>> ERROR (Intrepid::PointTools::getEquispacedLatticeLine): order must be positive" );
185  if (order == 0) {
186  points(0,0) = 0.0;
187  }
188  else {
189  const Scalar h = 2.0 / order;
190 
191  for (int i=offset;i<=order-offset;i++) {
192  points(i-offset,0) = -1.0 + h * (Scalar) i;
193  }
194  }
195 
196  return;
197  }
198 
199  template<class Scalar, class ArrayType>
201  const int order ,
202  const int offset )
203  {
204  TEUCHOS_TEST_FOR_EXCEPTION( order <= 0 ,
205  std::invalid_argument ,
206  ">>> ERROR (Intrepid::PointTools::getEquispacedLatticeLine): order must be positive" );
207 
208  const Scalar h = 1.0 / order;
209  int cur = 0;
210 
211  for (int i=offset;i<=order-offset;i++) {
212  for (int j=offset;j<=order-i-offset;j++) {
213  points(cur,0) = (Scalar)0.0 + (Scalar) j * h ;
214  points(cur,1) = (Scalar)0.0 + (Scalar) i * h;
215  cur++;
216  }
217  }
218 
219  return;
220  }
221 
222  template<class Scalar, class ArrayType>
224  const int order ,
225  const int offset )
226  {
227  TEUCHOS_TEST_FOR_EXCEPTION( (order <= 0) ,
228  std::invalid_argument ,
229  ">>> ERROR (Intrepid::PointTools::getEquispacedLatticeTetrahedron): order must be positive" );
230 
231  const Scalar h = 1.0 / order;
232  int cur = 0;
233 
234  for (int i=offset;i<=order-offset;i++) {
235  for (int j=offset;j<=order-i-offset;j++) {
236  for (int k=offset;k<=order-i-j-offset;k++) {
237  points(cur,0) = (Scalar) k * h;
238  points(cur,1) = (Scalar) j * h;
239  points(cur,2) = (Scalar) i * h;
240  cur++;
241  }
242  }
243  }
244 
245  return;
246  }
247 
248  template<class Scalar, class ArrayType>
249  void PointTools::getWarpBlendLatticeLine( ArrayType &points ,
250  const int order ,
251  const int offset )
252  {
253  Scalar *z = new Scalar[order+1];
254  Scalar *w = new Scalar[order+1];
255 
256  // order is order of polynomial degree. The Gauss-Lobatto points are accurate
257  // up to degree 2*i-1
258  IntrepidPolylib::zwglj( z , w , order+1 , 0.0 , 0.0 );
259 
260  for (int i=offset;i<=order-offset;i++) {
261  points(i-offset,0) = z[i];
262  }
263 
264  delete []z;
265  delete []w;
266 
267  return;
268  }
269 
270  template<class Scalar, class ArrayType>
271  void PointTools::warpFactor( const int order ,
272  const ArrayType &xnodes ,
273  const ArrayType &xout ,
274  ArrayType &warp)
275  {
276  TEUCHOS_TEST_FOR_EXCEPTION( ( warp.dimension(0) != xout.dimension(0) ) ,
277  std::invalid_argument ,
278  ">>> ERROR (PointTools::warpFactor): xout and warp must be same size." );
279 
280  warp.initialize();
281 
282  FieldContainer<Scalar> d( xout.dimension(0) );
283  d.initialize();
284 
285  FieldContainer<Scalar> xeq( order + 1 ,1);
286  PointTools::getEquispacedLatticeLine<Scalar,ArrayType>( xeq , order , 0 );
287  xeq.resize( order + 1 );
288 
289  TEUCHOS_TEST_FOR_EXCEPTION( ( xeq.dimension(0) != xnodes.dimension(0) ) ,
290  std::invalid_argument ,
291  ">>> ERROR (PointTools::warpFactor): xeq and xnodes must be same size." );
292 
293  for (int i=0;i<=order;i++) {
294 
295  for (int k=0;k<d.dimension(0);k++) {
296  d(k) = xnodes(i) - xeq(i);
297  }
298 
299  for (int j=1;j<order;j++) {
300  if (i != j) {
301  for (int k=0;k<d.dimension(0);k++) {
302  d(k) = d(k) * ( (xout(k)-xeq(j)) / (xeq(i)-xeq(j)) );
303  }
304  }
305  }
306 
307  // deflate end roots
308  if ( i != 0 ) {
309  for (int k=0;k<d.dimension(0);k++) {
310  d(k) = -d(k) / (xeq(i) - xeq(0));
311  }
312  }
313 
314  if (i != order ) {
315  for (int k=0;k<d.dimension(0);k++) {
316  d(k) = d(k) / (xeq(i) - xeq(order));
317  }
318  }
319 
320  for (int k=0;k<d.dimension(0);k++) {
321  warp(k) += d(k);
322  }
323 
324  }
325 
326 
327  return;
328  }
329 
330  template<class Scalar, class ArrayType>
331  void PointTools::getWarpBlendLatticeTriangle( ArrayType &points ,
332  const int order ,
333  const int offset )
334  {
335  /* get Gauss-Lobatto points */
336  Intrepid::FieldContainer<Scalar> gaussX( order + 1 , 1 );
337 
338  PointTools::getWarpBlendLatticeLine<Scalar,FieldContainer<Scalar> >( gaussX , order , 0 );
339 
340  gaussX.resize(gaussX.dimension(0));
341 
342  Scalar alpopt[] = {0.0000,0.0000,1.4152,0.1001,0.2751,0.9800,1.0999,
343  1.2832,1.3648, 1.4773, 1.4959, 1.5743, 1.5770, 1.6223, 1.6258};
344 
345  Scalar alpha;
346 
347  if (order >= 1 && order < 16) {
348  alpha = alpopt[order-1];
349  }
350  else {
351  alpha = 5.0 / 3.0;
352  }
353 
354  const int p = order; /* switch to Warburton's notation */
355  int N = (p+1)*(p+2)/2;
356 
357  /* equidistributed nodes on equilateral triangle */
363 
364  int sk = 0;
365  for (int n=1;n<=p+1;n++) {
366  for (int m=1;m<=p+2-n;m++) {
367  L1(sk) = (n-1) / (Scalar)p;
368  L3(sk) = (m-1) / (Scalar)p;
369  L2(sk) = 1.0 - L1(sk) - L3(sk);
370  sk++;
371  }
372  }
373 
374  for (int n=0;n<N;n++) {
375  X(n) = -L2(n) + L3(n);
376  Y(n) = (-L2(n) - L3(n) + 2*L1(n))/1.7320508075688772;
377  }
378 
379  /* get blending function for each node at each edge */
383 
384  for (int n=0;n<N;n++) {
385  blend1(n) = 4.0 * L2(n) * L3(n);
386  blend2(n) = 4.0 * L1(n) * L3(n);
387  blend3(n) = 4.0 * L1(n) * L2(n);
388  }
389 
390  /* get difference of each barycentric coordinate */
394 
395  for (int k=0;k<N;k++) {
396  L3mL2(k) = L3(k)-L2(k);
397  L1mL3(k) = L1(k)-L3(k);
398  L2mL1(k) = L2(k)-L1(k);
399  }
400 
401  FieldContainer<Scalar> warpfactor1(N);
402  FieldContainer<Scalar> warpfactor2(N);
403  FieldContainer<Scalar> warpfactor3(N);
404 
405  warpFactor<Scalar,FieldContainer<Scalar> >( order , gaussX , L3mL2 , warpfactor1 );
406  warpFactor<Scalar,FieldContainer<Scalar> >( order , gaussX , L1mL3 , warpfactor2 );
407  warpFactor<Scalar,FieldContainer<Scalar> >( order , gaussX , L2mL1 , warpfactor3 );
408 
409  FieldContainer<Scalar> warp1(N);
410  FieldContainer<Scalar> warp2(N);
411  FieldContainer<Scalar> warp3(N);
412 
413  for (int k=0;k<N;k++) {
414  warp1(k) = blend1(k) * warpfactor1(k) *
415  ( 1.0 + alpha * alpha * L1(k) * L1(k) );
416  warp2(k) = blend2(k) * warpfactor2(k) *
417  ( 1.0 + alpha * alpha * L2(k) * L2(k) );
418  warp3(k) = blend3(k) * warpfactor3(k) *
419  ( 1.0 + alpha * alpha * L3(k) * L3(k) );
420  }
421 
422  for (int k=0;k<N;k++) {
423  X(k) += 1.0 * warp1(k) + cos( 2.0 * M_PI / 3.0 ) * warp2(k) + cos(4*M_PI/3.0) * warp3(k);
424  Y(k) += 0.0 * warp1(k) + sin( 2.0 * M_PI / 3.0 ) * warp2(k) + sin( 4*M_PI/3.0) * warp3(k);
425  }
426 
427  FieldContainer<Scalar> warXY(N,2);
428 
429  for (int k=0;k<N;k++) {
430  warXY(k,0) = X(k);
431  warXY(k,1) = Y(k);
432  }
433 
434 
435  // finally, convert the warp-blend points to the correct triangle
436  FieldContainer<Scalar> warburtonVerts(1,3,2);
437  warburtonVerts(0,0,0) = -1.0;
438  warburtonVerts(0,0,1) = -1.0/sqrt(3.0);
439  warburtonVerts(0,1,0) = 1.0;
440  warburtonVerts(0,1,1) = -1.0/sqrt(3.0);
441  warburtonVerts(0,2,0) = 0.0;
442  warburtonVerts(0,2,1) = 2.0/sqrt(3.0);
443 
444  FieldContainer<Scalar> refPts(N,2);
445 
447  warXY ,
448  warburtonVerts ,
449  shards::getCellTopologyData< shards::Triangle<3> >(),
450  0 );
451 
452  // now write from refPts into points, taking care of offset
453  int noffcur = 0; // index into refPts
454  int offcur = 0; // index int points
455  for (int i=0;i<=order;i++) {
456  for (int j=0;j<=order-i;j++) {
457  if ( (i >= offset) && (i <= order-offset) &&
458  (j >= offset) && (j <= order-i-offset) ) {
459  points(offcur,0) = refPts(noffcur,0);
460  points(offcur,1) = refPts(noffcur,1);
461  offcur++;
462  }
463  noffcur++;
464  }
465  }
466 
467  return;
468  }
469 
470 
471  template<class Scalar, class ArrayType>
472  void PointTools::warpShiftFace3D( const int order ,
473  const Scalar pval ,
474  const ArrayType &L1,
475  const ArrayType &L2,
476  const ArrayType &L3,
477  const ArrayType &L4,
478  ArrayType &dxy)
479  {
480  evalshift<Scalar,ArrayType>(order,pval,L2,L3,L4,dxy);
481  return;
482  }
483 
484  template<class Scalar, class ArrayType>
485  void PointTools::evalshift( const int order ,
486  const Scalar pval ,
487  const ArrayType &L1 ,
488  const ArrayType &L2 ,
489  const ArrayType &L3 ,
490  ArrayType &dxy )
491  {
492  // get Gauss-Lobatto-nodes
493  FieldContainer<Scalar> gaussX(order+1,1);
494  PointTools::getWarpBlendLatticeLine<Scalar,FieldContainer<Scalar> >( gaussX , order , 0 );
495  gaussX.resize(order+1);
496  const int N = L1.dimension(0);
497 
498  // Warburton code reverses them
499  for (int k=0;k<=order;k++) {
500  gaussX(k) *= -1.0;
501  }
502 
503  // blending function at each node for each edge
504  FieldContainer<Scalar> blend1(N);
505  FieldContainer<Scalar> blend2(N);
506  FieldContainer<Scalar> blend3(N);
507 
508  for (int i=0;i<N;i++) {
509  blend1(i) = L2(i) * L3(i);
510  blend2(i) = L1(i) * L3(i);
511  blend3(i) = L1(i) * L2(i);
512  }
513 
514  // amount of warp for each node for each edge
515  FieldContainer<Scalar> warpfactor1(N);
516  FieldContainer<Scalar> warpfactor2(N);
517  FieldContainer<Scalar> warpfactor3(N);
518 
519  // differences of barycentric coordinates
520  FieldContainer<Scalar> L3mL2(N);
521  FieldContainer<Scalar> L1mL3(N);
522  FieldContainer<Scalar> L2mL1(N);
523 
524  for (int k=0;k<N;k++) {
525  L3mL2(k) = L3(k)-L2(k);
526  L1mL3(k) = L1(k)-L3(k);
527  L2mL1(k) = L2(k)-L1(k);
528  }
529 
530  evalwarp<Scalar,FieldContainer<Scalar> >( warpfactor1 , order , gaussX , L3mL2 );
531  evalwarp<Scalar,FieldContainer<Scalar> >( warpfactor2 , order , gaussX , L1mL3 );
532  evalwarp<Scalar,FieldContainer<Scalar> >( warpfactor3 , order , gaussX , L2mL1 );
533 
534  for (int k=0;k<N;k++) {
535  warpfactor1(k) *= 4.0;
536  warpfactor2(k) *= 4.0;
537  warpfactor3(k) *= 4.0;
538  }
539 
540  FieldContainer<Scalar> warp1(N);
541  FieldContainer<Scalar> warp2(N);
542  FieldContainer<Scalar> warp3(N);
543 
544  for (int k=0;k<N;k++) {
545  warp1(k) = blend1(k) * warpfactor1(k) *
546  ( 1.0 + pval * pval * L1(k) * L1(k) );
547  warp2(k) = blend2(k) * warpfactor2(k) *
548  ( 1.0 + pval * pval * L2(k) * L2(k) );
549  warp3(k) = blend3(k) * warpfactor3(k) *
550  ( 1.0 + pval * pval * L3(k) * L3(k) );
551  }
552 
553  for (int k=0;k<N;k++) {
554  dxy(k,0) = 1.0 * warp1(k) + cos( 2.0 * M_PI / 3.0 ) * warp2(k) + cos( 4.0*M_PI/3.0 ) * warp3(k);
555  dxy(k,1) = 0.0 * warp1(k) + sin( 2.0 * M_PI / 3.0 ) * warp2(k) + sin( 4.0*M_PI/3.0 ) * warp3(k);
556  }
557 
558  return;
559 
560  }
561 
562  /* one-d edge warping function */
563  template<class Scalar, class ArrayType>
564  void PointTools::evalwarp( ArrayType &warp ,
565  const int order ,
566  const ArrayType &xnodes ,
567  const ArrayType &xout )
568  {
569  FieldContainer<Scalar> xeq(order+1);
570  FieldContainer<Scalar> d(xout.dimension(0));
571 
572  d.initialize();
573 
574  for (int i=0;i<=order;i++) {
575  xeq(i) = -1.0 + 2.0 * ( order - i ) / order;
576  }
577 
578 
579 
580  for (int i=0;i<=order;i++) {
581  d.initialize( xnodes(i) - xeq(i) );
582  for (int j=1;j<order;j++) {
583  if (i!=j) {
584  for (int k=0;k<d.dimension(0);k++) {
585  d(k) = d(k) * (xout(k)-xeq(j))/(xeq(i)-xeq(j));
586  }
587  }
588  }
589  if (i!=0) {
590  for (int k=0;k<d.dimension(0);k++) {
591  d(k) = -d(k)/(xeq(i)-xeq(0));
592  }
593  }
594  if (i!=order) {
595  for (int k=0;k<d.dimension(0);k++) {
596  d(k) = d(k)/(xeq(i)-xeq(order));
597  }
598  }
599 
600  for (int k=0;k<d.dimension(0);k++) {
601  warp(k) += d(k);
602  }
603  }
604 
605  return;
606  }
607 
608 
609  template<class Scalar, class ArrayType>
611  const int order ,
612  const int offset )
613  {
614  Scalar alphastore[] = { 0,0,0,0.1002, 1.1332,1.5608,1.3413,1.2577,1.1603,
615  1.10153,0.6080,0.4523,0.8856,0.8717,0.9655};
616  Scalar alpha;
617 
618  if (order <= 15) {
619  alpha = alphastore[order-1];
620  }
621  else {
622  alpha = 1.0;
623  }
624 
625  const int N = (order+1)*(order+2)*(order+3)/6;
626  Scalar tol = 1.e-10;
627 
628  FieldContainer<Scalar> shift(N,3);
629  shift.initialize();
630 
631  /* create 3d equidistributed nodes on Warburton tet */
632  FieldContainer<Scalar> equipoints(N,3);
633  int sk = 0;
634  for (int n=0;n<=order;n++) {
635  for (int m=0;m<=order-n;m++) {
636  for (int q=0;q<=order-n-m;q++) {
637  equipoints(sk,0) = -1.0 + (q * 2.0 ) / order;
638  equipoints(sk,1) = -1.0 + (m * 2.0 ) / order;
639  equipoints(sk,2) = -1.0 + (n * 2.0 ) / order;
640  sk++;
641  }
642  }
643  }
644 
645 
646  /* construct barycentric coordinates for equispaced lattice */
651  for (int i=0;i<N;i++) {
652  L1(i) = (1.0 + equipoints(i,2)) / 2.0;
653  L2(i) = (1.0 + equipoints(i,1)) / 2.0;
654  L3(i) = -(1.0 + equipoints(i,0) + equipoints(i,1) + equipoints(i,2)) / 2.0;
655  L4(i) = (1.0 + equipoints(i,0)) / 2.0;
656  }
657 
658 
659  /* vertices of Warburton tet */
660  FieldContainer<Scalar> warVerts(4,3);
661  warVerts(0,0) = -1.0;
662  warVerts(0,1) = -1.0/sqrt(3.0);
663  warVerts(0,2) = -1.0/sqrt(6.0);
664  warVerts(1,0) = 1.0;
665  warVerts(1,1) = -1.0/sqrt(3.0);
666  warVerts(1,2) = -1.0/sqrt(6.0);
667  warVerts(2,0) = 0.0;
668  warVerts(2,1) = 2.0 / sqrt(3.0);
669  warVerts(2,2) = -1.0/sqrt(6.0);
670  warVerts(3,0) = 0.0;
671  warVerts(3,1) = 0.0;
672  warVerts(3,2) = 3.0 / sqrt(6.0);
673 
674 
675  /* tangents to faces */
676  FieldContainer<Scalar> t1(4,3);
677  FieldContainer<Scalar> t2(4,3);
678  for (int i=0;i<3;i++) {
679  t1(0,i) = warVerts(1,i) - warVerts(0,i);
680  t1(1,i) = warVerts(1,i) - warVerts(0,i);
681  t1(2,i) = warVerts(2,i) - warVerts(1,i);
682  t1(3,i) = warVerts(2,i) - warVerts(0,i);
683  t2(0,i) = warVerts(2,i) - 0.5 * ( warVerts(0,i) + warVerts(1,i) );
684  t2(1,i) = warVerts(3,i) - 0.5 * ( warVerts(0,i) + warVerts(1,i) );
685  t2(2,i) = warVerts(3,i) - 0.5 * ( warVerts(1,i) + warVerts(2,i) );
686  t2(3,i) = warVerts(3,i) - 0.5 * ( warVerts(0,i) + warVerts(2,i) );
687  }
688 
689  /* normalize tangents */
690  for (int n=0;n<4;n++) {
691  /* Compute norm of t1(n) and t2(n) */
692  Scalar normt1n = 0.0;
693  Scalar normt2n = 0.0;
694  for (int i=0;i<3;i++) {
695  normt1n += (t1(n,i) * t1(n,i));
696  normt2n += (t2(n,i) * t2(n,i));
697  }
698  normt1n = sqrt(normt1n);
699  normt2n = sqrt(normt2n);
700  /* normalize each tangent now */
701  for (int i=0;i<3;i++) {
702  t1(n,i) /= normt1n;
703  t2(n,i) /= normt2n;
704  }
705  }
706 
707  /* undeformed coordinates */
708  FieldContainer<Scalar> XYZ(N,3);
709  for (int i=0;i<N;i++) {
710  for (int j=0;j<3;j++) {
711  XYZ(i,j) = L3(i)*warVerts(0,j) + L4(i)*warVerts(1,j) + L2(i)*warVerts(2,j) + L1(i)*warVerts(3,j);
712  }
713  }
714 
715  for (int face=1;face<=4;face++) {
716  FieldContainer<Scalar> La, Lb, Lc, Ld;
717  FieldContainer<Scalar> warp(N,2);
718  FieldContainer<Scalar> blend(N);
719  FieldContainer<Scalar> denom(N);
720  switch (face) {
721  case 1:
722  La = L1; Lb = L2; Lc = L3; Ld = L4; break;
723  case 2:
724  La = L2; Lb = L1; Lc = L3; Ld = L4; break;
725  case 3:
726  La = L3; Lb = L1; Lc = L4; Ld = L2; break;
727  case 4:
728  La = L4; Lb = L1; Lc = L3; Ld = L2; break;
729  }
730 
731  /* get warp tangential to face */
732  warpShiftFace3D<Scalar,ArrayType>(order,alpha,La,Lb,Lc,Ld,warp);
733 
734  for (int k=0;k<N;k++) {
735  blend(k) = Lb(k) * Lc(k) * Ld(k);
736  }
737 
738  for (int k=0;k<N;k++) {
739  denom(k) = (Lb(k) + 0.5 * La(k)) * (Lc(k) + 0.5*La(k)) * (Ld(k) + 0.5 * La(k));
740  }
741 
742  for (int k=0;k<N;k++) {
743  if (denom(k) > tol) {
744  blend(k) *= ( 1.0 + alpha * alpha * La(k) * La(k) ) / denom(k);
745  }
746  }
747 
748 
749  // compute warp and blend
750  for (int k=0;k<N;k++) {
751  for (int j=0;j<3;j++) {
752  shift(k,j) = shift(k,j) + blend(k) * warp(k,0) * t1(face-1,j)
753  + blend(k) * warp(k,1) * t2(face-1,j);
754  }
755  }
756 
757  for (int k=0;k<N;k++) {
758  if (La(k) < tol && ( Lb(k) < tol || Lc(k) < tol || Ld(k) < tol )) {
759  for (int j=0;j<3;j++) {
760  shift(k,j) = warp(k,0) * t1(face-1,j) + warp(k,1) * t2(face-1,j);
761  }
762  }
763  }
764 
765  }
766 
767  FieldContainer<Scalar> updatedPoints(N,3);
768  for (int k=0;k<N;k++) {
769  for (int j=0;j<3;j++) {
770  updatedPoints(k,j) = XYZ(k,j) + shift(k,j);
771  }
772  }
773 
774  warVerts.resize( 1 , 4 , 3 );
775 
776  // now we convert to Pavel's reference triangle!
777  FieldContainer<Scalar> refPts(N,3);
778  CellTools<Scalar>::mapToReferenceFrame( refPts ,updatedPoints ,
779  warVerts ,
780  shards::getCellTopologyData<shards::Tetrahedron<4> >() ,
781  0 );
782 
783  // now write from refPts into points, taking offset into account
784  int noffcur = 0;
785  int offcur = 0;
786  for (int i=0;i<=order;i++) {
787  for (int j=0;j<=order-i;j++) {
788  for (int k=0;k<=order-i-j;k++) {
789  if ( (i >= offset) && (i <= order-offset) &&
790  (j >= offset) && (j <= order-i-offset) &&
791  (k >= offset) && (k <= order-i-j-offset) ) {
792  points(offcur,0) = refPts(noffcur,0);
793  points(offcur,1) = refPts(noffcur,1);
794  points(offcur,2) = refPts(noffcur,2);
795  offcur++;
796  }
797  noffcur++;
798  }
799  }
800  }
801 
802 
803 
804  }
805 
806 
807 } // face Intrepid
static void getWarpBlendLatticeLine(ArrayType &points, const int order, const int offset=0)
Returns the Gauss-Lobatto points of a given order on the reference line [-1,1]. The output array is (...
static void getGaussPoints(ArrayType &pts, const int order)
static void mapToReferenceFrame(ArrayRefPoint &refPoints, const ArrayPhysPoint &physPoints, const ArrayCell &cellWorkset, const shards::CellTopology &cellTopo, const int &whichCell=-1)
Computes , the inverse of the reference-to-physical frame map using a default initial guess...
static void warpShiftFace3D(const int order, const Scalar pval, const ArrayType &L1, const ArrayType &L2, const ArrayType &L3, const ArrayType &L4, ArrayType &dxy)
This is used internally to compute the tetrahedral warp-blend points one each face.
static void zwglj(Scalar *z, Scalar *w, const int np, const Scalar alpha, const Scalar beta)
Gauss-Lobatto-Jacobi zeros and weights with end point at z=-1,1.
static void warpFactor(const int order, const ArrayType &xnodes, const ArrayType &xout, ArrayType &warp)
interpolates Warburton&#39;s warp function on the line
static void evalwarp(ArrayType &warp, const int order, const ArrayType &xnodes, const ArrayType &xout)
Used internally to compute the warp on edges of a triangle in warp-blend points.
static void getWarpBlendLatticeTetrahedron(ArrayType &points, const int order, const int offset=0)
Returns Warburton&#39;s warp-blend points of a given order on the reference tetrahedron. The output array is (P,3), where.
static void evalshift(const int order, const Scalar pval, const ArrayType &L1, const ArrayType &L2, const ArrayType &L3, ArrayType &dxy)
Used internally to evaluate the point shift for warp-blend points on faces of tets.
static void getEquispacedLatticeTetrahedron(ArrayType &points, const int order, const int offset=0)
Computes an equispaced lattice of a given order on the reference tetrahedron. The output array is (P...
static void getEquispacedLatticeTriangle(ArrayType &points, const int order, const int offset=0)
Computes an equispaced lattice of a given order on the reference triangle. The output array is (P...
void resize(const int dim0)
Resizes FieldContainer to a rank-1 container with the specified dimension, initialized by 0...
void initialize(const Scalar value=0)
Initializes a field container by assigning value to all its elements.
EPointType
Enumeration of types of point distributions in Intrepid.
static void getLattice(ArrayType &pts, const shards::CellTopology &cellType, const int order, const int offset=0, const EPointType pointType=POINTTYPE_EQUISPACED)
Computes a lattice of points of a given order on a reference simplex (currently disabled for other ce...
static void getWarpBlendLattice(const shards::CellTopology &cellType, ArrayType &points, const int order, const int offset=0)
Computes a warped lattice (ala Warburton&#39;s warp-blend points of a given order on a reference simplex ...
static void zwgj(Scalar *z, Scalar *w, const int np, const Scalar alpha, const Scalar beta)
Gauss-Jacobi zeros and weights.
static void getWarpBlendLatticeTriangle(ArrayType &points, const int order, const int offset=0)
Returns Warburton&#39;s warp-blend points of a given order on the reference triangle. The output array is...
static void getEquispacedLattice(const shards::CellTopology &cellType, ArrayType &points, const int order, const int offset=0)
Computes an equispaced lattice of a given order on a reference simplex (currently disabled for other ...
static void getEquispacedLatticeLine(ArrayType &points, const int order, const int offset=0)
Computes an equispaced lattice of a given order on the reference line [-1,1]. The output array is (P...
static int getLatticeSize(const shards::CellTopology &cellType, const int order, const int offset=0)
Computes the number of points in a lattice of a given order on a simplex (currently disabled for othe...