GEOS
H1_TriangleFace_Lagrange1_Gauss1.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 
20 #ifndef GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1TRIANGLEFACELAGRANGE1GAUSS1_HPP_
21 #define GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1TRIANGLEFACELAGRANGE1GAUSS1_HPP_
22 
23 #include "FiniteElementBase.hpp"
24 #include "LagrangeBasis1.hpp"
25 
26 
27 namespace geos
28 {
29 namespace finiteElement
30 {
31 
51 {
52 public:
53 
56 
58  constexpr static localIndex numNodes = 3;
60  constexpr static localIndex maxSupportPoints = numNodes;
61 
63  constexpr static localIndex numQuadraturePoints = 1;
64 
66  virtual ~H1_TriangleFace_Lagrange1_Gauss1() override
67  {}
68 
70  virtual localIndex getNumQuadraturePoints() const override
71  {
72  return numQuadraturePoints;
73  }
74 
82  {
83  GEOS_UNUSED_VAR( stack );
84  return numQuadraturePoints;
85  }
86 
88  virtual localIndex getNumSupportPoints() const override
89  {
90  return numNodes;
91  }
92 
100  {
101  GEOS_UNUSED_VAR( stack );
102  return numNodes;
103  }
104 
106  virtual localIndex getMaxSupportPoints() const override
107  {
108  return maxSupportPoints;
109  }
110 
118  static void calcN( real64 const (&coords)[2],
119  real64 ( &N )[numNodes] );
120 
121 
130  static void calcN( localIndex const q,
131  real64 ( &N )[numNodes] );
132 
142  inline
143  static void calcN( localIndex const q,
144  StackVariables const & stack,
145  real64 ( &N )[numNodes] );
146 
154  static void calcBubbleN( real64 const (&pointCoord)[2],
155  real64 (& N)[1] )
156  {
157 
158  real64 const r = pointCoord[0];
159  real64 const s = pointCoord[1];
160 
161  N[0] = (1.0 - r - s) * r * s;
162 
163  }
164 
172  inline
173  static void calcBubbleN( localIndex const q,
174  real64 (& N)[1] )
175  {
176  GEOS_UNUSED_VAR( q );
177 
178  // single quadrature point (centroid), i.e. r = s = 1/3
179  real64 const qCoords[2] = { 1.0 / 3.0, 1.0 / 3.0};
180  calcBubbleN( qCoords, N );
181  }
182 
192  real64 const (&X)[numNodes][3] );
193 
203  template< localIndex NUMDOFSPERTRIALSUPPORTPOINT, bool UPPER >
205  inline
206  static void addGradGradStabilization( StackVariables const & stack,
207  real64 ( &matrix )
208  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT]
209  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT],
210  real64 const & scaleFactor );
211 
218  inline
219  static void getPermutation( int (& permutation)[numNodes] )
220  {
221  permutation[0] = 0;
222  permutation[1] = 1;
223  permutation[2] = 2;
224  }
225 
226 private:
228  constexpr static real64 parentArea = 0.5;
229 
231  constexpr static real64 weight = parentArea / numQuadraturePoints;
232 
233 };
234 
236 
237 template< localIndex NUMDOFSPERTRIALSUPPORTPOINT, bool UPPER >
239 inline
241  addGradGradStabilization( StackVariables const & stack,
242  real64 ( & matrix )
243  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT]
244  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT],
245  real64 const & scaleFactor )
246 {
247  GEOS_UNUSED_VAR( stack );
248  GEOS_UNUSED_VAR( matrix );
249  GEOS_UNUSED_VAR( scaleFactor );
250 }
251 
253 inline
254 void
256  calcN( real64 const (&coords)[2],
257  real64 ( & N )[numNodes] )
258 {
259  real64 const r = coords[0];
260  real64 const s = coords[1];
261 
262  N[0] = 1.0 - r - s;
263  N[1] = r;
264  N[2] = s;
265 }
266 
268 inline
269 void
271  calcN( localIndex const q,
272  real64 (& N)[numNodes] )
273 {
274  GEOS_UNUSED_VAR( q );
275 
276  // single quadrature point (centroid), i.e. r = s = 1/3
277  N[0] = 1.0 / 3.0; // N0 = 1 - r - s
278  N[1] = N[0]; // N1 = r
279  N[2] = N[0]; // N2 = s
280 }
281 
283 inline
285  calcN( localIndex const q,
286  StackVariables const & GEOS_UNUSED_PARAM( stack ),
287  real64 ( & N )[numNodes] )
288 {
289  return calcN( q, N );
290 }
291 
292 //*************************************************************************************************
293 
295 inline
296 real64
299  real64 const (&X)[numNodes][3] )
300 {
301  GEOS_UNUSED_VAR( q );
302  real64 n[3] = { ( X[1][1] - X[0][1] ) * ( X[2][2] - X[0][2] ) - ( X[2][1] - X[0][1] ) * ( X[1][2] - X[0][2] ),
303  ( X[2][0] - X[0][0] ) * ( X[1][2] - X[0][2] ) - ( X[1][0] - X[0][0] ) * ( X[2][2] - X[0][2] ),
304  ( X[1][0] - X[0][0] ) * ( X[2][1] - X[0][1] ) - ( X[2][0] - X[0][0] ) * ( X[1][1] - X[0][1] )};
305  return sqrt( n[0] * n[0] + n[1] * n[1] + n[2] * n[2] ) * weight;
306 }
307 
309 
310 }
311 }
312 #endif //GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1TRIANGLEFACELAGRANGE1GAUSS1_HPP_
#define GEOS_HOST_DEVICE
Marks a host-device function.
Definition: GeosxMacros.hpp:49
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
Definition: GeosxMacros.hpp:51
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:72
Base class for FEM element implementations.
constexpr static localIndex maxSupportPoints
The maximum number of support points per element.
static GEOS_HOST_DEVICE real64 transformedQuadratureWeight(localIndex const q, real64 const (&X)[numNodes][3])
Calculate the integration weights for a quadrature point.
virtual GEOS_HOST_DEVICE localIndex getNumQuadraturePoints() const override
Virtual getter for the number of quadrature points per element.
static GEOS_HOST_DEVICE localIndex getNumSupportPoints(StackVariables const &stack)
Get the number of support points.
static GEOS_HOST_DEVICE void getPermutation(int(&permutation)[numNodes])
Calculate the node permutation between the parent element and the geometric element....
constexpr static localIndex numNodes
The number of nodes/support points per element.
static GEOS_HOST_DEVICE void addGradGradStabilization(StackVariables const &stack, real64(&matrix)[maxSupportPoints *NUMDOFSPERTRIALSUPPORTPOINT][maxSupportPoints *NUMDOFSPERTRIALSUPPORTPOINT], real64 const &scaleFactor)
Empty method, here for compatibility with methods that require a stabilization of the grad-grad bilin...
static GEOS_HOST_DEVICE void calcN(localIndex const q, StackVariables const &stack, real64(&N)[numNodes])
Calculate shape functions values for each support point at a quadrature point.
constexpr static localIndex numQuadraturePoints
The number of quadrature points per element.
static GEOS_HOST_DEVICE void calcN(localIndex const q, real64(&N)[numNodes])
Calculate shape functions values for each support point at a quadrature point.
static GEOS_HOST_DEVICE void calcBubbleN(localIndex const q, real64(&N)[1])
Calculate shape bubble functions values at a quadrature point.
static GEOS_HOST_DEVICE localIndex getNumQuadraturePoints(StackVariables const &stack)
Get the number of quadrature points.
GEOS_HOST_DEVICE static GEOS_FORCE_INLINE void calcBubbleN(real64 const (&pointCoord)[2], real64(&N)[1])
Calculate shape bubble functions values at a given point in the parent space.
virtual GEOS_HOST_DEVICE localIndex getNumSupportPoints() const override
Virtual getter for the number of support points per element.
GEOS_HOST_DEVICE static GEOS_FORCE_INLINE void calcN(real64 const (&coords)[2], real64(&N)[numNodes])
Calculate shape functions values at a single point.
virtual GEOS_HOST_DEVICE localIndex getMaxSupportPoints() const override
Get the maximum number of support points for this element.
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