Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cleanup setMGRStrategy a bit #3422

Merged
merged 28 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
220fa52
keep well variables constant during poromech init
Oct 2, 2024
fc9b41a
cleanup setMGRStrategy a bit
Oct 3, 2024
ff67658
missing setMGRStrategy and add log messages
Oct 4, 2024
3a2e268
final pass
Oct 4, 2024
0606617
Merge branch 'pt/wells-seq-poromech-init' into pt/set-mgr-strategy
Oct 4, 2024
74aef74
clarify
Oct 4, 2024
a71d594
Merge branch 'develop' into pt/wells-seq-poromech-init
paveltomin Oct 4, 2024
5d52aad
Merge branch 'pt/wells-seq-poromech-init' into pt/set-mgr-strategy
paveltomin Oct 4, 2024
bff5314
Update SolidMechanicsEmbeddedFractures.cpp
paveltomin Oct 4, 2024
d10f4d2
Update WellSolverBase.cpp
paveltomin Oct 14, 2024
a0f4c63
Merge branch 'develop' into pt/wells-seq-poromech-init
paveltomin Oct 15, 2024
77e93bf
Merge branch 'pt/wells-seq-poromech-init' into pt/set-mgr-strategy
paveltomin Oct 25, 2024
56db5f5
Merge branch 'develop' into pt/wells-seq-poromech-init
paveltomin Oct 25, 2024
87e589d
Merge branch 'pt/wells-seq-poromech-init' into pt/set-mgr-strategy
paveltomin Oct 25, 2024
0f1efa0
Merge branch 'develop' into pt/wells-seq-poromech-init
paveltomin Oct 28, 2024
1c67dc6
bug fix
Oct 28, 2024
49166d4
Merge branch 'pt/wells-seq-poromech-init' into pt/set-mgr-strategy
paveltomin Oct 28, 2024
a5b1931
Update CoupledReservoirAndWellsBase.hpp
paveltomin Oct 29, 2024
5cb58fb
Update SinglePhasePoromechanicsConformingFractures.hpp
paveltomin Oct 29, 2024
20a5f92
build fix
Oct 29, 2024
2e637ae
Merge remote-tracking branch 'origin/develop' into pt/set-mgr-strategy
Nov 6, 2024
5398dcf
Merge branch 'develop' into pt/set-mgr-strategy
paveltomin Nov 7, 2024
a321039
Merge remote-tracking branch 'origin/develop' into pt/set-mgr-strategy
Nov 14, 2024
5b6ac85
code style and missing changes
Nov 14, 2024
e9e4fbb
Merge branch 'develop' into pt/set-mgr-strategy
paveltomin Nov 17, 2024
48208f6
Merge branch 'develop' into pt/set-mgr-strategy
paveltomin Nov 22, 2024
80e0eb5
Merge branch 'develop' into pt/set-mgr-strategy
paveltomin Dec 12, 2024
ba14408
Merge branch 'develop' into pt/set-mgr-strategy
paveltomin Dec 13, 2024
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 @@ -64,23 +64,37 @@ SolidMechanicsEmbeddedFractures::~SolidMechanicsEmbeddedFractures()

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

LinearSolverParameters & linParams = m_linearSolverParameters.get();

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

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

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

linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.dofsPerNode = 3;

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,6 +127,8 @@ 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,11 +73,28 @@ 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.separateComponents = true;
linearSolverParameters.dofsPerNode = 3;

LinearSolverParameters & linSolParams = m_linearSolverParameters.get();
linSolParams.mgr.strategy = LinearSolverParameters::MGR::StrategyType::lagrangianContactMechanics;
linSolParams.mgr.separateComponents = true;
linSolParams.dofsPerNode = 3;
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 )));
}

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

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

Expand Down Expand Up @@ -179,6 +178,10 @@ 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 @@ -77,48 +77,65 @@ void
CompositionalMultiphaseReservoirAndWells<>::
setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();

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

linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.dofsPerNode = 3;

if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseHybridFVM )
{
// add Reservoir
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirHybridFVM;
}
else if( isThermal() )
if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) )
{
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalCompositionalMultiphaseReservoirFVM;

if( isThermal() )
{
GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for thermal {}/{}",
this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName()));
}
else
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirHybridFVM;
}
}
else
{
// add Reservoir
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseReservoirFVM;
if( isThermal() )
{
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalCompositionalMultiphaseReservoirFVM;
}
else
{
linearSolverParameters.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 = this->m_linearSolverParameters.get();
LinearSolverParameters & linearSolverParameters = m_linearSolverParameters.get();

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

linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.dofsPerNode = 3;

// flow solver here is indeed flow solver, not poromechanics solver
if( flowSolver()->getLinearSolverParameters().mgr.strategy == LinearSolverParameters::MGR::StrategyType::compositionalMultiphaseHybridFVM )
if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) )
{
GEOS_ERROR( "The poromechanics MGR strategy for hybrid FVM is not implemented" );
GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}/{}",
this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName() ) );
}
else
{
// add Reservoir
linearSolverParameters.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 @@ -140,15 +157,6 @@ 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 @@ -95,14 +95,12 @@ class CompositionalMultiphaseReservoirAndWells : public CoupledReservoirAndWells

virtual void initializePreSubGroups() override;

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

private:

CompositionalMultiphaseBase * flowSolver() const;

void setMGRStrategy();

};

} /* namespace geos */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,18 @@ 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 ))
{
return;
GEOS_ERROR( GEOS_FMT( "{}: well perforations validation failed, bad perforations found", this->getName()));
}
}

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

setMGRStrategy();
}

virtual void
implicitStepSetup( real64 const & time_n,
real64 const & dt,
Expand Down Expand Up @@ -298,6 +306,12 @@ 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 @@ -81,12 +81,23 @@ 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;
}

// This may need to be different depending on whether poroelasticity is on or not.
m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::hydrofracture;
m_linearSolverParameters.get().mgr.separateComponents = true;
m_linearSolverParameters.get().dofsPerNode = 3;
template< typename POROMECHANICS_SOLVER >
void HydrofractureSolver< POROMECHANICS_SOLVER >::setMGRStrategy()
{
LinearSolverParameters & linearSolverParameters = this->m_linearSolverParameters.get();

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

linearSolverParameters.mgr.separateComponents = true;
linearSolverParameters.dofsPerNode = 3;

// 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 )));
}

template< typename POROMECHANICS_SOLVER >
Expand Down Expand Up @@ -157,6 +168,8 @@ 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 @@ -215,6 +215,7 @@ 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 @@ -25,6 +25,7 @@
#include "constitutive/fluid/multifluid/MultiFluidBase.hpp"
#include "constitutive/solid/PorousSolid.hpp"
#include "physicsSolvers/fluidFlow/FlowSolverBaseFields.hpp"
#include "physicsSolvers/fluidFlow/CompositionalMultiphaseHybridFVM.hpp"
#include "physicsSolvers/multiphysics/poromechanicsKernels/MultiphasePoromechanics.hpp"
#include "physicsSolvers/multiphysics/poromechanicsKernels/ThermalMultiphasePoromechanics.hpp"
#include "physicsSolvers/solidMechanics/SolidMechanicsFields.hpp"
Expand All @@ -45,18 +46,15 @@ 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.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 @@ -244,11 +242,37 @@ 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.separateComponents = true;
linearSolverParameters.dofsPerNode = 3;

if( dynamic_cast< CompositionalMultiphaseHybridFVM * >( this->flowSolver() ) )
{
GEOS_ERROR( GEOS_FMT( "{}: MGR strategy is not implemented for {}/{}",
this->getName(), this->getCatalogName(), this->flowSolver()->getCatalogName()));
}
else
{
this->m_linearSolverParameters.get().mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalMultiphasePoromechanics;
if( this->m_isThermal )
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::thermalMultiphasePoromechanics;
}
else
{
linearSolverParameters.mgr.strategy = LinearSolverParameters::MGR::StrategyType::multiphasePoromechanics;
}
}
GEOS_LOG_LEVEL_RANK_0( 1, GEOS_FMT( "{}: MGR strategy set to {}", getName(),
EnumStrings< LinearSolverParameters::MGR::StrategyType >::toString( linearSolverParameters.mgr.strategy )));
}

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ 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 @@ -129,7 +133,6 @@ class MultiphasePoromechanics : public PoromechanicsSolver< FLOW_SOLVER, MECHANI
real64 const dt,
PARAMS && ... params );


};

template< typename FLOW_SOLVER, typename MECHANICS_SOLVER >
Expand Down
Loading
Loading