GEOS
H1_QuadrilateralFace_Lagrange1_GaussLegendre2.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_H1QUADRILATERALFACELAGRANGE1GAUSSLEGENDRE2_HPP_
21 #define GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1QUADRILATERALFACELAGRANGE1GAUSSLEGENDRE2_HPP_
22 
23 #include "FiniteElementBase.hpp"
24 #include "LagrangeBasis1.hpp"
25 
26 
27 namespace geos
28 {
29 namespace finiteElement
30 {
31 
51 {
52 public:
55 
58 
60  using StackVariables = typename Base::StackVariables;
61 
63  template< typename SubregionType >
64  using MeshData = typename Base::template MeshData< SubregionType >;
65 
67  using Base::numNodes;
68 
71 
74 
76 
83 
85 
89  {
90  return numQuadraturePoints;
91  }
92 
100  {
101  GEOS_UNUSED_VAR( stack );
102  return numQuadraturePoints;
103  }
104 
108  {
109  return numNodes;
110  }
111 
115  {
116  return maxSupportPoints;
117  }
118 
126  {
127  GEOS_UNUSED_VAR( stack );
128  return numNodes;
129  }
130 
137  static void calcN( real64 const (&coords)[2],
138  real64 ( &N )[numNodes] );
139 
148  static void calcN( localIndex const q,
149  real64 ( &N )[numNodes] );
150 
160  inline
161  static void calcN( localIndex const q,
162  StackVariables const & stack,
163  real64 ( &N )[numNodes] );
164 
172  static void calcBubbleN( real64 const (&pointCoord)[2],
173  real64 (& N)[1] )
174  {
176  }
177 
185  inline
186  static void calcBubbleN( localIndex const q,
187  real64 (& N)[1] )
188  {
189  real64 const qCoords[2] = { quadratureFactor *parentCoords0( q ),
190  quadratureFactor *parentCoords1( q ) };
191 
192  calcBubbleN( qCoords, N );
193  }
194 
204  real64 const (&X)[numNodes][3] );
205 
215  template< localIndex NUMDOFSPERTRIALSUPPORTPOINT, bool UPPER >
217  inline
218  static void addGradGradStabilization( StackVariables const & stack,
219  real64 ( &matrix )
220  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT]
221  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT],
222  real64 const & scaleFactor );
223 
230  inline
231  static void getPermutation( int (& permutation)[numNodes] )
232  {
233  permutation[0] = 0;
234  permutation[1] = 1;
235  permutation[2] = 3;
236  permutation[3] = 2;
237  }
238 
239 private:
241  constexpr static real64 parentArea = 4.0;
242 
244  constexpr static real64 weight = parentArea / numQuadraturePoints;
245 
249  constexpr static real64 quadratureFactor = 1.0 / 1.732050807568877293528;
250 
258  template< typename T >
260  inline
261  constexpr static T linearMap( T const i, T const j )
262  {
263  return i + 2 * j;
264  }
265 
273  inline
274  constexpr static real64 parentCoords0( localIndex const a )
275  {
276  return -1.0 + 2.0 * (a & 1);
277  }
278 
286  inline
287  constexpr static real64 parentCoords1( localIndex const a )
288  {
289  return -1.0 + ( a & 2 );
290  }
291 
292 };
293 
295 
296 template< localIndex NUMDOFSPERTRIALSUPPORTPOINT, bool UPPER >
298 inline
301  real64 ( & matrix )
302  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT]
303  [maxSupportPoints * NUMDOFSPERTRIALSUPPORTPOINT],
304  real64 const & scaleFactor )
305 {
306  GEOS_UNUSED_VAR( stack );
307  GEOS_UNUSED_VAR( matrix );
308  GEOS_UNUSED_VAR( scaleFactor );
309 }
310 
312 inline
313 void
315  calcN( real64 const (&coords)[2],
316  real64 (& N)[numNodes] )
317 {
318  for( localIndex a=0; a<numNodes; ++a )
319  {
320  N[a] = 0.25 *
321  ( 1 + quadratureFactor*coords[0]*parentCoords0( a ) ) *
322  ( 1 + quadratureFactor*coords[1]*parentCoords1( a ) );
323  }
324 }
326 inline
327 void
329  calcN( localIndex const q,
330  real64 (& N)[numNodes] )
331 {
332  for( localIndex a=0; a<numNodes; ++a )
333  {
334  N[a] = 0.25 *
335  ( 1 + quadratureFactor*parentCoords0( q )*parentCoords0( a ) ) *
336  ( 1 + quadratureFactor*parentCoords1( q )*parentCoords1( a ) );
337  }
338 }
339 
341 inline
343  calcN( localIndex const q,
344  StackVariables const & GEOS_UNUSED_PARAM( stack ),
345  real64 ( & N )[numNodes] )
346 {
347  return calcN( q, N );
348 }
349 
350 //*************************************************************************************************
351 
353 inline
354 real64
357  real64 const (&X)[numNodes][3] )
358 {
359  real64 dXdXi[3][2] = {{0}};
360 
361  real64 const quadratureCoords[2] = { quadratureFactor *parentCoords0( q ),
362  quadratureFactor *parentCoords1( q ) };
363 
364  real64 const psi0[2] = { 0.5*( 1.0 - quadratureCoords[0] ),
365  0.5*( 1.0 + quadratureCoords[0] ) };
366  real64 const psi1[2] = { 0.5*( 1.0 - quadratureCoords[1] ),
367  0.5*( 1.0 + quadratureCoords[1] ) };
368  constexpr real64 dpsi[2] = { -0.5, 0.5 };
369 
370  for( int a=0; a<2; ++a )
371  {
372  for( int b=0; b<2; ++b )
373  {
374  real64 const dNdXi[2] = { dpsi[a] * psi1[b],
375  psi0[a] * dpsi[b] };
376 
377  localIndex const nodeIndex = linearMap( a, b );
378 
379  for( int i = 0; i < 3; ++i )
380  {
381  for( int j = 0; j < 2; ++j )
382  {
383  dXdXi[i][j] = dXdXi[i][j] + dNdXi[ j ] * X[nodeIndex][i];
384  }
385  }
386  }
387  }
388 
389  real64 const detJ = pow( dXdXi[1][0] * dXdXi[2][1] - dXdXi[2][0] * dXdXi[1][1], 2.0 )
390  + pow( dXdXi[2][0] * dXdXi[0][1] - dXdXi[0][0] * dXdXi[2][1], 2.0 )
391  + pow( dXdXi[0][0] * dXdXi[1][1] - dXdXi[1][0] * dXdXi[0][1], 2.0 );
392 
393  return sqrt( detJ ) * weight;
394 }
395 
397 
398 
401  public FiniteElementBase
402 {
403 public:
404 
407 
410 
415  {}
416 
417  virtual ~H1_QuadrilateralFace_Lagrange1_GaussLegendre2() override final = default;
418 
424  {
425  return static_cast< H1_QuadrilateralFace_Lagrange1_GaussLegendre2_impl * >(this);
426  }
427 
433  {
434  return static_cast< H1_QuadrilateralFace_Lagrange1_GaussLegendre2_impl const * >(this);
435  }
436 
437 
438 };
439 
440 }
441 }
442 #endif //GEOS_FINITEELEMENT_ELEMENTFORMULATIONS_H1QUADRILATERALFACELAGRANGE1GAUSSLEGENDRE2_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.
static GEOS_HOST_DEVICE real64 transformedQuadratureWeight(localIndex const q, real64 const (&X)[numNodes][3])
Calculate the integration weights for a quadrature point.
static GEOS_HOST_DEVICE void getPermutation(int(&permutation)[numNodes])
Calculate the node permutation between the parent element and the geometric element....
static GEOS_HOST_DEVICE localIndex getNumQuadraturePoints(StackVariables const &stack)
Get the number of quadrature 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 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 calcBubbleN(localIndex const q, real64(&N)[1])
Calculate shape bubble functions values at a quadrature point.
DO_NOT_DOCUMENT static GEOS_HOST_DEVICE localIndex getNumQuadraturePoints()
Get the number of quadrature 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.
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 localIndex getNumSupportPoints()
Get the number of support points.
typename Base::template MeshData< SubregionType > MeshData
Mesh data structure for the element.
static GEOS_HOST_DEVICE void calcN(real64 const (&coords)[2], real64(&N)[numNodes])
Calculate shape functions values at a single point.
static GEOS_HOST_DEVICE localIndex getNumSupportPoints(StackVariables const &stack)
Get the number of support points.
static GEOS_HOST_DEVICE localIndex getMaxSupportPoints()
Get the maximum number of support points.
H1_QuadrilateralFace_Lagrange1_GaussLegendre2_impl * getImpl()
Get the device-compatible implementation type.
H1_QuadrilateralFace_Lagrange1_GaussLegendre2_impl const * getImpl() const
Get the device-compatible implementation type.
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.
GEOS_HOST_DEVICE static GEOS_FORCE_INLINE void valueBubble(real64 const (&coords)[2], real64(&N)[1])
The value of the bubble basis function evaluated at a point along the axes.