CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

How to generate Time varying Inlet velocity with a particular profile

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes
  • 1 Post By simrego
  • 2 Post By simrego
  • 1 Post By simrego
  • 2 Post By simrego
  • 1 Post By simrego

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 5, 2018, 17:45
Smile How to generate Time varying Inlet velocity with a particular profile
  #1
New Member
 
Faiaz Khaled
Join Date: Oct 2017
Location: United States of America
Posts: 17
Rep Power: 9
faiazk is on a distinguished road
p { margin-bottom: 0.1in; line-height: 120%; } Hello Everyone,


I am doing Phd in civil engineering. I am at the initial phase of my research. I am using Openfoam. I am new to OpenFoam. I have made some progress but right now I need help with the following issue I am having.



I am trying to produce time varying inflow with a profile which is similar to wind behavior in atmospheric boundary layer. I was able to generate inlet velocity with a logarithmic profile. But, what I need to learn right now is to generate time varying inlet velocity with my particular profile.


I was able to generate the non uniform profile (not varying with time) of wind flow by changing the inlet velocity boundary condition in the following way.




inlet
{
type fixedValue;
value nonuniform List<vector>
2640
(
( -16.76486314 0 0 )
( -16.76486314 0 0 )
( -16.76486314 0 0 )
( -16.76486314 0 0 )
( -16.76486314 0 0 )
…………………………
………………………...


Can you please let me know if this is possible in OpenFoam and if it is possible then can you please share some idea or relevant materials with me.


I have also come across groovyBC. Is it feasible to use groovyBC for my purpose?


Please let me know.



Thank you.


Regards,
Faiaz Khaled
faiazk is offline   Reply With Quote

Old   June 6, 2018, 04:35
Default
  #2
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!

Try to search for that in the forum. As I remember this question comes up really often.
But for a guess if you need a BC which is not implemented, you can use codedFixedValueFvPatchField:
https://cpp.openfoam.org/v5/classFoa...d.html#details

You can write your own BC pretty easily. If the time dependence of your velocity cannot be expressed as a function, try to use an interpolation table. For example the fanPressureFvPatch field is using an interpolation table, so you can figure out how could you implement it:
https://cpp.openfoam.org/v5/fanPress...8C_source.html

I'm not so familiar with groovyBC, it is just a hint, so I hope someone can help you with groovyBC.
faiazk likes this.
simrego is offline   Reply With Quote

Old   July 3, 2018, 10:52
Default
  #3
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 15
clapointe is on a distinguished road
I've used groovyBC for generating time/space varying boundary conditions before. Usage is very straightforward. Here's an old link with examples : http://openfoamwiki.net/index.php/Co...Usage_Examples. groovyBC is now just part of swak4foam, but I do not think the usage will have changed much from the samples provided.

Caelan
clapointe is offline   Reply With Quote

Old   July 6, 2018, 07:27
Default
  #4
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 8
crizpi21 is on a distinguished road
Quote:
Originally Posted by faiazk View Post
p { margin-bottom: 0.1in; line-height: 120%; } Hello Everyone,


I am doing Phd in civil engineering. I am at the initial phase of my research. I am using Openfoam. I am new to OpenFoam. I have made some progress but right now I need help with the following issue I am having.



I am trying to produce time varying inflow with a profile which is similar to wind behavior in atmospheric boundary layer. I was able to generate inlet velocity with a logarithmic profile. But, what I need to learn right now is to generate time varying inlet velocity with my particular profile.


I was able to generate the non uniform profile (not varying with time) of wind flow by changing the inlet velocity boundary condition in the following way.




inlet
{
type fixedValue;
value nonuniform List<vector>
2640
(
( -16.76486314 0 0 )
( -16.76486314 0 0 )
( -16.76486314 0 0 )
( -16.76486314 0 0 )
( -16.76486314 0 0 )
…………………………
………………………...



Regards,
Faiaz Khaled
Hi Faiaz, I also want to generate an inlet velocity with a logarithmic profile (to model wind bounary layer). Could you please tell me how you have done this?
So far I have just managed to do a matlab script that calculates the values for the velocity profile and then prints them as a nonUniform list, but this is not practical if I want to make changes in my mesh (which will change the coordinates and number of points). Ideally, I would like to be able to specify directly to OpenFOAM the velocity inlet profile as a function of the height, and then get the list of values directly.

Have you made any progress on this?
crizpi21 is offline   Reply With Quote

Old   July 10, 2018, 17:31
Default
  #5
New Member
 
Faiaz Khaled
Join Date: Oct 2017
Location: United States of America
Posts: 17
Rep Power: 9
faiazk is on a distinguished road
Quote:
Originally Posted by crizpi21 View Post
Hi Faiaz, I also want to generate an inlet velocity with a logarithmic profile (to model wind bounary layer). Could you please tell me how you have done this?
So far I have just managed to do a matlab script that calculates the values for the velocity profile and then prints them as a nonUniform list, but this is not practical if I want to make changes in my mesh (which will change the coordinates and number of points). Ideally, I would like to be able to specify directly to OpenFOAM the velocity inlet profile as a function of the height, and then get the list of values directly.

Have you made any progress on this?
Hello Cristina,

I hope you are fine. As I said before, I was able to generate logarithmic velocity (without making it time varying) in the method shown in this video tutorial

https://www.youtube.com/watch?v=K-nAF3qAPTc

I hope this will help. But, I think there are other smarter ways to do this. You can also write your own boundary condition (by changing the .H and .C files) to get it done. The link I am sharing here should help you learn how to do that.

http://www.tfd.chalmers.se/~hani/kur...yCondition.pdf

I am not an expert. But, right now I am trying add fluctuation to the inflow velocity profile.

Thank you,

Regards,
Faiaz
faiazk is offline   Reply With Quote

Old   July 11, 2018, 06:48
Default
  #6
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!


I wrote a little bullshit code for you which sets the x component of the velocity equal to the y coordinate of the face centre. Of course this is useless, but i hope it can help you to write your own BC. You can simply add time dependence if you want.
After running you can easily check if your BC is what you want or not.



Code:
inlet
    {
        type            codedFixedValue;
        value           uniform (0 0 0);
        name            codedStuff;

        code
         #{
            //Initialize velocity with zeroes

            vectorField veloc(patch().size(), vector(0, 0, 0));
             

            //Go through all face centres:

            const vectorField& centre(patch().Cf());
            forAll(centre, i)
            {
                veloc[i].x() = centre[i].y();
            }


            //Apply the calculated velocities

             operator==(veloc);
        #};

        codeInclude
        #{
        #};

        //codeOptions
        //#{
        //    -I$(LIB_SRC)/surfMesh/lnInclude
        //#};
    }
utkunun and chc like this.
simrego is offline   Reply With Quote

Old   July 11, 2018, 09:23
Default
  #7
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 8
crizpi21 is on a distinguished road
Hi Faiaz, thanks for your tips!
I also came up with the youtube tutorial you shared and this is the way I was generating my inlet profile, but I find this very time consuming. Apart from the inlet, I also want to have the internalField defined as a power law profile (at the 0 time directory), so that's the reason why I was looking for a way to define both the internal field and the boundary mathematically. I assume you haven't tried that and you are just creating a script that writes the U file for you, am I right?

Let me know if you have any ideas about this and thanks for your help,

Cristina
crizpi21 is offline   Reply With Quote

Old   July 11, 2018, 09:28
Default
  #8
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 8
crizpi21 is on a distinguished road
Quote:
Originally Posted by simrego View Post
Hi!


I wrote a little bullshit code for you which sets the x component of the velocity equal to the y coordinate of the face centre. Of course this is useless, but i hope it can help you to write your own BC. You can simply add time dependence if you want.
After running you can easily check if your BC is what you want or not.
Hi,
Thanks for your answer. My objective is to define mathematically not only the boundaries but also the internalField. Do you think I could apply this same code to specify the internal field? If so, how would you suggest to do it, because for the internalField I cannot specify "type codedFixedvalue" so I don't know how to implement it.

Thanks in advance!

Cristina
crizpi21 is offline   Reply With Quote

Old   July 11, 2018, 09:37
Default
  #9
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi!

With setFields you can set the initial values for the internal field, but it can use only the followings, which are mostly primitives and predefined zones.
But why do you want to define the internalField? This should be your solution, and if you know the internal field, you don't need any calculations.


Code:
43
(
boundaryToFace
boxToCell
boxToFace
boxToPoint
cellToCell
cellToFace
cellToPoint
cylinderAnnulusToCell
cylinderToCell
faceToCell
faceToFace
faceToPoint
faceZoneToCell
faceZoneToFaceZone
fieldToCell
labelToCell
labelToFace
labelToPoint
nbrToCell
nearestToCell
nearestToPoint
normalToFace
patchToFace
pointToCell
pointToFace
pointToPoint
regionToCell
regionToFace
rotatedBoxToCell
searchableSurfaceToFaceZone
setAndNormalToFaceZone
setToCellZone
setToFaceZone
setToPointZone
setsToFaceZone
shapeToCell
sphereToCell
surfaceToCell
surfaceToPoint
targetVolumeToCell
zoneToCell
zoneToFace
zoneToPoint
)
faiazk likes this.
simrego is offline   Reply With Quote

Old   July 11, 2018, 09:59
Default
  #10
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 8
crizpi21 is on a distinguished road
Quote:
Originally Posted by simrego View Post
Hi!

But why do you want to define the internalField? This should be your solution, and if you know the internal field, you don't need any calculations.
I'll briefly explain you my case: I am evaluating the wind flow past my domain to validate my CFD model and then run simulations for the flow past a body. Currently, with no obstacle, I should have a logarithmic profile in all the domain and, when I add it, the U field should be solved accordingly.

If I only specify a logarithmic law in the inlet (time directory 0), it takes around 50s of simulation for the conditions of the inlet to reach all the domain. What I want is to have a logarithmic velocity profile in all the domain for t=0 (to avoid this simulation time) and then let OpenFOAM solve p and U fields.
crizpi21 is offline   Reply With Quote

Old   July 11, 2018, 10:12
Default
  #11
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Is it a transient or a steady simulation? 50 sec in real time? It's not a long simulation time I think.


And what if you just solve it once, and then just map the converged solution from the "empty" case to the "obstacle" case? Like this you will have a good starting point so you should reach convergence pretty fast. And it is much simpler than write some code to set the initial field in the whole domain i think. (At least I think you can set the initial field as you want only if you write some code for it.)


I'm also not sure if setting the velocity field is enough without the proper pressure field. Since the U and p equations are coupled, the "bad" initial pressure field will blow up your nicely defined velocity field. But it is just a guess.


I think you should just use mapping from an "empty" case to an obstacle case. It is not time consuming and you can find mapping example somewhere in the tutorials (maybe cavity case).
Of course like this you still have to solve the "empty" case, but just once.
faiazk and crizpi21 like this.
simrego is offline   Reply With Quote

Old   July 12, 2018, 07:13
Default
  #12
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
Hi crizpi21!!


I just accidentally found something which could be useful for you if you still want to define your internal field:
https://cpp.openfoam.org/v6/classFoa...m.html#details
Honestly i have never used it but i think this is what you need.
simrego is offline   Reply With Quote

Old   July 18, 2018, 06:11
Default
  #13
Member
 
Cristina Hernandez
Join Date: May 2018
Posts: 35
Rep Power: 8
crizpi21 is on a distinguished road
Hi simrego, thanks for your help! I decided to follow your advise: run an "empty" case to obtain the U profile and then map the solution into the "obstacle" case. This way, I am sure that the fields (U,p, k, omega) are consistent, rather than defining only U.

Quote:
Originally Posted by simrego View Post
Is it a transient or a steady simulation? 50 sec in real time? It's not a long simulation time I think.
It is a transient simulation and I am simulating 50s (my domain is 1000m long and U is around 50 m/s so it should be enough time for the conditions of the inlet to reach the end).

I have a last question that maybe you could answer. For my real case, I have a rather fine mesh and I have used the same fine mesh for the "empty" case, so it took long until I got the desired U profile. I am not sure if I could use a coarser mesh just for the empty case (to speed up) and then map the solution to the fine mesh or if I will loose accuracy in my U field during this mapping process. What do you think?

Thanks again for your help!

Cristina
crizpi21 is offline   Reply With Quote

Old   July 18, 2018, 06:20
Default
  #14
Senior Member
 
anonymous
Join Date: Jan 2016
Posts: 416
Rep Power: 14
simrego is on a distinguished road
You can use a coarser mesh and of course you will loose accuracy since your geometry will be totally different but it can be a good initial guess for the fields.
I think 50s won't be enough since it is a transient case. You should monitor some quantity and when you'll see some oscillations you can say that you won.


Check this link from slide 136. I hope it'll help to understand.

http://www.wolfdynamics.com/wiki/fvm_crash_intro.pdf
arashgmn likes this.
simrego is offline   Reply With Quote

Old   June 1, 2021, 08:38
Default Time-varying atmBoundaryLayerInletVelocity
  #15
New Member
 
Aina
Join Date: Jan 2020
Location: Spain
Posts: 9
Rep Power: 6
Aina is on a distinguished road
Hi everyone,

I am simulating an Atmospheric Boundary Layer, so I am using the following inlet boundary condition:

inlet
{
type atmBoundaryLayerInletVelocity;
initABL false;
Uref constant 1:
Zref constant 0.15;
kappa 0.41;
Cmu 0.9;
.
.
.
}

Now, I want to generate time-varying inlet velocity using the type atmBoundaryLayerInletVelocity. For that, I want the velocity Uref to ramp from the value Uref=1 to the value Uref=3 in the time interval between t1=0 and t2=0.1 for example. I would like to know if it is possible and how to do that.

Thanks for your help!
Aina
Aina is offline   Reply With Quote

Old   June 3, 2021, 07:16
Default
  #16
New Member
 
Aina
Join Date: Jan 2020
Location: Spain
Posts: 9
Rep Power: 6
Aina is on a distinguished road
Quote:
Originally Posted by Aina View Post
Hi everyone,

I am simulating an Atmospheric Boundary Layer, so I am using the following inlet boundary condition:

inlet
{
type atmBoundaryLayerInletVelocity;
initABL false;
Uref constant 1:
Zref constant 0.15;
kappa 0.41;
Cmu 0.9;
.
.
.
}

Now, I want to generate time-varying inlet velocity using the type atmBoundaryLayerInletVelocity. For that, I want the velocity Uref to ramp from the value Uref=1 to the value Uref=3 in the time interval between t1=0 and t2=0.1 for example. I would like to know if it is possible and how to do that.

Thanks for your help!
Aina

Hi everyone

After some tests, I finally find a way to time-varying the scalar variable Uref in the function type atmBoundaryLayerInletVelocity.

inlet
{
type atmBoundaryLayerInletVelocity;
initABL false;
kappa 0.41;
Cmu 0.09;
C1 0;
C2 1;
flowDir constant (1 0 0);
zDir constant (0 0 1);
Uref table
(
(0 1)
(0.5 3)
);
Zref constant 0.15;
z0 constant 0.001;
d constant 0;
value uniform (0 0 0);
}
Aina is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Time varying velocity inlet boundary conditions using TableFile.H pruthvi1991 OpenFOAM Running, Solving & CFD 4 November 4, 2015 01:22
3d velocity profile at velocity inlet swethaprakash FLUENT 3 September 1, 2015 03:10
Micro Scale Pore, icoFoam gooya_kabir OpenFOAM Running, Solving & CFD 2 November 2, 2013 14:58
dynamic Mesh is faster than MRF???? sharonyue OpenFOAM Running, Solving & CFD 14 August 26, 2013 08:47
time varying inlet velocity shillin.ks OpenFOAM 4 June 29, 2012 06:51


All times are GMT -4. The time now is 04:34.