Home » Dynamic mesh with OpenFOAM, Part 2: Prescribed motion

Dynamic mesh with OpenFOAM, Part 2: Prescribed motion

by thawtar

In this detailed tutorial, we will explain how to setup dynamic mesh with mesh deformation in OpenFOAM. For this tutorial, we will focus on prescribed mesh motion. If you want to know the general overview of dynamic meshing in OpenFOAM, you can check our previous post here.

Your final result will be like this!

Test case for dynamic mesh

We will be using the square body for our tutorial due to its very simple shape and easy mesh generation using blockMesh. We will be running an oscillating square cylinder in a flow field with prescribed oscillation frequency.

The case files can be downloaded here. OpenFOAM-v2012 and Ubuntu 20.04LTS are used to run the tutorial but newer ESI versions will work, too. 

Flow solver and numerical schemes

For the flow solver, we chose pimpleFoam for its simplicity. pimpleFoam is a single phase transient incompressible solver with turbulence modeling using RANS. pimpleFoam is simple enough to setup and run the simulation easily while extremely useful to learn because most of your industrial problems are likely to be those involving incompressible flows. Second order finite volume discretizations are used for accurate simulation practice although this tutorial is not designed for verification and validation purposes.

Requirements for a dynamic mesh simulation in OpenFOAM

In order to use dynamic mesh, we need the following:

  1. A dynamicMeshDict file
  2. A motion boundary conditions file (pointDisplacement or motionUx)
  3. A movingWallVelocity boundary condition for moving body
  4. An additional matrix solver for solving the mesh motion equation

The dynamicMeshDict file

As I mentioned above, if you want to run simulations involving dynamic meshes, one essential setting file is the dynamicMeshDict file. This file is located inside the $ROOT/constant/ directory. Here, $ROOT is your OpenFOAM case directory. This dynamicMeshDict file contains the definition of the type of dynamic mesh as well as the details of the mesh motion. For some problems such as sixDofRigidBodyMotion, it also contains the dynamic properties of the body. 

The following figure is the dynamicMeshDict file for our square cylinder forced oscillation simulation. The main settings are in Line 17, 19 and 21. For the dynamicFvMesh, dynamicMotionSolverFvMesh is chosen. This is the default setting for most of your dynamic mesh problems. You can also change it to dynamicOversetFvMesh if you want to use overset mesh.

dynamicMeshDict file (you can change the settings by un-commenting)

And the next line is to load the motion solver library for your body. For our prescribed motion case, we will choose fvMotionSolvers. If you want to use six dof rigid body motions, you need to change it to sixDofRigidBodyMotion solver. After that, we will choose something called displacementLaplacian solver for mesh motion. For deformed meshes, mesh motion is computed as point displacements (or velocities) by solving Laplace equation. You can choose whether you want to solve displacement or velocity field of mesh motion inside the Laplace equation. If you choose displacement, you need to setup a pointDisplacement boundary condition.

After that, you need to choose how to compute diffusivity for mesh motion solver which is displacementLaplacian for this case. From my experience, inverseDistance method works very well for most simulations. Inside the brackets, you need to give the name of the patch you want to move. For our case, it is “square” like in Line 27.

The motion boundary condition file

The pointDisplacement file is located inside the $ROOT/0/ directory. It contains the boundary conditions for the motion of your patches. Basically, you need to assign necessary type of motion for your patch here. Now, I defined oscillatingDisplacement boundary condition for my patch “square”. As you can see, I defined the motion amplitude as 0.1m in Y direction with an oscillation frequency of 2PI. You can set the value as uniform (0 0 0) as a placehanger. 

There are several other types of motion inside the file being disabled by commenting out. If you want to use these, just un-comment any of these. These are very useful motions, especially you can create mixed/multiple motions or you can setup time-dependent 6DoF motions.

pointDisplacement file: motion definition to our moving object

For your non-moving parts, you need to keep these fixed by setting as fixedValue and giving a value of uniform (0 0 0). For special patches such as empty or symmetryPlane, you just need to use the patch type as boundary condition.

pointDisplacement file: fixedValue for fixed boundaries

The movingWallVelocity boundary condition

All dynamic mesh simulations involve motion of bodies or patches. You need to transfer this motion to the fluid domain as a movingWallVelocity boundary condition. Otherwise, your moving body will have no significant effect on the flow field and you will have physically very wrong results. 

This is done by setting movingWallVelocity condition to your moving body inside the $ROOT/0/U file as follows.

0/U file: movingWallVelocity is essential component of dynamic mesh

The linear solver for mesh motion equations

As I mentioned above, mesh motion is calculated by solving the Laplace equation using displacement or velocity boundary conditions. You may need to add a linear solver for actually solving this additional equation, namely “cellDisplacement”. You can use GAMG solver but sometimes, Incomplete Cholesky Conjugate Method (ICCG) solver gives better and stable results. So, your $ROOT/system/fvSolution should have something like this.

You also need to add cellDisplacement solver in system/fvSolution

Testing the mesh motion

You may want to test the mesh motion you used and whether the deformations are too much and make sure that your mesh quality is good throughout the motion cycles before running your actual simulation. With your dynamicMeshDict, pointDisplacement and linear solvers being setup, you can run moveDynamicMesh tool. It will run only the mesh motion and generate results for mesh quality. If your mesh quality is bad, you may want to refine your mesh or decrease motion amplitudes. The command is just

moveDynamicMesh

The following is an example of moveDynamicMesh output. You can see that cellDisplacement is being solved and the mesh is OK. One of the very nice things about moveDynamicMesh is that you can run it at very large time steps, consuming not much time compared to actual CFD simulation. 

When you are satisfied with the body motion and mesh quality during the simulation, you can run the actual simulation using pimpleFoam. But do not forget to change your timestep size to small values, back! Now your pimpleFoam solver is happily running and all you need to do is wait for the simulation to finish and check the results.

Finally, lets see the results! You can check the results for multiple combined motions here:

Final results of our tutorial

Summary

We provided the detail requirements to setup a dynamic mesh simulation in OpenFOAM using mesh deformation and prescribed motion. This kind of simulation can be used to model several aerodynamics phenomena such as wing flapping or forced oscillations of structures or various offshore and marine hydrodynamics applications. 

🌟 Elevate Your Cloud Experience with CloudHPC 🌟
CloudHPC

Related Posts

Leave a Comment

🌟 Elevate Your Cloud Experience with CloudHPC 🌟

Step into a world of limitless possibilities with CloudHPC. Our state-of-the-art cloud computing platform offers unparalleled performance and scalability for your projects.

🚀 Supercharge Your Workflows: Harness the power of high-performance computing to accelerate your simulations, modeling, and data analysis tasks. 💡 Seamless Integration: Integrate seamlessly with popular tools and frameworks, ensuring a smooth transition for your projects.

🔒 Robust Security: Rest easy knowing your data is protected by industry-leading security measures, keeping your work safe and secure.

Explore the future of computing with CloudHPC. Sign up today and elevate your cloud experience to new heights!