Mesh checkpointing refactor#387
Conversation
…eckpointing. Remove unused mesh fields (meshSurfaceVectorFields_, meshVolVectorFields_, volScalarInternalFields_).
… of a reference, consistent with the rest of the checkpoints.
|
The reason why we do not need to checkpoint the mesh fields is that they are calculated on-demand once the mesh points move. This was also pointed to by the comment that was already in the OpenFOAM-adapter. Another reason why we don't need checkpoints for these fields is that they do not have void Foam::fvMesh::movePoints(const pointField& p)
{
// [...] The comment below is not mine, but from the OpenFOAM source code.
polyMesh::movePoints(p);
// Update or delete the local geometric properties as early as possible so
// they can be used if necessary. These get recreated here instead of
// demand driven since they might do parallel transfers which can conflict
// with when they're actually being used.
// Note that between above "polyMesh::movePoints(p)" and here nothing
// should use the local geometric properties.
updateGeomNotOldVol();
// [...]
}void Foam::fvMesh::updateGeomNotOldVol()
{
const bool haveV = (VPtr_ != nullptr);
const bool haveSf = (SfPtr_ != nullptr);
const bool haveMagSf = (magSfPtr_ != nullptr);
const bool haveCP = (CPtr_ != nullptr);
const bool haveCf = (CfPtr_ != nullptr);
clearGeomNotOldVol();
// Now recreate the fields
if (haveV)
{
(void)V();
}
if (haveSf)
{
(void)Sf();
}
if (haveMagSf)
{
(void)magSf();
}
if (haveCP)
{
(void)C();
}
if (haveCf)
{
(void)Cf();
}
} |
MakisH
left a comment
There was a problem hiding this comment.
Thanks a lot for this long-overdue cleanup!
It's nice to see so much code deleted. Let's also add an overview of checkpointed and non-checkpointed fields in the documentation (as you had a draft in #324 and as discussed on Matrix). The most fitting place would be a new section in https://precice.org/adapter-openfoam-extend.html (formulated from the perspective "this is what the adapter currently checkpoints, you might need to add more for a different use case").
| // Store mesh points | ||
| // swap pointers | ||
| *(meshOldPoints_) = *(meshPoints_); | ||
| *(meshPoints_) = mesh_.points(); |
There was a problem hiding this comment.
I guess this (and the previous way, if we use the same sizes) will break once we go for remeshing, correct?
Not necessary to solve it now, but as a first impulse for discussion.
|
Added documentation on checkpointed fields in extend.md |
Co-authored-by: Gerasimos Chourdakis <gerasimos.chourdakis@ipvs.uni-stuttgart.de>
Co-authored-by: Gerasimos Chourdakis <gerasimos.chourdakis@ipvs.uni-stuttgart.de>
… case headings. Added source file for diagram.
Overview
This pull request removes redundant checkpointing methods, which were either unused or had no effect. More detail on this later. This results in the large amount of line removals of this PR. In addition I refactored and cleaned up the mesh points checkpointing.
This pull request is one half of a larger refactor - PR #369, which also contains logic to correctly checkpoint mesh volumes, however it became clear that mesh volume checkpointing should not be merged at this time.
All methods and comments related to volume checkpointing were completely removed, since they haven't served any purpose so far. In the future the volume checkpointing could be re-implemented based on PR #369, however the only effect would be on implicit subcycling (see discussion on that PR).
Changes:
Cleanup and refactor
This relates to the bulk of line removals in this branch.
Just like checkpointed fields of physical variables, there were different types of checkpointed mesh fields, however they were unnecessary and empty. There were no
meshVolVectorFields_ormeshSurfaceVectorFields_(none that needed checkpointing) . The only checkpointed mesh field is face motion fluxmesh_.phi()of typesurfaceScalarField. As pointed to by in a comment insetupMeshCheckpointing():Edit: See new comment below with further explanation.
Mesh Points Checkpointing
Store
meshPoints_andmeshOldPoints_as pointers instead of objects for consistency with the rest of the codebase. These are actually pointers to the copies managed by the adapter.The main logic of restoring mesh point checkpoints is like this:
Otherwise
mesh_.oldPoints()would not get updated inside offvMesh.movePoints()->polyMesh.movePoints()in implicit iterations.Potentially this has can have no effect on the results, since we already checkpoint face motion flux
mesh_.phi(), which is the delta between points and oldPoints. However, there will be a difference when doing implicit subcycling, see the discussion in PR #369.TODO list:
docs/changelog-entries/(create directory if missing)