Skip to content

Commit bd70903

Browse files
authored
refactor: unify flow solver discretization name check (#3514)
1 parent ac45ee2 commit bd70903

File tree

5 files changed

+17
-24
lines changed

5 files changed

+17
-24
lines changed

src/coreComponents/physicsSolvers/fluidFlow/CompositionalMultiphaseFVM.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,7 @@ void CompositionalMultiphaseFVM::initializePreSubGroups()
165165
? LinearSolverParameters::MGR::StrategyType::thermalCompositionalMultiphaseFVM
166166
: LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseFVM;
167167

168-
DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );
169-
NumericalMethodsManager const & numericalMethodManager = domain.getNumericalMethodManager();
170-
FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager();
171-
if( !fvManager.hasGroup< FluxApproximationBase >( m_discretizationName ) )
172-
{
173-
GEOS_ERROR( "A discretization deriving from FluxApproximationBase must be selected with CompositionalMultiphaseFlow" );
174-
}
175-
168+
checkDiscretizationName();
176169
}
177170

178171
void CompositionalMultiphaseFVM::setupDofs( DomainPartition const & domain,

src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,18 @@ void FlowSolverBase::initializePreSubGroups()
368368
}
369369
}
370370

371+
void FlowSolverBase::checkDiscretizationName() const
372+
{
373+
DomainPartition const & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );
374+
NumericalMethodsManager const & numericalMethodManager = domain.getNumericalMethodManager();
375+
FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager();
376+
if( !fvManager.hasGroup< FluxApproximationBase >( m_discretizationName ) )
377+
{
378+
GEOS_ERROR( GEOS_FMT( "{}: can not find discretization named '{}' (a discretization deriving from FluxApproximationBase must be selected for {} solver '{}' )",
379+
getDataContext(), m_discretizationName, getCatalogName(), getName()));
380+
}
381+
}
382+
371383
void FlowSolverBase::validatePoreVolumes( DomainPartition const & domain ) const
372384
{
373385
real64 minPoreVolume = LvArray::NumericLimits< real64 >::max;

src/coreComponents/physicsSolvers/fluidFlow/FlowSolverBase.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ class FlowSolverBase : public PhysicsSolverBase
230230

231231
virtual void initializePreSubGroups() override;
232232

233+
void checkDiscretizationName() const;
234+
233235
virtual void initializePostInitialConditionsPreSubGroups() override;
234236

235237
void initializeState( DomainPartition & domain );

src/coreComponents/physicsSolvers/fluidFlow/ReactiveCompositionalMultiphaseOBL.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,7 @@ void ReactiveCompositionalMultiphaseOBL::initializePreSubGroups()
125125
{
126126
FlowSolverBase::initializePreSubGroups();
127127

128-
DomainPartition & domain = this->getGroupByPath< DomainPartition >( "/Problem/domain" );
129-
NumericalMethodsManager const & numericalMethodManager = domain.getNumericalMethodManager();
130-
FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager();
131-
if( !fvManager.hasGroup< FluxApproximationBase >( m_discretizationName ) )
132-
{
133-
GEOS_ERROR( "A discretization deriving from FluxApproximationBase must be selected with ReactiveCompositionalMultiphaseOBL" );
134-
}
135-
128+
checkDiscretizationName();
136129
}
137130

138131
void ReactiveCompositionalMultiphaseOBL::setupDofs( DomainPartition const & domain,

src/coreComponents/physicsSolvers/fluidFlow/SinglePhaseFVM.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,7 @@ void SinglePhaseFVM< BASE >::initializePreSubGroups()
6868
{
6969
BASE::initializePreSubGroups();
7070

71-
DomainPartition & domain = this->template getGroupByPath< DomainPartition >( "/Problem/domain" );
72-
NumericalMethodsManager const & numericalMethodManager = domain.getNumericalMethodManager();
73-
FiniteVolumeManager const & fvManager = numericalMethodManager.getFiniteVolumeManager();
74-
75-
if( !fvManager.hasGroup< FluxApproximationBase >( m_discretizationName ) )
76-
{
77-
GEOS_ERROR( "A discretization deriving from FluxApproximationBase must be selected with SinglePhaseFVM" );
78-
}
71+
this->checkDiscretizationName();
7972

8073
if( m_isThermal )
8174
{

0 commit comments

Comments
 (0)