GEOSX
FluxApproximationBase.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
20 #ifndef GEOS_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
21 #define GEOS_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
22 
23 #include "dataRepository/Group.hpp"
29 #include "mesh/DomainPartition.hpp"
30 
31 namespace geos
32 {
33 
38 {
39  PPU,
40  C1PPU,
41  IHU
42 };
43 
48  "PPU",
49  "C1PPU",
50  "IHU" );
51 
58 {
61 
63  //real64 epsC1PPU;
64 };
65 
75 {
76 public:
77 
85 
86  FluxApproximationBase() = delete;
87 
93  FluxApproximationBase( string const & name, dataRepository::Group * const parent );
94 
102  template< typename TYPE >
103  TYPE const & getStencil( MeshLevel const & mesh, string const & name ) const;
104 
108  template< typename TYPE >
109  TYPE & getStencil( MeshLevel & mesh, string const & name ) const;
110 
117  template< typename LAMBDA >
118  void forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
119 
128  template< typename TYPE, typename ... TYPES, typename LAMBDA >
129  void forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
130 
136  virtual void addToFractureStencil( MeshLevel & mesh,
137  string const & faceElementRegionName ) const = 0;
138 
145  string const & embeddedSurfaceRegionName ) const = 0;
146 
151  {
153  static constexpr char const * fieldNameString() { return "fieldName"; }
154 
156  static constexpr char const * coeffNameString() { return "coefficientName"; }
157 
159  static constexpr char const * targetRegionsString() { return "targetRegions"; }
160 
162  static constexpr char const * areaRelativeToleranceString() { return "areaRelTol"; }
163 
165  static constexpr char const * transMultiplierString() { return "TransMultiplier"; }
166 
167 
168  // Keys below are for wrappers registered on MeshLevel, not the current object
169 
171  static constexpr char const * cellStencilString() { return "cellStencil"; }
172 
174  static constexpr char const * fractureStencilString() { return "fractureStencil"; }
175 
177  static constexpr char const * upwindingSchemeString() { return "upwindingScheme"; }
178 
180  //static constexpr char const * epsC1PPUString() { return "epsC1PPU"; }
181 
182  };
183 
188  {
190  static constexpr auto stencilMeshGroupString() { return "finiteVolumeStencils"; }
191  };
192 
198  array1d< string > & targetRegions( string const & meshBodyName ) { return m_targetRegions[meshBodyName]; }
199 
204  void addFieldName( string const & name );
205 
210  void setCoeffName( string const & name );
211 
217 
218 protected:
219 
220  virtual void initializePreSubGroups() override;
221 
223 
228  virtual void registerCellStencil( Group & stencilGroup ) const = 0;
229 
234  virtual void computeCellStencil( MeshLevel & mesh ) const = 0;
235 
243  virtual void computeFractureStencil( MeshLevel & mesh ) const = 0;
244 
249  virtual void registerFractureStencil( Group & stencilGroup ) const = 0;
250 
256  virtual void registerBoundaryStencil( Group & stencilGroup,
257  string const & setName ) const = 0;
258 
265  virtual void computeBoundaryStencil( MeshLevel & mesh,
266  string const & setName,
267  SortedArrayView< localIndex const > const & faceSet ) const = 0;
268 
274  virtual void registerAquiferStencil( Group & stencilGroup,
275  string const & setName ) const = 0;
276 
282  virtual void computeAquiferStencil( DomainPartition & domain,
283  MeshLevel & mesh ) const = 0;
284 
285 
288 
290  string m_coeffName;
291 
294 
297 
300 
303 
304 };
305 
306 template< typename TYPE >
307 TYPE const & FluxApproximationBase::getStencil( MeshLevel const & mesh, string const & name ) const
308 {
309  Group const & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
310  return stencilGroup.getReference< TYPE >( name );
311 }
312 
313 template< typename TYPE >
314 TYPE & FluxApproximationBase::getStencil( MeshLevel & mesh, string const & name ) const
315 {
316  Group & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
317  return stencilGroup.getReference< TYPE >( name );
318 }
319 
320 template< typename LAMBDA >
321 void FluxApproximationBase::forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
322 {
323  //TODO remove dependence on CellElementStencilTPFA and SurfaceElementStencil
327  FaceElementToCellStencil >( mesh, std::forward< LAMBDA >( lambda ) );
328 }
329 
330 template< typename TYPE, typename ... TYPES, typename LAMBDA >
331 void FluxApproximationBase::forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
332 {
333  Group const & stencilGroup = mesh.getGroup( groupKeyStruct::stencilMeshGroupString() ).getGroup( getName() );
334  stencilGroup.forWrappers< TYPE, TYPES... >( [&] ( auto const & wrapper )
335  {
336  lambda( wrapper.reference() );
337  } );
338 }
339 
340 } // namespace geos
341 
342 #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:41
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:1308
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1252
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:333
void forWrappers(LAMBDA &&lambda)
Apply the given functor to wrappers.
Definition: Group.hpp:644
Base template for ordered and unordered maps.
Definition: DataTypes.hpp:369
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:139
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:122
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:311
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:216
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.