Skip to content
Open
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions src/libcadet/model/ModelSystemImpl-Residual.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,17 @@ int ModelSystem::residual(const SimulationTime& simTime, const ConstSimulationSt
}

_errorIndicator[i] = m->residual(simTime, applyOffset(simState, offset), res + offset, _threadLocalStorage);

for (int j = 0; j < _dofs[i]; j++)
{
if (std::isnan(res[offset + j]))
{
LOG(Warning) << "Residual has NAN value in unit " << i << " (at least) at index " << j;
_errorIndicator[i] = 1; // recoverable error
break;
}
}

} CADET_PARFOR_END;

// Handle connections
Expand Down Expand Up @@ -567,6 +578,16 @@ int ModelSystem::residualWithJacobian(const SimulationTime& simTime, const Const
_errorIndicator[i] = m->residualWithJacobian(simTime, applyOffset(simState, offset),
res + offset, applyOffset(adJac, offset), _threadLocalStorage);

for (int j = 0; j < _dofs[i]; j++)
{
if (std::isnan(res[offset + j]))
{
LOG(Warning) << "Residual has NAN value in unit " << i << " (at least) at index " << j;
_errorIndicator[i] = 1; // recoverable error
break;
}
}

} CADET_PARFOR_END;

// Handle connections
Expand Down
Loading