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 Total, S.A
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 GEOSX_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
21 #define GEOSX_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
22 
23 #include "dataRepository/Group.hpp"
26 #include "FaceElementStencil.hpp"
28 
29 namespace geosx
30 {
31 
37 {
44 
50  bool operator==( CellDescriptor const & other )
51  {
52  return( region==other.region && subRegion==other.subRegion && index==other.index );
53  }
54 };
55 
67 {
69  enum class Tag { CELL, FACE, NODE };
70 
73 
75  union
76  {
83  };
84 };
85 
95 {
96 public:
97 
104  static typename CatalogInterface::CatalogType & GetCatalog();
105 
106  FluxApproximationBase() = delete;
107 
113  FluxApproximationBase( string const & name, dataRepository::Group * const parent );
114 
122  template< typename TYPE >
123  TYPE const & getStencil( MeshLevel const & mesh, string const & name ) const;
124 
128  template< typename TYPE >
129  TYPE & getStencil( MeshLevel & mesh, string const & name ) const;
130 
137  template< typename LAMBDA >
138  void forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
139 
148  template< typename TYPE, typename ... TYPES, typename LAMBDA >
149  void forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const;
150 
157  virtual void addToFractureStencil( MeshLevel & mesh,
158  string const & faceElementRegionName,
159  bool const initFlag ) const = 0;
160 
166  virtual void addEDFracToFractureStencil( MeshLevel & mesh,
167  string const & embeddedSurfaceRegionName ) const = 0;
168 
173  {
175  static constexpr auto fieldNameString = "fieldName";
177  static constexpr auto coeffNameString = "coefficientName";
179  static constexpr auto targetRegionsString = "targetRegions";
181  static constexpr auto areaRelativeToleranceString = "areaRelTol";
183  static constexpr auto transMultiplierString = "TransMultiplier";
184 
185  // Keys below are for wrappers registered on MeshLevel, not the current object
186 
188  static constexpr auto cellStencilString = "cellStencil";
190  static constexpr auto fractureStencilString = "fractureStencil";
191  };
192 
197  {
199  static constexpr auto stencilMeshGroupString = "finiteVolumeStencils";
200  };
201 
206  string_array const & targetRegions() const { return m_targetRegions; }
210  string_array & targetRegions() { return m_targetRegions; }
211 
212 protected:
213 
214  virtual void RegisterDataOnMesh( Group * const meshBodies ) override;
215 
216  virtual void InitializePostInitialConditions_PreSubGroups( Group * const rootGroup ) override;
217 
222  virtual void registerCellStencil( Group & stencilGroup ) const = 0;
223 
228  virtual void computeCellStencil( MeshLevel & mesh ) const = 0;
229 
234  virtual void registerFractureStencil( Group & stencilGroup ) const = 0;
235 
241  virtual void registerBoundaryStencil( Group & stencilGroup,
242  string const & setName ) const = 0;
243 
250  virtual void computeBoundaryStencil( MeshLevel & mesh,
251  string const & setName,
252  SortedArrayView< localIndex const > const & faceSet ) const = 0;
253 
255  string m_fieldName;
256 
258  string m_coeffName;
259 
262 
265 
268 
269 };
270 
271 template< typename TYPE >
272 TYPE const & FluxApproximationBase::getStencil( MeshLevel const & mesh, string const & name ) const
273 {
274  Group const & stencilGroup = mesh.getGroupReference( groupKeyStruct::stencilMeshGroupString ).getGroupReference( getName() );
275  return stencilGroup.getReference< TYPE >( name );
276 }
277 
278 template< typename TYPE >
279 TYPE & FluxApproximationBase::getStencil( MeshLevel & mesh, string const & name ) const
280 {
281  Group & stencilGroup = mesh.getGroupReference( groupKeyStruct::stencilMeshGroupString ).getGroupReference( getName() );
282  return stencilGroup.getReference< TYPE >( name );
283 }
284 
285 template< typename LAMBDA >
286 void FluxApproximationBase::forAllStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
287 {
288  //TODO remove dependence on CellElementStencilTPFA and FaceElementStencil
289  forStencils< CellElementStencilTPFA, FaceElementStencil >( mesh, std::forward< LAMBDA >( lambda ) );
290 }
291 
292 template< typename TYPE, typename ... TYPES, typename LAMBDA >
293 void FluxApproximationBase::forStencils( MeshLevel const & mesh, LAMBDA && lambda ) const
294 {
295  Group const & stencilGroup = mesh.getGroupReference( groupKeyStruct::stencilMeshGroupString ).getGroupReference( getName() );
296  stencilGroup.forWrappers< TYPE, TYPES... >( [&] ( auto const & wrapper )
297  {
298  lambda( wrapper.reference() );
299  } );
300 }
301 
302 } // namespace geosx
303 
304 #endif //GEOSX_FINITEVOLUME_FLUXAPPROXIMATIONBASE_HPP_
string m_coeffName
name of the coefficient field
real64 m_areaRelTol
relative tolerance
void forStencils(MeshLevel const &mesh, LAMBDA &&lambda) const
Call a user-provided function for the each stencil according to the provided TYPE.
localIndex nodeIndex
node index
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:38
localIndex index
cell index
bool operator==(CellDescriptor const &other)
Comparison operator between two CellDescriptors.
string m_fieldName
name of the primary solution field
double real64
64-bit floating point type.
Definition: DataTypes.hpp:136
Tag
Enum to classify the variable location.
TYPE const & getStencil(MeshLevel const &mesh, string const &name) const
Extract stencil stored under the mesh group.
localIndex region
region index
CellDescriptor cellIndex
CellDescriptor index.
GEOSX_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1211
localIndex subRegion
subregion index
string_array const & targetRegions() const
Returns the target region name.
void forWrappers(LAMBDA lambda)
Apply the given functor to wrappers.
Definition: Group.hpp:688
localIndex faceIndex
face index
string_array & targetRegions()
Returns the target region name.
This class provides the base class/interface for the catalog value objects.
string_array m_targetRegions
names of target regions to build the stencil for
void forAllStencils(MeshLevel const &mesh, LAMBDA &&lambda) const
Call a user-provided function for each stencil.
real64 m_lengthScale
length scale of the mesh body
A structure containing a single cell (element) identifier triplet.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:125
This class provides a fixed dimensional resizeable array interface in addition to an interface simila...
Definition: Array.hpp:55
A structure describing an arbitrary point participating in a stencil.
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...
T & getGroupReference(string const &key)
Definition: Group.hpp:414