-
Notifications
You must be signed in to change notification settings - Fork 89
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
Linear algebra updates #2427
base: develop
Are you sure you want to change the base?
Linear algebra updates #2427
Conversation
std::array< Matrix const *, 2 > m_prolongators{}; | ||
|
||
/// Prolongation operators for each sub-block | ||
std::array< Matrix, 2 > m_prolongators; | ||
std::array< Matrix, 2 > m_prolongatorsOwned{}; | ||
|
||
/// Matrix blocks | ||
BlockOperator< Vector, Matrix > m_matBlocks; | ||
|
||
/// Individual block preconditioners | ||
std::array< std::unique_ptr< PreconditionerBase< LAI > >, 2 > m_solvers; | ||
/// Individual block preconditioner pointers | ||
std::array< PreconditionerBase< LAI > *, 2 > m_solvers{}; | ||
|
||
/// Individual block preconditioner operators (when owned) | ||
std::array< std::unique_ptr< PreconditionerBase< LAI > >, 2 > m_solversOwned{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes add support for constructing a BlockPreconditioner
out of sub-block solvers that exist elsewhere, which is occasionally useful (e.g. coupled multiscale smoother).
constexpr char const * headFormat = "{:>4} {:>12} {:>9} {:>12}"; | ||
constexpr char const * lineFormat = "{:>4} {:>12.6e} {:>9.6f} {:>12.6e}"; | ||
integer const iter = m_result.numIterations; | ||
if( iter == 0 ) | ||
{ | ||
GEOS_LOG_RANK_0( GEOS_FMT( "[{}] start iteration", methodName() ) ); | ||
GEOS_LOG_RANK_0( GEOS_FMT( headFormat, "iter", "resid.norm", "conv.rate", "rel.res.norm" ) ); | ||
} | ||
real64 const norm = m_residualNorms[iter]; | ||
real64 const relNorm = m_residualNorms[0] > 0.0 ? norm / m_residualNorms[0] : 0.0; | ||
real64 const convRate = iter > 0 ? norm / m_residualNorms[iter - 1] : 1.0; | ||
GEOS_LOG_RANK_0( GEOS_FMT( lineFormat, iter, norm, convRate, relNorm ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iteration progress output improved to provide more information and match that of hypre
src/coreComponents/linearAlgebra/unitTests/testKrylovSolvers.cpp
Outdated
Show resolved
Hide resolved
template< typename CHILD, typename T > | ||
void registerInputBlock( Group * parent, char const * const key, T & data ) | ||
{ | ||
parent->registerGroup( key, std::make_unique< CHILD >( key, parent, data ) ).setInputFlags( InputFlags::OPTIONAL ); | ||
} | ||
|
||
class BlockParametersInput final : public dataRepository::Group | ||
{ | ||
public: | ||
|
||
/// Constructor | ||
BlockParametersInput( string const & name, | ||
Group * const parent, | ||
LinearSolverParameters::Block & params ); | ||
|
||
virtual Group * createChild( string const & childKey, string const & childName ) override | ||
{ | ||
GEOS_UNUSED_VAR( childKey, childName ); | ||
return nullptr; | ||
} | ||
|
||
/// Keys appearing in XML | ||
struct viewKeyStruct | ||
{ | ||
static constexpr char const * shapeString() { return "shape"; } | ||
static constexpr char const * schurTypeString() { return "schurType"; } | ||
static constexpr char const * scalingString() { return "scaling"; } | ||
}; | ||
|
||
private: | ||
|
||
LinearSolverParameters::Block & m_parameters; | ||
}; | ||
|
||
BlockParametersInput::BlockParametersInput( string const & name, | ||
Group * const parent, | ||
LinearSolverParameters::Block & params ) | ||
: | ||
Group( name, parent ), | ||
m_parameters( params ) | ||
{ | ||
registerWrapper( viewKeyStruct::shapeString(), &m_parameters.shape ). | ||
setDefaultValue( m_parameters.shape ). | ||
setInputFlag( InputFlags::OPTIONAL ). | ||
setDescription( "Block preconditioner shape, options: " | ||
"``" + EnumStrings< LinearSolverParameters::Block::Shape >::concat( "``, ``" ) + "``" ); | ||
|
||
registerWrapper( viewKeyStruct::schurTypeString(), &m_parameters.schurType ). | ||
setDefaultValue( m_parameters.schurType ). | ||
setInputFlag( InputFlags::OPTIONAL ). | ||
setDescription( "Schur complement type, options: " | ||
"``" + EnumStrings< LinearSolverParameters::Block::SchurType >::concat( "``, ``" ) + "``" ); | ||
|
||
registerWrapper( viewKeyStruct::scalingString(), &m_parameters.scaling ). | ||
setDefaultValue( m_parameters.scaling ). | ||
setInputFlag( InputFlags::OPTIONAL ). | ||
setDescription( "Block scaling type, options: " | ||
"``" + EnumStrings< LinearSolverParameters::Block::Scaling >::concat( "``, ``" ) + "``" ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new way of structuring linear solver parameter inputs: instead of an ever-growing list of prefixed attributes like
<LinearSolverParameters
blockShape="..."
blockSchurType="..."
blockScaling="..."/>
we will start adding nested structure as follows:
<LinearSolverParameters>
<Block
shape="..."
schurType="..."
scaling="..."/>
</LinearSolverParameters>
This improves readability by indenting parameter blocks according to their logical structure and avoiding repetition of the prefixes. I use this extensively in multiscale work, but will also propose a similar refactoring for AMG parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very nice, specially if we want to expose some MGR options per level...
FieldIdentifiers fieldsToBeSync; | ||
fieldsToBeSync.addElementFields( { fields::flow::pressure::key() }, | ||
regionNames ); | ||
|
||
CommunicationTools::getInstance().synchronizeFields( fieldsToBeSync, mesh, domain.getNeighbors(), false ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This synchronization was useless because consistency of values is already guaranteed by virtue of ghosted cells being included in sets to which initial conditions are applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about other flow solvers?
switch( linParams.preconditionerType ) | ||
{ | ||
default: | ||
{ | ||
return LAInterface::createPreconditioner( linParams ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The switch
statement may seem pointless at the moment, but it's left as a placeholder for adding custom preconditioners (e.g. multiscale)
/// Rigid body modes; TODO remove mutable hack | ||
mutable array1d< ParallelVector > m_rigidBodyModes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now mutable
because it's populated on demand in createPreconditioner()
function which is const
. This is isn't great, but I don't have a better solution for now.
src/coreComponents/physicsSolvers/solidMechanics/SolidMechanicsLagrangianFEM.cpp
Outdated
Show resolved
Hide resolved
6aa101b
to
a167fdc
Compare
dfbc927
to
742c689
Compare
742c689
to
9004d43
Compare
9004d43
to
2bb59cd
Compare
This is a collection of LAI-related changes extracted from my multiscale branch to be reviewed separately. I will post some comments later highlighting the most important changes.
Rebaseline needed due to addition of new input parameters.
TODO: