GEOS
H1_TriangleFace_Lagrange1_Gauss.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 TotalEnergies
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_H1TRIANGLEFACELAGRANGE1GAUSS_HPP_
21 #define GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1TRIANGLEFACELAGRANGE1GAUSS_HPP_
22 
23 #include "FiniteElementBase.hpp"
24 #include "LagrangeBasis1.hpp"
25 
26 
27 namespace geos
28 {
29 namespace finiteElement
30 {
31 
50 template< typename NUM_Q_POINTS >
51 class H1_TriangleFace_Lagrange1_Gauss_impl : public FiniteElementBase_impl< 3, 3, NUM_Q_POINTS::value >
52 {
53 public:
56 
58  using StackVariables = typename Base::StackVariables;
59 
61  template< typename SubregionType >
62  using MeshData = typename Base::template MeshData< SubregionType >;
63 
65  using Base::numNodes;
66 
69 
72 
74  static_assert( ( NUM_Q_POINTS::value == 1 ||
75  NUM_Q_POINTS::value == 4 ||
76  NUM_Q_POINTS::value == 6 ),
77  "NUM_Q_POINTS::value must be 1, 4, or 6!" );
78 
81 
90 
94  {
95  return numQuadraturePoints;
96  }
97 
105  {
106  GEOS_UNUSED_VAR( stack );
107  return numQuadraturePoints;
108  }
109 
113  {
114  return numNodes;
115  }
116 
124  {
125  GEOS_UNUSED_VAR( stack );
126  return numNodes;
127  }
128 
132  {
133  return maxSupportPoints;
134  }
135 
143  static void calcN( real64 const (&coords)[2],
144  real64 ( &N )[numNodes] );
145 
146 
155  static void calcN( localIndex const q,
156  real64 ( &N )[numNodes] );
157 
167  inline
168  static void calcN( localIndex const q,
169  StackVariables const & stack,
170  real64 ( &N )[numNodes] );
171 
179  static void calcBubbleN( real64 const (&pointCoord)[2],
180  real64 (& N)[1] )
181  {
182 
183  real64 const r = pointCoord[0];
184  real64 const s = pointCoord[1];
185 
186  N[0] = (1.0 - r - s) * r * s;
187 
188  }
189 
197  inline
198  static void calcBubbleN( localIndex const q,
199  real64 (& N)[1] )
200  {
201 
202  real64 const qCoords[2] = {quadratureParentCoords0( q ), quadratureParentCoords1( q ) };
203 
204  calcBubbleN( qCoords, N );
205  }
206 
216  real64 const (&X)[numNodes][3] );
217 
227  template< localIndex NUMDOFSPERTRIALSUPPORTPOINT, bool UPPER >
229  inline
230  static void addGradGradStabilization( StackVariables const & stack,
231  real64 ( &matrix )
232  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT]
233  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT],
234  real64 const & scaleFactor );
235 
242  inline
243  static void getPermutation( int (& permutation)[numNodes] )
244  {
245  permutation[0] = 0;
246  permutation[1] = 1;
247  permutation[2] = 2;
248  }
249 
250 private:
252  constexpr static real64 parentArea = 0.5;
253 
255  //constexpr static real64 weight = parentArea / numQuadraturePoints;
256  constexpr static real64 weight = parentArea;
257 
264  inline
265  constexpr static real64 quadratureWeight( localIndex const q )
266  {
267 
268  if constexpr (numQuadraturePoints == 1)
269  {
270  constexpr real64 w[numQuadraturePoints] = { 1.0 };
271  return w[q];
272  }
273  else if constexpr (numQuadraturePoints == 4)
274  {
275  constexpr real64 w[numQuadraturePoints] = {-0.562500000000000,
276  0.520833333333333,
277  0.520833333333333,
278  0.520833333333333 };
279  return w[q];
280  }
281  else if constexpr (numQuadraturePoints == 6)
282  {
283  real64 const w[numQuadraturePoints] = { 0.166666666666666,
284  0.166666666666666,
285  0.166666666666666,
286  0.166666666666666,
287  0.166666666666666,
288  0.166666666666666 };
289  return w[q];
290  }
291 
292  }
293 
301  inline
302  constexpr static real64 quadratureParentCoords0( localIndex const q )
303  {
304 
305  if constexpr (numQuadraturePoints == 1)
306  {
307  constexpr real64 qCoords[numQuadraturePoints] = { 1.0/3.0 };
308  return qCoords[q];
309  }
310  else if constexpr (numQuadraturePoints == 4)
311  {
312  constexpr real64 qCoords[numQuadraturePoints] = { 0.333333333333333,
313  0.600000000000000,
314  0.200000000000000,
315  0.200000000000000 };
316  return qCoords[q];
317  }
318  else if constexpr (numQuadraturePoints == 6)
319  {
320  constexpr real64 qCoords[numQuadraturePoints] = { 0.659027622374092,
321  0.109039009072877,
322  0.231933368553031,
323  0.659027622374092,
324  0.109039009072877,
325  0.231933368553031 };
326  return qCoords[q];
327  }
328 
329  }
330 
338  inline
339  constexpr static real64 quadratureParentCoords1( localIndex const q )
340  {
341 
342  if constexpr (numQuadraturePoints == 1)
343  {
344  constexpr real64 qCoords[numQuadraturePoints] = { 1.0/3.0 };
345  return qCoords[q];
346  }
347  else if constexpr (numQuadraturePoints == 4)
348  {
349  constexpr real64 qCoords[numQuadraturePoints] = { 0.333333333333333,
350  0.200000000000000,
351  0.600000000000000,
352  0.200000000000000 };
353  return qCoords[q];
354  }
355  else if constexpr (numQuadraturePoints == 6)
356  {
357  constexpr real64 qCoords[numQuadraturePoints] = { 0.231933368553031,
358  0.659027622374092,
359  0.109039009072877,
360  0.109039009072877,
361  0.231933368553031,
362  0.659027622374092 };
363  return qCoords[q];
364  }
365 
366  }
367 
368 };
369 
371 
372 
373 template< typename NUM_Q_POINTS >
374 template< localIndex NUMDOFSPERTRIALSUPPORTPOINT, bool UPPER >
376 inline
379  real64 ( & matrix )
380  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT]
381  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT],
382  real64 const & scaleFactor )
383 {
384  GEOS_UNUSED_VAR( stack );
385  GEOS_UNUSED_VAR( matrix );
386  GEOS_UNUSED_VAR( scaleFactor );
387 }
388 
389 template< typename NUM_Q_POINTS >
391 inline
392 void
394 calcN( real64 const (&coords)[2],
395  real64 ( & N )[numNodes] )
396 {
397  real64 const r = coords[0];
398  real64 const s = coords[1];
399 
400  N[0] = 1.0 - r - s;
401  N[1] = r;
402  N[2] = s;
403 }
404 
405 template< typename NUM_Q_POINTS >
407 inline
408 void
410 calcN( localIndex const q,
411  real64 (& N)[numNodes] )
412 {
413 
414  real64 const qCoords[2] = {quadratureParentCoords0( q ), quadratureParentCoords1( q ) };
415 
416  calcN( qCoords, N );
417 
418 }
419 
420 template< typename NUM_Q_POINTS >
422 inline
424 calcN( localIndex const q,
425  StackVariables const & GEOS_UNUSED_PARAM( stack ),
426  real64 ( & N )[numNodes] )
427 {
428  return calcN( q, N );
429 }
430 
431 //*************************************************************************************************
432 
433 template< typename NUM_Q_POINTS >
435 inline
436 real64
439  real64 const (&X)[numNodes][3] )
440 {
441  //GEOS_UNUSED_VAR( q );
442  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] ),
443  ( X[2][0] - X[0][0] ) * ( X[1][2] - X[0][2] ) - ( X[1][0] - X[0][0] ) * ( X[2][2] - X[0][2] ),
444  ( X[1][0] - X[0][0] ) * ( X[2][1] - X[0][1] ) - ( X[2][0] - X[0][0] ) * ( X[1][1] - X[0][1] )};
445 
446  return sqrt( n[0] * n[0] + n[1] * n[1] + n[2] * n[2] ) * weight * quadratureWeight( q );
447 }
448 
450 
451 
453 template< typename NUM_Q_POINTS >
455  public FiniteElementBase
456 {
457 public:
458 
461 
464 
470  {}
471 
473  virtual ~H1_TriangleFace_Lagrange1_Gauss() override final = default;
474 
480  {
481  return static_cast< H1_TriangleFace_Lagrange1_Gauss_impl< NUM_Q_POINTS > * >(this);
482  }
483 
489  {
490  return static_cast< H1_TriangleFace_Lagrange1_Gauss_impl< NUM_Q_POINTS > const * >(this);
491  }
492 
493 };
494 
501 
508 
509 }
510 }
511 #endif //GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1TRIANGLEFACELAGRANGE1GAUSS_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
Device-compatible (non virtual) Base class for all finite element formulations.
constexpr static localIndex numQuadraturePoints
The number of quadrature points per element.
constexpr static localIndex maxSupportPoints
The maximum number of support points per element.
constexpr static localIndex numNodes
The number of nodes per element.
GEOS_HOST_DEVICE FiniteElementBase_impl & operator=(FiniteElementBase_impl const &)=default
Default copy assignment operator.
Base class for FEM element implementations.
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.
static GEOS_HOST_DEVICE void getPermutation(int(&permutation)[numNodes])
Calculate the node permutation between the parent element and the geometric element....
GEOS_HOST_DEVICE localIndex getMaxSupportPoints()
Get the maximum number of support points.
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.
static GEOS_HOST_DEVICE real64 transformedQuadratureWeight(localIndex const q, real64 const (&X)[numNodes][3])
Calculate the integration weights for a quadrature point.
GEOS_HOST_DEVICE localIndex getNumSupportPoints()
Get the number of support points.
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 getNumSupportPoints(StackVariables const &stack)
Get the number of support points.
DO_NOT_DOCUMENT GEOS_HOST_DEVICE localIndex getNumQuadraturePoints()
Get the number of quadrature points.
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 localIndex getNumQuadraturePoints(StackVariables const &stack)
Get the number of quadrature points.
typename Base::template MeshData< SubregionType > MeshData
Mesh data structure for the 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.
const H1_TriangleFace_Lagrange1_Gauss_impl< NUM_Q_POINTS > * getImpl() const
Get the device-compatible implementation type.
H1_TriangleFace_Lagrange1_Gauss_impl< NUM_Q_POINTS > * getImpl()
Get the device-compatible implementation type.
virtual ~H1_TriangleFace_Lagrange1_Gauss() override final=default
Destructor.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
Kernel variables (dof numbers, jacobian and residual) located on the stack.