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

feat: Do not allow linear solver fail feature #3274

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
10 changes: 10 additions & 0 deletions src/coreComponents/physicsSolvers/PhysicsSolverBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ PhysicsSolverBase::PhysicsSolverBase( string const & name,
setRestartFlags( RestartFlags::WRITE_AND_READ ).
setDescription( "Write matrix, rhs, solution to screen ( = 1) or file ( = 2)." );

registerWrapper( viewKeyStruct::allowNonConvergedLinearSolverSolutionString(), &m_allowNonConvergedLinearSolverSolution ).
setApplyDefaultValue( 1 ).
setInputFlag( InputFlags::OPTIONAL ).
setRestartFlags( RestartFlags::WRITE_AND_READ ).
setDescription( "Cut time step if linear solution fail without going until max nonlinear iterations." );

addLogLevel< logInfo::Fields >();
addLogLevel< logInfo::LineSearch >();
addLogLevel< logInfo::Solution >();
Expand Down Expand Up @@ -1046,6 +1052,10 @@ bool PhysicsSolverBase::solveNonlinearSystem( real64 const & time_n,

// Output the linear system solution for debugging purposes
debugOutputSolution( time_n, cycleNumber, newtonIter, m_solution );

// Do not allow non converged linear solver - cut time step
if( !m_allowNonConvergedLinearSolverSolution && m_linearSolverResult.status == LinearSolverResult::Status::NotConverged )
return false;
}

{
Expand Down
6 changes: 6 additions & 0 deletions src/coreComponents/physicsSolvers/PhysicsSolverBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ class PhysicsSolverBase : public ExecutableGroup

/// @return string for the writeLinearSystem wrapper
static constexpr char const * writeLinearSystemString() { return "writeLinearSystem"; }

/// @return string for the allowNonConvergedLinearSolverSolution wrapper
static constexpr char const * allowNonConvergedLinearSolverSolutionString() { return "allowNonConvergedLinearSolverSolution"; }
};

/**
Expand Down Expand Up @@ -1001,6 +1004,9 @@ class PhysicsSolverBase : public ExecutableGroup
/// timestep of the next cycle
real64 m_nextDt;

/// behavior in case of linear solver failure
integer m_allowNonConvergedLinearSolverSolution;

/// Number of cycles since last timestep cut
integer m_numTimestepsSinceLastDtCut;

Expand Down
Loading