GEOS
SinglePhaseWell.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_SINGLEPHASEWELL_HPP_
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_
22 
23 #include "physicsSolvers/fluidFlow/wells/WellControls.hpp"
24 
25 #include "constitutive/fluid/singlefluid/SingleFluidLayouts.hpp"
26 
27 namespace geos
28 {
29 
30 namespace dataRepository
31 {
32 class Group;
33 }
34 
35 namespace constitutive
36 {
37 class SingleFluidBase;
38 }
39 
40 namespace singlePhaseStatistics
41 {
42 class StatsAggregator;
43 }
44 
45 class WellElementSubRegion;
46 
53 {
54 public:
55 
56  using DerivOffset = constitutive::singlefluid::DerivativeOffsetC< 1 >;
62  SinglePhaseWell( const string & name,
63  Group * const parent );
64 
66  SinglePhaseWell() = delete;
67 
69  SinglePhaseWell( SinglePhaseWell const & ) = delete;
70 
73 
75  SinglePhaseWell & operator=( SinglePhaseWell const & ) = delete;
76 
79 
83  virtual ~SinglePhaseWell() override;
84 
85  void registerWellDataOnMesh( WellElementSubRegion & subRegion ) override;
86 
101  virtual void initializeWell( DomainPartition & domain, Group & meshBodies, string const & meshBodyName, MeshLevel & mesh, WellElementSubRegion & subRegion, real64 const & time_n )override;
102 
103  virtual void initializeWellPostInitialConditionsPreSubGroups( WellElementSubRegion & subRegion )override;
104 
105  virtual bool isCompositional() const override { return false; }
109  virtual void assembleWellAccumulationTerms( real64 const & time,
110  real64 const & dt,
111  WellElementSubRegion & subRegion,
112  DofManager const & dofManager,
113  CRSMatrixView< real64, globalIndex const > const & localMatrix,
114  arrayView1d< real64 > const & localRhs ) override;
118  virtual void assembleWellPressureRelations( real64 const & time_n,
119  real64 const & dt,
120  WellElementSubRegion const & subRegion,
121  DofManager const & dofManager,
122  CRSMatrixView< real64, globalIndex const > const & localMatrix,
123  arrayView1d< real64 > const & localRhs ) override;
124 
128  virtual void assembleWellConstraintTerms( real64 const & time_n,
129  real64 const & dt,
130  WellElementSubRegion const & subRegion,
131  DofManager const & dofManager,
132  CRSMatrixView< real64, globalIndex const > const & localMatrix,
133  arrayView1d< real64 > const & localRhs ) override;
134 
138  virtual void computeWellPerforationRates( real64 const & time_n,
139  real64 const & GEOS_UNUSED_PARAM( dt ),
140  ElementRegionManager & elemManager,
141  WellElementSubRegion & subRegion ) override;
142 
146  virtual void assembleWellFluxTerms( real64 const & time,
147  real64 const & dt,
148  WellElementSubRegion const & subRegion,
149  DofManager const & dofManager,
150  CRSMatrixView< real64, globalIndex const > const & localMatrix,
151  arrayView1d< real64 > const & localRhs ) override;
162  virtual array1d< real64 >
163  calculateLocalWellResidualNorm( real64 const & time_n,
164  real64 const & dt,
165  NonlinearSolverParameters const & nonlinearSolverParameters,
166  WellElementSubRegion const & subRegion,
167  DofManager const & dofManager,
168  arrayView1d< real64 const > const & localRhs )override;
169 
170 
171  virtual real64
172  calculateWellResidualNorm( real64 const & time_n,
173  real64 const & dt,
174  NonlinearSolverParameters const & nonlinearSolverParameters,
175  WellElementSubRegion const & subRegion,
176  DofManager const & dofManager,
177  arrayView1d< real64 const > const & localRhs ) override;
178 
191  DofManager const & dofManager,
192  real64 & maxDeltaPres,
193  real64 & maxDeltaTemp,
194  real64 & minPresScalingFactor,
195  real64 & minTempScalingFactor,
196  arrayView1d< real64 const > const & localSolution );
197 
198  virtual real64 scalingForWellSystemSolution( WellElementSubRegion & subRegion,
199  DofManager const & dofManager,
200  arrayView1d< real64 const > const & localSolution ) override;
206  virtual bool
208  DofManager const & dofManager,
209  arrayView1d< real64 const > const & localSolution,
210  real64 const scalingFactor,
211  real64 & minPressure,
212  real64 & minDensity,
213  real64 & minTotalDensity,
214  ElementsReporterBuffer & negPressureIds,
215  ElementsReporterBuffer & negDensityIds,
216  ElementsReporterBuffer & negTotalDensityIds ) override;
220  virtual void
221  applyWellSystemSolution( DofManager const & dofManager,
222  arrayView1d< real64 const > const & localSolution,
223  real64 const scalingFactor,
224  real64 const dt,
225  DomainPartition & domain,
226  MeshLevel & mesh,
227  WellElementSubRegion & subRegion ) override;
228 
229  virtual void applyWellBoundaryConditions( real64 const time_n,
230  real64 const dt,
231  ElementRegionManager & elemManager,
232  WellElementSubRegion & subRegion,
233  DofManager const & dofManager,
234  arrayView1d< real64 > const & localRhs,
235  CRSMatrixView< real64, globalIndex const > const & localMatrix ) override;
236 
238  string const & meshBodyName, ElementRegionManager const & elemManager, WellElementSubRegion & subRegion ) override;
239 
240  virtual void implicitStepSetup( real64 const & time_n,
241  real64 const & GEOS_UNUSED_PARAM( dt ),
242  DomainPartition & domain,
243  string const & meshBodyName,
244  ElementRegionManager & elemManager,
245  WellElementSubRegion & subRegion )override;
246 
247  virtual void
248  implicitStepComplete( real64 const & time,
249  real64 const & dt,
250  WellElementSubRegion const & subRegion ) override;
251 
252  virtual void printRates( real64 const & time_n,
253  real64 const & dt,
254  WellElementSubRegion const & subRegion ) override;
255 
256  virtual real64 updateSubRegionState( real64 const time_n,
257  MeshBody const & meshBody,
258  ElementRegionManager const & elemManager,
259  WellElementSubRegion & subRegion ) override;
260 
263  virtual string wellElementDofName() const override { return viewKeyStruct::dofFieldString(); }
264 
265  virtual string resElementDofName() const override;
266 
267  virtual localIndex numFluidComponents() const override { return 0; }
268 
269  virtual localIndex numFluidPhases() const override { return 1; }
270 
275  virtual void updateBHPForConstraint( WellElementSubRegion & subRegion );
276 
281  virtual void updateFluidModel( WellElementSubRegion & subRegion ) const;
287  void updateSeparator( ElementRegionManager const & elemManager, WellElementSubRegion & subRegion );
288 
294 
302  virtual real64 updateWellState( MeshBody const & meshBody,
303  ElementRegionManager const & elemManager,
304  WellElementSubRegion & subRegion ) override;
305 
306 
307  void assembleVolumeBalanceTerms( DomainPartition const & domain,
308  DofManager const & dofManager,
309  CRSMatrixView< real64, globalIndex const > const & localMatrix,
310  arrayView1d< real64 > const & localRhs );
311 
313  {
314  static constexpr char const * dofFieldString() { return "wellVars"; }
315 
316 
317  };
318 
319 protected:
320 
322 
323  void saveState( WellElementSubRegion & subRegion );
324 
325  virtual void resetShutInControlState() override;
326 
327  virtual void postRestartInitialization( )override;
330 
331 private:
332 
333  struct ReferenceConditions
334  {
335  real64 pressure;
336  real64 temperature;
337  };
338 
340  std::unique_ptr< singlePhaseStatistics::StatsAggregator > m_reservoirStatsAggregator;
341 
342  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
343 
348  void initializeWells( DomainPartition & domain, real64 const & time_n );
349 
350  void precomputeReferenceConditions( real64 time_n,
351  Group & meshBodies,
352  MeshBody & meshBody,
353  WellElementSubRegion const & subRegion );
354 
355  ReferenceConditions getReferenceConditions( WellElementSubRegion const & subRegion );
356 
363  virtual void validateWellConstraints( real64 const & time_n,
364  real64 const & dt,
365  WellElementSubRegion const & subRegion
366  ) override;
367 
368 
369 
373  virtual void createSeparator( WellElementSubRegion & subRegion ) override;
374 
375 };
376 
377 } // namespace geos
378 
379 
380 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_SINGLEPHASEWELL_HPP_
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:97
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...
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
A buffer to count and store element ids during kernel execution. This facilitates the reporting mecha...
The class is used to manage mesh body.
Definition: MeshBody.hpp:36
Class facilitating the representation of a multi-level discretization of a MeshBody.
Definition: MeshLevel.hpp:42
virtual ~SinglePhaseWell() override
default destructor
virtual void initializePostInitialConditionsPreSubGroups() override
Called by InitializePostInitialConditions() prior to initializing sub-Groups.
SinglePhaseWell(const string &name, Group *const parent)
main constructor for Group Objects
virtual real64 updateWellState(MeshBody const &meshBody, ElementRegionManager const &elemManager, WellElementSubRegion &subRegion) override
Recompute all dependent quantities from primary variables (including constitutive models)
SinglePhaseWell(SinglePhaseWell &&)=delete
default move constructor
SinglePhaseWell & operator=(SinglePhaseWell const &)=delete
deleted assignment operator
SinglePhaseWell(SinglePhaseWell const &)=delete
deleted copy constructor
void calculateReferenceElementRates(WellElementSubRegion &subRegion)
Calculate well rates at the reference element.
virtual void updateFluidModel(WellElementSubRegion &subRegion) const
Update fluid constitutive model state.
integer m_allowNegativePressure
flag if negative pressure is allowed
void updateSeparator(ElementRegionManager const &elemManager, WellElementSubRegion &subRegion)
Update separator model state.
SinglePhaseWell & operator=(SinglePhaseWell &&)=delete
deleted move operator
virtual void updateBHPForConstraint(WellElementSubRegion &subRegion)
Recompute the BHP pressure that is used in the well constraints.
virtual void postRestartInitialization() override
Performs initialization required after reading from a restart file.
SinglePhaseWell()=delete
deleted default constructor
This class describes the controls used to operate a well.
This class describes a collection of local well elements and perforations.
virtual bool checkWellSystemSolution(WellElementSubRegion &subRegion, DofManager const &dofManager, arrayView1d< real64 const > const &localSolution, real64 const scalingFactor, real64 &minPressure, real64 &minDensity, real64 &minTotalDensity, ElementsReporterBuffer &negPressureIds, ElementsReporterBuffer &negDensityIds, ElementsReporterBuffer &negTotalDensityIds) override
real64 scalingForLocalSystemSolution(WellElementSubRegion &subRegion, DofManager const &dofManager, real64 &maxDeltaPres, real64 &maxDeltaTemp, real64 &minPresScalingFactor, real64 &minTempScalingFactor, arrayView1d< real64 const > const &localSolution)
Compute the Newton update scaling factor of one well, with the quantities reported in the log.
virtual void resetStateToBeginningOfStep(DomainPartition &domain, string const &meshBodyName, ElementRegionManager const &elemManager, WellElementSubRegion &subRegion) override
Reset the well state to the beginning of the time step.
virtual void applyWellSystemSolution(DofManager const &dofManager, arrayView1d< real64 const > const &localSolution, real64 const scalingFactor, real64 const dt, DomainPartition &domain, MeshLevel &mesh, WellElementSubRegion &subRegion) override
virtual void assembleWellAccumulationTerms(real64 const &time, real64 const &dt, WellElementSubRegion &subRegion, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the accumulation term for an individual well
virtual void assembleWellConstraintTerms(real64 const &time_n, real64 const &dt, WellElementSubRegion const &subRegion, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the well constraint terms for an individual well
virtual void computeWellPerforationRates(real64 const &time_n, real64 const &GEOS_UNUSED_PARAM(dt), ElementRegionManager &elemManager, WellElementSubRegion &subRegion) override
Recompute the perforation rates for all the wells.
virtual void initializeWell(DomainPartition &domain, Group &meshBodies, string const &meshBodyName, MeshLevel &mesh, WellElementSubRegion &subRegion, real64 const &time_n) override
Initialize well for the beginning of a simulation or restart.
virtual void assembleWellPressureRelations(real64 const &time_n, real64 const &dt, WellElementSubRegion const &subRegion, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
assembles the well constraint terms for an individual well
virtual void assembleWellFluxTerms(real64 const &time, real64 const &dt, WellElementSubRegion const &subRegion, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs) override
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:309
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
Struct to serve as a container for variable strings and keys.