Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
#include "physicsSolvers/fluidFlow/wells/WellFields.hpp"
#include "physicsSolvers/fluidFlow/wells/CompositionalMultiphaseWellFields.hpp"
#include "physicsSolvers/fluidFlow/wells/WellControls.hpp"

#include "physicsSolvers/fluidFlow/wells/WellInjectionConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellProductionConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellBHPConstraints.hpp"
#include "physicsSolvers/fluidFlow/wells/WellVolumeRateConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellPhaseVolumeRateConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellMassRateConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellLiquidRateConstraint.hpp"

#include "physicsSolvers/fluidFlow/wells/kernels/CompositionalMultiphaseWellKernels.hpp"
#include "physicsSolvers/fluidFlow/wells/kernels/ThermalCompositionalMultiphaseWellKernels.hpp"
#include "physicsSolvers/fluidFlow/wells/kernels/PerforationFluxKernels.hpp"
Expand Down Expand Up @@ -192,7 +201,6 @@ void CompositionalMultiphaseWell::registerWellDataOnMesh( WellElementSubRegion &

subRegion.registerField< well::gravityCoefficient >( getName() );


subRegion.registerField< well::globalCompDensity >( getName() ).
reference().resizeDimension< 1 >( m_numComponents );
subRegion.registerField< well::globalCompDensity_n >( getName() ).
Expand Down Expand Up @@ -360,28 +368,11 @@ void CompositionalMultiphaseWell::validateWellConstraints( real64 const & time_n
if( !useSurfaceConditions() )
{
bool const useSeg = getReferenceReservoirRegion().empty();
GEOS_WARNING_IF( useSeg,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation now occurs before this points. So when we get to here, we can assume everything is set up properly.

GEOS_FMT( "WellControls {} not set and well constraint fluid property calculations will use "
"top segement pressure and temp ",
WellControls::viewKeyStruct::referenceReservoirRegionString() ) );
if( useSeg )
{
setRegionAveragePressure( -1 );
setRegionAverageTemperature( -1 );
}
else
{
// Check if region name exists in list of Reservoir's target regions
string const regionName = getReferenceReservoirRegion();
CompositionalMultiphaseBase const & flowSolver = getParent().getParent().getGroup< CompositionalMultiphaseBase >( getFlowSolverName() );
string_array const & targetRegionsNames = flowSolver.getTargetRegionNames();
auto const pos = std::find( targetRegionsNames.begin(), targetRegionsNames.end(), regionName );
GEOS_ERROR_IF( pos == targetRegionsNames.end(),
GEOS_FMT( "{}: Region {} is not a target of the reservoir solver and cannot be used for referenceReservoirRegion in WellControl {}.",
getDataContext(), regionName, getName() ) );


}
}
string const & fluidName = subRegion.getReference< string >( viewKeyStruct::fluidNamesString());
MultiFluidBase const & fluid = subRegion.getConstitutiveModel< MultiFluidBase >( fluidName );
Expand All @@ -390,21 +381,16 @@ void CompositionalMultiphaseWell::validateWellConstraints( real64 const & time_n
{
constraint.validatePhaseType( fluid );
} );



}

void CompositionalMultiphaseWell::initializePostSubGroups()
{
WellControls::initializePostSubGroups();

}

void CompositionalMultiphaseWell::initializePostInitialConditionsPreSubGroups()
{
WellControls::initializePostInitialConditionsPreSubGroups();

}

void CompositionalMultiphaseWell::initializeWellPostInitialConditionsPreSubGroups( WellElementSubRegion & subRegion )
Expand Down Expand Up @@ -768,19 +754,11 @@ void CompositionalMultiphaseWell::updateSeparator( ElementRegionManager const &
{
if( !getReferenceReservoirRegion().empty() )
{
ElementRegionBase const & region = elemManager.getRegion( getReferenceReservoirRegion() );
GEOS_ERROR_IF ( !region.hasWrapper( CompositionalMultiphaseStatistics::regionStatisticsName()),
GEOS_FMT( "{}: WellControl {} referenceReservoirRegion field requires CompositionalMultiphaseStatistics to be configured for region {} ",
getDataContext(), getName(), getReferenceReservoirRegion() ) );

CompositionalMultiphaseStatistics::RegionStatistics const & stats = region.getReference< CompositionalMultiphaseStatistics::RegionStatistics >(
CompositionalMultiphaseStatistics::regionStatisticsName() );
GEOS_ERROR_IF( stats.averagePressure <= 0.0,
GEOS_FMT(
"{}: No region average quantities computed. WellControl {} referenceReservoirRegion field requires CompositionalMultiphaseStatistics to be configured for region {} ",
getDataContext(), getName(), getReferenceReservoirRegion() ));
setRegionAveragePressure( stats.averagePressure );
setRegionAverageTemperature( stats.averageTemperature );
real64 averagePressure = 0.0;
real64 averageTemperature = 0.0;
validateReferenceRegionStatistics< CompositionalMultiphaseStatistics >( elemManager, averagePressure, averageTemperature );
setRegionAveragePressure( averagePressure );
setRegionAverageTemperature( averageTemperature );
}
// If flashPressure is not set by region the value is defaulted to -1 and indicates to use top segment conditions
flashPressure = getRegionAveragePressure();
Expand Down Expand Up @@ -1122,10 +1100,10 @@ void CompositionalMultiphaseWell::initializeWell( DomainPartition & domain, Mesh
{
if( isProducer() )
{
forSubGroups< MinimumBHPConstraint, ProductionConstraint< VolumeRateConstraint >, ProductionConstraint< MassRateConstraint >,
ProductionConstraint< PhaseVolumeRateConstraint > >( [&](
auto
& constraint )
forSubGroups< MinimumBHPConstraint,
ProductionConstraint< VolumeRateConstraint >,
ProductionConstraint< MassRateConstraint >,
ProductionConstraint< PhaseVolumeRateConstraint > >( [&]( auto & constraint )
{
if( ConstraintTypeId( getControl()) == constraint.getControl() )
{
Expand All @@ -1135,10 +1113,10 @@ void CompositionalMultiphaseWell::initializeWell( DomainPartition & domain, Mesh
}
else
{
forSubGroups< MaximumBHPConstraint, InjectionConstraint< VolumeRateConstraint >, InjectionConstraint< MassRateConstraint >, InjectionConstraint< PhaseVolumeRateConstraint > >( [&](
auto
&
constraint )
forSubGroups< MaximumBHPConstraint,
InjectionConstraint< VolumeRateConstraint >,
InjectionConstraint< MassRateConstraint >,
InjectionConstraint< PhaseVolumeRateConstraint > >( [&]( auto & constraint )
{
if( ConstraintTypeId( getControl()) == constraint.getControl() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
#include "physicsSolvers/fluidFlow/wells/WellFields.hpp"
#include "physicsSolvers/fluidFlow/wells/WellSolverBaseFields.hpp"
#include "physicsSolvers/fluidFlow/wells/SinglePhaseWellFields.hpp"

#include "physicsSolvers/fluidFlow/wells/WellInjectionConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellProductionConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellBHPConstraints.hpp"
#include "physicsSolvers/fluidFlow/wells/WellVolumeRateConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellPhaseVolumeRateConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellMassRateConstraint.hpp"
#include "physicsSolvers/fluidFlow/wells/WellLiquidRateConstraint.hpp"

#include "physicsSolvers/fluidFlow/wells/kernels/SinglePhaseWellKernels.hpp"
#include "physicsSolvers/fluidFlow/wells/kernels/ThermalSinglePhaseWellKernels.hpp"
#include "physicsSolvers/fluidFlow/wells/kernels/SinglePhasePerforationFluxKernels.hpp"
Expand Down Expand Up @@ -336,22 +345,11 @@ void SinglePhaseWell::updateSeparator( ElementRegionManager const & elemManager,
{
if( !getReferenceReservoirRegion().empty() )
{
ElementRegionBase const & region = elemManager.getRegion( getReferenceReservoirRegion() );
GEOS_ERROR_IF ( !region.hasWrapper( SinglePhaseStatistics::regionStatisticsName()),
GEOS_FMT( "WellControl {} referenceReservoirRegion field requires SinglePhaseStatistics to be configured for region {} ",
getName(), getReferenceReservoirRegion() ),
getDataContext() );

SinglePhaseStatistics::RegionStatistics const & stats = region.getReference< SinglePhaseStatistics::RegionStatistics >(
SinglePhaseStatistics::regionStatisticsName() );

GEOS_ERROR_IF( stats.averagePressure <= 0.0,
GEOS_FMT(
"No region average quantities computed. WellControl {} referenceReservoirRegion field requires SinglePhaseStatistics to be configured for region {} ",
getName(), getReferenceReservoirRegion() ),
getDataContext());
setRegionAveragePressure( stats.averagePressure );
setRegionAverageTemperature( stats.averageTemperature );
real64 averagePressure = 0.0;
real64 averageTemperature = 0.0;
validateReferenceRegionStatistics< SinglePhaseStatistics >( elemManager, averagePressure, averageTemperature );
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed this up into WellControls with a generic method that covers both single phase and multiphase.

setRegionAveragePressure( averagePressure );
setRegionAverageTemperature( averageTemperature );
}
// use region conditions
flashPressure = getRegionAveragePressure();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void WellConstraintBase::postInputInitialization()

}

void WellConstraintBase::setNextDtFromTables( real64 const currentTime, real64 & nextDt )
void WellConstraintBase::setNextDtFromTables( real64 const currentTime, real64 & nextDt ) const
{
setNextDtFromTable( m_constraintScheduleTable, currentTime, nextDt );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class WellConstraintBase : public dataRepository::Group
* @param[in] currentTime the current time
* @param[inout] nextDt the time step
*/
void setNextDtFromTables( real64 const currentTime, real64 & nextDt );
void setNextDtFromTables( real64 const currentTime, real64 & nextDt ) const;


protected:
Expand All @@ -247,7 +247,7 @@ class WellConstraintBase : public dataRepository::Group
/// Constraint value
real64 m_constraintValue;

void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );
static void setNextDtFromTable( TableFunction const * table, real64 const currentTime, real64 & nextDt );

/// Constraint schedule table name
string m_constraintScheduleTableName;
Expand Down
Loading
Loading