GEOS
LagrangeBasis4GL.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 Total, S.A
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
16 #ifndef GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_ELEMENTFORMULATIONS_LAGRANGEBASIS4GL_HPP_
17 #define GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_ELEMENTFORMULATIONS_LAGRANGEBASIS4GL_HPP_
18 
23 #include "common/DataTypes.hpp"
24 
25 namespace geos
26 {
27 namespace finiteElement
28 {
29 
40 {
41 public:
43  constexpr static localIndex numSupportPoints = 5;
44 
46  constexpr static real64 sqrt3_7 = 0.6546536707079771;
47 
55  constexpr static real64 weight( const int q )
56  {
57  switch( q )
58  {
59  case 0:
60  case 4:
61  return 1.0/10.0;
62  case 1:
63  case 3:
64  return 49.0/90.0;
65  default:
66  return 32.0/45.0;
67  }
68  }
69 
78  // depending on the supportPointIndex value
79  //Switch case
80  constexpr static real64 parentSupportCoord( const localIndex supportPointIndex )
81  {
82  real64 result=0.0;
83 
84  switch( supportPointIndex )
85  {
86  case 0:
87  result = -1.0;
88  break;
89  case 1:
90  result = -sqrt3_7;
91  break;
92  case 2:
93  result = 0.0;
94  break;
95  case 3:
96  result = sqrt3_7;
97  break;
98  case 4:
99  result = 1.0;
100  break;
101  default:
102  break;
103  }
104 
105  return result;
106  }
107 
108 
118  constexpr static real64 value( const int index,
119  const real64 xi )
120  {
121  real64 result=0.0;
122 
123  switch( index )
124  {
125  case 0:
126  result = LagrangeBasis4GL::value0( xi );
127  break;
128  case 1:
129  result = LagrangeBasis4GL::value1( xi );
130  break;
131  case 2:
132  result = LagrangeBasis4GL::value2( xi );
133  break;
134  case 3:
135  result = LagrangeBasis4GL::value3( xi );
136  break;
137  case 4:
138  result = LagrangeBasis4GL::value4( xi );
139  break;
140  default:
141  break;
142  }
143 
144  return result;
145  }
146 
147 
155  //MODFI4 : Implemented new base functions and their derivative for Q3
156  constexpr static real64 value0( const real64 xi )
157  {
158  return (1.0/8.0)*(-1.0+xi)*xi*(-3.0+7.0*xi*xi);
159  }
160 
168  constexpr static real64 value1( const real64 xi )
169  {
170  return (49.0/24.0)*(sqrt3_7-xi)*xi*(-1.0+xi*xi);
171  }
172 
180  constexpr static real64 value2( const real64 xi )
181  {
182  return (1.0/3.0)*(3.0-10.0*xi*xi+7.0*xi*xi*xi*xi);
183  }
184 
192  constexpr static real64 value3( const real64 xi )
193  {
194  return -(49.0/24.0)*(sqrt3_7+xi)*xi*(-1.0+xi*xi);
195  }
196 
204  constexpr static real64 value4( const real64 xi )
205  {
206  return (1.0/8.0)*(1.0+xi)*xi*(-3.0+7.0*xi*xi);
207  }
208 
209 
219  constexpr static real64 gradient( const int index,
220  const real64 xi )
221  {
222  real64 result=0.0;
223 
224  switch( index )
225  {
226  case 0:
227  result = LagrangeBasis4GL::gradient0( xi );
228  break;
229  case 1:
230  result = LagrangeBasis4GL::gradient1( xi );
231  break;
232  case 2:
233  result = LagrangeBasis4GL::gradient2( xi );
234  break;
235  case 3:
236  result = LagrangeBasis4GL::gradient3( xi );
237  break;
238  case 4:
239  result = LagrangeBasis4GL::gradient4( xi );
240  break;
241  default:
242  break;
243  }
244 
245  return result;
246  }
247 
256  constexpr static real64 gradient0( const real64 xi )
257  {
258  return (1.0/8.0)*(3.0+xi*(-6.0+7.0*xi*(-3.0+4.0*xi)));
259  }
260 
269  constexpr static real64 gradient1( const real64 xi )
270  {
271  return (49.0/24.0)*(-sqrt3_7+xi*(2.0+3.0*sqrt3_7*xi-4.0*xi*xi));
272  }
273 
282  constexpr static real64 gradient2( const real64 xi )
283  {
284  return (4.0/3.0)*xi*(-5.0+7.0*xi*xi);
285  }
286 
295  constexpr static real64 gradient3( const real64 xi )
296  {
297  return (49.0/24.0)*(sqrt3_7+xi*(2.0-3.0*sqrt3_7*xi-4.0*xi*xi));
298  }
299 
308  constexpr static real64 gradient4( const real64 xi )
309  {
310  return (1.0/8.0)*(-3.0+xi*(-6.0+7.0*xi*(3.0+4.0*xi)));
311  }
312 
322  constexpr static real64 gradientAt( const int q,
323  const int p )
324  {
325  switch( q )
326  {
327  case 0:
328  switch( p )
329  {
330  case 0: return -5.0000000000000000000;
331  case 1: return -1.2409902530309828578;
332  case 2: return 0.37500000000000000000;
333  }
334  break;
335  case 1:
336  switch( p )
337  {
338  case 0: return 6.7565024887242400038;
339  case 1: return 0.0;
340  case 2: return -1.3365845776954533353;
341  }
342  break;
343  case 2:
344  switch( p )
345  {
346  case 0: return -2.6666666666666666667;
347  case 1: return 1.7457431218879390501;
348  case 2: return 0.0;
349  }
350  break;
351  case 3:
352  switch( p )
353  {
354  case 0: return 1.4101641779424266628;
355  case 1: return -0.7637626158259733344;
356  case 2: return 1.3365845776954533353;
357  }
358  break;
359  case 4:
360  switch( p )
361  {
362  case 0: return -0.50000000000000000000;
363  case 1: return 0.25900974696901714215;
364  case 2: return -0.37500000000000000000;
365  }
366  break;
367  }
368  return 0;
369  }
370 
397  {
399  constexpr static localIndex numSupportPoints = 25;
400 
410  constexpr static int linearIndex( const int i,
411  const int j )
412  {
413  return i + 5 * j;
414  }
415 
416 
417 
427  constexpr static void multiIndex( int const linearIndex,
428  int & i0,
429  int & i1 )
430  {
431 
432  i1 = linearIndex/5;
433 
434  i0 = linearIndex%5;
435 
436  }
437 
438 
448  static void value( const real64 (& coords)[2],
449  real64 (& N)[numSupportPoints] )
450  {
451  for( int a=0; a<5; ++a )
452  {
453  for( int b=0; b<5; ++b )
454  {
455  const int lindex = LagrangeBasis4GL::TensorProduct2D::linearIndex( a, b );
456  N[ lindex ] = LagrangeBasis4GL::value( a, coords[0] ) *
457  LagrangeBasis4GL::value( b, coords[1] );
458  }
459  }
460  }
461  };
462 
499  {
501  constexpr static localIndex numSupportPoints = 125;
502 
513  constexpr static int linearIndex( const int i,
514  const int j,
515  const int k )
516  {
517  return i + 5 * j + 25 * k;
518  }
519 
520 
521 
532  constexpr static void multiIndex( int const linearIndex,
533  int & i0,
534  int & i1,
535  int & i2 )
536  {
537 
538  i2 = linearIndex/25;
539 
540  i1 = (linearIndex%25)/5;
541 
542  i0 = (linearIndex%25)%5;
543 
544  }
545 
546 
556  static void value( const real64 (& coords)[3],
557  real64 (& N)[numSupportPoints] )
558  {
559  for( int a=0; a<5; ++a )
560  {
561  for( int b=0; b<5; ++b )
562  {
563  for( int c=0; c<5; ++c )
564  {
565  const int lindex = LagrangeBasis4GL::TensorProduct3D::linearIndex( a, b, c );
566  N[ lindex ] = LagrangeBasis4GL::value( a, coords[0] ) *
567  LagrangeBasis4GL::value( b, coords[1] ) *
568  LagrangeBasis4GL::value( c, coords[2] );
569  }
570  }
571  }
572  }
573  };
574 };
575 
576 
577 }
578 }
579 
580 
581 #endif /* GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_ELEMENTFORMULATIONS_LAGRANGEBASIS4GL_HPP_ */
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
Definition: GeosxMacros.hpp:51
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 parentSupportCoord(const localIndex supportPointIndex)
Calculate the parent coordinates for the xi0 direction, given the linear index of a support point.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradient0(const real64 xi)
The gradient of the basis function for support point 0 evaluated at a point along the axes.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradientAt(const int q, const int p)
The gradient of the basis function for a support point evaluated at a given support point....
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 value4(const real64 xi)
The value of the basis function for support point 4.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 weight(const int q)
The value of the weight for the given support point.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 value0(const real64 xi)
The value of the basis function for support point 0.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 value1(const real64 xi)
The value of the basis function for support point 1.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 value2(const real64 xi)
The value of the basis function for support point 2.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradient(const int index, const real64 xi)
The gradient of the basis function for a support point evaluated at a point along the axes.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 value3(const real64 xi)
The value of the basis function for support point 3.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 value(const int index, const real64 xi)
The value of the basis function for a support point evaluated at a point along the axes.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradient1(const real64 xi)
The gradient of the basis function for support point 1 evaluated at a point along the axes.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradient2(const real64 xi)
The gradient of the basis function for support point 1 evaluated at a point along the axes.
constexpr static real64 sqrt3_7
sqrt(3/7)
constexpr static localIndex numSupportPoints
The number of support points for the basis.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradient4(const real64 xi)
The gradient of the basis function for support point 4 evaluated at a point along the axes.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE real64 gradient3(const real64 xi)
The gradient of the basis function for support point 3 evaluated at a point along the axes.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
constexpr static localIndex numSupportPoints
The number of support points in the 2D tensor product.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE void multiIndex(int const linearIndex, int &i0, int &i1)
Calculate the Cartesian/TensorProduct index given the linear index of a support point.
GEOS_HOST_DEVICE static GEOS_FORCE_INLINE void value(const real64(&coords)[2], real64(&N)[numSupportPoints])
The value of the basis function for a support point evaluated at a point along the axes.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE int linearIndex(const int i, const int j)
Calculates the linear index for support/quadrature points from ij coordinates.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE void multiIndex(int const linearIndex, int &i0, int &i1, int &i2)
Calculate the Cartesian/TensorProduct index given the linear index of a support point.
GEOS_HOST_DEVICE constexpr static GEOS_FORCE_INLINE int linearIndex(const int i, const int j, const int k)
Calculates the linear index for support/quadrature points from ijk coordinates.
GEOS_HOST_DEVICE static GEOS_FORCE_INLINE void value(const real64(&coords)[3], real64(&N)[numSupportPoints])
The value of the basis function for a support point evaluated at a point along the axes.
constexpr static localIndex numSupportPoints
The number of support points in the 3D tensor product.