Skip to content

Commit

Permalink
Revert "refactor: cleanup setMGRStrategy a bit (#3386)" (#3420)
Browse files Browse the repository at this point in the history
This reverts commit dd09e8e.
  • Loading branch information
paveltomin authored Nov 1, 2024
1 parent dd09e8e commit 3ee47da
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,22 @@ SolidMechanicsEmbeddedFractures::~SolidMechanicsEmbeddedFractures()

void SolidMechanicsEmbeddedFractures::postInputInitialization()
{
ContactSolverBase::postInputInitialization();
SolidMechanicsLagrangianFEM::postInputInitialization();

LinearSolverParameters & linParams = m_linearSolverParameters.get();

if( m_useStaticCondensation )
{
// configure AMG
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();
linearSolverParameters.dofsPerNode = 3;
linearSolverParameters.isSymmetric = true;
linearSolverParameters.amg.separateComponents = true;
linParams.dofsPerNode = 3;
linParams.isSymmetric = true;
linParams.amg.separateComponents = true;
}
else
{
setMGRStrategy();
linParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::solidMechanicsEmbeddedFractures;
}
}

void SolidMechanicsEmbeddedFractures::setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::solidMechanicsEmbeddedFractures;
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
}

void SolidMechanicsEmbeddedFractures::registerDataOnMesh( dataRepository::Group & meshBodies )
{
ContactSolverBase::registerDataOnMesh( meshBodies );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ class SolidMechanicsEmbeddedFractures : public ContactSolverBase

virtual void postInputInitialization() override final;

void setMGRStrategy();

private:

void updateJump( DofManager const & dofManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,12 @@ SolidMechanicsLagrangeContact::SolidMechanicsLagrangeContact( const string & nam
setDescription( "It be used to increase the scale of the stabilization entries. A value < 1.0 results in larger entries in the stabilization matrix." );

addLogLevel< logInfo::Configuration >();
}

void SolidMechanicsLagrangeContact::postInputInitialization()
{
ContactSolverBase::postInputInitialization();

setMGRStrategy();
}

void SolidMechanicsLagrangeContact::setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanics;
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
LinearSolverParameters & linSolParams = m_linearSolverParameters.get();
linSolParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanics;
linSolParams.mgr.separateComponents = true;
linSolParams.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
linSolParams.dofsPerNode = 3;
}

void SolidMechanicsLagrangeContact::registerDataOnMesh( Group & meshBodies )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class NumericalMethodsManager;
class SolidMechanicsLagrangeContact : public ContactSolverBase
{
public:

SolidMechanicsLagrangeContact( const string & name,
Group * const parent );

Expand Down Expand Up @@ -178,10 +179,6 @@ class SolidMechanicsLagrangeContact : public ContactSolverBase
DofManager const & dofManager,
arrayView1d< real64 const > const & localRhs );

virtual void postInputInitialization() override final;

void setMGRStrategy();

private:
string m_stabilizationName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,47 +75,33 @@ void
CompositionalMultiphaseReservoirAndWells<>::
setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( flowSolver() ) )
if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseHybridFVM )
{
// add Reservoir
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirHybridFVM;
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirHybridFVM;
}
else
{
// add Reservoir
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirFVM;
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirFVM;
}
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
}

template<>
void
CompositionalMultiphaseReservoirAndWells< MultiphasePoromechanics<> >::
setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

// flow solver here is indeed flow solver, not poromechanics solver
if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( flowSolver() ) )
if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseHybridFVM )
{
GEOS_ERROR( "The poromechanics MGR strategy for hybrid FVM is not implemented" );
}
else
{
// add Reservoir
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanicsReservoirFVM;
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanicsReservoirFVM;
}
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
}

template< typename RESERVOIR_SOLVER >
Expand All @@ -137,6 +123,15 @@ initializePreSubGroups()
InputError );
}

template< typename RESERVOIR_SOLVER >
void
CompositionalMultiphaseReservoirAndWells< RESERVOIR_SOLVER >::
initializePostInitialConditionsPreSubGroups()
{
Base::initializePostInitialConditionsPreSubGroups();
setMGRStrategy();
}

template< typename RESERVOIR_SOLVER >
void
CompositionalMultiphaseReservoirAndWells< RESERVOIR_SOLVER >::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ class CompositionalMultiphaseReservoirAndWells : public CoupledReservoirAndWells

virtual void initializePreSubGroups() override;

virtual void setMGRStrategy() override;
virtual void initializePostInitialConditionsPreSubGroups() override;

private:

CompositionalMultiphaseBase * flowSolver() const;

void setMGRStrategy();

};

} /* namespace geos */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,10 @@ class CoupledReservoirAndWellsBase : public CoupledSolver< RESERVOIR_SOLVER, WEL
// Validate well perforations: Ensure that each perforation is in a region targeted by the solver
if( !validateWellPerforations( domain ))
{
GEOS_ERROR( GEOS_FMT( "{}: well perforations validation failed, bad perforations found", this->getName()));
return;
}
}

virtual void
postInputInitialization() override
{
Base::postInputInitialization();

setMGRStrategy();
}

virtual void
implicitStepSetup( real64 const & time_n,
real64 const & dt,
Expand Down Expand Up @@ -306,12 +298,6 @@ class CoupledReservoirAndWellsBase : public CoupledSolver< RESERVOIR_SOLVER, WEL
DofManager const & dofManager,
SparsityPatternView< globalIndex > const & pattern ) const = 0;

virtual void setMGRStrategy()
{
if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr )
GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName()));
}

/// Flag to determine whether the well transmissibility needs to be computed
bool m_isWellTransmissibilityComputed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,13 @@ HydrofractureSolver< POROMECHANICS_SOLVER >::HydrofractureSolver( const string &
setDescription( "Flag to determine whether or not to apply lagging update for the fracture stencil weights. " );

m_numResolves[0] = 0;
}

template< typename POROMECHANICS_SOLVER >
void HydrofractureSolver< POROMECHANICS_SOLVER >::setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

// This may need to be different depending on whether poroelasticity is on or not.
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::hydrofracture;
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", this->getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
linearSolverParameters.mgr.separateComponents = false;
linearSolverParameters.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::hydrofracture;
m_linearSolverParameters.get().mgr.separateComponents = false;
m_linearSolverParameters.get().mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
m_linearSolverParameters.get().dofsPerNode = 3;

}

template< typename POROMECHANICS_SOLVER >
Expand Down Expand Up @@ -166,8 +157,6 @@ void HydrofractureSolver< POROMECHANICS_SOLVER >::postInputInitialization()
{
Base::postInputInitialization();

setMGRStrategy();

static const std::set< integer > binaryOptions = { 0, 1 };
GEOS_ERROR_IF( binaryOptions.count( m_isMatrixPoroelastic ) == 0, viewKeyStruct::isMatrixPoroelasticString() << " option can be either 0 (false) or 1 (true)" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ class HydrofractureSolver : public POROMECHANICS_SOLVER
DofManager const & dofManager,
CRSMatrix< real64, globalIndex > & localMatrix );

virtual void setMGRStrategy() override;

private:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::MultiphasePoromechanics( const string & name,
Group * const parent )
: Base( name, parent )
{}
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanics;
linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
linearSolverParameters.dofsPerNode = 3;
}

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::postInputInitialization()
{
Base::postInputInitialization();

setMGRStrategy();

GEOS_ERROR_IF( this->flowSolver()->getCatalogName() == "CompositionalMultiphaseReservoir" &&
this->getNonlinearSolverParameters().couplingType() != NonlinearSolverParameters::CouplingType::Sequential,
GEOS_FMT( "{}: {} solver is only designed to work for {} = {}",
Expand Down Expand Up @@ -272,28 +276,11 @@ void MultiphasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::initializePostIni
getCatalogName(), this->getDataContext(), poromechanicsTargetRegionNames[i], this->flowSolver()->getDataContext() ),
InputError );
}
}

template<>
void MultiphasePoromechanics<>::setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

if( this->m_isThermal )
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalMultiphasePoromechanics;
}
else
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanics;
this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalMultiphasePoromechanics;
}
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
}

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ class MultiphasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHANI

virtual void initializePostInitialConditionsPreSubGroups() override;

virtual void setMGRStrategy()
{
if( this->m_linearSolverParameters.get().preconditionerType == LinearSolverParameters::PreconditionerType::mgr )
GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}", this->getName(), this->getCatalogName()));
}


private:

Expand All @@ -135,6 +131,7 @@ class MultiphasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHANI
real64 const dt,
PARAMS && ... params );


};

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::SinglePhasePoromechanics( const string & name,
Group * const parent )
: Base( name, parent )
{}
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanics;
linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
linearSolverParameters.dofsPerNode = 3;
}

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::postInputInitialization()
{
Base::postInputInitialization();

setMGRStrategy();

GEOS_ERROR_IF( this->flowSolver()->getCatalogName() == "SinglePhaseReservoir" &&
this->getNonlinearSolverParameters().couplingType() != NonlinearSolverParameters::CouplingType::Sequential,
GEOS_FMT( "{}: {} solver is only designed to work for {} = {}",
Expand Down Expand Up @@ -110,33 +114,18 @@ void SinglePhasePoromechanics< FLOW_SOLVER, MECHANICS_SOLVER >::initializePostIn
getCatalogName(), this->getDataContext(), poromechanicsTargetRegionNames[i], this->flowSolver()->getDataContext() ),
InputError );
}
}

template<>
void SinglePhasePoromechanics<>::setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();

if( linearSolverParameters.preconditionerType != LinearSolverParameters::PreconditionerType::mgr )
return;

if( this->m_isThermal )
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalSinglePhasePoromechanics;
this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalSinglePhasePoromechanics;
}
else
{
if( this->flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::singlePhaseHybridFVM )
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::hybridSinglePhasePoromechanics;
}
else
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::singlePhasePoromechanics;
this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::hybridSinglePhasePoromechanics;
}
}
linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.mgr.displacementFieldName = solidMechanics::totalDisplacement::key();
}

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
Expand Down
Loading

0 comments on commit 3ee47da

Please sign in to comment.