GEOS
HydrofractureSolver.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_MULTIPHYSICS_HYDROFRACTURESOLVER_HPP_
21 #define GEOS_PHYSICSSOLVERS_MULTIPHYSICS_HYDROFRACTURESOLVER_HPP_
22 
28 
29 namespace geos
30 {
31 
32 using dataRepository::Group;
33 
34 template< typename POROMECHANICS_SOLVER = SinglePhasePoromechanics<> >
35 class HydrofractureSolver : public POROMECHANICS_SOLVER
36 {
37 public:
38 
39  using Base = POROMECHANICS_SOLVER;
40  using Base::m_solvers;
41  using Base::m_names;
42  using Base::m_dofManager;
43  using Base::m_localMatrix;
44  using Base::m_rhs;
45  using Base::m_solution;
46  using Base::m_linearSolverParameters;
47 
48  using Base::registerWrapper;
49  using Base::forDiscretizationOnMeshTargets;
50  using Base::getMeshModificationTimestamp;
51  using Base::getSystemSetupTimestamp;
52  using Base::nonlinearImplicitStep;
53  using Base::implicitStepComplete;
54  using Base::getLogLevel;
55  using Base::setSystemSetupTimestamp;
56  using Base::setupDofs;
57  using Base::flowSolver;
58  using Base::solidMechanicsSolver;
59  using Base::assembleElementBasedTerms;
60  using Base::resetStateToBeginningOfStep;
61 
62 
68  HydrofractureSolver( const string & name,
69  Group * const parent );
70 
72  ~HydrofractureSolver() override {}
73 
74  static string catalogName()
75  {
76  // single phase
77  if constexpr ( std::is_same_v< POROMECHANICS_SOLVER, SinglePhasePoromechanics< SinglePhaseBase > > )
78  {
79  return "Hydrofracture";
80  }
81 // // multi phase (TODO)
82 // else if constexpr ( std::is_same_v< POROMECHANICS_SOLVER, MultiphasePoromechanics< CompositionalMultiphaseBase > > )
83 // {
84 // return "MultiphaseHydrofracture";
85 // }
86  }
90  string getCatalogName() const override { return catalogName(); }
91 
93  static string coupledSolverAttributePrefix() { return "poromechanics"; }
94 
102  virtual void registerDataOnMesh( Group & MeshBodies ) override final;
103 
104  virtual void setupCoupling( DomainPartition const & domain,
105  DofManager & dofManager ) const override final;
106 
107  virtual void setupSystem( DomainPartition & domain,
108  DofManager & dofManager,
109  CRSMatrix< real64, globalIndex > & localMatrix,
110  ParallelVector & rhs,
111  ParallelVector & solution,
112  bool const setSparsity = true ) override;
113 
114  virtual void implicitStepSetup( real64 const & time_n,
115  real64 const & dt,
116  DomainPartition & domain ) override final;
117 
118  virtual void assembleSystem( real64 const time,
119  real64 const dt,
120  DomainPartition & domain,
121  DofManager const & dofManager,
122  CRSMatrixView< real64, globalIndex const > const & localMatrix,
123  arrayView1d< real64 > const & localRhs ) override;
124 
125  virtual real64 setNextDt( real64 const & currentDt,
126  DomainPartition & domain ) override;
127 
128  virtual void updateState( DomainPartition & domain ) override final;
129 
130  virtual void implicitStepComplete( real64 const & time_n,
131  real64 const & dt,
132  DomainPartition & domain ) override final;
133 
134  virtual void resetStateToBeginningOfStep( DomainPartition & domain ) override final;
135 
138  void updateHydraulicApertureAndFracturePermeability( DomainPartition & domain );
139 
140  void assembleForceResidualDerivativeWrtPressure( DomainPartition & domain,
141  CRSMatrixView< real64, globalIndex const > const & localMatrix,
142  arrayView1d< real64 > const & localRhs );
143 
144  void assembleFluidMassResidualDerivativeWrtDisplacement( DomainPartition const & domain,
145  CRSMatrixView< real64, globalIndex const > const & localMatrix );
146 
147  std::unique_ptr< CRSMatrix< real64, localIndex > > & getRefDerivativeFluxResidual_dAperture()
148  {
149  return m_derivativeFluxResidual_dAperture;
150  }
151 
152  CRSMatrixView< real64, localIndex const > getDerivativeFluxResidual_dNormalJump()
153  {
154  return m_derivativeFluxResidual_dAperture->toViewConstSizes();
155  }
156 
157  CRSMatrixView< real64 const, localIndex const > getDerivativeFluxResidual_dNormalJump() const
158  {
159  return m_derivativeFluxResidual_dAperture->toViewConst();
160  }
161 
162  enum class InitializationType : integer
163  {
164  Pressure,
165  Displacement,
166  };
167 
168  struct viewKeyStruct : Base::viewKeyStruct
169  {
170  constexpr static char const * surfaceGeneratorNameString() { return "surfaceGeneratorName"; }
171 
172  constexpr static char const * maxNumResolvesString() { return "maxNumResolves"; }
173 
174  constexpr static char const * isMatrixPoroelasticString() { return "isMatrixPoroelastic"; }
175 
176  constexpr static char const * newFractureInitializationTypeString() { return "newFractureInitializationType"; }
177 
178  constexpr static char const * useQuasiNewtonString() { return "useQuasiNewton"; }
179 
180  constexpr static char const * isLaggingFractureStencilWeightsUpdateString() { return "isLaggingFractureStencilWeightsUpdate"; }
181 
182 #ifdef GEOS_USE_SEPARATION_COEFFICIENT
183  constexpr static char const * separationCoeff0String() { return "separationCoeff0"; }
184  constexpr static char const * apertureAtFailureString() { return "apertureAtFailure"; }
185 #endif
186  };
187 
188 protected:
189 
190  virtual void postInputInitialization() override final;
191 
199  DofManager & dofManager,
200  arrayView1d< localIndex > const & rowLengths ) const;
201 
202 
210  DofManager & dofManager,
211  SparsityPatternView< globalIndex > const & pattern ) const;
212 
213 
214  void setUpDflux_dApertureMatrix( DomainPartition & domain,
215  DofManager const & dofManager,
216  CRSMatrix< real64, globalIndex > & localMatrix );
217 
218 
219 private:
220 
221  virtual real64 fullyCoupledSolverStep( real64 const & time_n,
222  real64 const & dt,
223  int const cycleNumber,
224  DomainPartition & domain ) override final;
225 
226 
231  void initializeNewFractureFields( DomainPartition & domain );
232 
233  // name of the contact relation
234  string m_contactRelationName;
235 
237  string m_surfaceGeneratorName;
238 
240  SurfaceGenerator * m_surfaceGenerator;
241 
242  // it is only important for this case.
243  std::unique_ptr< CRSMatrix< real64, localIndex > > m_derivativeFluxResidual_dAperture;
244 
245  integer m_maxNumResolves;
246  integer m_numResolves[2];
247 
248  integer m_isMatrixPoroelastic;
249 
250  // flag to determine which initialization type to use for the new fracture cell
251  InitializationType m_newFractureInitializationType;
252 
253  integer m_useQuasiNewton; // use Quasi-Newton (see https://arxiv.org/abs/2111.00264)
254 
255  // flag to determine whether or not to apply lagging update for the fracture stencil weights
256  integer m_isLaggingFractureStencilWeightsUpdate;
257 
258 };
259 
261  "Pressure",
262  "Displacement" );
263 
264 
265 } /* namespace geos */
266 
267 #endif /* GEOS_PHYSICSSOLVERS_MULTIPHYSICS_HYDROFRACTURESOLVER_HPP_ */
@ Pressure
Pressure in Pascal.
Definition: Units.hpp:62
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:44
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
~HydrofractureSolver() override
Destructor for the class.
HydrofractureSolver(const string &name, Group *const parent)
main constructor for HydrofractureSolver objects
static string coupledSolverAttributePrefix()
String used to form the solverName used to register solvers in CoupledSolver.
void addFluxApertureCouplingSparsityPattern(DomainPartition &domain, DofManager &dofManager, SparsityPatternView< globalIndex > const &pattern) const
virtual void postInputInitialization() override final
string getCatalogName() const override
void addFluxApertureCouplingNNZ(DomainPartition &domain, DofManager &dofManager, arrayView1d< localIndex > const &rowLengths) const
virtual void setupCoupling(DomainPartition const &domain, DofManager &dofManager) const override final
Utility function to set the coupling between degrees of freedom.
virtual void resetStateToBeginningOfStep(DomainPartition &domain) override final
reset state of physics back to the beginning of the step.
virtual void implicitStepComplete(real64 const &time_n, real64 const &dt, DomainPartition &domain) override final
perform cleanup for implicit timestep
virtual real64 setNextDt(real64 const &currentDt, DomainPartition &domain) override
function to set the next time step size
virtual void registerDataOnMesh(Group &MeshBodies) override final
Register wrappers that contain data on the mesh objects.
virtual void setupSystem(DomainPartition &domain, DofManager &dofManager, CRSMatrix< real64, globalIndex > &localMatrix, ParallelVector &rhs, ParallelVector &solution, bool const setSparsity=true) override
Set up the linear system (DOF indices and sparsity patterns)
virtual void assembleSystem(real64 const time, 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 updateState(DomainPartition &domain) override final
Recompute all dependent quantities from primary variables (including constitutive models)
virtual void implicitStepSetup(real64 const &time_n, real64 const &dt, DomainPartition &domain) override final
function to perform setup for implicit timestep
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
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:88
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "preconditioner")
Declare strings associated with enumeration values.
LvArray::SparsityPatternView< COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > SparsityPatternView
Alias for Sparsity pattern View.
Definition: DataTypes.hpp:302
double real64
64-bit floating point type.
Definition: DataTypes.hpp:99
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:85
std::int32_t integer
Signed integer type.
Definition: DataTypes.hpp:82
LvArray::CRSMatrix< T, COL_INDEX, localIndex, LvArray::ChaiBuffer > CRSMatrix
Alias for CRS Matrix class.
Definition: DataTypes.hpp:306
LAInterface::ParallelVector ParallelVector
Alias for ParallelVector.