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 Total, S.A
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 
26 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
27 #include "constitutive/solid/CoupledSolidBase.hpp"
28 
29 
30 namespace geos
31 {
32 
33 namespace constitutive
34 {
35 
36 class ConstitutiveBase;
37 
38 }
39 
46 {
47 public:
53  SinglePhaseBase( const string & name,
54  Group * const parent );
55 
56 
58  SinglePhaseBase() = delete;
59 
61  SinglePhaseBase( SinglePhaseBase const & ) = delete;
62 
65 
67  SinglePhaseBase & operator=( SinglePhaseBase const & ) = delete;
68 
71 
75  virtual ~SinglePhaseBase() override = default;
76 
77  virtual void registerDataOnMesh( Group & meshBodies ) override;
78 
85 
86  virtual void
87  implicitStepSetup( real64 const & time_n,
88  real64 const & dt,
89  DomainPartition & domain ) override;
90 
91  virtual void
92  assembleSystem( real64 const time_n,
93  real64 const dt,
94  DomainPartition & domain,
95  DofManager const & dofManager,
97  arrayView1d< real64 > const & localRhs ) override;
98 
99  virtual void
101  real64 const dt,
102  DomainPartition & domain,
103  DofManager const & dofManager,
104  CRSMatrixView< real64, globalIndex const > const & localMatrix,
105  arrayView1d< real64 > const & localRhs ) override;
106 
107  virtual real64
109  DofManager const & dofManager,
110  arrayView1d< real64 const > const & localSolution ) override;
111 
112  virtual bool
114  DofManager const & dofManager,
115  arrayView1d< real64 const > const & localSolution,
116  real64 const scalingFactor ) override;
117 
118  virtual void
120 
121  virtual void
123  real64 const & dt,
124  DomainPartition & domain ) override;
125 
127 
138  DofManager const & dofManager,
139  CRSMatrixView< real64, globalIndex const > const & localMatrix,
140  arrayView1d< real64 > const & localRhs );
141 
151  template< typename SUBREGION_TYPE >
152  void accumulationAssemblyLaunch( DofManager const & dofManager,
153  SUBREGION_TYPE const & subRegion,
154  CRSMatrixView< real64, globalIndex const > const & localMatrix,
155  arrayView1d< real64 > const & localRhs );
156 
166  virtual void
168  DomainPartition const & domain,
169  DofManager const & dofManager,
170  CRSMatrixView< real64, globalIndex const > const & localMatrix,
171  arrayView1d< real64 > const & localRhs ) = 0;
172 
182  virtual void
184  DomainPartition const & domain,
185  DofManager const & dofManager,
186  CRSMatrixView< real64, globalIndex const > const & localMatrix,
187  arrayView1d< real64 > const & localRhs ) = 0;
188 
199  virtual void
201  real64 const dt,
202  DomainPartition const & domain,
203  DofManager const & dofManager,
204  CRSMatrixView< real64, globalIndex const > const & localMatrix,
205  arrayView1d< real64 > const & localRhs,
206  string const & jumpDofKey ) = 0;
207 
218  virtual void
220  real64 const dt,
221  DomainPartition const & domain,
222  DofManager const & dofManager,
223  CRSMatrixView< real64, globalIndex const > const & localMatrix,
224  arrayView1d< real64 > const & localRhs,
225  CRSMatrixView< real64, localIndex const > const & dR_dAper ) = 0;
226 
228  {
229  static constexpr char const * elemDofFieldString() { return "singlePhaseVariables"; }
230  };
231 
241  void
242  applyDirichletBC( real64 const time_n,
243  real64 const dt,
244  DomainPartition & domain,
245  DofManager const & dofManager,
246  CRSMatrixView< real64, globalIndex const > const & localMatrix,
247  arrayView1d< real64 > const & localRhs ) const;
248 
258  void
259  applySourceFluxBC( real64 const time_n,
260  real64 const dt,
261  DomainPartition & domain,
262  DofManager const & dofManager,
263  CRSMatrixView< real64, globalIndex const > const & localMatrix,
264  arrayView1d< real64 > const & localRhs ) const;
265 
275  virtual void
276  applyAquiferBC( real64 const time,
277  real64 const dt,
278  DomainPartition & domain,
279  DofManager const & dofManager,
280  CRSMatrixView< real64, globalIndex const > const & localMatrix,
281  arrayView1d< real64 > const & localRhs ) const = 0;
282 
283  virtual void
284  updateState ( DomainPartition & domain ) override final;
285 
290  real64
292 
293 
298  virtual void
299  updateFluidModel( ObjectManagerBase & dataGroup ) const;
300 
305  void
306  updateMass( ElementSubRegionBase & subRegion ) const;
307 
312  void
313  updateEnergy( ElementSubRegionBase & subRegion ) const;
314 
320 
326 
331  void
332  updateMobility( ObjectManagerBase & dataGroup ) const;
333 
334  virtual void initializePreSubGroups() override;
335 
337 
342 
346  virtual void updatePressureGradient( DomainPartition & domain )
347  {
348  GEOS_UNUSED_VAR( domain );
349  }
350 
363  real64 const dt,
364  DofManager const & dofManager,
365  DomainPartition & domain,
366  CRSMatrixView< real64, globalIndex const > const & localMatrix,
367  arrayView1d< real64 > const & localRhs ) const;
368 
369 protected:
370 
375  virtual void validateConstitutiveModels( DomainPartition & domain ) const;
376 
380  void initializeAquiferBC() const;
381 
382  virtual void setConstitutiveNamesCallSuper( ElementSubRegionBase & subRegion ) const override;
383 
388  virtual void saveConvergedState( ElementSubRegionBase & subRegion ) const override;
389 
394  {
401  };
402 
407  {
410  };
411 
422  virtual FluidPropViews getFluidProperties( constitutive::ConstitutiveBase const & fluid ) const;
423 
424  virtual ThermalFluidPropViews getThermalFluidProperties( constitutive::ConstitutiveBase const & fluid ) const;
425 
426 private:
427  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
428 
429 };
430 
431 template< typename SUBREGION_TYPE >
433  SUBREGION_TYPE const & subRegion,
434  CRSMatrixView< real64, globalIndex const > const & localMatrix,
435  arrayView1d< real64 > const & localRhs )
436 {
437  geos::constitutive::SingleFluidBase const & fluid =
438  getConstitutiveModel< geos::constitutive::SingleFluidBase >( subRegion, subRegion.template getReference< string >( viewKeyStruct::fluidNamesString() ) );
439  //START_SPHINX_INCLUDE_COUPLEDSOLID
440  geos::constitutive::CoupledSolidBase const & solid =
441  getConstitutiveModel< geos::constitutive::CoupledSolidBase >( subRegion, subRegion.template getReference< string >( viewKeyStruct::solidNamesString() ) );
442  //END_SPHINX_INCLUDE_COUPLEDSOLID
443 
444  string const dofKey = dofManager.getKey( viewKeyStruct::elemDofFieldString() );
445 
446  if( m_isThermal )
447  {
448  thermalSinglePhaseBaseKernels::
449  AccumulationKernelFactory::
450  createAndLaunch< parallelDevicePolicy<> >( dofManager.rankOffset(),
451  dofKey,
452  subRegion,
453  fluid,
454  solid,
455  localMatrix,
456  localRhs );
457  }
458  else
459  {
460  singlePhaseBaseKernels::
461  AccumulationKernelFactory::
462  createAndLaunch< parallelDevicePolicy<> >( dofManager.rankOffset(),
463  dofKey,
464  subRegion,
465  fluid,
466  solid,
467  localMatrix,
468  localRhs );
469  }
470 }
471 
472 } /* namespace geos */
473 
474 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEBASE_HPP_
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
Definition: GeosxMacros.hpp:84
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:44
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
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
virtual void updatePressureGradient(DomainPartition &domain)
Update the cell-wise pressure gradient.
virtual void setConstitutiveNamesCallSuper(ElementSubRegionBase &subRegion) const override
This function sets constitutive name fields on an ElementSubRegionBase, and calls the base function i...
SinglePhaseBase & operator=(SinglePhaseBase &&)=delete
deleted move operator
real64 updateFluidState(ElementSubRegionBase &subRegion) const
Function to update all constitutive state and dependent variables.
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.
virtual ~SinglePhaseBase() override=default
default destructor
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 computeHydrostaticEquilibrium()
Compute the hydrostatic equilibrium using the compositions and temperature input tables.
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.
void updateMass(ElementSubRegionBase &subRegion) const
Function to update fluid mass.
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.
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.
virtual void validateConstitutiveModels(DomainPartition &domain) const
Checks constitutive models for consistency.
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 updateFluidModel(ObjectManagerBase &dataGroup) const
Function to update all constitutive models.
virtual void updateState(DomainPartition &domain) override final
Recompute all dependent quantities from primary variables (including constitutive models)
virtual FluidPropViews getFluidProperties(constitutive::ConstitutiveBase const &fluid) const
Extract properties from a fluid.
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
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)=0
assembles the flux terms for all cells for the hydrofracture case
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:180
LvArray::CRSMatrixView< T, COL_INDEX, localIndex const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:310
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
ArrayView< T, 2, USD > arrayView2d
Alias for 2D array view.
Definition: DataTypes.hpp:196
Structure holding views into fluid properties used by the base solver.
arrayView2d< real64 const > const dDens_dPres
derivative of density w.r.t. pressure
arrayView2d< real64 const > const visc
viscosity
real64 const defaultViscosity
default vi to use for new elements
real64 const defaultDensity
default density to use for new elements
arrayView2d< real64 const > const dVisc_dPres
derivative of viscosity w.r.t. pressure
arrayView2d< real64 const > const dens
density
Structure holding views into thermal fluid properties used by the base solver.
arrayView2d< real64 const > const dDens_dTemp
derivative of density w.r.t. temperature
arrayView2d< real64 const > const dVisc_dTemp
derivative of viscosity w.r.t. temperature