GEOS
CompositionalMultiphaseWell.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_WELLS_COMPOSITIONALMULTIPHASEWELL_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_COMPOSITIONALMULTIPHASEWELL_HPP_
22 
25 
26 namespace geos
27 {
28 
29 namespace constitutive
30 {
31 class ConstitutiveManager;
32 class MultiFluidBase;
33 }
34 
41 {
42 public:
43 
49  CompositionalMultiphaseWell( const string & name,
50  Group * const parent );
51 
54 
57 
60 
63 
66 
70  virtual ~CompositionalMultiphaseWell() override = default;
71 
76  static string catalogName() { return "CompositionalMultiphaseWell"; }
80  string getCatalogName() const override { return catalogName(); }
81 
82  virtual void registerDataOnMesh( Group & meshBodies ) override;
83 
84 
93  virtual real64
94  calculateResidualNorm( real64 const & time_n,
95  real64 const & dt,
96  DomainPartition const & domain,
97  DofManager const & dofManager,
98  arrayView1d< real64 const > const & localRhs ) override;
99 
100  virtual real64
102  DofManager const & dofManager,
103  arrayView1d< real64 const > const & localSolution ) override;
104 
105  virtual bool
107  DofManager const & dofManager,
108  arrayView1d< real64 const > const & localSolution,
109  real64 const scalingFactor ) override;
110 
111  virtual void
112  applySystemSolution( DofManager const & dofManager,
113  arrayView1d< real64 const > const & localSolution,
114  real64 const scalingFactor,
115  real64 const dt,
116  DomainPartition & domain ) override;
117 
118  virtual void
120 
121  virtual void
122  implicitStepSetup( real64 const & time,
123  real64 const & dt,
124  DomainPartition & domain ) override;
125 
126  virtual void
128  real64 const & dt,
129  DomainPartition & domain ) override;
130 
138 
145 
152 
159 
166 
171  void updateTotalMassDensity( WellElementSubRegion & subRegion ) const;
172 
177  virtual void computePerforationRates( real64 const & time_n,
178  real64 const & dt, DomainPartition & domain ) override;
179 
184  virtual void updateState( DomainPartition & domain ) override;
185 
186  virtual real64 updateSubRegionState( WellElementSubRegion & subRegion ) override;
187 
188  virtual string wellElementDofName() const override { return viewKeyStruct::dofFieldString(); }
189 
190  virtual string resElementDofName() const override { return CompositionalMultiphaseBase::viewKeyStruct::elemDofFieldString(); }
191 
192  virtual localIndex numFluidComponents() const override { return m_numComponents; }
193 
194  virtual localIndex numFluidPhases() const override { return m_numPhases; }
195 
196  integer useTotalMassEquation() const { return m_useTotalMassEquation; }
197 
208  virtual void assembleFluxTerms( real64 const & time_n,
209  real64 const & dt,
210  DomainPartition & domain,
211  DofManager const & dofManager,
212  CRSMatrixView< real64, globalIndex const > const & localMatrix,
213  arrayView1d< real64 > const & localRhs )override;
221  virtual void assembleAccumulationTerms( 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 ) override;
227 
237  virtual void assemblePressureRelations( real64 const & time_n,
238  real64 const & dt,
239  DomainPartition const & domain,
240  DofManager const & dofManager,
241  CRSMatrixView< real64, globalIndex const > const & localMatrix,
242  arrayView1d< real64 > const & localRhs ) override;
243 
249 
251  {
252  static constexpr char const * dofFieldString() { return "compositionalWellVars"; }
253 
254  // inputs
255 
256  static constexpr char const * useMassFlagString() { return CompositionalMultiphaseBase::viewKeyStruct::useMassFlagString(); }
257 
258  static constexpr char const * useTotalMassEquationString() { return CompositionalMultiphaseBase::viewKeyStruct::useTotalMassEquationString(); }
259 
260  static constexpr char const * maxCompFracChangeString() { return CompositionalMultiphaseBase::viewKeyStruct::maxCompFracChangeString(); }
261 
262  static constexpr char const * maxRelativePresChangeString() { return "maxRelativePressureChange"; }
263 
264  static constexpr char const * maxAbsolutePresChangeString() { return "maxAbsolutePressureChange"; }
265 
266  static constexpr char const * maxRelativeCompDensChangeString() { return "maxRelativeCompDensChange"; }
267 
268  static constexpr char const * maxRelativeTempChangeString() { return "maxRelativeTemperatureChange"; }
269 
270  static constexpr char const * allowLocalCompDensChoppingString() { return CompositionalMultiphaseBase::viewKeyStruct::allowLocalCompDensChoppingString(); }
271 
272  // control data (not registered on the mesh)
273 
274  static constexpr char const * massDensityString() { return "massDensity";}
275 
276  static constexpr char const * currentBHPString() { return "currentBHP"; }
277  static constexpr char const * dCurrentBHPString() { return "dCurrentBHP"; }
278 
279  static constexpr char const * dCurrentBHP_dPresString() { return "dCurrentBHP_dPres"; }
280  static constexpr char const * dCurrentBHP_dCompDensString() { return "dCurrentBHP_dCompDens"; }
281 
282  static constexpr char const * currentPhaseVolRateString() { return "currentPhaseVolumetricRate"; }
283  static constexpr char const * dCurrentPhaseVolRateString() { return "dCurrentPhaseVolumetricRate"; }
284 
285 
286  static constexpr char const * dCurrentPhaseVolRate_dPresString() { return "dCurrentPhaseVolumetricRate_dPres"; }
287 
288  static constexpr char const * dCurrentPhaseVolRate_dCompDensString() { return "dCurrentPhaseVolumetricRate_dCompDens"; }
289 
290  static constexpr char const * dCurrentPhaseVolRate_dRateString() { return "dCurrentPhaseVolumetricRate_dRate"; }
291 
292  static constexpr char const * currentTotalVolRateString() { return "currentTotalVolumetricRate"; }
293  static constexpr char const * dCurrentTotalVolRateString() { return "dCurrentTotalVolumetricRate"; }
294 
295  static constexpr char const * currentMassRateString() { return "currentMassRate"; }
296 
297  static constexpr char const * dCurrentTotalVolRate_dPresString() { return "dCurrentTotalVolumetricRate_dPres"; }
298 
299  static constexpr char const * dCurrentTotalVolRate_dCompDensString() { return "dCurrentTotalVolumetricRate_dCompDens"; }
300 
301  static constexpr char const * dCurrentTotalVolRate_dRateString() { return "dCurrentTotalVolumetricRate_dRate"; }
302 
303  } viewKeysCompMultiphaseWell;
304 
305 protected:
306 
307  virtual void postInputInitialization() override;
308 
309  virtual void initializePostSubGroups() override;
310 
312 
313  /*
314  * @brief Utility function that checks the consistency of the constitutive models
315  * @param[in] domain the domain partition
316  * @detail
317  * This function will produce an error if one of the well constitutive models
318  * is incompatible with the corresponding models in reservoir
319  * regions connected to that particular well.
320  */
321  void validateConstitutiveModels( DomainPartition const & domain ) const;
322 
327  void validateWellControlsForFluid( WellControls const & wellControls,
328  constitutive::MultiFluidBase const & fluid ) const;
329 
334  void validateInjectionStreams( WellElementSubRegion const & subRegion ) const;
335 
342  virtual void validateWellConstraints( real64 const & time_n,
343  real64 const & dt,
344  WellElementSubRegion const & subRegion ) override;
345 
346  void printRates( real64 const & time_n,
347  real64 const & dt,
348  DomainPartition & domain ) override;
349 
350 private:
351 
356  void initializeWells( DomainPartition & domain, real64 const & time_n, real64 const & dt ) override;
357 
358  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
359 
360 
361 
363  integer m_useMass;
364 
366  integer m_useTotalMassEquation;
367 
369  real64 m_maxCompFracChange;
370 
372  real64 m_maxRelativePresChange;
373 
375  real64 m_maxAbsolutePresChange;
376 
378  real64 m_maxRelativeCompDensChange;
379 
381  real64 m_maxRelativeTempChange;
382 
384  real64 m_minScalingFactor;
385 
387  integer m_allowCompDensChopping;
388 
390  localIndex m_targetPhaseIndex;
391 
392 
393 
394 };
395 
396 } // namespace geos
397 
398 
399 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_COMPOSITIONALMULTIPHASEWELL_HPP_
void updateFluidModel(WellElementSubRegion &subRegion)
Update all relevant fluid models using current values of pressure and composition.
virtual void assembleFluxTerms(real64 const &time_n, real64 const &dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the flux terms for all connections between well elements
virtual void updateState(DomainPartition &domain) override
Recompute all dependent quantities from primary variables (including constitutive models)
void chopNegativeDensities(DomainPartition &domain)
Sets all the negative component densities (if any) to zero.
virtual string wellElementDofName() const override
get the name of DOF defined on well elements
CompositionalMultiphaseWell(CompositionalMultiphaseWell const &)=delete
deleted copy constructor
void validateWellControlsForFluid(WellControls const &wellControls, constitutive::MultiFluidBase const &fluid) const
Checks if the WellControls parameters are within the fluid tables ranges.
void updateGlobalComponentFraction(WellElementSubRegion &subRegion) const
Recompute global component fractions from primary variables (component densities)
void updateTotalMassDensity(WellElementSubRegion &subRegion) const
Recompute total mass densities from mass density and phase volume fractions.
CompositionalMultiphaseWell(CompositionalMultiphaseWell &&)=default
default move constructor
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
virtual void computePerforationRates(real64 const &time_n, real64 const &dt, DomainPartition &domain) override
Recompute the perforation rates for all the wells.
void validateInjectionStreams(WellElementSubRegion const &subRegion) const
Checks injection streams for validity (compositions sum to one)
virtual real64 updateSubRegionState(WellElementSubRegion &subRegion) override
Recompute all dependent quantities from primary variables (including constitutive models)
virtual ~CompositionalMultiphaseWell() override=default
default destructor
virtual localIndex numFluidComponents() const override
const getter for the number of fluid components
virtual void validateWellConstraints(real64 const &time_n, real64 const &dt, WellElementSubRegion const &subRegion) override
Make sure that the well constraints are compatible.
CompositionalMultiphaseWell(const string &name, Group *const parent)
main constructor for Group Objects
static string catalogName()
name of the node manager in the object catalog
virtual void registerDataOnMesh(Group &meshBodies) override
Register wrappers that contain data on the mesh objects.
CompositionalMultiphaseWell & operator=(CompositionalMultiphaseWell &&)=delete
deleted move operator
virtual void assembleAccumulationTerms(real64 const &time_n, real64 const &dt, DomainPartition &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the accumulation term for all the well elements
void updateVolRatesForConstraint(WellElementSubRegion &subRegion)
Recompute the volumetric rates that are used in the well constraints.
virtual void assemblePressureRelations(real64 const &time_n, real64 const &dt, DomainPartition const &domain, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the pressure relations at all connections between well elements except at the well head
virtual localIndex numFluidPhases() const override
Get the number of fluid phases.
CompositionalMultiphaseWell & operator=(CompositionalMultiphaseWell const &)=delete
deleted assignment operator
virtual string resElementDofName() const override
get the name of DOF defined on well elements
CompositionalMultiphaseWell()=delete
deleted default constructor
virtual void postInputInitialization() override
real64 updatePhaseVolumeFraction(WellElementSubRegion &subRegion) const
Recompute phase volume fractions (saturations) from constitutive and primary variables.
void updateBHPForConstraint(WellElementSubRegion &subRegion)
Recompute the current BHP pressure.
virtual void initializePostSubGroups() override
Called by Initialize() after to initializing sub-Groups.
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...
This class describes the controls used to operate a well.
This class describes a collection of local well elements and perforations.
integer m_numComponents
the number of fluid components
integer m_numPhases
the max number of fluid phases
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 implicitStepSetup(real64 const &time, 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.
virtual void implicitStepComplete(real64 const &time, real64 const &dt, DomainPartition &domain) override
perform cleanup for implicit timestep
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 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 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.
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
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