GEOS
LagrangeBasis3GL.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_LAGRANGEBASIS3GL_HPP_
17 #define GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_ELEMENTFORMULATIONS_LAGRANGEBASIS3GL_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 = 4;
44 
46  constexpr static real64 sqrt5 = 2.2360679774997897;
47 
54  inline
55  constexpr static real64 weight( const int q )
56  {
57  switch( q )
58  {
59  case 1:
60  case 2:
61  return 5.0/6.0;
62  default:
63  return 1.0/6.0;
64  }
65  }
66 
74  inline
75  // MODIF1 : Harcoding the Gauss-Lobatto coordinates and return the right one
76  // depending on the supportPointIndex value
77  //Switch case
78  constexpr static real64 parentSupportCoord( const localIndex supportPointIndex )
79  {
80  real64 result=0.0;
81 
82  switch( supportPointIndex )
83  {
84  case 0:
85  result = -1.0;
86  break;
87  case 1:
88  result = -1.0/sqrt5;
89  break;
90  case 2:
91  result = 1.0/sqrt5;
92  break;
93  case 3:
94  result = 1.0;
95  break;
96  default:
97  break;
98  }
99 
100  return result;
101  }
102 
103 
112  inline
113 //MODIF3 : Change the way to return the base function evaluated at the desired coord
114  constexpr static real64 value( const int index,
115  const real64 xi )
116  {
117  real64 result=0.0;
118 
119  switch( index )
120  {
121  case 0:
122  result = LagrangeBasis3GL::value0( xi );
123  break;
124  case 1:
125  result = LagrangeBasis3GL::value1( xi );
126  break;
127  case 2:
128  result = LagrangeBasis3GL::value2( xi );
129  break;
130  case 3:
131  result = LagrangeBasis3GL::value3( xi );
132  break;
133  default:
134  break;
135  }
136 
137  return result;
138  }
139 
140 
147  inline
148  //MODFI4 : Implemented new base functions and their derivative for Q3
149  constexpr static real64 value0( const real64 xi )
150  {
151  return -(5.0/8.0)*(xi*xi*xi-xi*xi-(1.0/5.0)*xi+1.0/5.0);
152  }
153 
160  inline
161  constexpr static real64 value1( const real64 xi )
162  {
163  return (5.0*sqrt5/8.0)*(xi*xi*xi-(1.0/sqrt5)*xi*xi-xi+1.0/sqrt5);
164  }
165 
172  inline
173  constexpr static real64 value2( const real64 xi )
174  {
175  return -(5.0*sqrt5/8.0)*(xi*xi*xi+(1.0/sqrt5)*xi*xi-xi-1.0/sqrt5);
176  }
177 
184  inline
185  constexpr static real64 value3( const real64 xi )
186  {
187  return (5.0/8.0)*(xi*xi*xi+xi*xi-(1.0/5.0)*xi-1.0/5.0);
188  }
189 
190 
199  inline
200  //MODIF5 : New function returning the derivated base function at desired coord
201  constexpr static real64 gradient( const int index,
202  const real64 xi )
203  {
204  real64 result=0.0;
205 
206  switch( index )
207  {
208  case 0:
209  result = LagrangeBasis3GL::gradient0( xi );
210  break;
211  case 1:
212  result = LagrangeBasis3GL::gradient1( xi );
213  break;
214  case 2:
215  result = LagrangeBasis3GL::gradient2( xi );
216  break;
217  case 3:
218  result = LagrangeBasis3GL::gradient3( xi );
219  break;
220  default:
221  break;
222  }
223 
224  return result;
225  }
226 
234  inline
235  constexpr static real64 gradient0( const real64 xi )
236  {
237  return -(5.0/8.0)*(3.0*xi*xi-2.0*xi-(1.0/5.0));
238  }
239 
247  inline
248  constexpr static real64 gradient1( const real64 xi )
249  {
250  return (5.0*sqrt5/8.0)*(3.0*xi*xi-(2.0/sqrt5)*xi-1.0);
251  }
252 
260  inline
261  constexpr static real64 gradient2( const real64 xi )
262  {
263  return -(5.0*sqrt5/8.0)*(3.0*xi*xi+(2.0/sqrt5)*xi-1.0);
264  }
265 
273  inline
274  constexpr static real64 gradient3( const real64 xi )
275  {
276  return (5.0/8.0)*(3.0*xi*xi+2.0*xi-(1.0/5.0));;
277  }
278 
288  constexpr static real64 gradientAt( const int q,
289  const int p )
290  {
291  switch( q )
292  {
293  case 0:
294  return p == 0 ? -3.0 : -0.80901699437494742410;
295  case 1:
296  return p == 0 ? 4.0450849718747371205 : 0.0;
297  case 2:
298  return p == 0 ? -1.5450849718747371205 : 1.1180339887498948482;
299  case 3:
300  return p == 0 ? 0.5 : -0.30901699437494742410;
301  default:
302  return 0;
303  }
304  }
305 
332  {
334  constexpr static localIndex numSupportPoints = 16;
335 
344  inline
345  constexpr static int linearIndex( const int i,
346  const int j )
347  {
348  return i + 4 * j;
349  }
350 
351 
352 
361  inline
362  constexpr static void multiIndex( int const linearIndex,
363  int & i0,
364  int & i1 )
365  {
366 
367  i1 = linearIndex/4;
368 
369  i0 = linearIndex%4;
370 
371  }
372 
373 
382  inline
383  static void value( const real64 (& coords)[2],
384  real64 (& N)[numSupportPoints] )
385  {
386  for( int a=0; a<4; ++a )
387  {
388  for( int b=0; b<4; ++b )
389  {
390  const int lindex = LagrangeBasis3GL::TensorProduct2D::linearIndex( a, b );
391  N[ lindex ] = LagrangeBasis3GL::value( a, coords[0] ) *
392  LagrangeBasis3GL::value( b, coords[1] );
393  }
394  }
395  }
396  };
397 
434  {
436  constexpr static localIndex numSupportPoints = 64;
437 
447  inline
448  //MODIF6 : Change linearIndex for 64 nodes
449  constexpr static int linearIndex( const int i,
450  const int j,
451  const int k )
452  {
453  return i + 4 * j + 16 * k;
454  }
455 
456 
457 
467  inline
468  //MODIF7 : Change calcul of multiIndex
469  constexpr static void multiIndex( int const linearIndex,
470  int & i0,
471  int & i1,
472  int & i2 )
473  {
474 
475  i2 = linearIndex/16;
476 
477  i1 = (linearIndex%16)/4;
478 
479  i0 = (linearIndex%16)%4;
480 
481  }
482 
483 
492  inline
493  static void value( const real64 (& coords)[3],
494  real64 (& N)[numSupportPoints] )
495  {
496  for( int a=0; a<4; ++a )
497  {
498  for( int b=0; b<4; ++b )
499  {
500  for( int c=0; c<4; ++c )
501  {
502  const int lindex = LagrangeBasis3GL::TensorProduct3D::linearIndex( a, b, c );
503  N[ lindex ] = LagrangeBasis3GL::value( a, coords[0] ) *
504  LagrangeBasis3GL::value( b, coords[1] ) *
505  LagrangeBasis3GL::value( c, coords[2] );
506  }
507  }
508  }
509  }
510  };
511 };
512 
513 
514 }
515 }
516 
517 
518 #endif /* GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_ELEMENTFORMULATIONS_LAGRANGEBASIS3GL_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
constexpr static GEOS_HOST_DEVICE real64 parentSupportCoord(const localIndex supportPointIndex)
Calculate the parent coordinates for the xi0 direction, given the linear index of a support point.
constexpr static GEOS_HOST_DEVICE real64 gradient1(const real64 xi)
The gradient of the basis function for support point 1 evaluated at a point along the axes.
constexpr static GEOS_HOST_DEVICE real64 value3(const real64 xi)
The value of the basis function for support point 3.
constexpr static GEOS_HOST_DEVICE real64 gradient3(const real64 xi)
The gradient of the basis function for support point 3 evaluated at a point along the axes.
constexpr static GEOS_HOST_DEVICE real64 value0(const real64 xi)
The value of the basis function for support point 0.
constexpr static GEOS_HOST_DEVICE real64 gradient0(const real64 xi)
The gradient of the basis function for support point 0 evaluated at a point along the axes.
constexpr static real64 sqrt5
sqrt(5)
constexpr static GEOS_HOST_DEVICE 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.
constexpr static localIndex numSupportPoints
The number of support points for the basis.
constexpr static GEOS_HOST_DEVICE real64 gradient2(const real64 xi)
The gradient of the basis function for support point 1 evaluated at a point along the axes.
constexpr static GEOS_HOST_DEVICE real64 value2(const real64 xi)
The value of the basis function for support point 2.
constexpr static GEOS_HOST_DEVICE real64 weight(const int q)
The value of the weight for the given support point.
constexpr static GEOS_HOST_DEVICE real64 value1(const real64 xi)
The value of the basis function for support point 1.
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....
constexpr static GEOS_HOST_DEVICE 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.
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.
constexpr static GEOS_HOST_DEVICE int linearIndex(const int i, const int j)
Calculates the linear index for support/quadrature points from ij coordinates.
constexpr static GEOS_HOST_DEVICE void multiIndex(int const linearIndex, int &i0, int &i1)
Calculate the Cartesian/TensorProduct index given the linear index of a support point.
static GEOS_HOST_DEVICE 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.
constexpr static GEOS_HOST_DEVICE int linearIndex(const int i, const int j, const int k)
Calculates the linear index for support/quadrature points from ijk coordinates.
constexpr static localIndex numSupportPoints
The number of support points in the 3D tensor product.
static GEOS_HOST_DEVICE 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 GEOS_HOST_DEVICE void multiIndex(int const linearIndex, int &i0, int &i1, int &i2)
Calculate the Cartesian/TensorProduct index given the linear index of a support point.