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  HU2PH
44 };
45 
50  "PPU",
51  "C1PPU",
52  "IHU",
53  "HU2PH" );
54 
61 {
64 
66  //real64 epsC1PPU;
67 };
68 
78 {
79 public:
80 
88 
89  FluxApproximationBase() = delete;
90 
96  FluxApproximationBase( string const & name, dataRepository::Group * const parent );
97 
105  template< typename TYPE >
106  TYPE const & getStencil( MeshLevel const & mesh, string const & name ) const;
107 
111  template< typename TYPE >
112  TYPE & getStencil( MeshLevel & mesh, string const & name ) const;
113 
120  template< typename LAMBDA >
121  void forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
122 
131  template< typename TYPE, typename ... TYPES, typename LAMBDA >
132  void forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
133 
139  virtual void addToFractureStencil( MeshLevel & mesh,
140  string const & faceElementRegionName ) const = 0;
141 
148  string const & embeddedSurfaceRegionName ) const = 0;
149 
154  {
156  static constexpr char const * fieldNameString() { return "fieldName"; }
157 
159  static constexpr char const * coeffNameString() { return "coefficientName"; }
160 
162  static constexpr char const * targetRegionsString() { return "targetRegions"; }
163 
165  static constexpr char const * areaRelativeToleranceString() { return "areaRelTol"; }
166 
168  static constexpr char const * transMultiplierString() { return "TransMultiplier"; }
169 
170 
171  // Keys below are for wrappers registered on MeshLevel, not the current object
172 
174  static constexpr char const * cellStencilString() { return "cellStencil"; }
175 
177  static constexpr char const * fractureStencilString() { return "fractureStencil"; }
178 
180  static constexpr char const * upwindingSchemeString() { return "upwindingScheme"; }
181 
183  //static constexpr char const * epsC1PPUString() { return "epsC1PPU"; }
184 
185  };
186 
191  {
193  static constexpr auto stencilMeshGroupString() { return "finiteVolumeStencils"; }
194  };
195 
201  string_array & targetRegions( string const & meshBodyName ) { return m_targetRegions[meshBodyName]; }
202 
207  void addFieldName( string const & name );
208 
213  void setCoeffName( string const & name );
214 
220 
221 protected:
222 
223  virtual void initializePreSubGroups() override;
224 
226 
231  virtual void registerCellStencil( Group & stencilGroup ) const = 0;
232 
237  virtual void computeCellStencil( MeshLevel & mesh ) const = 0;
238 
246  virtual void computeFractureStencil( MeshLevel & mesh ) const = 0;
247 
252  virtual void registerFractureStencil( Group & stencilGroup ) const = 0;
253 
259  virtual void registerBoundaryStencil( Group & stencilGroup,
260  string const & setName ) const = 0;
261 
268  virtual void computeBoundaryStencil( MeshLevel & mesh,
269  string const & setName,
270  SortedArrayView< localIndex const > const & faceSet ) const = 0;
271 
277  virtual void registerAquiferStencil( Group & stencilGroup,
278  string const & setName ) const = 0;
279 
285  virtual void computeAquiferStencil( DomainPartition & domain,
286  MeshLevel & mesh ) const = 0;
287 
288 
291 
293  string m_coeffName;
294 
297 
300 
303 
306 
307 };
308 
309 template< typename TYPE >
310 TYPE const & FluxApproximationBase::getStencil( MeshLevel const & mesh, string const & name ) const
311 {
312  Group const & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
313  return stencilGroup.getReference< TYPE >( name );
314 }
315 
316 template< typename TYPE >
317 TYPE & FluxApproximationBase::getStencil( MeshLevel & mesh, string const & name ) const
318 {
319  Group & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
320  return stencilGroup.getReference< TYPE >( name );
321 }
322 
323 template< typename LAMBDA >
324 void FluxApproximationBase::forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
325 {
326  //TODO remove dependence on CellElementStencilTPFA and SurfaceElementStencil
330  FaceElementToCellStencil >( mesh, std::forward< LAMBDA >( lambda ) );
331 }
332 
333 template< typename TYPE, typename ... TYPES, typename LAMBDA >
334 void FluxApproximationBase::forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
335 {
336  Group const & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
337  stencilGroup.forWrappers< TYPE, TYPES... >( [&] ( auto const & wrapper )
338  {
339  lambda( wrapper.reference() );
340  } );
341 }
342 
343 } // namespace geos
344 
345 #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.
string_array & targetRegions(string const &meshBodyName)
get the list of the target regions on a given mesh body.
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.
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
static CatalogInterface::CatalogType & getCatalog()
Return the data type in the data repository.
map< string, string_array > m_targetRegions
names of target regions to build the stencil for
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
string_array m_fieldNames
name of the primary solution field
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.
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:1331
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1275
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:318
void forWrappers(LAMBDA &&lambda)
Apply the given functor to wrappers.
Definition: Group.hpp:637
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.
@ HU2PH
HU simplified 2-phase version.
@ 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
std::vector< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:393
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 or HU2PH.