CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Reinitialize velocity field during simulation (http://www.cfd-online.com/Forums/openfoam-solving/114805-reinitialize-velocity-field-during-simulation.html)

emirust March 18, 2013 06:28

Reinitialize velocity field during simulation
 
2 Attachment(s)
Dear Foamers,

I am using the interFoam solver to simulate the fall of a water drop in an oil phase.

For small droplets, I have trouble with initializing the case: I am using the funkySetFields to create the initial drop:

Code:

funkySetFields -field alpha1 -expression 1 -time 0 -keepPatches -condition "pow(pos().x-(20*0.000100/2),2)+pow(pos().y-(0.9*60*0.000100),2)<=pow((0.000100/2),2)"
During the first time steps, the drop will snap into a position which is more spherical than what the resolution of the mesh can offer (see attached screenshots). This initial field will greatly affect the trajectory of the drop, as it is very small, and in some cases it will often "eject" it out of the mesh.

My idea was to simulate the first time step, keep the field for the phase fraction alpha1 but set the velocity field back to zero so gravity can act on the drop undisturbed. Does anyone know how to procede?

Thank you a lot!

gschaider March 19, 2013 10:48

Quote:

Originally Posted by emirust (Post 414640)
Dear Foamers,

I am using the interFoam solver to simulate the fall of a water drop in an oil phase.

For small droplets, I have trouble with initializing the case: I am using the funkySetFields to create the initial drop:

Code:

funkySetFields -field alpha1 -expression 1 -time 0 -keepPatches -condition "pow(pos().x-(20*0.000100/2),2)+pow(pos().y-(0.9*60*0.000100),2)<=pow((0.000100/2),2)"
During the first time steps, the drop will snap into a position which is more spherical than what the resolution of the mesh can offer (see attached screenshots). This initial field will greatly affect the trajectory of the drop, as it is very small, and in some cases it will often "eject" it out of the mesh.

My idea was to simulate the first time step, keep the field for the phase fraction alpha1 but set the velocity field back to zero so gravity can act on the drop undisturbed. Does anyone know how to procede?

Thank you a lot!

Sounds dirty. But I've also got a dirty solution. Using swak4Foam.

Add this function object:
Code:

clearVelocity {
    type manipulateField;
    variables (
      "startTime=0.1;"
    );
    mask "time()<startTime";
    expression "vector(0,0,0)";
    fieldName U;
}

This should clear the field until t=0.1 and then do nothing. I'm doing this from memory, so there may be parameters missing. Not sure, but it may also be necessary to clear phi

emirust March 19, 2013 12:00

Thank you!

Another idea I got was to initialize the pressure field to be what is expected from theory, by using the formula for pressure difference due to surface tension:

Young Laplace Equation

I believe this can easily be done with funkySetFields for cells within the drop. I suspect it will avoid the snapping of the drop into place, but haven't implemented any of those suggestions yet.

I'll keep this post up to date ;-)

gschaider March 19, 2013 12:15

Quote:

Originally Posted by emirust (Post 415039)
Thank you!

Another idea I got was to initialize the pressure field to be what is expected from theory, by using the formula for pressure difference due to surface tension:

Young Laplace Equation

I believe this can easily be done with funkySetFields for cells within the drop. I suspect it will avoid the snapping of the drop into place, but haven't implemented any of those suggestions yet.

I'll keep this post up to date ;-)

Also have a look at http://openfoamwiki.net/index.php/Co...on_Sloping_Bed and the discussion referenced from it. That might help by making the field a little bit more "blurry" (not so 0/1) on the border. Maybe this at least reduces the snapping

emirust March 20, 2013 13:56

For your information:

it is possible to reinitialize the velocity field by using funkySetFields:
Code:

funkySetFields -field U -expression 'vector(0,0,0)' -time 0.01 -keepPatches

One can also force the initial pressure difference to be 28 for example:

Code:

funkySetFields -field p_rgh -expression 28 -time 0 -keepPatches -condition "alpha1==1"
Results are not greatly improved however, probably due to the smallness of the drop.

Best of luck!

liguifan March 31, 2013 21:42

Hi emirust,

I am currently working on a similar project like yours, simulating a droplet of oil phase (radius is around 2mm) fall into a water tank. However, the results seems to be bad since when I use setFields to initialise the droplet; it seems to be out of its capacilty to generate such a small droplet. I am trying to use funkySetFields to do it, but the resource, where funkySetFields package can be downloaded, has been removed from OpenFOAMWiki. Just wondering, where did you get your funkySetFields package if you can tell me? Thanks in advance and hope we can have further discussion later.

BTW, have you successfully used the snapphyHexMesh to refine the area around your droplet?

Best,
Quote:

Originally Posted by emirust (Post 415324)
For your information:

it is possible to reinitialize the velocity field by using funkySetFields:
Code:

funkySetFields -field U -expression 'vector(0,0,0)' -time 0.01 -keepPatches
One can also force the initial pressure difference to be 28 for example:

Code:

funkySetFields -field p_rgh -expression 28 -time 0 -keepPatches -condition "alpha1==1"
Results are not greatly improved however, probably due to the smallness of the drop.

Best of luck!


immortality April 1, 2013 03:51

see this thread of mine to download swak4foam.inside swak4foam there is funkysetfiels.↲http://www.cfd-online.com/Forums/ope...ybc-of220.html

emirust April 7, 2013 09:20

Hey!

What do you mean by out of capacity? Have you looked at the interface tension and viscosity ratio of the two phases? This may be the reason for the bubble disapearing, if you are still in a test phase..

To initialize the fields, you must install the swak4foam package (groovyBC, funkySetFields and others have now been put together in swak4Foam). funkySetFields is included in it, and I believe you can find information on how to install it :D

Here is my blockMeshDict:

Code:

convertToMeters 1;
vertices       
(
    (  0  0  0 )          //0
    (  0.01  0  0 )          //1
    (  0.01  0.04  0 )          //2
    (  0  0.04  0 )          //3
    (  0  0  5e-07 )          //4
    (  0.01  0  5e-07 )        //5
    (  0.01  0.04  5e-07 )              //6
    (  0  0.04  5e-07 )        //7
   
 
);

blocks         
(
    hex (0 1 2 3 4 5 6 7) (30 120 1) simpleGrading (1 1 1)          //1
 
);
 
 edges         
 (
 );
boundary
(
    topWall
    {
        type patch;
        faces
        (
            (3 7 6 2)
        );
    }
    leftWall
    {
        type wall;
        faces
        (
            (0 4 7 3)
        );
    }
    rightWall
    {
        type wall;
        faces
        (
            (2 6 5 1)
        );
    }
    bottomWall
    {
        type wall;
        faces
        (
            (1 5 4 0)
        );
    }
    front
    {
        type empty;
        faces
        (
            (4 5 6 7)
        );
    }
    back
    {
        type empty;
        faces
        (
            (0 3 2 1)
           
        );
    }

And here is the topoSetDict (I run refineMesh two times on the same area created by the topoSet utility), so that the cells are divided by 4 smaller cells:

Code:

actions
(
           
        {
        name    c0;
        type    cellSet;
        action  clear;
       
            }       

        {
        name    c0;
        type    cellSet;
        action  new;
        source  boxToCell;
        sourceInfo
        {
            box (0.0028 0 -1) (0.0072 0.04 1);
        }
            }       
   

);

Hope this helps!

E.

liguifan April 7, 2013 22:14

Hi Emirust,

Thanks for your reply and your code.

I have implement my mesh and gave it a try. But when the mesh size is small, like droplet in mm, the simulation seems to be quite bad. The time step Delta T goes to some number like 1.5e-21 or even smaller. If I use a constant time step like 0.0001, the courant number would go to very large.

My case is actually 3D, I built up a cylinder and define bottom half is water, and funkySet to create a droplet on top of the water surface( inside the upper air phase)

Besides, I am not using MultiphaseInterFoam, so I think I don't need to take viscosity ratio into consideration( correct me if i am wrong), for the interfacial tension, I gave it a value (water oil) 0.025 (air water) 0.07 (air oil) 0.045.

Not sure whether you have met the same problem as mine, if yes, could you please give some suggestions? Appreciated that.

Best,

emirust April 8, 2013 05:03

Hello,

I based my case on the damBreak tutorial, so I am using the interFoam solver. The fact that the Courant number gets so small is probably a sign that the phases are changing a lot, and thus require smaller time step: for my case the time step is adjusting itself automatically (adjustTimeStep in controlDict). Typically this happened to me when I used a interfacial tension far too small, which caused by drop to "pop" and disapear.

Regarding the properties of the fluids: I specify it in the transportProperties file. There I need to specify both the viscosities of the phases and the interfacial tension between the two phases.


All times are GMT -4. The time now is 20:22.