Skip to content
Snippets Groups Projects
Commit eaa0ea65 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[NL] Throw exception in MFront, catch in NSolver.

This causes the time step to fail and repeated if possible.
parent 1466c966
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <MGIS/Behaviour/Integrate.hxx> #include <MGIS/Behaviour/Integrate.hxx>
#include "NumLib/Exceptions.h"
namespace namespace
{ {
/// Converts between OGSes and MFront's Kelvin vector indices. /// Converts between OGSes and MFront's Kelvin vector indices.
...@@ -313,7 +315,8 @@ MFront<DisplacementDim>::integrateStress( ...@@ -313,7 +315,8 @@ MFront<DisplacementDim>::integrateStress(
auto const status = mgis::behaviour::integrate(v, _behaviour); auto const status = mgis::behaviour::integrate(v, _behaviour);
if (status != 1) if (status != 1)
{ {
OGS_FATAL("Integration failed with status %i.", status); throw NumLib::AssemblyException("MFront: integration failed with status"
+ std::to_string(status) + ".");
} }
KelvinVector sigma; KelvinVector sigma;
......
/**
* \file
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include <stdexcept>
#include <string>
namespace NumLib
{
struct AssemblyException : public std::runtime_error
{
AssemblyException(std::string const& reason)
: std::runtime_error{"Error in process' assembly: " + reason} {};
};
} // namespace NumLib
...@@ -15,9 +15,10 @@ ...@@ -15,9 +15,10 @@
#include "BaseLib/ConfigTree.h" #include "BaseLib/ConfigTree.h"
#include "BaseLib/Error.h" #include "BaseLib/Error.h"
#include "BaseLib/RunTime.h" #include "BaseLib/RunTime.h"
#include "ConvergenceCriterion.h"
#include "MathLib/LinAlg/LinAlg.h" #include "MathLib/LinAlg/LinAlg.h"
#include "NumLib/DOF/GlobalMatrixProviders.h" #include "NumLib/DOF/GlobalMatrixProviders.h"
#include "ConvergenceCriterion.h" #include "NumLib/Exceptions.h"
namespace NumLib namespace NumLib
{ {
...@@ -277,7 +278,18 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Newton>::solve( ...@@ -277,7 +278,18 @@ NonlinearSolverStatus NonlinearSolver<NonlinearSolverTag::Newton>::solve(
BaseLib::RunTime time_assembly; BaseLib::RunTime time_assembly;
time_assembly.start(); time_assembly.start();
sys.assemble(x, process_id); try
{
sys.assemble(x, process_id);
}
catch (AssemblyException const& e)
{
ERR("Abort nonlinear iteration. Repeating timestep. Reason: %s",
e.what());
error_norms_met = false;
iteration = _maxiter;
break;
}
sys.getResidual(*x[process_id], res); sys.getResidual(*x[process_id], res);
sys.getJacobian(J); sys.getJacobian(J);
INFO("[time] Assembly took %g s.", time_assembly.elapsed()); INFO("[time] Assembly took %g s.", time_assembly.elapsed());
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "MathLib/LinAlg/ApplyKnownSolution.h" #include "MathLib/LinAlg/ApplyKnownSolution.h"
#include "MathLib/LinAlg/UnifiedMatrixSetters.h" #include "MathLib/LinAlg/UnifiedMatrixSetters.h"
#include "NumLib/IndexValueVector.h" #include "NumLib/IndexValueVector.h"
#include "NumLib/Exceptions.h"
namespace detail namespace detail
{ {
...@@ -91,8 +92,16 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear, ...@@ -91,8 +92,16 @@ void TimeDiscretizedODESystem<ODESystemTag::FirstOrderImplicitQuasilinear,
_Jac->setZero(); _Jac->setZero();
_ode.preAssemble(t, dt, x_curr); _ode.preAssemble(t, dt, x_curr);
_ode.assembleWithJacobian(t, dt, x_new_timestep, xdot, dxdot_dx, dx_dx, try
process_id, *_M, *_K, *_b, *_Jac); {
_ode.assembleWithJacobian(t, dt, x_new_timestep, xdot, dxdot_dx, dx_dx,
process_id, *_M, *_K, *_b, *_Jac);
}
catch (AssemblyException const&)
{
NumLib::GlobalVectorProvider::provider.releaseVector(xdot);
throw;
}
LinAlg::finalizeAssembly(*_M); LinAlg::finalizeAssembly(*_M);
LinAlg::finalizeAssembly(*_K); LinAlg::finalizeAssembly(*_K);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment