CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Moving mesh part 2 (

lr103476 September 18, 2006 08:43

Hi, The mesh motion works u

The mesh motion works using the latest development code using the oscillatingFixedValue boundary condition. Now I am considering oscillating bodies (flat plates and cylinders) on different grids at low Reynolds numbers to see how the grid motion behaves.

I've got the following questions/remarks:

1) On coarse grids the meh motion performs very nicely, but on finer grids the mesh gots distorted near the body causing the flow solver to diverge. Since the oscillatory motion stays the same, but the cells are smaller (on the finer grid) the relative cell displacement is increased, i.e. the boundary of the body moves multiple cell sizes within one timestep. Besides choosing a very very small timestep, is there a good solution for this??

2) So, what are the ideal motion solver settings for this kind of problems?

3) At my place, another moving mesh method is developed using radial basis functions. This method is capable of using very large time steps without severe mesh destortion near the moving body boundary. How difficult is implementing such a new mesh motion algorithm in OpenFOAM?, or is this almost impossible?

4) I am also trying to expand the oscillatoryFixedValue boundary conditions towards a 6 DOF boundary condition which could handle arbitrary functions for 6 variables (not only oscillatory functions). Do you think this is feasible? Is it smart to start with the movingFlapFvMesh class from OpenFoam 1.2?

5) In the development sources, I am using, a top level Fluid Structure Interaction solver is present, icoFsiFoam. Is there also a tutorial available for this, just as an example how to define a problem using this solver. Unfortunately I haven't seen prof. Jasak's presentation at the 5th ICCSM, but I have read the paper and I'm impressed.

Best regards, Frank

hjasak September 18, 2006 14:55

Heya, Nice to hear you got

Nice to hear you got it working.

1) You need tuning. First, choose a better diffusion algorithm to limit mesh deformation next to the moving boundary. Second, carefully tune solver tolerances. Doing too much work in the solver makes the algorithm expensive (cannot really help) and too little accumulates motion errors.

2) There is a Thesis - dr. Zeljko Tukovic. Unfortunately, it's still being translated to English (sigh)

3) Easy: if you can define how the mesh moves (use radial functions like everybody else), just use new poilt locations to execute mesh motion - everything else remains the same

4) For a 6 DUB solver, you need to calculate forces and moments onto the surface and solve an ODE (ordinary diferential equation). Both should be trivial - see liftDrag for the forces, and ODE solvers are already impelmented

5) Yes, I've got a tutorial of sorts but people are waiting to publish their results. Once that happens, I'm happy to release the tutorial as well.

BTW, you haven't seen my presentation at ICCSM 'cause it's on Thursday :-)

Have fun,


lr103476 October 16, 2006 05:28

Hi, I succeeded in perform

I succeeded in performing a 2D oscillating cylinder simulation (see my website, link below) with oscillatingFixedValue boundary condition. My problems (of diverging motion solver) were caused by a time step which was too large. Right now I used 800 timesteps within one vortex shedding cycle which works actually quite good for the mesh motion. In general this time step size is sufficient to capture the relevant flow physics of this problem.

Then I tried to solve the mesh motion of a simple 3D problem: a moving cube inside a cube shaped domain. I solved the mesh motion for a fixedValue boundary condition with motion in 3 directions of 1 m/s. As you can see on my website, the cube body is moving correctly in 3 directions, but also the boundary of the domain is moving (only in x-direction).
I got similar (strange) results using the oscillatingFixedValue boundary condition (not shown). The mesh motion was nice, but of course this motion of the domain is not good.

I updated my website to show you the flow and motion solver settings, along with some results:

then go to Research -> CFD -> OpenFOAM moving mesh.

So, my question:

Does anyone got any ideas why the (oscillating)fixedValue boundary conditions in my 3D problem lead to an additional motion of the domain boundaries?

Regards, Frank

ztukovic October 16, 2006 05:55

Hi, Try following BC for mo

Try following BC for motionU:

type fixedValue;
value uniform (0 0 0);
type fixedValue;
value uniform (0 0 0);


lr103476 October 16, 2006 07:53

Thanks Zeljko, it works! T
Thanks Zeljko, it works!

Too easy, I should have seen it myself :-S

Regards, Frank

lr103476 October 20, 2006 10:47

Hi again, Does anyone know
Hi again,

Does anyone know how to use subsets of meshes in order to only move the subset directly around the moving body. That probably will reduce the computation time considerably.

I've already created a mesh using Gambit, which consists of a 'inner' and an 'outer' mesh. These two different parts are recognised by foamMeshToFoam and 2 different sets are created in the constant/polyMesh directory.

How do I set the boundary conditions in such a way that the motion is only applied to the inner set?

Thanks and have a good weekend!


hjasak October 20, 2006 11:03

Yup, I've already done that: m
Yup, I've already done that: make a subset, create a motion solver on it. Once the motion is solved for, use the functionality of the subset to map onto the complete mesh for motion and you're done.


lr103476 October 30, 2006 11:38

mmm, I dont think that I under
mmm, I dont think that I understand it correctly.

When I look in the constant/polyMesh/sets directory, there are already some subsets present from the fluentMeshToFoam conversion.

Isn't it possible to call the subsets that I want to move from dynamicMeshDict? If not, do I have to include the motion on the subset and the mapping, you referred to, in my user solver.

Is there a tutorial on this?

Regards, Frank

lr103476 November 29, 2006 16:37

Hi everybody. I updated my
Hi everybody.

I updated my site with some new problems, this time considering the use of subsets: sh/2D_movingmesh_wing

In order to move/deform the mesh around an oscillating wing I tried using no subset, one subset containing the inner part and one subset containing the outer part of the computational domain, see the site.

1) No subsets result in severe mesh distortion near the leading and trailing edges of the wing. Most likely, this is also the reason for the very slow convergence, which I addressed in another tread on this forum.
2) The inner part as a subset led to similar results.
3) The outer part as a subset deforms that part nice, but the inner part remains unchanged, which leads to the overlapping of both regions.

I used the subsetMotionSolverFvMesh library from prof. Jasak's sources. Is this the thing you mentioned in the post above? What is alpha doing?

The best solution for my problem seems to use two subsets together. The inner subset moving fixed to the wing, preserving high quality cells in the boundary layer. The outer subset deforming accordingly.


So my questions:

1) Did I make any mistakes implementing a subset using subsetMotionSolverFvMesh? please check my site...

2) How can I use two subsets together. On rigidly moving, the other deforming accordingly. (Could someone maybe share an example using multiple subsets?)


This are the problems I am facing now. When solved, I want to extend this model to 3D for further use in my PhD. I am very very eager to overcome these problems, since I don't want to return to Fluent (bad experiences).

Regards and thanks in advance,

hjasak November 30, 2006 04:53

Have you seen the pictures at
Have you seen the pictures at the bottom of this page:

OpenFOAM training Wiki

A proper choice of variable diffusivity in mesh motion is likely to solve your problem.


lr103476 November 30, 2006 08:21

Allright, seems t
Allright, seems to work with a diffusion coefficient depending on deformationEnergy or distortionEnergy.

All distance based diffusion coefficients, constant, linear, quadratic and exponential do not work at all. In those cases the mesh collapses, as shown on my site. In your paper 'Automatic mesh motion for the unstructured FVM', you also used distance based diffusion for the pitching airfoil.

1) Is there a reference with info about deformationEnergy or distortionEnergy? What means the constant (gamma) which is needed?

From my previous post:
2) How can I use two subsets together. On rigidly moving, the other deforming accordingly. (Could someone maybe share an example using multiple subsets?)

Regards and thanks,

hjasak November 30, 2006 08:33

Here we go again: All dis
Here we go again:


All distance based diffusion coefficients, constant, linear, quadratic and exponential do not work at all. In those cases the mesh collapses, as shown on my site. In your paper 'Automatic mesh motion for the unstructured FVM', you also used distance based diffusion for the pitching airfoil.
What do you mean: they do not work at all??? I have just shown you the pictures of ALL of them not only working but also producing correct results. Could you please explain what you mean by "do not work at all" and how is it possible that Zeljko and I get perfect results for a case which is much more difficult than yours and you cannot get even the basic stuff to work.

The reference for the other 2 diffusion methods is a PhD Thesis by dr. Tukovic.

A constant gamma is the diffusion coefficient you will start with in the mesh motio equation.

From the example you are showing it seems to me you time step for the mesh motion algorithm is much too large. Could you please tell me what is the boundary motion in terms of near-wall mesh size in a single time-step - that would be the mesh motion Courant number.

Multiple mesh motion: You can use as meany subsets as you like, provided they do not overlap. If they do, you will need to update them in a reasonable order and call them one at a time.


lr103476 November 30, 2006 09:29

Sorry to bother you. With
Sorry to bother you.

With 'they do not work at all' I mean that using those distance-based methods the mesh collapses just after maximal amplitude. For the moving mesh testing I used dt=0.005. When I solve for the flow I use adjustableRunTime with a maximum Co of 2.

The boundary motion is prescribed using the oscillatingFixedValue b.c. a pure sine motion. The maximal velocity is 2*pi*f = 1.57. The smallest cellsize (at leading and trailing edges) is about 0.0036. Together with a timestep of about 0.005 the mesh courant number becomes more or less 2.18. This is worst case, since all other cells are larger and the velocity is maximal only a short time.

So you think that I should be able to use the distance based methods when I reduce the timestep even further??
Btw, the mesh I used is only for testing, I really need a much denser mesh for my research, so a much smaller timestep.

While you were writing the post, I just found the theory of the other 2 diffusion methods in dr. Tukovic PhD thesis. It's a pity that it's in croatian, but that issue is already mentioned a couple of times in this forum.

Multiple mesh motion: How do I create multiple subsets, using subsetMesh. Using subsetMotionSolverFvMeshCoeffs, only one set is taken an moved. How do I use two sets together?


hjasak November 30, 2006 11:25

Try running it the with mesh C
Try running it the with mesh Co number of 0.5 and see if it gets any better.

The Thesis is being translated (I know, there was nothing I could do about the choice of language at the time). It will be made available when we're done with it. In the meantime, there is a series of accompanying papers coming out and I'm sure to advertise :-)

As for multiple subsets, nobody says the subsets need to be connected. You can have two "islands" of mesh motion operating independently. If this is not what you want, look at how I did mesh motion on a subset and modify the class to include multiple subsets - that's easy.



lr103476 December 1, 2006 12:28

Allright, when I decrease the
Allright, when I decrease the timestep 4 times, the mesh Co number gets around 0.5 and the mesh moves a lot better using linear or quadratic. Constant diffusion leads to a lot of skewness near the leading and trailing edges.

I get the best meshes at the largest time-steps for the distortionEnergy and deformationEnergy diffusion coefficients. Nevertheless it seems that the flow solver covergence put a much tighter restriction on the time-step than the motion solver.

I do understand that multiple subsets are possible, but I do not know how to use them together. From gambit to openFOAM, I end up with two sets (inner_fluid, outer_fluid) from which I create subsets with 'subsetMesh'.
How do I configure these in /constant/dynamicMeshDict and /constant/motionSubset/dynamicMeshDict?? All I can think of is: rewriting subsetMotionSolverFvMesh in order to make it possible to define two or more subsets in dynamicMeshDict.

Regards and thanks,

lr103476 February 21, 2007 06:21

Dear prof. Jasak. At my de
Dear prof. Jasak.

At my department people are also working with a cfd code which uses radial basis functions to update the mesh point positions in time. Those people are very happy with the robustness of this method.

At this point, I am able to solve the flow around a translating and rotating 3D object using OpenFOAM. I would like to compare your method (solving laplace equation) with the radial basis functions method.

My questions:
1) Did you ever consider to implement the radial basis function method? From a previous post I conclude that you are aware of this method (you suggest that everyone is using it). If not, why?

2) Will a different motion method be hard to implement. Which classes do I have to modify?

Regards, Frank

hjasak February 21, 2007 09:03

Heya, No, I did not impleme

No, I did not implement radial basis functions and indeed I know very little about the subject. Basically, if you want to move the mesh in OpenFOAM, all you need to do is to calculate the new point position in any way you like and depending on any parameters you like. Calling mesh.movePoints(newPoints) with you newPoints will give you all the support in motion and discretisation you need further on. Come to think of it, this is really cool! :-)

Thus, you can start just by using radial basis functions in your top-level code to calculate the new point position and you are in business. If you want to pack it further, you cna create a new type of dynamicFvMesh with radial basis function-based motion and using run-time selection.

I'd like to see it when you get it done, as well as learn some theory.



lr103476 January 15, 2008 10:20

Dear all, I have a problem
Dear all,

I have a problem with the use of mesh subsets in parallel.

Basically I have a developed a library based on subsetMotionSolverFvMesh which generates 2 subsets, one innerMesh and one outerMesh. For both subsets the initial conditions, motion parameters and solver settings are defined in:


I define a very high uniform diffusivity on innerMesh and a quadratic inverseDistance diffusivity on the outerMesh, such that the innerMesh moves nicely with the wing !!! It is really working perfect, but not in parallel :-(

The problem is always something like this:
--> FOAM FATAL ERROR : index 1024 out of range 0 ... 87

So the solver is looking outside the subset array......but in serial it works fine!

1) Has someone encountered similar problems ? Any ideas how this can be solved ?

2) Could someone please confirm that fvMeshSubset should work in parallel ?

Thanks and regards,

mattijs January 15, 2008 13:49

2) It should. Can you recompil
2) It should. Can you recompile your application and fvMeshSubset.C with -O0 -g -DFULLDEBUG and produce a traceback?

It helps running the separate processes in separate windows. The mpirunDebug script is one which does this (for local running). Have a look.

lr103476 January 15, 2008 17:37

Where can I find that mpirunDe
Where can I find that mpirunDebug script ?

All times are GMT -4. The time now is 06:36.