After a couple of evenings of coding and testing I managed to get Adaptive Mesh Refinement (AMR) working together with a moving meshes in OpenFOAM v2112. It was quite a journey!
The creation of a new library (dynamicMotionSolverRefineFvMesh) which could handle mesh moving and dynamic refinement was actually the easy part. I just followed a paper by Andreas Nygren (which was developed back in the day for OpenFOAM 3.X), and it worked perfectly.
But that’s when I hit a wall: all the six degree of freedom methods currently available on OpenFOAM rely on moving the mesh based on displacements: calculating the next position of each node from its original position at the start of the simulation. This is fundamentally incompatible with adding and deleting nodes from the mesh, and making it compatible would have required a deep rewrite of those methods, as far as I see.
Luckily, there was another way: work with velocities, and move each node from its last position instead of its original one. That involved creating a custom sixDoFRigidBodyVelocity boundary condition, which calculates those velocities for every node of the moving object on each step. And it worked!
There are still a few issues to work out:
-
OpenFOAM does not currently have a load balancing of the decomposed mesh. Hence, this simulation using AMR takes about the same run time as just refining the entire region statically. I plan on implementing a makeshift rebalancing strategy, by stopping the simulation at a certain interval, reconstructing the mesh, and then decomposing it again. I’ll let you know how that goes.
-
I’m not sure about the accuracy of my sixDoFRigidBodyVelocity implementation. Resulting disk velocities seem to be slightly different from the previous simulations.
-
Using the Crank-Nicolson time discretization method produces all kinds of issues in the refinement/unrefinement zone. I’m not sure if this happens with the vanilla implementation of AMR too. In any case I switched to Euler for now.
In any case, I have uploaded the new library, boundary condition and case to the GitHub repository of the disk entry project in case you want to take a look.