Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes a small bug which can crash runs unpredictably.
In
ProblemOperatorInterface::Init
, theBlockVector
of a given variable has its size and offsets updated, with the relevant amount of memory allocated for the object. This is done by MFEM'sVector::SetSize
which calls uponMemory<T>::New
. The latter function allocates memory without initialising it, meaning any memory remains already existing in that space allocated for it will stay there. TheBlockVector
will then interpret those values as elements of its array. In principle this shouldn't be an issue because before the run begins properly these values will get initialised to their proper values or they will host the result of some calculation step. However, MFEM'sNewtonSolver::Mult
has a check that theBlockVector
is finite before it gets initialised. Thus, if some memory remains in those spaces and any element gets interpreted byBlockVector
as aninf
ornan
, this will fail MFEM's finiteness check and crash the run. Because the content of newly allocated memory spaces is effectively unpredictable, this crash may happen at any time. All of this can be prevented by simply initialising newBlockVectors
with finite values. Here we choose zero.