GEOS
WellControls.hpp
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 
16 /*
17  * @file WellControls.hpp
18  */
19 
20 #ifndef GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
21 #define GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
22 
25 #include "dataRepository/Group.hpp"
27 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
28 
29 #include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
30 #include "constitutive/fluid/singlefluid/SingleFluidBase.hpp"
31 #include "physicsSolvers/fluidFlow/wells/WellConstraintsBase.hpp"
33 
34 namespace geos
35 {
36 namespace dataRepository
37 {
38 namespace keys
39 {
40 static constexpr auto wellControls = "WellControls";
41 }
42 }
43 
44 class ElementsReporterBuffer;
45 
46 
52 {
53 public:
54 
58  enum class Type : integer
59  {
60  PRODUCER,
61  INJECTOR
62  };
63 
67  enum class Status : integer
68  {
69  OPEN,
70  CLOSED
71  };
72 
73 
78 
84  explicit WellControls( string const & name, dataRepository::Group * const parent );
85 
86 
90  ~WellControls() override;
91 
95  WellControls() = delete;
96 
100  WellControls( WellControls const & ) = delete;
101 
105  WellControls( WellControls && ) = delete;
106 
111  WellControls & operator=( WellControls const & ) = delete;
112 
118 
120 
121 
123  static string coupledSolverAttributePrefix() { return "well"; }
124 
131  virtual Group * createChild( string const & childKey, string const & childName ) override;
132 
134  virtual void expandObjectCatalogs() override;
135 
136  virtual void registerWellDataOnMesh( WellElementSubRegion & subRegion );
137  virtual void setConstitutiveNames( ElementSubRegionBase & subRegion ) const = 0;
141  virtual void createSeparator( WellElementSubRegion & subRegion ) = 0;
142 
151  virtual void validateWellConstraints( real64 const & time_n,
152  real64 const & dt,
153  WellElementSubRegion const & subRegion ) = 0;
154 
155  virtual bool isCompositional() const = 0;
164  virtual void initializeWell( DomainPartition & domain, Group & meshBodies, string const & meshBodyName, MeshLevel & mesh, WellElementSubRegion & subRegion, real64 const & time_n ) = 0;
172  real64 setNextDt( real64 const & currentTime,
173  real64 const & currentDt,
174  WellElementSubRegion & subRegion );
175  // Bring the base class implicitStepSetup into scope to avoid hiding the overloaded virtual function
176 
177 
178  virtual void implicitStepSetup( real64 const & time_n,
179  real64 const & GEOS_UNUSED_PARAM( dt ),
180  DomainPartition & domain,
181  string const & meshBodyName,
182  ElementRegionManager & elemManager,
183  WellElementSubRegion & subRegion ) = 0;
184 
185  virtual void
186  implicitStepComplete( real64 const & time,
187  real64 const & dt,
188  WellElementSubRegion const & subRegion ) = 0;
189  virtual real64 updateSubRegionState( real64 const time_n,
190  MeshBody const & meshBody,
191  ElementRegionManager const & elemManager,
192  WellElementSubRegion & subRegion ) = 0;
193 
200  bool evaluateConstraints( real64 const & time_n,
201  WellElementSubRegion & subRegion );
202 
209  bool evaluateConstraints( real64 const & time_n,
210  real64 const & dt,
211  integer const cycleNumber,
212  integer const coupledIterationNumber,
213  DomainPartition & domain,
214  MeshLevel & mesh,
215  ElementRegionManager & elemManager,
216  WellElementSubRegion & subRegion,
217  DofManager const & dofManager );
218 
219  void solveConstraint( WellConstraintBase *constraint,
220  real64 const & time_n,
221  real64 const & dt,
222  integer const cycleNumber,
223  integer const coupledIterationNumber,
224  DomainPartition & domain,
225  MeshLevel & mesh,
226  ElementRegionManager & elemManager,
227  WellElementSubRegion & subRegion,
228  DofManager const & dofManager );
229 
230  void assembleSystem( real64 const & time_n,
231  real64 const & dt,
232  integer const cycleNumber,
233  ElementRegionManager & elemManager,
234  WellElementSubRegion & subRegion,
235  DofManager const & dofManager,
236  CRSMatrixView< real64, globalIndex const > const & localMatrix,
237  arrayView1d< real64 > const & localRhs );
247  virtual void assembleWellAccumulationTerms( real64 const & time,
248  real64 const & dt,
249  WellElementSubRegion & subRegion,
250  DofManager const & dofManager,
251  CRSMatrixView< real64, globalIndex const > const & localMatrix,
252  arrayView1d< real64 > const & localRhs ) = 0;
262  virtual void assembleWellPressureRelations( real64 const & time_n,
263  real64 const & dt,
264  WellElementSubRegion const & subRegion,
265  DofManager const & dofManager,
266  CRSMatrixView< real64, globalIndex const > const & localMatrix,
267  arrayView1d< real64 > const & localRhs ) = 0;
277  virtual void assembleWellConstraintTerms( real64 const & time_n,
278  real64 const & dt,
279  WellElementSubRegion const & subRegion,
280  DofManager const & dofManager,
281  CRSMatrixView< real64, globalIndex const > const & localMatrix,
282  arrayView1d< real64 > const & localRhs ) = 0;
283 
291  virtual void computeWellPerforationRates( real64 const & time_n,
292  real64 const & GEOS_UNUSED_PARAM( dt ),
293  ElementRegionManager & elemManager,
294  WellElementSubRegion & subRegion ) = 0;
295 
305  virtual void assembleWellFluxTerms( real64 const & time,
306  real64 const & dt,
307  WellElementSubRegion const & subRegion,
308  DofManager const & dofManager,
309  CRSMatrixView< real64, globalIndex const > const & localMatrix,
310  arrayView1d< real64 > const & localRhs ) = 0;
311  virtual real64
312  calculateWellResidualNorm( real64 const & time_n,
313  real64 const & dt,
314  NonlinearSolverParameters const & nonlinearSolverParameters,
315  WellElementSubRegion const & subRegion,
316  DofManager const & dofManager,
317  arrayView1d< real64 const > const & localRhs ) = 0;
318 
319  virtual array1d< real64 >
320  calculateLocalWellResidualNorm( real64 const & time_n,
321  real64 const & dt,
322  NonlinearSolverParameters const & nonlinearSolverParameters,
323  WellElementSubRegion const & subRegion,
324  DofManager const & dofManager,
325  arrayView1d< real64 const > const & localRhs ) = 0;
326 
327  virtual real64
328  scalingForWellSystemSolution( WellElementSubRegion & subRegion,
329  DofManager const & dofManager,
330  arrayView1d< real64 const > const & localSolution ) = 0;
331 
332  virtual bool
333  checkWellSystemSolution( WellElementSubRegion & subRegion,
334  DofManager const & dofManager,
335  arrayView1d< real64 const > const & localSolution,
336  real64 const scalingFactor,
337  real64 & minPressure,
338  real64 & minDensity,
339  real64 & minTotalDensity,
340  ElementsReporterBuffer & negPressureIds,
341  ElementsReporterBuffer & negDensityIds,
342  ElementsReporterBuffer & negTotalDensityIds ) = 0;
343 
344  virtual void
345  applyWellSystemSolution( DofManager const & dofManager,
346  arrayView1d< real64 const > const & localSolution,
347  real64 const scalingFactor,
348  real64 const dt,
349  DomainPartition & domain,
350  MeshLevel & mesh,
351  WellElementSubRegion & subRegion ) = 0;
352 
353  virtual void applyWellBoundaryConditions( real64 const time_n,
354  real64 const dt,
355  ElementRegionManager & elemManager,
356  WellElementSubRegion & subRegion,
357  DofManager const & dofManager,
358  arrayView1d< real64 > const & localRhs,
359  CRSMatrixView< real64, globalIndex const > const & localMatrix ) = 0;
364  virtual real64 updateWellState( MeshBody const & meshBody,
365  ElementRegionManager const & elemManager,
366  WellElementSubRegion & subRegion ) = 0;
367 
373  string const & meshBodyName, ElementRegionManager const & elemManager, WellElementSubRegion & subRegion ) = 0;
374 
375  virtual void postInputInitialization() override;
376 
377  virtual void initializePreSubGroups() override;
378 
379  virtual void initializeWellPostInitialConditionsPreSubGroups( WellElementSubRegion & subRegion ) = 0;
380  virtual void printRates( real64 const & time_n,
381  real64 const & dt,
382  WellElementSubRegion const & subRegion ) = 0;
383 
388 
396  template< typename CONSTITUTIVE_BASE_TYPE >
397  static string getConstitutiveName( ElementSubRegionBase const & subRegion );
398 
407  template< typename CONSTITUTIVE >
408  void setConstitutiveName( ElementSubRegionBase & subRegion, string const & wrapperName, string const & constitutiveType ) const;
409 
414  string_array const & getTargetRegionNames() const {return m_targetRegionNames;}
420 
425  void setFlowSolverName( const std::string & flowSolverName ) { m_flowSolverName = flowSolverName; }
426 
432 
437  void setDiscretizationName( const std::string & discretizationName ) { m_discretizationName = discretizationName; }
443 
448  void setControl( ConstraintTypeId const & newControl ) { m_currentControl = newControl; }
449 
455 
460  integer estimateSolution() const { return m_estimateSolution; }
461 
462 
468  real64 getTargetBHP( real64 const & targetTime, const ConstraintSourceId source = ConstraintSourceId::USER ) const;
469 
475 
481 
487 
493 
499 
504  string const & referenceReservoirRegion() const { return m_referenceReservoirRegion; }
505 
510  const real64 & getSurfacePressure() const { return m_surfacePres; }
511 
516  const real64 & getSurfaceTemperature() const { return m_surfaceTemp; }
517 
522  bool isInjector() const { return ( m_type == Type::INJECTOR ); }
523 
528  bool isProducer() const { return ( m_type == Type::PRODUCER ); }
529 
534  integer isThermal() const { return m_isThermal; }
535 
542 
549 
555  integer useMass( ) { return m_useMass;}
556 
561  bool isWellOpen() const;
562 
567  void setWellState( bool open );
572  bool getWellState() const;
573 
578  void setCurrentConstraint( WellConstraintBase * currentConstraint )
579  {
580  setControl( currentConstraint->getControl() );
581  m_currentConstraint = currentConstraint;
582  }
587  WellConstraintBase * getCurrentConstraint() { return m_currentConstraint; }
588  WellConstraintBase const * getCurrentConstraint() const { return m_currentConstraint; }
589 
594  bool isCrossflowEnabled() const { return m_isCrossflowEnabled; }
595 
601 
607  void setNextDtFromTables( real64 const & currentTime, real64 & nextDt );
616  void setKeepVariablesConstantDuringInitStep( bool const keepVariablesConstantDuringInitStep )
617  { m_keepVariablesConstantDuringInitStep = keepVariablesConstantDuringInitStep; }
618 
623  void setFluidSeparator( std::unique_ptr< constitutive::ConstitutiveBase > fluidSeparatorPtr ) { m_fluidSeparatorPtr = std::move( fluidSeparatorPtr );}
628  constitutive::MultiFluidBase & getMultiFluidSeparator() { return dynamicCast< constitutive::MultiFluidBase & >( *m_fluidSeparatorPtr ); }
629 
634  constitutive::SingleFluidBase & getSingleFluidSeparator() { return dynamicCast< constitutive::SingleFluidBase & >( *m_fluidSeparatorPtr ); }
635 
642 
648  void setRegionAveragePressure( real64 regionAveragePressure ) { m_regionAveragePressure = regionAveragePressure; }
649 
655 
660  void setRegionAverageTemperature( real64 regionAverageTemperature ) { m_regionAverageTemperature = regionAverageTemperature; }
661 
667  void setWellStatus ( real64 const & currentTime, WellControls::Status status );
668 
675 
676  virtual string wellElementDofName() const = 0;
677 
678  virtual string resElementDofName() const = 0;
679 
685 
691 
692 
693  virtual localIndex numFluidComponents() const = 0;
694 
695  virtual localIndex numFluidPhases() const = 0;
696 
702  {
704  static constexpr char const * fluidNamesString() { return "fluidNames"; }
706  static constexpr char const * writeCSVFlagString() { return "writeCSV"; }
707  static constexpr char const * timeStepFromTablesFlagString() { return "timeStepFromTables"; }
709  static constexpr char const * targetRegionsString() { return "targetRegions"; }
710 
712  static constexpr char const * refElevString() { return "referenceElevation"; }
714  static constexpr char const * typeString() { return "type"; }
716  static constexpr char const * currentControlString() { return "currentControl"; }
718  static constexpr char const * inputControlString() { return "control"; }
720  static constexpr char const * useSurfaceConditionsString() { return "useSurfaceConditions"; }
722  static constexpr char const * referenceReservoirRegionString() { return "referenceReservoirRegion"; }
724  static constexpr char const * surfacePressureString() { return "surfacePressure"; }
726  static constexpr char const * surfaceTemperatureString() { return "surfaceTemperature"; }
727 
729  static constexpr char const * statusTableNameString() { return "statusTableName"; }
731  static constexpr char const * perfStatusTableNameString() { return "perfStatusTableName"; }
733  static constexpr char const * enableCrossflowString() { return "enableCrossflow"; }
735  static constexpr char const * initialPressureCoefficientString() { return "initialPressureCoefficient"; }
736 
738  static constexpr char const * estimateWellSolutionString() { return "estimateWellSolution"; }
740  static constexpr char const * enableIsoThermalEstimatorString() { return "enableIsoThermalEstimator"; }
741 
742  // control data (not registered on the mesh)
743  static constexpr char const * massDensityString() { return "massDensity";}
744 
745  static constexpr char const * currentBHPString() { return "currentBHP"; }
746 
747  static constexpr char const * currentPhaseVolRateString() { return "currentPhaseVolumetricRate"; }
748  static constexpr char const * currentVolRateString() { return "currentVolRate"; }
749 
750  static constexpr char const * currentTotalVolRateString() { return "currentTotalVolumetricRate"; }
751 
752  static constexpr char const * currentMassRateString() { return "currentMassRate"; }
753  };
754 
759  {
761  static constexpr char const * wellNewtonSolverString() { return "WellNewtonSolver"; }
762  };
763 
764  void setPerforationStatus( real64 const & time_n, WellElementSubRegion & subRegion );
765  void setGravCoef( WellElementSubRegion & subRegion, R1Tensor const & gravVector );
773  static void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );
774 
780  template< typename ConstraintType > void createConstraint ( string const & constraintName );
781 
782 
793 
802 
810 
815  void enableThermalEffects ( bool enable ) { m_thermalEffectsEnabled = enable; };
816 
821  bool thermalEffectsEnabled() const { return m_thermalEffectsEnabled; }
822 
827  bool isoThermalEstimatorEnabled() const { return m_enableIsoThermalEstimator; }
828 
829  void setupWellDofs( DomainPartition & domain, WellElementRegion & wellElementRegion, string const & meshBodyName, MeshLevel const & meshLevel );
830  WellNewtonSolver & getWellNewtonSolver() { return m_wellNewtonSolver; }
831 
832  void selectWellConstraint( real64 const & time_n,
833  real64 const & dt,
834  integer const cycleNumber,
835  integer const coupledIterationNumber,
836  DomainPartition & domain,
837  string const & meshBodyName,
838  MeshLevel & mesh,
839  ElementRegionManager & elemManager,
840  WellElementSubRegion & subRegion,
841  DofManager const & dofManager );
842 
843 protected:
844  virtual void postRestartInitialization( )override;
845 
862  void logConstraint( WellConstraintBase const * constraint,
863  WellElementSubRegion const & region,
864  real64 time,
865  bool isLimiting = false ) const;
866 
875 
891  //template< typename STATISTICS >
892  //bool validateReferenceRegionStatistics( ElementRegionManager const & elementManager,
893  // real64 & averagePressure,
894  // real64 & averageTemperature ) const;
895 
896 private:
898  string_array m_targetRegionNames;
899 
900 protected:
901 
904 
907 
910 
913 
916 
919 
922 
925 
932  string const m_ratesOutputDir;
933 
934  // flag to enable time step selection base on rates/bhp tables coordinates
935  integer m_timeStepFromTables;
936 
939 
942 
945 
948 
951 
952  // Fuild model to compute properties for constraint equation user specified conditions
953  std::unique_ptr< constitutive::ConstitutiveBase > m_fluidSeparatorPtr;
954 
957 
960 
963 
966 
969 
972 
975 
976  // Current constrint
977  WellConstraintBase * m_currentConstraint{};
978 
981 
984 
987 
990 
993 
996 
997  integer m_estimateSolution;
998  integer m_enableIsoThermalEstimator;
999  bool m_thermalEffectsEnabled;
1000 
1001  WellNewtonSolver m_wellNewtonSolver;
1002 
1003 
1008  bool m_dofManagerInitialized;
1009 };
1010 
1011 
1012 // Use local aliases to avoid accidental macro expansion of the tokens 'Type' or 'Control'
1015  "producer",
1016  "injector" );
1017 
1020  "BHP",
1021  "phaseVolRate",
1022  "totalVolRate",
1023  "massRate",
1024  "uninitialized" );
1025 
1026 
1027 template< typename CONSTITUTIVE >
1028 void WellControls::setConstitutiveName( ElementSubRegionBase & subRegion, string const & wrapperName, string const & constitutiveType ) const
1029 {
1030  subRegion.registerWrapper< string >( wrapperName ).
1031  setPlotLevel( dataRepository::PlotLevel::NOPLOT ).
1033  setSizedFromParent( 0 );
1034 
1035  string & constitutiveName = subRegion.getReference< string >( wrapperName );
1036  constitutiveName = getConstitutiveName< CONSTITUTIVE >( subRegion );
1037  GEOS_ERROR_IF( constitutiveName.empty(), GEOS_FMT( "{}: {} constitutive model not found on subregion {}",
1038  getDataContext(), constitutiveType, subRegion.getName() ) );
1039 }
1040 template< typename CONSTITUTIVE_BASE_TYPE >
1042 {
1043  string validName;
1044  dataRepository::Group const & constitutiveModels = subRegion.getConstitutiveModels();
1045 
1046  constitutiveModels.forSubGroups< CONSTITUTIVE_BASE_TYPE >( [&]( dataRepository::Group const & model )
1047  {
1048  GEOS_ERROR_IF( !validName.empty(), "A valid constitutive model was already found." );
1049  validName = model.getName();
1050  } );
1051 
1052  return validName;
1053 }
1054 
1063 template< typename BASETYPE = constitutive::ConstitutiveBase, typename LOOKUP_TYPE >
1064 static BASETYPE const & getConstitutiveModel( dataRepository::Group const & dataGroup, LOOKUP_TYPE const & key )
1065 {
1067  return constitutiveModels.getGroup< BASETYPE >( key );
1068 }
1077 template< typename BASETYPE = constitutive::ConstitutiveBase, typename LOOKUP_TYPE >
1078 static BASETYPE & getConstitutiveModel( dataRepository::Group & dataGroup, LOOKUP_TYPE const & key )
1079 {
1081  return constitutiveModels.getGroup< BASETYPE >( key );
1082 }
1083 } //namespace geos
1084 
1085 #endif //GEOS_PHYSICSSOLVERS_FLUIDFLOW_WELLS_WELLCONTROLS_HPP
#define GEOS_UNUSED_PARAM(X)
Mark an unused argument and silence compiler warnings.
Definition: GeosxMacros.hpp:97
#define GEOS_ERROR_IF(COND,...)
Conditionally raise a hard error and terminate the program.
Definition: Logger.hpp:217
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...
dataRepository::Group const & getConstitutiveModels() const
Get the group in which the constitutive models of this subregion are registered.
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
This class describes the controls used to operate a well.
~WellControls() override
Default destructor.
WellControls & operator=(WellControls &&)=delete
Deleted move operator.
WellControls(WellControls &&)=delete
Deleted move constructor.
WellControls(string const &name, dataRepository::Group *const parent)
Constructor for WellControls Objects.
WellControls(WellControls const &)=delete
Deleted copy constructor.
WellControls & operator=(WellControls const &)=delete
Deleted assignment operator.
virtual void createSeparator(WellElementSubRegion &subRegion)=0
Create well separator.
virtual void expandObjectCatalogs() override
Expand catalog for schema generation.
virtual Group * createChild(string const &childKey, string const &childName) override
Create a new constraint object as a child of this group.
static string coupledSolverAttributePrefix()
String used to form the solverName used to register single-physics solvers in CoupledSolver.
WellControls()=delete
Deleted default constructor.
This class specializes the element region for the case of a well. This class is also in charge of sta...
This class describes a collection of local well elements and perforations.
Base class for all physics solvers.
Wrapper< TBASE > & registerWrapper(string const &name, wrapperMap::KeyIndex::index_type *const rkey=nullptr)
Create and register a Wrapper around a new object.
DataContext const & getDataContext() const
Definition: Group.hpp:1343
void setRestartFlags(RestartFlags flags)
Set flags that control restart output of this group.
Definition: Group.hpp:1428
string const & getName() const
Get group name.
Definition: Group.hpp:1329
GEOS_DECLTYPE_AUTO_RETURN getReference(LOOKUP_TYPE const &lookup) const
Look up a wrapper and get reference to wrapped object.
Definition: Group.hpp:1273
T & getGroup(KEY const &key)
Return a reference to a sub-group of the current Group.
Definition: Group.hpp:318
void forSubGroups(LAMBDA &&lambda)
Apply the given functor to subgroups that can be casted to one of specified types.
Definition: Group.hpp:500
Group & setSizedFromParent(int val)
Set whether this wrapper is resized when its parent is resized.
Definition: Group.hpp:1413
virtual void initializePreSubGroups() override
Called by Initialize() prior to initializing sub-Groups.
real64 m_refGravCoef
Gravity coefficient of the reference elevation.
void logConstraint(WellConstraintBase const *constraint, WellElementSubRegion const &region, real64 time, bool isLimiting=false) const
Logs the state and values of a specific well constraint.
static constexpr char const * initialPressureCoefficientString()
string key for the initial pressure coefficient
ConstraintTypeId getControl() const
Get the control type for the well.
integer m_useSurfaceConditions
Flag to decide whether rates are controlled at rates or surface conditions.
integer estimateSolution() const
getter for esitmator switch
WellConstraintBase const * getBHPConstraint(const ConstraintSourceId source=ConstraintSourceId::USER) const
Gets the defined BHP constraint.
void setWellStatus(real64 const &currentTime, WellControls::Status status)
Set well status from time and internal action, eg. all perfs closed.
static constexpr char const * fluidNamesString()
String key for the fluid model names.
ConstraintTypeId m_currentControl
Well controls as a Control enum.
stdVector< WellConstraintBase const * > getAllConstraints() const
Gets a list of all constraints constraints.
void setUseMass(integer useMass)
setter to activate mass formulation
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)=0
assembles the well constraint terms for an individual well
bool isProducer() const
Is the well a producer?
virtual void postInputInitialization() override
stdVector< WellConstraintBase const * > getRateConstraints() const
Gets a list of rate constraints.
static constexpr char const * targetRegionsString()
String for the targetRegions wrapper.
real64 getRegionAverageTemperature() const
Getter for the reservoir average temperature when m_useSurfaceConditions == 0.
void createConstraint(string const &constraintName)
Create a constraint.
static constexpr char const * useSurfaceConditionsString()
String key for checking the rates at surface conditions.
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)=0
assembles the well momentum terms for an individual well
real64 m_regionAveragePressure
Region average pressure used in volume rate constraint calculations.
void setNextDtFromTables(real64 const &currentTime, real64 &nextDt)
set next time step based on tables intervals
bool getWellState() const
Get the well state.
static constexpr char const * perfStatusTableNameString()
string key for perforation status table name
bool m_keepVariablesConstantDuringInitStep
flag to freeze the initial state during initialization in coupled problems
string m_referenceReservoirRegion
Reservoir region associated with reservoir volume constraint.
static constexpr char const * refElevString()
String key for the well reference elevation (for BHP control)
bool isInjector() const
Is the well an injector?
real64 getReferenceElevation() const
Return the reference elvation where pressure constraint is measured.
void enableThermalEffects(bool enable)
Set thermal effects enable.
static constexpr char const * enableCrossflowString()
string key for the crossflow flag
integer m_isCrossflowEnabled
Flag to enable crossflow.
integer m_useMass
flag indicating whether mass or molar formulation should be used
WellControls::Status getWellStatus() const
Is the well open (or shut) based on internal action.
std::string m_discretizationName
Name of the discretization for the region.
bool validateReferenceRegion() const
Validates the reference region.
static constexpr char const * writeCSVFlagString()
String key for the write CSV flag.
real64 getRegionAveragePressure() const
Getter for the reservoir average pressure when m_useSurfaceConditions == 0.
std::string getFlowSolverName() const
Get the control type for the well.
integer m_isThermal
flag indicating whether thermal formulation is used
integer useSurfaceConditions() const
Getter for the flag specifying whether we check rates at surface or reservoir conditions.
integer isThermal() const
getter for iso/thermal switch
bool evaluateConstraints(real64 const &time_n, WellElementSubRegion &subRegion)
Function to evaluate well constraints after applying the solution update.
WellControls::Status m_wellStatus
Well status.
string const & referenceReservoirRegion() const
Getter for the reservoir region associated with reservoir volume constraint.
static constexpr char const * referenceReservoirRegionString()
String key for reference reservoir region.
integer m_writeCSV
rates output
string m_referenceFluidModelName
name of the fluid constitutive model used as a reference for component/phase description on subregion
void setFluidSeparator(std::unique_ptr< constitutive::ConstitutiveBase > fluidSeparatorPtr)
setter for multi fluid separator
integer m_numDofPerResElement
the number of Degrees of Freedom per reservoir element
static constexpr char const * surfaceTemperatureString()
String key for the surface temperature.
virtual real64 updateWellState(MeshBody const &meshBody, ElementRegionManager const &elemManager, WellElementSubRegion &subRegion)=0
Recompute all dependent quantities from primary variables (including constitutive models)
void setRegionAverageTemperature(real64 regionAverageTemperature)
Set the reservoir average temperature when m_useSurfaceConditions == 0.
void setCurrentConstraint(WellConstraintBase *currentConstraint)
Set the current consrtaint.
TableFunction const * m_statusTable
Status table.
real64 m_regionAverageTemperature
Region average temperature used in volume rate constraint calculations.
static constexpr char const * statusTableNameString()
string key for status table name
localIndex numDofPerWellElement() const
getter for the number of degrees of freedom per well element
real64 m_surfaceTemp
Surface temperature.
bool m_wellOpen
Well open flag.
string m_statusTableName
Well status table name.
real64 m_refElevation
Reference elevation.
real64 m_initialPressureCoefficient
Tuning coefficient for the initial well pressure.
constitutive::SingleFluidBase & getSingleFluidSeparator()
Getter for single fluid separator.
localIndex numDofPerResElement() const
getter for the number of degrees of freedom per mesh element
real64 getTargetBHP(real64 const &targetTime, const ConstraintSourceId source=ConstraintSourceId::USER) const
Returns the target bottom hole pressure value.
static constexpr char const * enableIsoThermalEstimatorString()
string key for the enable iso thermal estimator flag
bool isoThermalEstimatorEnabled() const
Is isoThermalEstimator enabled.
bool thermalEffectsEnabled() const
Are thermal effects enabled.
Type m_type
Well type (as Type enum)
void setThermal(bool isThermal)
setter for iso/thermal switch
real64 m_surfacePres
Surface pressure.
string m_perfStatusTableName
Perforation status table name.
WellConstraintBase * getCurrentConstraint()
Get the current consrtaint.
bool isCrossflowEnabled() const
Getter for the flag to enable crossflow.
integer getConstraintPhaseIndex() const
Const accessor for the phase constraint index.
static constexpr char const * surfacePressureString()
String key for the surface pressure.
std::string m_flowSolverName
Name of the flow solver managing this well.
bool isWellOpen() const
Is the well open (or shut) at currentTime, status initalized in WellSolverBase::implicitStepSetup.
const real64 & getSurfaceTemperature() const
Getter for the surface temperature when m_useSurfaceConditions == 1.
static constexpr char const * wellNewtonSolverString()
string key for the well Newton solver
bool evaluateConstraints(real64 const &time_n, real64 const &dt, integer const cycleNumber, integer const coupledIterationNumber, DomainPartition &domain, MeshLevel &mesh, ElementRegionManager &elemManager, WellElementSubRegion &subRegion, DofManager const &dofManager)
Function to evaluate well constraints after applying the solution update.
static constexpr char const * estimateWellSolutionString()
string key for the estimate well solution flag
arrayView1d< real64 const > getInjectionStream() const
Const accessor for the injection stream.
virtual void computeWellPerforationRates(real64 const &time_n, real64 const &GEOS_UNUSED_PARAM(dt), ElementRegionManager &elemManager, WellElementSubRegion &subRegion)=0
Recompute the perforation rates for all the wells.
integer m_numComponents
the number of fluid components
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)=0
assembles the flux terms for individual well for all connections between well elements
void setControl(ConstraintTypeId const &newControl)
Set the control type for the well.
integer m_numPhases
the max number of fluid phases
void setConstitutiveName(ElementSubRegionBase &subRegion, string const &wrapperName, string const &constitutiveType) const
Register wrapper with given name and store constitutive model name on the subregion.
static void setNextDtFromTable(TableFunction const *table, real64 const currentTime, real64 &nextDt)
Set next time step based on a table function.
virtual void assembleWellAccumulationTerms(real64 const &time, real64 const &dt, WellElementSubRegion &subRegion, DofManager const &dofManager, CRSMatrixView< real64, globalIndex const > const &localMatrix, arrayView1d< real64 > const &localRhs)=0
assembles the accumulation term for an individual well
static constexpr char const * inputControlString()
String key for the well input control.
virtual void initializeWell(DomainPartition &domain, Group &meshBodies, string const &meshBodyName, MeshLevel &mesh, WellElementSubRegion &subRegion, real64 const &time_n)=0
Initialize well for the beginning of a simulation or restart.
integer useMass()
is useMass option active
real64 getInitialPressureCoefficient() const
Getter for the initial pressure coefficient.
DofManager m_estimatorDoFManager
Well DofManager.
string_array const & getTargetRegionNames() const
return the list of target regions
static string getConstitutiveName(ElementSubRegionBase const &subRegion)
Get the Constitutive Name object.
const real64 & getSurfacePressure() const
Getter for the surface pressure when m_useSurfaceConditions == 1.
integer m_numDofPerWellElement
the number of Degrees of Freedom per well element
ConstraintTypeId m_inputControl
Input well controls as a Control enum.
static constexpr char const * typeString()
String key for the well type.
void setKeepVariablesConstantDuringInitStep(bool const keepVariablesConstantDuringInitStep)
Utility function to keep the well variables during a time step (used in poromechanics simulations)
virtual void resetStateToBeginningOfStep(DomainPartition &domain, string const &meshBodyName, ElementRegionManager const &elemManager, WellElementSubRegion &subRegion)=0
Reset the well state to the beginning of the time step.
void setWellState(bool open)
Set the well state.
std::string getDiscretizationName() const
return the name of the discretization object
virtual void postRestartInitialization() override
Performs initialization required after reading from a restart file.
void setDiscretizationName(const std::string &discretizationName)
set the name of the discretization object
static constexpr char const * currentControlString()
String key for the well current control.
constitutive::MultiFluidBase & getMultiFluidSeparator()
Getter for multi fluid separator.
void setFlowSolverName(const std::string &flowSolverName)
Set the control type for the well.
ConstraintTypeId getInputControl() const
Get the input control type for the well.
real64 getInjectionTemperature() const
Const accessor for the temperature of the injection stream.
void setRegionAveragePressure(real64 regionAveragePressure)
Set the reservoir average pressure when m_useSurfaceConditions == 0.
real64 setNextDt(real64 const &currentTime, real64 const &currentDt, WellElementSubRegion &subRegion)
function to set the next time step size
@ NOPLOT
Do not ever write to plot file.
@ NO_WRITE
Do not write into restart.
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
std::string string
String type.
Definition: DataTypes.hpp:90
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
static BASETYPE const & getConstitutiveModel(dataRepository::Group const &dataGroup, LOOKUP_TYPE const &key)
Get the Constitutive Model object.
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
ENUM_STRINGS(LinearSolverParameters::SolverType, "direct", "cg", "gmres", "fgmres", "bicgstab", "richardson", "preconditioner")
Declare strings associated with enumeration values.
internal::StdVectorWrapper< T, Allocator, USE_STD_CONTAINER_BOUNDS_CHECKING > stdVector
Structure to hold scoped key names.
Struct to serve as a container for variable strings and keys.