CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

InterFoam - setFields for a non-rectangular 3D domain

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 3, 2010, 21:18
Default InterFoam - setFields for a non-rectangular 3D domain
  #1
New Member
 
Kishore, A.
Join Date: May 2010
Location: Cincinnati
Posts: 7
Rep Power: 15
Ak_cfd is on a distinguished road
Hello All,

I have been working with OF-1.5 and using interFoam.

My domain is a cylindrical tube with the axis aligned with the gravity vector. The tube is closed at the bottom and I need to initialize the flow-field such that half of the tube is filled with liquid.

When I run setfields, I can only prescribe dimensions of a box. I used dimensions for a box that would encapsulate the cylindrical region that I needed to initialize, but setFields does not work. Doesn't throw an exception either.

Any ideas on how I can handle this problem is appreciated. Thanks.
Aravind
Ak_cfd is offline   Reply With Quote

Old   June 4, 2010, 02:32
Default
  #2
Senior Member
 
Gijsbert Wierink
Join Date: Mar 2009
Posts: 383
Rep Power: 18
gwierink is on a distinguished road
Hi!

I would use funkySetFields, with which you can set all kind of shape for fields using regular expressions. You need to install it separately, just follow the instructions in the previous link.

If you want to set a cylinder you probably have to do something like the following (it's just a first guess!):



Code:
funkySetFields -field alpha1 -expression 1 -time 0 -keepPatches -condition "pow(pos().x,2) + pow(pos().y,2) < pow(0.1,2) && 0 < pos().z < 0.2"
Here I assumed the following:
  • you want to set a field ("-field")called alpha1 to 1 ("-expression 1") in the specified region
  • at time 0
  • for a cylinder with radii in x- and y-directions, with a radius of 0.1
  • the vertical axis is the z-axis and you want to "fill it with alpha1 = 1" up to z-level 0.2
Once again, the command may needs some improvement, but I hope it is something to start from.
__________________
Regards, Gijs
gwierink is offline   Reply With Quote

Old   June 4, 2010, 13:39
Default
  #3
New Member
 
Kishore, A.
Join Date: May 2010
Location: Cincinnati
Posts: 7
Rep Power: 15
Ak_cfd is on a distinguished road
Hi Gijsbert,

Thanks for your reply. I'll try this over the weekend and write back in the forum as to how it worked!

Aravind
Ak_cfd is offline   Reply With Quote

Old   December 22, 2010, 06:51
Default
  #4
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Gijsbert,
i am trying to simulate a round jet in a rectangular cartesian mesh for some validation study. I am using funkySetFields to set the alpha1 =1 in a round shape using your approach specified above. The command I use is :\

funkySetFields -field alpha1 -expression 1 -time 0 -keepPatches -valuePatches "inletWall" -condition "pow(pos().x-2.1e-3,2) + pow(pos().y-2.1e-3,2) < pow(0.1e-3,2)"

This command generates a circular inlet with alpha1 =1. But it also generates a alpha1=1 field in the z direction till the end of the domain.Where as I want the alpha1=1 only in one cell in the z-direction. Because it is my flow direction.
So i tried your approach

funkySetFields -field alpha1 -expression 1 -time 0 -valuePatches "inletWall" -condition "pow(pos().x-2.1e-3,2) + pow(pos().y-2.1e-3,2) < pow(0.1e-3,2) && 0<pos().z<2e-3"

But this gives a syntax error.

could you please tell me where am I going wrong.
regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   December 22, 2010, 07:19
Default
  #5
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
0<pos().z<2e-3
This is not valid afaik.
I think you should replace this with:
(pos().z>0) && (pos().z<2e-3)
Bernhard is offline   Reply With Quote

Old   December 22, 2010, 07:41
Default
  #6
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Bernhard,
That correction solved my problem and that was exactly what I wanted to do. Thankyou very much for your prompt and accurate response.
Now I want to set a parabolic velocity profile on that round inlet.

Should I use funkysetFields or groovvyBc. To me it looks like funkySetFields is more appropriate.
I will try using funkySetFields.
If you have any experience on how to do this, any hints are welcome.
Thanks and Happy holidays
regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   December 22, 2010, 08:21
Default
  #7
Member
 
Duong A. Hoang
Join Date: Apr 2009
Location: Delft, Netherlands
Posts: 93
Rep Power: 17
duongquaphim is on a distinguished road
Send a message via Yahoo to duongquaphim
Hi Suresh,

I think you should use groovvyBc to set up parabolic velocity profile at the inlet since it is the boundary condition which have to be used during your simulation. FunkysetFields is only for creating the initial field at 0 time step.

Regards,

Duong
duongquaphim is offline   Reply With Quote

Old   December 22, 2010, 09:32
Default
  #8
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Duong,
Thanks for your suggestion. I already looked for the groovyBC and it looks like a powerful tool to set inlet boundary coniditon.
But I found that the groovyBC is used to set the boundary condition as parabolic or some condition on a complete patch.
But in my case I want to set the parabolic velocity condition only on the round inlet(alpha=1) that I have defined on the inlet patch using funkysetfields.

So the other part of my mesh other than the (alpha1=1) on the inlet patch should have a velocity of 0 (or wall) .

Thanks for your help and any suggestions on how to set the parabolic inlet will be very helpful. I use interFoam for running the simulation

regards
K.Suresh kumar
Attached Images
File Type: png roundinlet.png (7.3 KB, 203 views)
kumar is offline   Reply With Quote

Old   December 23, 2010, 07:24
Default
  #9
Member
 
Duong A. Hoang
Join Date: Apr 2009
Location: Delft, Netherlands
Posts: 93
Rep Power: 17
duongquaphim is on a distinguished road
Send a message via Yahoo to duongquaphim
Hi Suresh,

I think what you can do might be like this:

atmosphere { type groovyBC; valueExpression "-(gamma+internalField(gamma))*0.5*normal()"; value uniform (0 0 0); }

but instead of linear, make something like gamma*{your parabolic function}. Then when gamma = 0 --> vel = 0 and gamma = 1: you have your parabolic velocity.

You can find more detail in section 4.1.3 in http://openfoamwiki.net/index.php/Contrib_groovyBC

Merry Christmas.

Cheers,

Duong
duongquaphim is offline   Reply With Quote

Old   December 24, 2010, 04:11
Default
  #10
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Duong,
Thankyou very much for your idea. I tried your approach. First I did a test with: My U file
internalField uniform (0 0 0);

boundaryField
{
inletWall
{
type groovyBC;
valueExpression "-(alpha1+internalField(alpha1))*0.5*normal()";
value uniform (0 0 20);
timelines ();
}

atmosphere
{
type fixedValue;
value uniform (0 0 0);
}

}
here since my flow is in the +z direction. I specified 20 in the value uniform (0 0 20). I am not sure if this is where I have to define the velocity.
It is still running. I will check after sometime.

The second approach for setting a parabolic velocity. I did something like this.
internalField uniform (0 0 0);

boundaryField
{
inletWall
{
type groovyBC;
variables "rpm=0.0;Un=20;c=vector(2.1e-3,2.1e-3,0);n=sum(normal())/mag(sum(normal()));p=pos()-c;r=mag(p)+1.0e-10;R=max(r);xt=vector(n.y,-n.x,0);xT=xt/mag(xt);yt=vector(-n.x*n.z,-n.y*n.z,n.x*n.x+n.y*n.y);yT=yt/mag(yt);";
valueExpression "-(alpha1+internalField(alpha1))*{-Un*normal()*(1-pow(r/R,2)) + (rpm*pi/30)*((p & yT)*xT - (p & xT)*yT)}";
value uniform (0 0 0);
timelines ();
}

atmosphere
{
type fixedValue;
value uniform (0 0 0);
}

}

But his gives me an error, when I run the solver:
--> FOAM FATAL ERROR:
The expected return type scalar is different from the stored result type "vector"



From function tmp<Field<Type> > ExpressionResult::getResult()
in file lnInclude/ExpressionResultI.H at line 76.

FOAM aborting

#0 Foam::error:rintStack(Foam::Ostream&) in "/home/kumar/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::error::abort() in "/home/kumar/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 Foam::Field<double>* Foam::PatchValueExpressionDriver::getField<double> (Foam::string const&) in "/home/kumar/OpenFOAM/kumar-1.6.x/lib/linux64GccDPOpt/libswak4FoamParsers.so"
#3 parserPatch::PatchValueExpressionParser:arse() in "/home/kumar/OpenFOAM/kumar-1.6.x/lib/linux64GccDPOpt/libswak4FoamParsers.so"
#4 Foam::PatchValueExpressionDriver:arse(std::strin g const&) in "/home/kumar/OpenFOAM/kumar-1.6.x/lib/linux64GccDPOpt/libswak4FoamParsers.so"
#5 Foam::CommonValueExpressionDriver::evaluateVariabl e(Foam::word const&, Foam::string const&) in "/home/kumar/OpenFOAM/kumar-1.6.x/lib/linux64GccDPOpt/libswak4FoamParsers.so"
#6 Foam::CommonValueExpressionDriver::addVariables(Fo am::string const&, bool) in "/home/kumar/OpenFOAM/kumar-1.6.x/lib/linux64GccDPOpt/libswak4FoamParsers.so"
#7 Foam::groovyBCFvPatchField<Foam::Vector<double> >::updateCoeffs() in "/home/kumar/OpenFOAM/kumar-1.6.x/lib/linux64GccDPOpt/libgroovyBC.so"

Any suggestions on where I am wrong, will be very helpful.

regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   December 24, 2010, 06:10
Default
  #11
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Duong,
The linear profile case is running correctly by using the format you told me. I checked some initial results, it seems to be ok. Now I will work on the parabolic velocity profile case and try to fix it.

Thanks again for your explanation.

bye
regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   December 28, 2010, 11:44
Default
  #12
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Duong,
I tried different expressions for setting the parabolic velocity profile on the defined alpha1=1 inital field using groovyBC, but failed.
The flat or uniform profile case is running properly.

It will be really helpful, if you give me some idea on how to set the parabolic velocity function.

bye
regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   January 4, 2011, 08:58
Default
  #13
Member
 
Duong A. Hoang
Join Date: Apr 2009
Location: Delft, Netherlands
Posts: 93
Rep Power: 17
duongquaphim is on a distinguished road
Send a message via Yahoo to duongquaphim
Hi Kumar,

I was on vacation so ... . But, here is my solution:

inlet
{
type groovyBC;
variables "yp=pos().y;zp=pos().z;quad=-(pow((yp-5e-4)/1e-4,2)+pow((zp-5e-4)/1e-4,2))+1;";
valueExpression "alpha1*vector(1*quad,0,0)";
value uniform (1 0 0);
}

I made a simple parabolic velocity profile on the alpha1 area and tested it. You can take a look at the figure in the attachment. I think you can modify these things to get what you want.

I am sorry that I did not have time to check your implementation. But just give it to try.

Cheers,

Duong
Attached Images
File Type: jpg inlet.jpg (16.7 KB, 178 views)
raj kumar saini likes this.
duongquaphim is offline   Reply With Quote

Old   January 4, 2011, 09:24
Default
  #14
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hi Duong,
Thankyou very much for your explanation. I have one more question.
I am not exactly able to figure out your expression because I cannot see the coordinate system in the figure you have attached.

It would be really helpful to set the same condition in my case if you give me some explanation on the variables you have used. like quad=-(pow((yp-5e-4)/1e-4,2)+pow((zp-5e-4)/1e-4,2))+1
Since i am not that familiar with the syntax, sorry for the basic question.
I am going to implement it straight away and check if it is working.

Thanks for you reply.
bye
regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   January 4, 2011, 09:47
Default
  #15
Member
 
Duong A. Hoang
Join Date: Apr 2009
Location: Delft, Netherlands
Posts: 93
Rep Power: 17
duongquaphim is on a distinguished road
Send a message via Yahoo to duongquaphim
Hi Kumar,

I make the inlet for a channel case 10x1x1mm. Therefore, the plane you see in the attachment is the inlet 1x1mm. What I did is set up a velocity profile based on the sphere with the center at (0,0.5,0.5)mm and radius of 0.1mm. The mathematical of my implementation is:

quad = ((y-5e-4)/1e-4)^2+((z-5e-4)/1e-4)^2+1;
U = alpha1*quad;

I divide the term by 1e-4 just to make it easier to demonstrate and also make the term ((y-5e-4)/1e-4)^2+((z-5e-4)/1e-4)^2 not so small comparing to 1.

That's it. Hope it will help.

Cheers,

Duong
duongquaphim is offline   Reply With Quote

Old   January 5, 2011, 10:16
Default
  #16
Senior Member
 
Suresh kumar Kannan
Join Date: Mar 2009
Location: Luxembourg, Luxembourg, Luxembourg
Posts: 129
Rep Power: 17
kumar is on a distinguished road
Hello Duong,
I have succesfully generated the uniform profile and the parabolic profile using your instructions. Thanks for the clear explanations.

goodluck
bye
regards
K.Suresh kumar
kumar is offline   Reply With Quote

Old   April 13, 2012, 19:50
Default SetFields for a non-rectangular 3D domain
  #17
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Hi every body

My domain is a cylindrical object in a bath of fluid and its axis aligned with the gravity vector. The bath is half full and the fluid is around the cylinder.

Can any one help me with a code for FunkySetFiels?

Thanks
Mahyar
Mahyar Javidi is offline   Reply With Quote

Old   April 13, 2012, 19:54
Default
  #18
Senior Member
 
Join Date: Mar 2009
Posts: 225
Rep Power: 18
paka is on a distinguished road
For gods sake, write something more, describe what problem you have. How do you expect people to help you out without more details? It's like saying "I'm bleeding" without saying what happened and where.
paka is offline   Reply With Quote

Old   April 14, 2012, 12:33
Default
  #19
New Member
 
anonymous
Join Date: Jan 2012
Location: Canada
Posts: 24
Rep Power: 14
Mahyar Javidi is on a distinguished road
Hi again

Sorry, I am new in openFOAm. As I told I have a solid cylinder in a middle of a rectangular bath of liquid. The liquid bath is half full and 3/4 of the cylinder's length is in the fluid of bath and rest of it is outside of it in the air so I have two fluid in the system, air and a liquid. Actually I have to move the cylinder with a constant velocity to study the behavior of the system and specially fluid. Now I want to define liquid as my second fluid in the system ( I set the first fluid as air),
I was wondering how can I define liquid in my system.
I saw a code foe the fluid in the cylinder in this page, but in my system the liquid is around the cylinder.
I just do not know the code for this geometry in the funkySetFields and if I want to use ZoneToCell or regionToCell as an other option, I just do not know how to do that.


I put a figure of the geometry. It is symmetrical and I try to simulate a quarter of it for saving time so I can define a quarter of the cylinder as a boundary which cause a curve wall in the left and I could not use BoxToCell option. I put a figure for this condition as well.

I appreciate any help.

mahyar
Attached Images
File Type: jpg Coating 2 (2).jpg (12.1 KB, 47 views)
File Type: jpg Coating 2 (1).jpg (8.2 KB, 35 views)
Mahyar Javidi is offline   Reply With Quote

Old   April 14, 2012, 15:23
Default
  #20
Senior Member
 
Join Date: Mar 2009
Posts: 225
Rep Power: 18
paka is on a distinguished road
I cannot help you directly since I've never run a case like yours, but I can direct you to the right sources.

First of all go over to interFoam solver examples; go to tutorials folder and study those cases. I believe there is a damBreak and one more case. I'm also sure if you search here for interFoam you will find plenty of different examples.

In terms of rotational nature of you case I won't be much help to you. Nonetheless, I think you can assign velocity field to you fluid boundary - it's just an idea - this way you could define preassigned rotational field.

Study always from very basic cases make sure you understand them then proceed to the case you are solving.

I wish you good luck!
K
paka is offline   Reply With Quote

Reply

Tags
interfoam, openfoam 1.5, setfields


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
Domain format problem on airfoil flow simulation andrenonaka CFX 14 December 7, 2015 00:42
setFields doesn't function for a tetrahedral mesh - interFoam tommie OpenFOAM Pre-Processing 5 April 15, 2010 03:32
CFX Solver Memory Error mike CFX 1 March 19, 2008 07:22
[blockMesh] BlockMesh for a rectangular domain with curved bottom surface segersson OpenFOAM Meshing & Mesh Conversion 0 April 17, 2006 14:11
Import a rectangular domain into CFX 5.7 from ICEM SKLam CFX 9 March 8, 2006 00:47


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