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 
179  virtual real64 scalingForWellSystemSolution( WellElementSubRegion & subRegion,
180  DofManager const & dofManager,
181  arrayView1d< real64 const > const & localSolution ) override;
187  virtual bool
189  DofManager const & dofManager,
190  arrayView1d< real64 const > const & localSolution,
191  real64 const scalingFactor,
192  real64 & minPressure,
193  real64 & minDensity,
194  real64 & minTotalDensity,
195  ElementsReporterBuffer & negPressureIds,
196  ElementsReporterBuffer & negDensityIds,
197  ElementsReporterBuffer & negTotalDensityIds ) override;
201  virtual void
202  applyWellSystemSolution( DofManager const & dofManager,
203  arrayView1d< real64 const > const & localSolution,
204  real64 const scalingFactor,
205  real64 const dt,
206  DomainPartition & domain,
207  MeshLevel & mesh,
208  WellElementSubRegion & subRegion ) override;
209 
210  virtual void applyWellBoundaryConditions ( real64 const GEOS_UNUSED_PARAM( time_n ),
211  real64 const GEOS_UNUSED_PARAM( dt ),
212  ElementRegionManager & GEOS_UNUSED_PARAM( elemManager ),
214  DofManager const & GEOS_UNUSED_PARAM( dofManager ),
215  arrayView1d< real64 > const & GEOS_UNUSED_PARAM( localRhs ),
216  CRSMatrixView< real64, globalIndex const > const & GEOS_UNUSED_PARAM( localMatrix ) )override {};
217 
219  string const & meshBodyName, ElementRegionManager const & elemManager, WellElementSubRegion & subRegion ) override;
220 
221  virtual void implicitStepSetup( real64 const & time_n,
222  real64 const & GEOS_UNUSED_PARAM( dt ),
223  DomainPartition & domain,
224  string const & meshBodyName,
225  ElementRegionManager & elemManager,
226  WellElementSubRegion & subRegion )override;
227 
228  virtual void
229  implicitStepComplete( real64 const & time,
230  real64 const & dt,
231  WellElementSubRegion const & subRegion ) override;
232 
233  virtual void printRates( real64 const & time_n,
234  real64 const & dt,
235  WellElementSubRegion const & subRegion ) override;
236 
237  virtual real64 updateSubRegionState( real64 const time_n,
238  MeshBody const & meshBody,
239  ElementRegionManager const & elemManager,
240  WellElementSubRegion & subRegion ) override;
241 
244  virtual string wellElementDofName() const override { return viewKeyStruct::dofFieldString(); }
245 
246  virtual string resElementDofName() const override;
247 
248  virtual localIndex numFluidComponents() const override { return 0; }
249 
250  virtual localIndex numFluidPhases() const override { return 1; }
251 
256  virtual void updateBHPForConstraint( WellElementSubRegion & subRegion );
257 
262  virtual void updateFluidModel( WellElementSubRegion & subRegion ) const;
268  void updateSeparator( ElementRegionManager const & elemManager, WellElementSubRegion & subRegion );
269 
275 
283  virtual real64 updateWellState( MeshBody const & meshBody,
284  ElementRegionManager const & elemManager,
285  WellElementSubRegion & subRegion ) override;
286 
287 
288  /*
289  * @brief apply a special treatment to the wells that are shut
290 
291  * @param dofManager degree-of-freedom manager associated with the linear system
292  * @param matrix the system matrix
293  * @param rhs the system right-hand side vector
294  */
295  void shutDownWell( WellElementSubRegion & subRegion,
296  DofManager const & dofManager,
297  CRSMatrixView< real64, globalIndex const > const & localMatrix,
298  arrayView1d< real64 > const & localRhs );
299 
300  void assembleVolumeBalanceTerms( DomainPartition const & domain,
301  DofManager const & dofManager,
302  CRSMatrixView< real64, globalIndex const > const & localMatrix,
303  arrayView1d< real64 > const & localRhs );
304 
306  {
307  static constexpr char const * dofFieldString() { return "wellVars"; }
308 
309 
310  };
311 
312 protected:
313 
315 
316  void saveState( WellElementSubRegion & subRegion );
317 
318  virtual void postRestartInitialization( )override;
321 
322 private:
323 
324  struct ReferenceConditions
325  {
326  real64 pressure;
327  real64 temperature;
328  };
329 
331  std::unique_ptr< singlePhaseStatistics::StatsAggregator > m_reservoirStatsAggregator;
332 
333  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const override;
334 
339  void initializeWells( DomainPartition & domain, real64 const & time_n );
340 
341  void precomputeReferenceConditions( real64 time_n,
342  Group & meshBodies,
343  MeshBody & meshBody,
344  WellElementSubRegion const & subRegion );
345 
346  ReferenceConditions getReferenceConditions( WellElementSubRegion const & subRegion );
347 
354  virtual void validateWellConstraints( real64 const & time_n,
355  real64 const & dt,
356  WellElementSubRegion const & subRegion
357  ) override;
358 
359 
360 
364  virtual void createSeparator( WellElementSubRegion & subRegion ) override;
365 
366 };
367 
368 } // namespace geos
369 
370 
371 #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
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.