Skip to content

Oscillating Cylinder in Laminar Crossflow – pimpleDyMFoam

In this post I am going to simulate an oscillating cylinder in a cross-flow… just for fun… and to provide an additional tutorial case for those wishing to use some of the dynamic meshing features of OpenFOAM.

The case I am going to simulate is a cylinder in a Reynolds number 200 cross-flow (U=2 m/s, D=1 m, nu = 0.01 m^2/s), oscillating at a rate of 0.2 hz.

Tutorial Files

The tutorial files for this case can be downloaded from here:

Download Tutorial Files

Please let me know if the download does not work or if there is a problem running the tutorial files. Note: I ran this case in parallel on a relatively fast 6-core computer. It will take a long time if you try to run it as single core.

Mesh Generation

For this simulation, I built a simple two dimensional O-grid around the cylinder which joined to a series of blocks making a rectangular domain. I built this using the native OpenFOAM meshing utility blockMesh (which I like a lot).

mesh.0000
Fig: Grid

If you are wondering about the blockMesh set up… I intend to a blockMesh tutorial post… not that it’s all that necessary since the OpenFOAM manual covers it pretty well.

Case Set-up

dynamicMeshDict

When running a dynamic mesh case a solver runs as part of the solution and solves for the new grid at each timestep. Several are available in OpenFOAM and I am not really trying to do a full post on that right now. So I’ll just tell you that in this case I decided to use the displacementLaplacian solver.

Along with the solver one must define the coefficients that go with the solver. For most of the solvers this means setting the diffusivity for the Laplace solver. Since I am relatively new to these types of solutions I did what we all do… and turned to the great CFD online forum! A discussion in this post (http://www.cfd-online.com/Forums/openfoam-meshing/97299-diffusivity-dynamicmeshdict.htm) made me think that a good starting point would be the inverseDistance model for the mesh diffusivity.

In the end my dynamicMeshDict (which belongs in the constant folder) looked like:

dynamicFvMesh dynamicMotionSolverFvMesh;

motionSolverLibs ( "libfvMotionSolvers.so" );

solver displacementLaplacian;


displacementLaplacianCoeffs
{
      diffusivity inverseDistance 1(cylinder);
}

The solver produces the grid movements through time as the simulation is performed. Here is what the mesh looks like while it is moving! I added the stationary mesh and the moving mesh. Click on them to get a clearer picture 🙂

Boundary Conditions

The set up for this case is simple. An inlet boundary (on the far left) where I specified the incoming velocity and pressure (both are uniform fixedValue). The top and bottom boundaries are slip boundaries (but could also be freestream depending on your preferred set-up style).

The cylinder itself requires some special treatment because of the moving mesh. It must obey the no-slip condition right? So do we set it as uniform (0 0 0) ? No! The cylinder is moving! Luckily there is a handy boundary condition for this in the U file:

 cylinder
 {
      type movingWallVelocity;
      value uniform (0 0 0);
 }

For a typical simulation using pimpleFoam a p and U file would be all that are required. However, since we are doing a moving mesh simulation there is another parameter that must be solved for and requires boundary conditions… pointDisplacement.

For the pointDisplacement boundary conditions, we know that all of the outer edges should NOT move. Therefore they are all fixed with a type of fixedValue and  a value of uniform (0 0 0).

The cylinder however is moving and requires a definition. In this simulation we are simulating and oscillating cylinder. Since we are using the displacement solver the type is oscillatingDisplacement. We input and omega (rad/s) and an amplitude (m) in the following way:

 cylinder
 {
 type oscillatingDisplacement;
 omega 1.256; 
 amplitude (0 0.5 0); // Max piston stroke
 value uniform (0 0 0);
 }

Results

Yay! Now its time to look at the results. Well since I am not doing this for any particular scientific study… let’s look at some pretty pictures!

Here is an animation of vorticity:

vort
Wake of Oscillating Cylinder

Looks pretty nice! I personally have a big nerd love for vortex shedding…. I don’t know why.

Obviously if you intend to do any scientific or engineering work with this type of problem you would need to think very carefully about the grid resolution, diffusivity model, Reynolds number, oscillation frequency  etc. All of these were arbitrarily selected here to facilitate the blog post and to provide a nice tutorial example!

Conclusion

In this post I briefly covered the set-up of this type of dynamic meshing problem. The main difference for running a dynamic mesh case is that you require a dynamic mesh solver (you must specify in the dynamicMeshDict), and you also require boundary conditions for that solver.

Let me know if there are any problems with this blog post or with the tutorial files provided.

18 thoughts on “Oscillating Cylinder in Laminar Crossflow – pimpleDyMFoam Leave a comment

  1. Hi, I am beginner to OpenFOAM and wish to know that how can we generate mesh for two cylinders … Is there any way to mirror the mesh I will really appreciate for your advice?

  2. Thank you for this post! It helped me setup my first case with a dynamic mesh. The link to the cfd forum broken, though. What was the short version of why this particular type of dynamic mesh was chosen? I am curious whether this will have a big effect on the results I get for my setup.

  3. Hey
    Can you do a tutorial on immersed boundary method (Direct) in OpenFoam? i will appreciate

  4. Hello, thank you for sharing. I have tried to run your case but I get a fatal error
    –> FOAM FATAL IO ERROR:
    keyword pcorrFinal is undefined in dictionary “/home/jlorenzo/.local/share/Trash/files/cylinderMotion/system/fvSolution.solvers”
    Do you know how this can be solved?

    • pcorrFinal
      {
      $pcorr;
      tolerance 0.1;
      relTol 0;
      }

      Include pcorrFinal in fvSolution file as above.

  5. Hi there,I log on to your new stuff named “Oscillating Cylinder in Laminar Crossflow – pimpleDyMFoam | curiosityFluids” on a regular basis.Your humoristic style is awesome, keep up the good work! And you can look our website about powerful love spells.

  6. Hi, thank you for this example. I want to do the same thing but I want to reduce continously the amplitude of the cylinder till it stabilize. How canI do this? Do you have any idea or suggestion for me?
    Thank you

    • Hi., It seems through your question that you are working on free oscillations of the cylinder, where oscillations of the cylinder are induced entirely by the flow. However this blog is about forced oscillations i.e., cylinder is forced to oscillate with the given parameters like frequency and amplitude.
      If, this is true, your problem is much more complicated where 2 way Fluid structure interaction involved. Actually, in this case, every step consists of substeps involving transfer of force from fluid to structure leading to incremental dispacement. And further transfer of this displacement from structure to fluid to alter the flow field.
      I am currently working on this in ANSYS and i dont have any idea in openFOAM at present.

      Y. Omkar. AMAeSI,
      B.E/B.Tech (Aeronautical Engg),
      M.Tech (Ocean Engineering),
      Indian Institute of Technology.
      Kharagpur, West Bengal,
      India.

  7. First, I’m new to OpenFoam so please forgive any stupid questions. I tried running the tutorial using v. 2.3.0 (blockMesh and then pimpleDyMFoam) but the output is illegible, fully of crazy characters. Should I have ran another executable prior to pimpleDyMFoam?

    • Are you trying to read it in a text editor? Probably the case is outputting in binary (you can check this in the controlDict). You should view the data with ParaView, or if you really want to view it in the text editor, change the write format in controlDict to ascii.

    • Never mind – just realized the controlDict was set to output binary and not ascii. Problem solved!

  8. Can this same case on oscillating square cylinder up and down be done using Ansys Fluent? If so, can u please help me.

    • I’m sure that you could. However, curiosityFluids is dedicated to open-source software… which fluent is not. With a little work, you could modify this case for an oscillating square cylinder and run it using pimpleDyMFoam.

Leave a Reply to Laudy JrCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from curiosityFluids

Subscribe now to keep reading and get access to the full archive.

Continue reading