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 
85  static string catalogName()
86  {
87  return "SinglePhaseReactiveTransport";
88  }
89 
93  string getCatalogName() const override { return catalogName(); }
94 
95  virtual void registerDataOnMesh( dataRepository::Group & meshBodies ) override;
96 
97  virtual void
98  setupDofs( DomainPartition const & domain,
99  DofManager & dofManager ) const override;
100 
101  virtual void
102  implicitStepSetup( real64 const & time_n,
103  real64 const & dt,
104  DomainPartition & domain ) override final;
105 
106  virtual void
107  assembleSystem( real64 const time_n,
108  real64 const dt,
109  DomainPartition & domain,
110  DofManager const & dofManager,
111  CRSMatrixView< real64, globalIndex const > const & localMatrix,
112  arrayView1d< real64 > const & localRhs ) override;
113 
114  virtual void
116  real64 const dt,
117  DomainPartition & domain,
118  DofManager const & dofManager,
119  CRSMatrixView< real64, globalIndex const > const & localMatrix,
120  arrayView1d< real64 > const & localRhs ) override;
121 
122  virtual real64
123  calculateResidualNorm( real64 const & time_n,
124  real64 const & dt,
125  DomainPartition const & domain,
126  DofManager const & dofManager,
127  arrayView1d< real64 const > const & localRhs ) override;
128 
129  virtual void
130  applySystemSolution( DofManager const & dofManager,
131  arrayView1d< real64 const > const & localSolution,
132  real64 const scalingFactor,
133  real64 const dt,
134  DomainPartition & domain ) override;
135 
136  virtual void
138 
139  virtual void
141  real64 const & dt,
142  DomainPartition & domain ) override final;
143 
144  virtual void saveConvergedState( ElementSubRegionBase & subRegion ) const override final;
145 
146  virtual void
147  updateState ( DomainPartition & domain ) override final;
148 
149  void updateMixedReactionSystem( ElementSubRegionBase & subRegion ) const;
150 
151  void updateSurfaceArea( ElementSubRegionBase & subRegion ) const;
152 
153  void updateSpeciesAmount( ElementSubRegionBase & subRegion ) const;
154 
155  void updateKineticReactionMolarIncrements( real64 const dt,
156  ElementSubRegionBase & subRegion ) const;
157 
158  virtual void updateFluidModel( ObjectManagerBase & dataGroup ) const override;
159 
160  virtual void updatePorosityAndPermeability( CellElementSubRegion & subRegion ) const override;
161 
163 
164  virtual void initializeFluidState( MeshLevel & mesh, string_array const & regionNames ) override;
165 
166  void initializeEquilibriumReaction( ElementSubRegionBase & subRegion ) const;
167 
172  virtual void validateConstitutiveModels( DomainPartition & domain ) const override final;
173 
179 
189  DomainPartition & domain,
190  DofManager const & dofManager,
191  CRSMatrixView< real64, globalIndex const > const & localMatrix,
192  arrayView1d< real64 > const & localRhs ) const;
193 
202  virtual void
204  DomainPartition const & domain,
205  DofManager const & dofManager,
206  CRSMatrixView< real64, globalIndex const > const & localMatrix,
207  arrayView1d< real64 > const & localRhs ) override;
208 
218  virtual void
219  applySourceFluxBC( real64 const time_n,
220  real64 const dt,
221  DomainPartition & domain,
222  DofManager const & dofManager,
223  CRSMatrixView< real64, globalIndex const > const & localMatrix,
224  arrayView1d< real64 > const & localRhs ) const override;
225 
235  virtual void
236  applyDirichletBC( real64 const time_n,
237  real64 const dt,
238  DomainPartition & domain,
239  DofManager const & dofManager,
240  CRSMatrixView< real64, globalIndex const > const & localMatrix,
241  arrayView1d< real64 > const & localRhs ) const override;
242 
252  template< typename OBJECT_TYPE >
253  void applyFieldValue( real64 const & time_n,
254  real64 const & dt,
255  MeshLevel & mesh,
256  char const logMessage[],
257  string const fieldKey,
258  string const boundaryFieldKey ) const;
259 
260  virtual void
261  applyAquiferBC( real64 const time,
262  real64 const dt,
263  DomainPartition & domain,
264  DofManager const & dofManager,
265  CRSMatrixView< real64, globalIndex const > const & localMatrix,
266  arrayView1d< real64 > const & localRhs ) const override;
267 
268  virtual void
270  real64 const dt,
271  DomainPartition const & domain,
272  DofManager const & dofManager,
273  CRSMatrixView< real64, globalIndex const > const & localMatrix,
274  arrayView1d< real64 > const & localRhs,
275  string const & jumpDofKey ) override final;
276 
277  virtual void
279  DomainPartition const & domain,
280  DofManager const & dofManager,
281  CRSMatrixView< real64, globalIndex const > const & localMatrix,
282  arrayView1d< real64 > const & localRhs ) override;
283 
285  {
286  static constexpr char const * diffusionNamesString() { return "diffusionNames"; }
287  static constexpr char const * isUpdateReactivePorosityString() { return "isUpdateReactivePorosity"; }
288  static constexpr char const * isUpdateSurfaceAreaString() { return "isUpdateSurfaceArea"; }
289  static constexpr char const * immobilePrimarySpeciesIndicesString() { return "immobilePrimarySpeciesIndices"; }
290  };
291 
292 protected:
293 
296 
299 
302 
305 
308 
311 
314 
315 private:
316 
326  void applyFaceDirichletBC( real64 const time_n,
327  real64 const dt,
328  DofManager const & faceSet,
329  DomainPartition & domain,
330  CRSMatrixView< real64, globalIndex const > const & localMatrix,
331  arrayView1d< real64 > const & localRhs );
332 
333 };
334 
335 template< typename OBJECT_TYPE >
337  real64 const & dt,
338  MeshLevel & mesh,
339  char const logMessage[],
340  string const fieldKey,
341  string const boundaryFieldKey ) const
342 {
344 
345  fsManager.apply< OBJECT_TYPE >( time_n + dt,
346  mesh,
347  fieldKey,
348  [&]( FieldSpecificationBase const & fs,
349  string const & setName,
351  OBJECT_TYPE & targetGroup,
352  string const & )
353  {
354  if( fs.getLogLevel() >= 1 && m_nonlinearSolverParameters.m_numNewtonIterations == 0 )
355  {
356  globalIndex const numTargetElems = MpiWrapper::sum< globalIndex >( lset.size() );
357  GEOS_LOG_RANK_0( GEOS_FMT( logMessage,
358  getName(), time_n+dt, fs.getCatalogName(), fs.getName(),
359  setName, targetGroup.getName(), fs.getScale(), numTargetElems ) );
360  }
361 
362  // Specify the bc value of the field
363  fs.applyFieldValue< FieldSpecificationEqual,
364  parallelDevicePolicy<> >( lset,
365  time_n + dt,
366  targetGroup,
367  boundaryFieldKey );
368  } );
369 }
370 
371 } /* namespace geos */
372 
373 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_SINGLEPHASEREACTIVETRANSPORT_HPP_
#define GEOS_LOG_RANK_0(msg)
Log a message on screen on rank 0.
Definition: Logger.hpp:102
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:1331
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