CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Pre-Processing (http://www.cfd-online.com/Forums/openfoam-pre-processing/)
-   -   Simulation of waves on a Water Surface (http://www.cfd-online.com/Forums/openfoam-pre-processing/95294-simulation-waves-water-surface.html)

Leech December 12, 2011 18:20

Simulation of waves on a Water Surface
 
Hi anyone,

my natural language is not english, so I hope i can still describe my problem.

What i want to do is to build a OpenFoam-Model which consists of a rectangular prism. The bottom half is filled with water, the top half with air.
So far I am able to do it.
Now I got 2 questions:
-The Air on Top is supposed to flow in a distribution. What i mean is that the air shall be injected with high speed on top of the prism and with low speed near the water surface (pretty simular to a boundary layer in big).
-The water shall be moved by the walls of the prism. For example one wall is oscillating in a sinus-shape or a wave-function so that waves will get build on the water surface.

Actually i got no idea how to build this model.
Any help would be appreciated.

I hope my english isnt that horrible, that nobody understands what I'm trying to ask.

Thanks a lot!

nimasam December 18, 2011 15:50

hi pier
could you tell me in which part you face the problem?
i didn't get what you are going to model, however if you want to have interface and see water surface you can use interFoam, if you want to make nonuniform boundary condition you should use a utility called groovyBC ( you can find it in wiki)

Leech December 18, 2011 19:52

hi,

i allready found the swak4foam library and succesfully installed it.
So what Im trying to do right now, is to create a box and fill it half with water. (Used with InterFOAM later with InterDymFoam, so ill use the setfieldsdict to fill it).
My only trouble right now is if ill get the groovy bc to work and to make some waves for me. But well see that.

Other question is: At the bottom half of the box ill use groovy bc to get waves into the water. At the top half i want to inject the wind (air in a distribution as described before). For that surpose i created 2 boxes right on top of each other, so i can insert 2 bc's (top-air inlet bottom-groovybc). Will this work? When the water gets waving itll move over the bottom box. What will the air inlet do to the waterwaves in front of it?

Thanks!

ngj December 19, 2011 02:56

Hi Pierre

Since you are going to generate waves, you might be interested in looking into waves2Foam (http://openfoamwiki.net/index.php/Contrib/waves2Foam). It is not straight forward applicable for your problem, since there has been given no thought for the velocity field in the air. However, if you change the waveVelocityFvVectorPatchField.* files, then I suppose you should be able to achieve what you describe.

Kind regards,

Niels

nimasam December 19, 2011 03:25

Quote:

Originally Posted by Leech (Post 336266)
hi,

i allready found the swak4foam library and succesfully installed it.
So what Im trying to do right now, is to create a box and fill it half with water. (Used with InterFOAM later with InterDymFoam, so ill use the setfieldsdict to fill it).
My only trouble right now is if ill get the groovy bc to work and to make some waves for me. But well see that.

Other question is: At the bottom half of the box ill use groovy bc to get waves into the water. At the top half i want to inject the wind (air in a distribution as described before). For that surpose i created 2 boxes right on top of each other, so i can insert 2 bc's (top-air inlet bottom-groovybc). Will this work? When the water gets waving itll move over the bottom box. What will the air inlet do to the waterwaves in front of it?

Thanks!

you can apply different BC in different position of a patch, just by groovyBC, in other words you dont need to creat two box at all,
if you look in groovyBc tutorials in wiki you will find some examples about it

ngj December 19, 2011 05:43

Hi Pierre,

One more consideration with respect to the problem you describe. The solver 'interFoam' produces considerable velocities in the air, which originate from numerical inaccuracies, so you should be very careful, if you are thinking of using interFoam to study the effect of wind on the shape and other properties of surface water waves.

Good luck,

Niels

Leech December 19, 2011 11:39

Quote:

Originally Posted by ngj (Post 336284)
Hi Pierre

Since you are going to generate waves, you might be interested in looking into waves2Foam (http://openfoamwiki.net/index.php/Contrib/waves2Foam). It is not straight forward applicable for your problem, since there has been given no thought for the velocity field in the air. However, if you change the waveVelocityFvVectorPatchField.* files, then I suppose you should be able to achieve what you describe.

Kind regards,

Niels


Thanks, ill take a look at that!

Leech December 19, 2011 11:41

Quote:

Originally Posted by ngj (Post 336302)
Hi Pierre,

One more consideration with respect to the problem you describe. The solver 'interFoam' produces considerable velocities in the air, which originate from numerical inaccuracies, so you should be very careful, if you are thinking of using interFoam to study the effect of wind on the shape and other properties of surface water waves.

Good luck,

Niels


Hi,

good to know about these limitations. But i guess these wont bother me too much. The goal ist to place a floating object on the water, the wind ist just there to make the sea-simulation a bit more complete. I dont think that the wind effect on the water surface is important.

Leech December 19, 2011 11:50

Quote:

Originally Posted by nimasam (Post 336288)
you can apply different BC in different position of a patch, just by groovyBC, in other words you dont need to creat two box at all,
if you look in groovyBc tutorials in wiki you will find some examples about it

Hi,

thanks for that tip. But what function exactly is it that is able to place different BC's on one face? Can't find it in the wiki :(

Phicau December 19, 2011 11:58

Hi

http://openfoamwiki.net/index.php/Co...groovyWaveTank

Code:

  inlet
  {
      type            groovyBC;
      valueExpression "(pos().z<=A*cos(-w*time())+0.5*k*A*A*cos(2*(-w*time()))) ? vector( A*w*exp(k*pos().z)*cos(-w*time()), 0, A*w*exp(k*pos().z)*sin(-w*time())) : wind)";
      variables      "l=5;A=0.1;g=vector(0,0,-9.81);k=2*pi/l;w=sqrt(k*mag(g));wind=vector(0,0,0);";
      timelines      ();
  }

Just change "wind" components to what you need.

Leech December 19, 2011 12:07

Quote:

Originally Posted by Phicau (Post 336348)
Hi

http://openfoamwiki.net/index.php/Co...groovyWaveTank

Code:

  inlet
  {
      type            groovyBC;
      valueExpression "(pos().z<=A*cos(-w*time())+0.5*k*A*A*cos(2*(-w*time()))) ? vector( A*w*exp(k*pos().z)*cos(-w*time()), 0, A*w*exp(k*pos().z)*sin(-w*time())) : wind)";
      variables      "l=5;A=0.1;g=vector(0,0,-9.81);k=2*pi/l;w=sqrt(k*mag(g));wind=vector(0,0,0);";
      timelines      ();
  }

Just change "wind" components to what you need.


I'm sorry but i don't get it :(
Where do you define that the wind is on the upper half of the patch and that the wave is on the lower half of the patch? Or are both of these functions intersecting over the complete patch?

Thank you so much!

Phicau December 19, 2011 12:16

Hi,

each time step it generates waves (alpha1=1) for cells with centers below the calculated eta, with the prescribed velocity.

Otherwise (what lies over it) gets alpha1=0 (air) and sets velocity to vector(0,0,0) on the original code. I changed that to define variable "wind", which is basically the same now, as it is set to (0,0,0). But you can modify that to introduce wind.

For example, wind=vector(1,0,0); will produce 1m/s of wind in the x direction.

Regards

nimasam December 19, 2011 12:20

groovyBC
 
let me simplify with an example:
consider you have a vertical face with the height of 1m
and your interface is in a position 0.5 so pos().z > 0.5 is air and pos().z < 0.5 is water
now you should change your boundary condition in file alpha and U to groovy BC
then in alpha file you should define which portion of face is water and which portion of it is air , some thing like this
Code:

valueExpression "pos().z>0.5 ? 1.0 : 0)";
and in U
Code:

valueExpression "vector(pos().z>0.5 ? a : b,0,0)";
instead of a and b you should implement your function
i hope you get the whole idea!

Leech December 19, 2011 12:22

I think i got it now!
Thank you all so much. I'll try to get it working :)

musahossein December 19, 2011 14:50

sampling forces from one phase only
 
Dear All:
In sampleDict is there any way to measure pressure due to one phase only (eg water and not the air above it?). I am trying to sample pressure forces on the left and right wall of a 2D tank using interDyMFoam. I get pressure at cell / cell point along the vertical face of the left and right walls. The tank is half full of water, with air in the top half of the tank. I am only interested in the pressure from the water. Can this be done?

Thanks

Leech December 20, 2011 16:41

1 Attachment(s)
Hey Anyone,

i still could use some help!
I am actually creating the tank with the groovy BC as you informed me.

I got some problems now (to find the problems i attached my wavetank-Folder):
-BlockMesh work fine (...)
-When I type setFields OpenFoam says :"Couldnt find value expression on inlet" for both U and alpha1. I tried to add value uniform 1 oder value uniform (1 0 0) and then it worked but I am not shure if these are ok? Why he asks me to add this line?

-I got no outlet somewhere. And I am using p_rgh. In the GroovyWaveTank-Tutorial they were using pd with an athmosphere. I am a bit confused what i need to do to create a athmosphere? (which i want to have)

-What conditions do I have to give to the walls, so that the waves transmitted from the inlet just go trough and do not rebound?

-When i am trying to run InterFoam he says: "Unknow BC at Inlet GroovyBC". But i installed the swak4foam library and i allready runned some of the examples and they worked?


So much questions...
Thank you all

Greetings

Leech December 20, 2011 16:51

Quote:

Originally Posted by nimasam (Post 336354)
let me simplify with an example:
consider you have a vertical face with the height of 1m
and your interface is in a position 0.5 so pos().z > 0.5 is air and pos().z < 0.5 is water
now you should change your boundary condition in file alpha and U to groovy BC
then in alpha file you should define which portion of face is water and which portion of it is air , some thing like this
Code:

valueExpression "pos().z>0.5 ? 1.0 : 0)";
and in U
Code:

valueExpression "vector(pos().z>0.5 ? a : b,0,0)";
instead of a and b you should implement your function
i hope you get the whole idea!

With "your function" you mean the function for the wind injection?
I just wrote 1,0,0 in the attached pack in the previous post, because the vector wind is also 1 0 0? Or did i missunderstood something?

nimasam December 20, 2011 18:15

two many questions :)
1) i suggest to use funkySetFields instead of setFields (find in wiki)
2) add this line into your controlDict
Code:

libs ("libOpenFOAM.so""libgroovyBC.so");
3) if air injection is uniform then it would be constant but you have chance to choose any function or distribution for air injection

Leech December 20, 2011 19:21

Quote:

Originally Posted by nimasam (Post 336533)
two many questions :)
1) i suggest to use funkySetFields instead of setFields (find in wiki)
2) add this line into your controlDict
Code:

libs ("libOpenFOAM.so""libgroovyBC.so");
3) if air injection is uniform then it would be constant but you have chance to choose any function or distribution for air injection

to 1) what would be the difference or the benefit?
to 2) ill try that tomorrow, thanks!
to 3) where is that function added? at a:b? what type of function can i write there?
to x) whats about the error of setFields "need to add value"?

Thanks!

nimasam December 21, 2011 01:36

to 1 and x ) use the funkySetFields you will find its great benefits
to 2) first try then, if you face problem, ask again ;)
3)a or b should be replaced with your function :))
for example you can use this function sin (pos().z), i didnt know what function was suitable for your simulation so i remained it for your modification


All times are GMT -4. The time now is 16:02.