GEOS
FlowSolverBase.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_PHYSICSSOLVERS_FINITEVOLUME_FLOWSOLVERBASE_HPP_
21 #define GEOS_PHYSICSSOLVERS_FINITEVOLUME_FLOWSOLVERBASE_HPP_
22 
24 #include "common/Units.hpp"
27 
28 namespace geos
29 {
30 
38 {
39  template< typename VIEWTYPE >
41 
42 public:
43 
45  static string coupledSolverAttributePrefix() { return "flow"; }
46 
52  FlowSolverBase( const string & name,
53  Group * const parent );
54 
55 
57  FlowSolverBase() = delete;
58 
60  FlowSolverBase( FlowSolverBase const & ) = delete;
61 
63  FlowSolverBase( FlowSolverBase && ) = default;
64 
66  FlowSolverBase & operator=( FlowSolverBase const & ) = delete;
67 
70 
71  virtual void registerDataOnMesh( Group & MeshBodies ) override;
72 
74  {
75  // misc inputs
76  static constexpr char const * isThermalString() { return "isThermal"; }
77  static constexpr char const * inputTemperatureString() { return "temperature"; }
78  static constexpr char const * allowNegativePressureString() { return "allowNegativePressure"; }
79  static constexpr char const * maxAbsolutePresChangeString() { return "maxAbsolutePressureChange"; }
80  static constexpr char const * maxAbsoluteTempChangeString() { return "maxAbsoluteTemperatureChange"; }
81  static constexpr char const * maxSequentialPresChangeString() { return "maxSequentialPressureChange"; }
82  static constexpr char const * maxSequentialTempChangeString() { return "maxSequentialTemperatureChange"; }
83 
84  static constexpr char const * fluidNamesString() { return "fluidNames"; }
85  static constexpr char const * solidNamesString() { return "solidNames"; }
86  static constexpr char const * permeabilityNamesString() { return "permeabilityNames"; }
87  static constexpr char const * solidInternalEnergyNamesString() { return "solidInternalEnergyNames"; }
88  static constexpr char const * thermalConductivityNamesString() { return "thermalConductivityNames"; }
89  };
90 
96  void prepareStencilWeights( DomainPartition & domain ) const;
97 
103  void updateStencilWeights( DomainPartition & domain ) const;
104 
105  void enableFixedStressPoromechanicsUpdate() { m_isFixedStressPoromechanicsUpdate = true; }
106 
107  void enableJumpStabilization() { m_isJumpStabilized = true; }
108 
109  virtual void updatePorosityAndPermeability( CellElementSubRegion & subRegion ) const;
110 
111  virtual void updatePorosityAndPermeability( SurfaceElementSubRegion & subRegion ) const;
112 
117  virtual void saveSequentialIterationState( DomainPartition & domain ) override;
118 
119  integer & isThermal() { return m_isThermal; }
120 
124  virtual units::Unit getMassUnit() const { return units::Unit::Mass; }
125 
130 
136  void setKeepVariablesConstantDuringInitStep( bool const keepVariablesConstantDuringInitStep )
137  { m_keepVariablesConstantDuringInitStep = keepVariablesConstantDuringInitStep; }
138 
139  virtual bool checkSequentialSolutionIncrements( DomainPartition & domain ) const override;
140 
141  void enableLaggingFractureStencilWeightsUpdate(){ m_isLaggingFractureStencilWeightsUpdate = 1; };
142 
143  real64 sumAquiferFluxes( BoundaryStencil const & stencil,
144  AquiferBoundaryCondition::KernelWrapper const & aquiferBCWrapper,
145  ElementViewConst< arrayView1d< real64 const > > const & pres,
146  ElementViewConst< arrayView1d< real64 const > > const & presOld,
147  ElementViewConst< arrayView1d< real64 const > > const & gravCoef,
148  real64 const & timeAtBeginningOfStep,
149  real64 const & dt );
150 
167  virtual void assembleHydrofracFluxTerms( real64 const time_n,
168  real64 const dt,
169  DomainPartition const & domain,
170  DofManager const & dofManager,
171  CRSMatrixView< real64, globalIndex const > const & localMatrix,
172  arrayView1d< real64 > const & localRhs,
174  stdMap< string, localIndex > const * const dR_dAperOffsets )
175  {
176  GEOS_UNUSED_VAR ( time_n, dt, domain, dofManager, localMatrix, localRhs, dR_dAper, dR_dAperOffsets );
177  GEOS_ERROR( "Poroelastic fluxes with conforming fractures not yet implemented." );
178  }
179 
180  void initializeState( DomainPartition & domain );
181 
182  virtual void initializeFluidState( MeshLevel & mesh, string_array const & regionNames ) { GEOS_UNUSED_VAR( mesh, regionNames ); }
183 
184  virtual void initializeThermalState( MeshLevel & mesh, string_array const & regionNames ) { GEOS_UNUSED_VAR( mesh, regionNames ); }
185 
193  void findMinMaxElevationInEquilibriumTarget( DomainPartition & domain, // cannot be const...
194  stdMap< string, localIndex > const & equilNameToEquilId,
195  arrayView1d< real64 > const & maxElevation,
196  arrayView1d< real64 > const & minElevation ) const;
197 
207  real64 const & dt,
208  DomainPartition & domain, // cannot be const...
209  stdMap< string, localIndex > const & bcNameToBcId,
210  arrayView1d< globalIndex > const & bcAllSetsSize ) const;
211 
212  integer numberOfDofsPerCell() const { return m_numDofPerCell; }
213 
220  void applyDeltaVolume( ElementSubRegionBase & subRegion ) const;
221 
222 protected:
223 
233  template< typename OBJECT_TYPE >
234  void applyFieldValue( real64 const & time_n,
235  real64 const & dt,
236  MeshLevel & mesh,
237  char const logMessage[],
238  string const fieldKey,
239  string const boundaryFieldKey ) const;
240 
250  virtual void saveAquiferConvergedState( real64 const & time,
251  real64 const & dt,
252  DomainPartition & domain );
253 
258  virtual void saveConvergedState( ElementSubRegionBase & subRegion ) const;
259 
264  virtual void validatePoreVolumes( DomainPartition const & domain ) const;
265 
266  virtual void precomputeData( MeshLevel & mesh,
267  string_array const & regionNames );
268 
269  virtual void initializePreSubGroups() override;
270 
275 
277 
278  virtual void computeHydrostaticEquilibrium( DomainPartition & domain ) { GEOS_UNUSED_VAR( domain ); }
279 
280  void initializePorosityAndPermeability( MeshLevel & mesh, string_array const & regionNames );
281 
282  void initializeHydraulicAperture( MeshLevel & mesh, string_array const & regionNames );
283 
284  void saveInitialPressureAndTemperature( MeshLevel & mesh, string_array const & regionNames );
285 
286  virtual void setConstitutiveNamesCallSuper( ElementSubRegionBase & subRegion ) const override;
287 
290 
293 
296 
299 
302 
305 
308 
311 
314 
317  real64 m_maxSequentialPresChange;
318 
321  real64 m_maxSequentialTempChange;
322 
326  class BCMessage
327  {
328 public:
329  static string pressureConflict( string_view regionName, string_view subRegionName,
330  string_view setName, string_view fieldName );
331 
332  static string temperatureConflict( string_view regionName, string_view subRegionName,
333  string_view setName, string_view fieldName );
334 
335  static string missingPressure( string_view regionName, string_view subRegionName,
336  string_view setName, string_view fieldName );
337 
338  static string missingTemperature( string_view regionName, string_view subRegionName,
339  string_view setName, string_view fieldName );
340 
341  static string conflictingComposition( int comp, string_view componentName,
342  string_view regionName, string_view subRegionName,
343  string_view setName, string_view fieldName );
344 
345  static string invalidComponentIndex( int comp,
346  string_view fsName, string_view fieldName );
347 
348  static string notAppliedOnRegion( int componentIndex, string_view componentName,
349  string_view regionName, string_view subRegionName,
350  string_view setName, string_view fieldName );
351 private:
352  static string generateMessage( string_view baseMessage,
353  string_view fieldName, string_view setName );
354  };
355 
356 private:
357  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
358 
359  // flag to determine whether or not to apply lagging update for the fracture stencil weights
360  integer m_isLaggingFractureStencilWeightsUpdate;
361 
362 };
363 
364 
365 }
366 
367 #endif //GEOS_PHYSICSSOLVERS_FINITEVOLUME_FLOWSOLVERBASE_HPP_
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_ERROR(...)
Raise a hard error and terminate the program.
Definition: Logger.hpp:220
Enumerates the Units that are in use in GEOS and regroups useful conversion and formatting functions.
Unit
Enumerator of available unit types for given physical scales. Units are in SI by default.
Definition: Units.hpp:59
Provides management of the boundary stencil points (stencils used to prescribe boundary conditions on...
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:45
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
typename ElementViewAccessor< VIEWTYPE >::NestedViewTypeConst ElementViewConst
The ElementViewAccessor at the ElementRegionManager level is the type resulting from ElementViewAcces...
Class used for displaying boundary warning message.
void computeSourceFluxSizeScalingFactor(real64 const &time, real64 const &dt, DomainPartition &domain, stdMap< string, localIndex > const &bcNameToBcId, arrayView1d< globalIndex > const &bcAllSetsSize) const
For each source flux boundary condition, loop over all the target cells and sum the owned cells.
virtual void saveSequentialIterationState(DomainPartition &domain) override
Utility function to save the iteration state (useful for sequential simulations)
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
bool m_keepVariablesConstantDuringInitStep
flag to freeze the initial state during initialization in coupled problems
virtual void validatePoreVolumes(DomainPartition const &domain) const
Helper function to compute/report the elements with small pore volumes.
void findMinMaxElevationInEquilibriumTarget(DomainPartition &domain, stdMap< string, localIndex > const &equilNameToEquilId, arrayView1d< real64 > const &maxElevation, arrayView1d< real64 > const &minElevation) const
For each equilibrium initial condition, loop over all the target cells and compute the min/max elevat...
virtual units::Unit getMassUnit() const
virtual void registerDataOnMesh(Group &MeshBodies) override
Register wrappers that contain data on the mesh objects.
FlowSolverBase(FlowSolverBase &&)=default
default move constructor
FlowSolverBase & operator=(FlowSolverBase const &)=delete
deleted assignment operator
real64 m_sequentialPresChange
maximum (absolute) pressure change in a sequential iteration
real64 m_maxAbsoluteTempChange
maximum (absolute) temperature change in a Newton iteration
void updateStencilWeights(DomainPartition &domain) const
Update the stencil weights by adding the contribution of the hydraulic aperture after the aperture is...
bool m_isFixedStressPoromechanicsUpdate
enable the fixed stress poromechanics update of porosity
void setKeepVariablesConstantDuringInitStep(bool const keepVariablesConstantDuringInitStep)
Utility function to keep the flow variables during a time step (used in poromechanics simulations)
FlowSolverBase & operator=(FlowSolverBase &&)=delete
deleted move operator
bool m_isJumpStabilized
enable pressure jump stabilzation for fixed-stress poromechanics
void applyFieldValue(real64 const &time_n, real64 const &dt, MeshLevel &mesh, char const logMessage[], string const fieldKey, string const boundaryFieldKey) const
Utility function that encapsulates the call to FieldSpecificationImpl::applyFieldValue in BC applicat...
virtual void assembleHydrofracFluxTerms(real64 const time_n, real64 const dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, CRSMatrixView< real64, localIndex const > const &dR_dAper, stdMap< string, localIndex > const *const dR_dAperOffsets)
assembles the flux terms for all cells for the hydrofracture case
void prepareStencilWeights(DomainPartition &domain) const
Prepare the stencil weights by removing the contribution of the hydraulic aperture before the apertur...
FlowSolverBase(const string &name, Group *const parent)
main constructor for Group Objects
virtual void setConstitutiveNamesCallSuper(ElementSubRegionBase &subRegion) const override
This function sets constitutive name fields on an ElementSubRegionBase, and calls the base function i...
FlowSolverBase(FlowSolverBase const &)=delete
deleted copy constructor
virtual void initializePreSubGroups() override
Called by Initialize() prior to initializing sub-Groups.
static string coupledSolverAttributePrefix()
String used to form the solverName used to register single-physics solvers in CoupledSolver.
integer m_allowNegativePressure
flag if negative pressure is allowed
integer m_isThermal
flag to determine whether or not this is a thermal simulation
real64 m_maxAbsolutePresChange
maximum (absolute) pressure change in a Newton iteration
virtual bool checkSequentialSolutionIncrements(DomainPartition &domain) const override
Check if the solution increments are ok to use.
void allowNegativePressure()
Function to activate the flag allowing negative pressure.
real64 m_sequentialTempChange
maximum (absolute) temperature change in a sequential iteration
FlowSolverBase()=delete
deleted default constructor
void applyDeltaVolume(ElementSubRegionBase &subRegion) const
Apply the delta volume to the element volume and reset delta volume to zero @detail This is needed fo...
integer m_numDofPerCell
the number of Degrees of Freedom per cell
void checkDiscretizationName() const
Checks the validity of the discretization name for the FiniteVolume method (errors if issues are dete...
virtual void saveAquiferConvergedState(real64 const &time, real64 const &dt, DomainPartition &domain)
Increment the cumulative flux from each aquifer.
virtual void saveConvergedState(ElementSubRegionBase &subRegion) const
Utility function to save the converged state.
real64 m_inputTemperature
the input temperature
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
Base class for all physics solvers.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
stdVector< string > string_array
A 1-dimensional array of geos::string types.
Definition: DataTypes.hpp:361
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:309
internal::StdMapWrapper< std::map< Key, T, Compare, Allocator >, USE_STD_CONTAINER_BOUNDS_CHECKING > stdMap
int integer
Signed integer type.
Definition: DataTypes.hpp:81
std::string_view string_view
String type.
Definition: DataTypes.hpp:93
Structure to hold scoped key names.