Manually updating cellDisplacement in displacementMotionSolver
Hi!
I am pushing the displacementSBRStressFvMotionSolver to its limits when trying to run the equivalent of the SnakeRiver canyon, but with much higher resolution and complex topography.
I have modified moveDynamicMesh in order to check if the mesh contains incorrectly oriented face pyramids. It happens quiet often. If it is the case, I load the mesh (at the end of a pimple loop) using the class Foam::Module::polyMeshGen and untangle it using Foam::Module::meshOptimizer. I have modified the source of CFmesh in order to do that.
The problem is to re-assign the points back into the motionSolver. I understand I need to reset both the cellDisplacement and the pointDisplacement.
I tried this, but it doesnt work:
displacementSBRStressFvMotionSolver &motionSolver = const_cast<displacementSBRStressFvMotionSolver &>(mesh.lookupObject<displacementSBRStressFvMotionSolver>("dynamicMeshDict"));
const volVectorField oldDisplacement(motionSolver.cellDisplacement());
const pointField oldC(mesh.C());
// Here I optimize the points, where Foam::Module::polyMeshGen &pmg
const pointField newPoints(optimizePoints(mesh, pmg, meshDict, report));
mesh.movePoints(newPoints);
forAll(cellDisplacement, celli)
{
cellDisplacement.primitiveFieldRef()[celli] = oldDisplacement[celli] + (mesh.C()[celli] - oldC[celli]);
}
forAll(pointDisplacement, pointi)
{
pointDisplacement.primitiveFieldRef()[pointi] = newPoints[pointi] - points0[pointi];
}
cellDisplacement.correctBoundaryConditions();
The change doesnt need to propagate, as I get again errors the iteration after. But if i stop the simulation, improve the mesh using improveMeshQuality, and restart the solver, it works fine.
Any idea how to solve this?
Many thanks!!!