GEOS
FluxApproximationBase.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 
21 #ifndef GEOS_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
22 #define GEOS_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
23 
24 #include "dataRepository/Group.hpp"
30 #include "mesh/DomainPartition.hpp"
31 
32 namespace geos
33 {
34 
39 {
40  PPU,
41  C1PPU,
42  IHU
43 };
44 
49  "PPU",
50  "C1PPU",
51  "IHU" );
52 
59 {
62 
64  //real64 epsC1PPU;
65 };
66 
76 {
77 public:
78 
86 
87  FluxApproximationBase() = delete;
88 
94  FluxApproximationBase( string const & name, dataRepository::Group * const parent );
95 
103  template< typename TYPE >
104  TYPE const & getStencil( MeshLevel const & mesh, string const & name ) const;
105 
109  template< typename TYPE >
110  TYPE & getStencil( MeshLevel & mesh, string const & name ) const;
111 
118  template< typename LAMBDA >
119  void forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
120 
129  template< typename TYPE, typename ... TYPES, typename LAMBDA >
130  void forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
131 
137  virtual void addToFractureStencil( MeshLevel & mesh,
138  string const & faceElementRegionName ) const = 0;
139 
146  string const & embeddedSurfaceRegionName ) const = 0;
147 
152  {
154  static constexpr char const * fieldNameString() { return "fieldName"; }
155 
157  static constexpr char const * coeffNameString() { return "coefficientName"; }
158 
160  static constexpr char const * targetRegionsString() { return "targetRegions"; }
161 
163  static constexpr char const * areaRelativeToleranceString() { return "areaRelTol"; }
164 
166  static constexpr char const * transMultiplierString() { return "TransMultiplier"; }
167 
168 
169  // Keys below are for wrappers registered on MeshLevel, not the current object
170 
172  static constexpr char const * cellStencilString() { return "cellStencil"; }
173 
175  static constexpr char const * fractureStencilString() { return "fractureStencil"; }
176 
178  static constexpr char const * upwindingSchemeString() { return "upwindingScheme"; }
179 
181  //static constexpr char const * epsC1PPUString() { return "epsC1PPU"; }
182 
183  };
184 
189  {
191  static constexpr auto stencilMeshGroupString() { return "finiteVolumeStencils"; }
192  };
193 
199  array1d< string > & targetRegions( string const & meshBodyName ) { return m_targetRegions[meshBodyName]; }
200 
205  void addFieldName( string const & name );
206 
211  void setCoeffName( string const & name );
212 
218 
219 protected:
220 
221  virtual void initializePreSubGroups() override;
222 
224 
229  virtual void registerCellStencil( Group & stencilGroup ) const = 0;
230 
235  virtual void computeCellStencil( MeshLevel & mesh ) const = 0;
236 
244  virtual void computeFractureStencil( MeshLevel & mesh ) const = 0;
245 
250  virtual void registerFractureStencil( Group & stencilGroup ) const = 0;
251 
257  virtual void registerBoundaryStencil( Group & stencilGroup,
258  string const & setName ) const = 0;
259 
266  virtual void computeBoundaryStencil( MeshLevel & mesh,
267  string const & setName,
268  SortedArrayView< localIndex const > const & faceSet ) const = 0;
269 
275  virtual void registerAquiferStencil( Group & stencilGroup,
276  string const & setName ) const = 0;
277 
283  virtual void computeAquiferStencil( DomainPartition & domain,
284  MeshLevel & mesh ) const = 0;
285 
286 
289 
291  string m_coeffName;
292 
295 
298 
301 
304 
305 };
306 
307 template< typename TYPE >
308 TYPE const & FluxApproximationBase::getStencil( MeshLevel const & mesh, string const & name ) const
309 {
310  Group const & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
311  return stencilGroup.getReference< TYPE >( name );
312 }
313 
314 template< typename TYPE >
315 TYPE & FluxApproximationBase::getStencil( MeshLevel & mesh, string const & name ) const
316 {
317  Group & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
318  return stencilGroup.getReference< TYPE >( name );
319 }
320 
321 template< typename LAMBDA >
322 void FluxApproximationBase::forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
323 {
324  //TODO remove dependence on CellElementStencilTPFA and SurfaceElementStencil
328  FaceElementToCellStencil >( mesh, std::forward< LAMBDA >( lambda ) );
329 }
330 
331 template< typename TYPE, typename ... TYPES, typename LAMBDA >
332 void FluxApproximationBase::forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
333 {
334  Group const & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
335  stencilGroup.forWrappers< TYPE, TYPES... >( [&] ( auto const & wrapper )
336  {
337  lambda( wrapper.reference() );
338  } );
339 }
340 
341 } // namespace geos
342 
343 #endif //GEOS_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Provides management of the interior stencil points for a face elements when using Two-Point flux appr...
virtual void initializePreSubGroups() override
Called by Initialize() prior to initializing sub-Groups.
real64 m_areaRelTol
relative tolerance
virtual void addEmbeddedFracturesToStencils(MeshLevel &mesh, string const &embeddedSurfaceRegionName) const =0
Add a new embedded fracture stencil.
void setCoeffName(string const &name)
set the name of the coefficient.
array1d< string > & targetRegions(string const &meshBodyName)
get the list of the target regions on a given mesh body.
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
map< string, array1d< string > > m_targetRegions
names of target regions to build the stencil for
static CatalogInterface::CatalogType & getCatalog()
Return the data type in the data repository.
string m_coeffName
name of the coefficient field
void addFieldName(string const &name)
set the name of the field.
UpwindingParameters const & upwindingParams() const
get the upwinding parameters.
virtual void computeFractureStencil(MeshLevel &mesh) const =0
Actual Computation of the fracture related stencils.
real64 m_lengthScale
length scale of the mesh body
virtual void registerAquiferStencil(Group &stencilGroup, string const &setName) const =0
Register the wrapper for aquifer stencil on a mesh.
FluxApproximationBase(string const &name, dataRepository::Group *const parent)
Constructor.
virtual void registerCellStencil(Group &stencilGroup) const =0
Register the wrapper for cell stencil on a mesh.
array1d< string > m_fieldNames
name of the primary solution field
UpwindingParameters m_upwindingParams
upwinding parameters
virtual void computeBoundaryStencil(MeshLevel &mesh, string const &setName, SortedArrayView< localIndex const > const &faceSet) const =0
Allocate and populate a stencil to be used in dirichlet boundary condition application.
virtual void computeCellStencil(MeshLevel &mesh) const =0
Actual computation of the cell-to-cell stencil.
virtual void registerFractureStencil(Group &stencilGroup) const =0
Register the wrapper for fracture stencil on a mesh.
void forStencils(MeshLevel const &mesh, LAMBDA &&lambda) const
Call a user-provided function for the each stencil according to the provided TYPE.
virtual void registerBoundaryStencil(Group &stencilGroup, string const &setName) const =0
Register the wrapper for boundary face stencil on a mesh.
void forAllStencils(MeshLevel const &mesh, LAMBDA &&lambda) const
Call a user-provided function for each stencil.
TYPE const & getStencil(MeshLevel const &mesh, string const &name) const
Extract stencil stored under the mesh group.
virtual void addToFractureStencil(MeshLevel &mesh, string const &faceElementRegionName) const =0
Add a new fracture stencil.
virtual void computeAquiferStencil(DomainPartition &domain, MeshLevel &mesh) const =0
Allocate and populate a stencil to be used in aquifer boundary condition application.
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
Provides management of the interior stencil points for a face elements when using Two-Point flux appr...
This class provides the base class/interface for the catalog value objects.
std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
This is the type that will be used for the catalog. The catalog is actually instantiated in the BASET...
string const & getName() const
Get group name.
Definition: Group.hpp:1329
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1273
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:336
void forWrappers(LAMBDA &&lambda)
Apply the given functor to wrappers.
Definition: Group.hpp:655
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:329
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
UpwindingScheme
Upwinding scheme.
@ PPU
PPU upwinding.
@ C1PPU
C1-PPU upwinding from https://doi.org/10.1016/j.advwatres.2017.07.028.
@ IHU
IHU as in https://link.springer.com/content/pdf/10.1007/s10596-019-09835-6.pdf.
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:271
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:176
static constexpr char const * fractureStencilString()
static constexpr char const * targetRegionsString()
static constexpr char const * upwindingSchemeString()
static constexpr char const * cellStencilString()
static constexpr char const * areaRelativeToleranceString()
static constexpr char const * transMultiplierString()
static constexpr char const * fieldNameString()
static constexpr char const * coeffNameString()
UpwindingScheme upwindingScheme
PPU or C1-PPU or IHU.