Skip to content

Commit

Permalink
Add more context to errors - physicsSolvers/ files (GEOS-DEV#2448)
Browse files Browse the repository at this point in the history
  • Loading branch information
MelReyCG authored Sep 20, 2023
1 parent c4052de commit d184d82
Show file tree
Hide file tree
Showing 38 changed files with 401 additions and 278 deletions.
3 changes: 2 additions & 1 deletion src/coreComponents/physicsSolvers/FieldStatisticsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class FieldStatisticsBase : public TaskBase

m_solver = physicsSolverManager.getGroupPointer< SOLVER >( m_solverName );
GEOS_THROW_IF( m_solver == nullptr,
GEOS_FMT( "Could not find solver '{}' of type {}",
GEOS_FMT( "{}: Could not find solver '{}' of type {}",
getDataContext(),
m_solverName, LvArray::system::demangleType< SOLVER >() ),
InputError );
}
Expand Down
68 changes: 49 additions & 19 deletions src/coreComponents/physicsSolvers/LinearSolverParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,25 +206,55 @@ void LinearSolverParametersInput::postProcessInput()

static const std::set< integer > binaryOptions = { 0, 1 };

GEOS_ERROR_IF( binaryOptions.count( m_parameters.stopIfError ) == 0, viewKeyStruct::stopIfErrorString() << " option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.checkResidual ) == 0, viewKeyStruct::directCheckResidualString() << " option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.equilibrate ) == 0, viewKeyStruct::directEquilString() << " option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.replaceTinyPivot ) == 0, viewKeyStruct::directReplTinyPivotString() << " option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.iterativeRefine ) == 0, viewKeyStruct::directIterRefString() << " option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.parallel ) == 0, viewKeyStruct::directParallelString() << " option can be either 0 (false) or 1 (true)" );

GEOS_ERROR_IF_LT_MSG( m_parameters.krylov.maxIterations, 0, "Invalid value of " << viewKeyStruct::krylovMaxIterString() );
GEOS_ERROR_IF_LT_MSG( m_parameters.krylov.maxRestart, 0, "Invalid value of " << viewKeyStruct::krylovMaxRestartString() );

GEOS_ERROR_IF_LT_MSG( m_parameters.krylov.relTolerance, 0.0, "Invalid value of " << viewKeyStruct::krylovTolString() );
GEOS_ERROR_IF_GT_MSG( m_parameters.krylov.relTolerance, 1.0, "Invalid value of " << viewKeyStruct::krylovTolString() );

GEOS_ERROR_IF_LT_MSG( m_parameters.ifact.fill, 0, "Invalid value of " << viewKeyStruct::iluFillString() );
GEOS_ERROR_IF_LT_MSG( m_parameters.ifact.threshold, 0.0, "Invalid value of " << viewKeyStruct::iluThresholdString() );

GEOS_ERROR_IF_LT_MSG( m_parameters.amg.numSweeps, 0, "Invalid value of " << viewKeyStruct::amgNumSweepsString() );
GEOS_ERROR_IF_LT_MSG( m_parameters.amg.threshold, 0.0, "Invalid value of " << viewKeyStruct::amgThresholdString() );
GEOS_ERROR_IF_GT_MSG( m_parameters.amg.threshold, 1.0, "Invalid value of " << viewKeyStruct::amgThresholdString() );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.stopIfError ) == 0,
getWrapperDataContext( viewKeyStruct::stopIfErrorString() ) <<
": option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.checkResidual ) == 0,
getWrapperDataContext( viewKeyStruct::directCheckResidualString() ) <<
": option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.equilibrate ) == 0,
getWrapperDataContext( viewKeyStruct::directEquilString() ) <<
": option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.replaceTinyPivot ) == 0,
getWrapperDataContext( viewKeyStruct::directReplTinyPivotString() ) <<
": option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.iterativeRefine ) == 0,
getWrapperDataContext( viewKeyStruct::directIterRefString() ) <<
": option can be either 0 (false) or 1 (true)" );
GEOS_ERROR_IF( binaryOptions.count( m_parameters.direct.parallel ) == 0,
getWrapperDataContext( viewKeyStruct::directParallelString() ) <<
": option can be either 0 (false) or 1 (true)" );

GEOS_ERROR_IF_LT_MSG( m_parameters.krylov.maxIterations, 0,
getWrapperDataContext( viewKeyStruct::krylovMaxIterString() ) <<
": Invalid value." );
GEOS_ERROR_IF_LT_MSG( m_parameters.krylov.maxRestart, 0,
getWrapperDataContext( viewKeyStruct::krylovMaxRestartString() ) <<
": Invalid value." );

GEOS_ERROR_IF_LT_MSG( m_parameters.krylov.relTolerance, 0.0,
getWrapperDataContext( viewKeyStruct::krylovTolString() ) <<
": Invalid value." );
GEOS_ERROR_IF_GT_MSG( m_parameters.krylov.relTolerance, 1.0,
getWrapperDataContext( viewKeyStruct::krylovTolString() ) <<
": Invalid value." );

GEOS_ERROR_IF_LT_MSG( m_parameters.ifact.fill, 0,
getWrapperDataContext( viewKeyStruct::iluFillString() ) <<
": Invalid value." );
GEOS_ERROR_IF_LT_MSG( m_parameters.ifact.threshold, 0.0,
getWrapperDataContext( viewKeyStruct::iluThresholdString() ) <<
": Invalid value." );

GEOS_ERROR_IF_LT_MSG( m_parameters.amg.numSweeps, 0,
getWrapperDataContext( viewKeyStruct::amgNumSweepsString() ) <<
": Invalid value." );
GEOS_ERROR_IF_LT_MSG( m_parameters.amg.threshold, 0.0,
getWrapperDataContext( viewKeyStruct::amgThresholdString() ) <<
": Invalid value." );
GEOS_ERROR_IF_GT_MSG( m_parameters.amg.threshold, 1.0,
getWrapperDataContext( viewKeyStruct::amgThresholdString() ) <<
": Invalid value." );

// TODO input validation for other AMG parameters ?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@ NonlinearSolverParameters::NonlinearSolverParameters( string const & name,

void NonlinearSolverParameters::postProcessInput()
{
if( m_timeStepDecreaseIterLimit <= m_timeStepIncreaseIterLimit )
{
GEOS_ERROR( " timeStepIncreaseIterLimit should be smaller than timeStepDecreaseIterLimit!!" );
}
GEOS_ERROR_IF_LE_MSG( m_timeStepDecreaseIterLimit, m_timeStepIncreaseIterLimit,
getWrapperDataContext( viewKeysStruct::timeStepIncreaseIterLimString() ) <<
": should be smaller than " << viewKeysStruct::timeStepDecreaseIterLimString() );
}


Expand Down
21 changes: 13 additions & 8 deletions src/coreComponents/physicsSolvers/SolverBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ void SolverBase::generateMeshTargetsFromTargetRegions( Group const & meshBodies
if( targetTokens.size()==1 ) // no MeshBody or MeshLevel specified
{
GEOS_ERROR_IF( meshBodies.numSubGroups() != 1,
"No MeshBody information is specified in SolverBase::meshTargets, but there are multiple MeshBody objects" );
getDataContext() << ": No MeshBody information is specified in" <<
" SolverBase::meshTargets, but there are multiple MeshBody objects" );
MeshBody const & meshBody = meshBodies.getGroup< MeshBody >( 0 );
string const meshBodyName = meshBody.getName();

Expand All @@ -129,7 +130,8 @@ void SolverBase::generateMeshTargetsFromTargetRegions( Group const & meshBodies
{
string const meshBodyName = targetTokens[0];
GEOS_ERROR_IF( !meshBodies.hasGroup( meshBodyName ),
"MeshBody ("<<meshBodyName<<") is specified in targetRegions, but does not exist." );
getWrapperDataContext( viewKeyStruct::targetRegionsString() ) << ": MeshBody (" <<
meshBodyName << ") is specified in targetRegions, but does not exist." );

string const meshLevelName = m_discretizationName;

Expand All @@ -141,7 +143,7 @@ void SolverBase::generateMeshTargetsFromTargetRegions( Group const & meshBodies
}
else
{
GEOS_ERROR( "Invalid specification of targetRegions" );
GEOS_ERROR( getDataContext() << ": Invalid specification of targetRegions" );
}
}
}
Expand Down Expand Up @@ -184,7 +186,9 @@ SolverBase::CatalogInterface::CatalogType & SolverBase::getCatalog()
localIndex SolverBase::targetRegionIndex( string const & regionName ) const
{
auto const pos = std::find( m_targetRegionNames.begin(), m_targetRegionNames.end(), regionName );
GEOS_ERROR_IF( pos == m_targetRegionNames.end(), GEOS_FMT( "Region {} is not a target of solver {}", regionName, getName() ) );
GEOS_ERROR_IF( pos == m_targetRegionNames.end(),
GEOS_FMT( "{}: Region {} is not a target of the solver.",
getDataContext(), regionName ) );
return std::distance( m_targetRegionNames.begin(), pos );
}

Expand Down Expand Up @@ -271,7 +275,8 @@ bool SolverBase::execute( real64 const time_n,
}
}

GEOS_ERROR_IF( dtRemaining > 0.0, "Maximum allowed number of sub-steps reached. Consider increasing maxSubSteps." );
GEOS_ERROR_IF( dtRemaining > 0.0, getDataContext() << ": Maximum allowed number of sub-steps"
" reached. Consider increasing maxSubSteps." );

// Decide what to do with the next Dt for the event running the solver.
m_nextDt = setNextDt( nextDt, domain );
Expand Down Expand Up @@ -760,7 +765,7 @@ real64 SolverBase::nonlinearImplicitStep( real64 const & time_n,
}
else
{
GEOS_ERROR( "Nonconverged solutions not allowed. Terminating..." );
GEOS_ERROR( getDataContext() << ": Nonconverged solutions not allowed. Terminating..." );
}
}

Expand Down Expand Up @@ -1149,11 +1154,11 @@ void SolverBase::solveLinearSystem( DofManager const & dofManager,

if( params.stopIfError )
{
GEOS_ERROR_IF( m_linearSolverResult.breakdown(), "Linear solution breakdown -> simulation STOP" );
GEOS_ERROR_IF( m_linearSolverResult.breakdown(), getDataContext() << ": Linear solution breakdown -> simulation STOP" );
}
else
{
GEOS_WARNING_IF( !m_linearSolverResult.success(), "Linear solution failed" );
GEOS_WARNING_IF( !m_linearSolverResult.success(), getDataContext() << ": Linear solution failed" );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ real64 ContactSolverBase::explicitStep( real64 const & GEOS_UNUSED_PARAM( time_n
DomainPartition & GEOS_UNUSED_PARAM( domain ) )
{
GEOS_MARK_FUNCTION;
GEOS_ERROR( "ExplicitStep non available for contact solvers." );
GEOS_ERROR( getDataContext() << ": ExplicitStep non available for contact solvers." );
return dt;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ void LagrangianContactSolver::setConstitutiveNames( ElementSubRegionBase & subRe

string & contactRelationName = subRegion.getReference< string >( viewKeyStruct::contactRelationNameString() );
contactRelationName = this->m_contactRelationName;
GEOS_ERROR_IF( contactRelationName.empty(), GEOS_FMT( "Solid model not found on subregion {}", subRegion.getName() ) );
GEOS_ERROR_IF( contactRelationName.empty(),
GEOS_FMT( "{}: Solid model not found on subregion {}",
getDataContext(), subRegion.getName() ) );
}


Expand Down Expand Up @@ -882,7 +884,8 @@ void LagrangianContactSolver::computeFaceNodalArea( arrayView2d< real64 const, n
}
else
{
GEOS_ERROR( "LagrangianContactSolver: face with " << numNodesPerFace << " nodes. Only triangles and quadrilaterals are supported." );
GEOS_ERROR( "LagrangianContactSolver " << getDataContext() << ": face with " << numNodesPerFace <<
" nodes. Only triangles and quadrilaterals are supported." );
}
}

Expand Down Expand Up @@ -1287,9 +1290,11 @@ void LagrangianContactSolver::assembleStabilization( MeshLevel const & mesh,
SurfaceElementRegion const & fractureRegion = elemManager.getRegion< SurfaceElementRegion >( getFractureRegionName() );
FaceElementSubRegion const & fractureSubRegion = fractureRegion.getUniqueSubRegion< FaceElementSubRegion >();

GEOS_ERROR_IF( !fractureSubRegion.hasField< contact::traction >(), "The fracture subregion must contain traction field." );
GEOS_ERROR_IF( !fractureSubRegion.hasField< contact::traction >(),
getDataContext() << ": The fracture subregion must contain traction field." );
arrayView2d< localIndex const > const faceMap = fractureSubRegion.faceList();
GEOS_ERROR_IF( faceMap.size( 1 ) != 2, "A fracture face has to be shared by two cells." );
GEOS_ERROR_IF( faceMap.size( 1 ) != 2,
getDataContext() << ": A fracture face has to be shared by two cells." );

// Get the state of fracture elements
arrayView1d< integer const > const & fractureState =
Expand Down Expand Up @@ -1375,7 +1380,8 @@ void LagrangianContactSolver::assembleStabilization( MeshLevel const & mesh,
realNodes++;
}
}
GEOS_ERROR_IF( realNodes != 2, "An edge shared by two fracture elements must have 2 nodes." );
GEOS_ERROR_IF( realNodes != 2,
getDataContext() << ": An edge shared by two fracture elements must have 2 nodes." );
edge.resize( realNodes );

// Compute nodal area factor
Expand Down
Loading

0 comments on commit d184d82

Please sign in to comment.