GEOS
SinglePhaseBase.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_FLUIDFLOW_SINGLEPHASEBASE_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEBASE_HPP_
22 
27 #include "constitutive/ConstitutiveBase.hpp"
28 #include "constitutive/fluid/singlefluid/SingleFluidLayouts.hpp"
29 #include "constitutive/fluid/singlefluid/SingleFluidUtils.hpp"
30 
31 
32 namespace geos
33 {
34 
35 namespace constitutive
36 {
37 
38 class ConstitutiveBase;
39 
40 }
41 
48 {
49 public:
50  using SingleFluidProp = constitutive::SingleFluidVar< real64, 2, constitutive::singlefluid::LAYOUT_FLUID, constitutive::singlefluid::LAYOUT_FLUID_DER >;
51 
57  SinglePhaseBase( const string & name,
58  Group * const parent );
59 
60 
62  SinglePhaseBase() = delete;
63 
65  SinglePhaseBase( SinglePhaseBase const & ) = delete;
66 
69 
71  SinglePhaseBase & operator=( SinglePhaseBase const & ) = delete;
72 
75 
79  virtual ~SinglePhaseBase() override
80  {}
81 
82  virtual void registerDataOnMesh( Group & meshBodies ) override;
83 
90 
91  virtual void
92  implicitStepSetup( real64 const & time_n,
93  real64 const & dt,
94  DomainPartition & domain ) override;
95 
96  virtual void
97  assembleSystem( real64 const time_n,
98  real64 const dt,
99  DomainPartition & domain,
100  DofManager const & dofManager,
101  CRSMatrixView< real64, globalIndex const > const & localMatrix,
102  arrayView1d< real64 > const & localRhs ) override;
103 
104  virtual void
106  real64 const dt,
107  DomainPartition & domain,
108  DofManager const & dofManager,
109  CRSMatrixView< real64, globalIndex const > const & localMatrix,
110  arrayView1d< real64 > const & localRhs ) override;
111 
112  virtual real64
114  DofManager const & dofManager,
115  arrayView1d< real64 const > const & localSolution ) override;
116 
117  virtual bool
119  DofManager const & dofManager,
120  arrayView1d< real64 const > const & localSolution,
121  real64 const scalingFactor ) override;
122 
123  virtual void
125 
126  virtual void
128  real64 const & dt,
129  DomainPartition & domain ) override;
130 
132 
143  DofManager const & dofManager,
144  CRSMatrixView< real64, globalIndex const > const & localMatrix,
145  arrayView1d< real64 > const & localRhs );
146 
156  template< typename SUBREGION_TYPE >
157  void accumulationAssemblyLaunch( DofManager const & dofManager,
158  SUBREGION_TYPE const & subRegion,
159  CRSMatrixView< real64, globalIndex const > const & localMatrix,
160  arrayView1d< real64 > const & localRhs );
161 
171  virtual void
173  DomainPartition const & domain,
174  DofManager const & dofManager,
175  CRSMatrixView< real64, globalIndex const > const & localMatrix,
176  arrayView1d< real64 > const & localRhs ) = 0;
177 
187  virtual void
189  DomainPartition const & domain,
190  DofManager const & dofManager,
191  CRSMatrixView< real64, globalIndex const > const & localMatrix,
192  arrayView1d< real64 > const & localRhs ) = 0;
193 
204  virtual void
206  real64 const dt,
207  DomainPartition const & domain,
208  DofManager const & dofManager,
209  CRSMatrixView< real64, globalIndex const > const & localMatrix,
210  arrayView1d< real64 > const & localRhs,
211  string const & jumpDofKey ) = 0;
212 
214  {
215  static constexpr char const * elemDofFieldString() { return "singlePhaseVariables"; }
216  };
217 
227  virtual void
228  applyDirichletBC( real64 const time_n,
229  real64 const dt,
230  DomainPartition & domain,
231  DofManager const & dofManager,
232  CRSMatrixView< real64, globalIndex const > const & localMatrix,
233  arrayView1d< real64 > const & localRhs ) const;
234 
244  virtual void
245  applySourceFluxBC( real64 const time_n,
246  real64 const dt,
247  DomainPartition & domain,
248  DofManager const & dofManager,
249  CRSMatrixView< real64, globalIndex const > const & localMatrix,
250  arrayView1d< real64 > const & localRhs ) const;
251 
261  virtual void
262  applyAquiferBC( real64 const time,
263  real64 const dt,
264  DomainPartition & domain,
265  DofManager const & dofManager,
266  CRSMatrixView< real64, globalIndex const > const & localMatrix,
267  arrayView1d< real64 > const & localRhs ) const = 0;
268 
269  virtual void
270  updateState ( DomainPartition & domain ) override;
271 
276  real64
278 
279 
284  virtual void
285  updateFluidModel( ObjectManagerBase & dataGroup ) const;
286 
291  void
292  updateMass( ElementSubRegionBase & subRegion ) const;
293 
298  template< integer IS_THERMAL >
299  void updateMass( ElementSubRegionBase & subRegion ) const;
300 
305  void
306  updateEnergy( ElementSubRegionBase & subRegion ) const;
307 
313 
319 
324  void
325  updateMobility( ObjectManagerBase & dataGroup ) const;
326 
327  virtual void initializePreSubGroups() override;
328 
330 
331  virtual void initializeFluidState( MeshLevel & mesh, string_array const & regionNames ) override;
332 
333  virtual void initializeThermalState( MeshLevel & mesh, string_array const & regionNames ) override;
334 
338  virtual void computeHydrostaticEquilibrium( DomainPartition & domain ) override;
339 
343  virtual void updatePressureGradient( DomainPartition & domain )
344  {
345  GEOS_UNUSED_VAR( domain );
346  }
347 
360  real64 const dt,
361  DofManager const & dofManager,
362  DomainPartition & domain,
363  CRSMatrixView< real64, globalIndex const > const & localMatrix,
364  arrayView1d< real64 > const & localRhs ) const;
365 
366 protected:
367 
372  virtual void validateConstitutiveModels( DomainPartition & domain ) const;
373 
377  void initializeAquiferBC() const;
378 
383  virtual void saveConvergedState( ElementSubRegionBase & subRegion ) const override;
384 
387 
388 private:
389 
390  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
391 
392 };
393 
394 template< typename SUBREGION_TYPE >
396  SUBREGION_TYPE const & subRegion,
397  CRSMatrixView< real64, globalIndex const > const & localMatrix,
398  arrayView1d< real64 > const & localRhs )
399 {
400  string const dofKey = dofManager.getKey( viewKeyStruct::elemDofFieldString() );
401 
402  if( m_isThermal )
403  {
404  thermalSinglePhaseBaseKernels::
405  AccumulationKernelFactory::
406  createAndLaunch< parallelDevicePolicy<> >( dofManager.rankOffset(),
407  dofKey,
408  subRegion,
409  localMatrix,
410  localRhs );
411  }
412  else
413  {
414  singlePhaseBaseKernels::
415  AccumulationKernelFactory::
416  createAndLaunch< parallelDevicePolicy<> >( dofManager.rankOffset(),
417  dofKey,
418  subRegion,
419  localMatrix,
420  localRhs );
421  }
422 }
423 
424 } /* namespace geos */
425 
426 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEBASE_HPP_
ScalingType
Solution scaling type.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:45
globalIndex rankOffset(string const &fieldName) const
string const & getKey(string const &fieldName) const
Return the key used to record the field in the DofManager.
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
integer m_isThermal
flag to determine whether or not this is a thermal simulation
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
virtual void applySourceFluxBC(real64 const time_n, real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) const
Apply source flux boundary conditions to the system.
virtual void computeHydrostaticEquilibrium(DomainPartition &domain) override
Compute the hydrostatic equilibrium using the compositions and temperature input tables.
virtual void updatePressureGradient(DomainPartition &domain)
Update the cell-wise pressure gradient.
SinglePhaseBase & operator=(SinglePhaseBase &&)=delete
deleted move operator
real64 updateFluidState(ElementSubRegionBase &subRegion) const
Function to update all constitutive state and dependent variables.
void updateMass(ElementSubRegionBase &subRegion) const
Template function to update fluid mass.
virtual void saveConvergedState(ElementSubRegionBase &subRegion) const override
Utility function to save the converged state.
void keepVariablesConstantDuringInitStep(real64 const time, real64 const dt, DofManager const &dofManager, DomainPartition &domain, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) const
Function to fix the initial state during the initialization step in coupled problems.
void updateEnergy(ElementSubRegionBase &subRegion) const
Function to update energy.
void initializeAquiferBC() const
Initialize the aquifer boundary condition (gravity vector, water phase index)
virtual void applyAquiferBC(real64 const time, real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) const =0
Apply aquifer boundary conditions to the system.
void updateMobility(ObjectManagerBase &dataGroup) const
Function to update fluid mobility.
virtual void assembleEDFMFluxTerms(real64 const time_n, real64 const dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs, string const &jumpDofKey)=0
assembles the flux terms for all cells for the poroelastic case
SinglePhaseBase & operator=(SinglePhaseBase const &)=delete
deleted assignment operator
void updateSolidInternalEnergyModel(ObjectManagerBase &dataGroup) const
Update all relevant solid internal energy models using current values of temperature.
SinglePhaseBase()=delete
deleted default constructor
SinglePhaseBase(SinglePhaseBase const &)=delete
deleted copy constructor
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
flowSolverUtilities::ScalingType m_scalingType
Solution scaling type.
void updateMass(ElementSubRegionBase &subRegion) const
Function to update fluid mass.
virtual void validateConstitutiveModels(DomainPartition &domain) const
Checks constitutive models for consistency.
virtual void applyDirichletBC(real64 const time_n, real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) const
Function to perform the Application of Dirichlet type BC's.
void assembleAccumulationTerms(DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
assembles the accumulation terms for all cells
virtual void registerDataOnMesh(Group &meshBodies) override
Register wrappers that contain data on the mesh objects.
virtual void updateState(DomainPartition &domain) override
Recompute all dependent quantities from primary variables (including constitutive models)
virtual void updateFluidModel(ObjectManagerBase &dataGroup) const
Function to update all constitutive models.
virtual ~SinglePhaseBase() override
default destructor
virtual void assembleStabilizedFluxTerms(real64 const dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)=0
assembles the flux terms for all cells including jump stabilization
virtual void assembleFluxTerms(real64 const dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)=0
assembles the flux terms for all cells
void accumulationAssemblyLaunch(DofManager const &dofManager, SUBREGION_TYPE const &subRegion, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)
assembles the accumulation terms for all cells of a spcefici subRegion.
SinglePhaseBase(const string &name, Group *const parent)
main constructor for Group Objects
void updateThermalConductivity(ElementSubRegionBase &subRegion) const
Update thermal conductivity.
SinglePhaseBase(SinglePhaseBase &&)=default
default move constructor
virtual void initializePreSubGroups() override
Called by Initialize() prior to initializing sub-Groups.
virtual real64 scalingForSystemSolution(DomainPartition &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localSolution) override
Function to determine if the solution vector should be scaled back in order to maintain a known const...
virtual void implicitStepComplete(real64 const &time, real64 const &dt, DomainPartition &domain) override
perform cleanup for implicit timestep
virtual void assembleSystem(real64 const time_n, real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
function to assemble the linear system matrix and rhs
virtual void applyBoundaryConditions(real64 const time_n, real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
apply boundary condition to system
virtual bool checkSystemSolution(DomainPartition &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localSolution, real64 const scalingFactor) override
Function to check system solution for physical consistency and constraint violation.
virtual void implicitStepSetup(real64 const &time_n, real64 const &dt, DomainPartition &domain) override
function to perform setup for implicit timestep
virtual void resetStateToBeginningOfStep(DomainPartition &domain) override
reset state of physics back to the beginning of the step.
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