GEOS
SinglePhaseReactiveTransport.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_SINGLEPHASEREACTIVETRANSPORT_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVETRANSPORT_HPP_
22 
38 #include "constitutive/fluid/reactivefluid/ReactiveSinglePhaseFluid.hpp"
39 
40 
41 namespace geos
42 {
43 
50 {
51 
52 public:
53 
59  SinglePhaseReactiveTransport( const string & name,
60  dataRepository::Group * const parent );
61 
63 
66 
69 
72 
75 
79  virtual ~SinglePhaseReactiveTransport() override = default;
80 
81  using SinglePhaseBase::updatePorosityAndPermeability;
82 
87  static string catalogName()
88  {
89  return "SinglePhaseReactiveTransport";
90  }
91 
95  string getCatalogName() const override { return catalogName(); }
96 
97  virtual void registerDataOnMesh( dataRepository::Group & meshBodies ) override;
98 
99  virtual void
100  setupDofs( DomainPartition const & domain,
101  DofManager & dofManager ) const override;
102 
103  virtual void
104  implicitStepSetup( real64 const & time_n,
105  real64 const & dt,
106  DomainPartition & domain ) override final;
107 
108  virtual void
109  assembleSystem( real64 const time_n,
110  real64 const dt,
111  DomainPartition & domain,
112  DofManager const & dofManager,
113  CRSMatrixView< real64, globalIndex const > const & localMatrix,
114  arrayView1d< real64 > const & localRhs ) override;
115 
116  virtual void
118  real64 const dt,
119  DomainPartition & domain,
120  DofManager const & dofManager,
121  CRSMatrixView< real64, globalIndex const > const & localMatrix,
122  arrayView1d< real64 > const & localRhs ) override;
123 
124  virtual real64
125  calculateResidualNorm( real64 const & time_n,
126  real64 const & dt,
127  DomainPartition const & domain,
128  DofManager const & dofManager,
129  arrayView1d< real64 const > const & localRhs ) override;
130 
131  virtual void
132  applySystemSolution( DofManager const & dofManager,
133  arrayView1d< real64 const > const & localSolution,
134  real64 const scalingFactor,
135  real64 const dt,
136  DomainPartition & domain ) override;
137 
138  virtual void
140 
141  virtual void
143  real64 const & dt,
144  DomainPartition & domain ) override final;
145 
146  virtual void saveConvergedState( ElementSubRegionBase & subRegion ) const override final;
147 
148  virtual void
149  updateState ( DomainPartition & domain ) override final;
150 
151  void updateMixedReactionSystem( ElementSubRegionBase & subRegion ) const;
152 
153  void updateSurfaceArea( ElementSubRegionBase & subRegion ) const;
154 
155  void updateSpeciesAmount( ElementSubRegionBase & subRegion ) const;
156 
157  void updateKineticReactionMolarIncrements( real64 const dt,
158  ElementSubRegionBase & subRegion ) const;
159 
160  virtual void updateFluidModel( ObjectManagerBase & dataGroup ) const override;
161 
162  virtual void updatePorosityAndPermeability( CellElementSubRegion & subRegion ) const override;
163 
165 
166  virtual void initializeFluidState( MeshLevel & mesh, string_array const & regionNames ) override;
167 
168  void initializeEquilibriumReaction( ElementSubRegionBase & subRegion ) const;
169 
174  virtual void validateConstitutiveModels( DomainPartition & domain ) const override final;
175 
181 
191  DomainPartition & domain,
192  DofManager const & dofManager,
193  CRSMatrixView< real64, globalIndex const > const & localMatrix,
194  arrayView1d< real64 > const & localRhs ) const;
195 
204  virtual void
206  DomainPartition const & domain,
207  DofManager const & dofManager,
208  CRSMatrixView< real64, globalIndex const > const & localMatrix,
209  arrayView1d< real64 > const & localRhs ) override;
210 
220  virtual void
221  applySourceFluxBC( real64 const time_n,
222  real64 const dt,
223  DomainPartition & domain,
224  DofManager const & dofManager,
225  CRSMatrixView< real64, globalIndex const > const & localMatrix,
226  arrayView1d< real64 > const & localRhs ) const override;
227 
237  virtual void
238  applyDirichletBC( real64 const time_n,
239  real64 const dt,
240  DomainPartition & domain,
241  DofManager const & dofManager,
242  CRSMatrixView< real64, globalIndex const > const & localMatrix,
243  arrayView1d< real64 > const & localRhs ) const override;
244 
254  template< typename OBJECT_TYPE >
255  void applyFieldValue( real64 const & time_n,
256  real64 const & dt,
257  MeshLevel & mesh,
258  char const logMessage[],
259  string const fieldKey,
260  string const boundaryFieldKey ) const;
261 
262  virtual void
263  applyAquiferBC( real64 const time,
264  real64 const dt,
265  DomainPartition & domain,
266  DofManager const & dofManager,
267  CRSMatrixView< real64, globalIndex const > const & localMatrix,
268  arrayView1d< real64 > const & localRhs ) const override;
269 
270  virtual void
272  real64 const dt,
273  DomainPartition const & domain,
274  DofManager const & dofManager,
275  CRSMatrixView< real64, globalIndex const > const & localMatrix,
276  arrayView1d< real64 > const & localRhs,
277  string const & jumpDofKey ) override final;
278 
279  virtual void
281  DomainPartition const & domain,
282  DofManager const & dofManager,
283  CRSMatrixView< real64, globalIndex const > const & localMatrix,
284  arrayView1d< real64 > const & localRhs ) override;
285 
287  {
288  static constexpr char const * diffusionNamesString() { return "diffusionNames"; }
289  static constexpr char const * isUpdateReactivePorosityString() { return "isUpdateReactivePorosity"; }
290  static constexpr char const * isUpdateSurfaceAreaString() { return "isUpdateSurfaceArea"; }
291  static constexpr char const * immobilePrimarySpeciesIndicesString() { return "immobilePrimarySpeciesIndices"; }
292  };
293 
294 protected:
295 
298 
301 
304 
307 
310 
313 
316 
317 private:
318 
328  void applyFaceDirichletBC( real64 const time_n,
329  real64 const dt,
330  DofManager const & faceSet,
331  DomainPartition & domain,
332  CRSMatrixView< real64, globalIndex const > const & localMatrix,
333  arrayView1d< real64 > const & localRhs );
334 
335 };
336 
337 template< typename OBJECT_TYPE >
339  real64 const & dt,
340  MeshLevel & mesh,
341  char const logMessage[],
342  string const fieldKey,
343  string const boundaryFieldKey ) const
344 {
346 
347  fsManager.apply< OBJECT_TYPE >( time_n + dt,
348  mesh,
349  fieldKey,
350  [&]( FieldSpecificationBase const & fs,
351  string const & setName,
353  OBJECT_TYPE & targetGroup,
354  string const & )
355  {
356  if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 )
357  {
358  globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( lset.size() );
359  GEOS_LOG_RANK_0( GEOS_FMT( logMessage,
360  getName(), time_n+dt, fs.getCatalogName(), fs.getName(),
361  setName, targetGroup.getName(), fs.getScale(), numTargetElems ) );
362  }
363 
364  // Specify the bc value of the field
365  fs.applyFieldValue< FieldSpecificationEqual,
366  parallelDevicePolicy<> >( lset,
367  time_n + dt,
368  targetGroup,
369  boundaryFieldKey );
370  } );
371 }
372 
373 } /* namespace geos */
374 
375 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVETRANSPORT_HPP_
#define GEOS_LOG_RANK_0(msg)
Log a message on screen on rank 0.
Definition: Logger.hpp:99
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...
void apply(real64 const time, MeshLevel &mesh, string const &fieldName, LAMBDA &&lambda) const
This function is the main driver for the field applications.
static FieldSpecificationManager & getInstance()
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
integer m_numNewtonIterations
The number of nonlinear iterations that have been exectued.
The ObjectManagerBase is the base object of all object managers in the mesh data hierachy.
NonlinearSolverParameters m_nonlinearSolverParameters
Nonlinear solver parameters.
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
virtual void validateConstitutiveModels(DomainPartition &domain) const override final
Checks constitutive models for consistency.
virtual ~SinglePhaseReactiveTransport() override=default
default destructor
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 override
Function to perform the Application of Dirichlet type BC's.
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 override
Apply source flux boundary conditions to the system.
virtual void resetStateToBeginningOfStep(DomainPartition &domain) override
reset state of physics back to the beginning of the step.
virtual void assembleStabilizedFluxTerms(real64 const dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the flux terms for all cells including jump stabilization
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
array1d< integer > m_immobilePrimarySpeciesIndices
array to store the indices of immobile primary species
virtual void saveConvergedState(ElementSubRegionBase &subRegion) const override final
Utility function to save the converged state.
virtual void applySystemSolution(DofManager const &dofManager, arrayView1d< real64 const > const &localSolution, real64 const scalingFactor, real64 const dt, DomainPartition &domain) override
Function to apply the solution vector to the state.
virtual void updateFluidModel(ObjectManagerBase &dataGroup) const override
Function to update all constitutive models.
integer m_isUpdateSurfaceArea
flag to determine whether or not to update the surface area
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 implicitStepComplete(real64 const &time, real64 const &dt, DomainPartition &domain) override final
perform cleanup for implicit timestep
virtual void updateState(DomainPartition &domain) override final
Recompute all dependent quantities from primary variables (including constitutive models)
integer numPrimarySpecies() const
Getter for the number of fluid components (species)
integer m_hasDiffusion
flag to determine whether or not to apply diffusion
integer m_isUpdateReactivePorosity
flag to determine whether or not to use the reactive porosity
SinglePhaseReactiveTransport(SinglePhaseReactiveTransport &&)=default
default move constructor
virtual void registerDataOnMesh(dataRepository::Group &meshBodies) override
Register wrappers that contain data on the mesh objects.
virtual void implicitStepSetup(real64 const &time_n, real64 const &dt, DomainPartition &domain) override final
function to perform setup for implicit timestep
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 FieldSpecificationBase::applyFieldValue in BC applicat...
void assembleAccumulationTermsInMassBalanceAndSpeciesAmountEqs(real64 const dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) const
assembles the accumulation terms in total mass balance and primary species amount equation for all ce...
static string catalogName()
name of the node manager in the object catalog
virtual void setupDofs(DomainPartition const &domain, DofManager &dofManager) const override
Populate degree-of-freedom manager with fields relevant to this solver.
SinglePhaseReactiveTransport(SinglePhaseReactiveTransport const &)=delete
deleted copy constructor
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) override final
assembles the flux terms for all cells for the poroelastic case
integer m_numKineticReactions
the number of kinetic reactions
SinglePhaseReactiveTransport & operator=(SinglePhaseReactiveTransport const &)=delete
deleted assignment operator
SinglePhaseReactiveTransport(const string &name, dataRepository::Group *const parent)
main constructor for Group Objects
SinglePhaseReactiveTransport & operator=(SinglePhaseReactiveTransport &&)=delete
deleted move operator
virtual real64 calculateResidualNorm(real64 const &time_n, real64 const &dt, DomainPartition const &domain, DofManager const &dofManager, arrayView1d< real64 const > const &localRhs) override
calculate the norm of the global system residual
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 override
Apply aquifer boundary conditions to the system.
integer m_numPrimarySpecies
the number of primary species in the fluid
virtual void assembleFluxTerms(real64 const dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the flux terms for all cells
string m_reactiveFluidModelName
name of the reactive fluid constitutive model
string const & getName() const
Get group name.
Definition: Group.hpp:1329
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
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
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
LvArray::SortedArrayView< T, localIndex, LvArray::ChaiBuffer > SortedArrayView
A sorted array view of local indices.
Definition: DataTypes.hpp:270
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175