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

Equations in Cylinder Coordinates

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 9, 2010, 13:47
Question Equations in Cylinder Coordinates
  #1
New Member
 
Steffen K.
Join Date: Jan 2010
Posts: 11
Rep Power: 16
fishlurch is on a distinguished road
Hi,


I just started learning OpenFOAM and somewhere on the first manual pages it is mentioned, that OpenFOAM uses the carthesian coordinate system by default. I want to simulate the flow through a cylinder and so want to set up my equations in cylindrical coordinates... can I "teach" OpenFOAM to use another system than the cathesian one?


Thanks a lot
Greez
Steffen

P.S. is there a good source for learning how to develop a simulation case by hand? = not take an example and change the settings but develop a case by myself...

Thanks
fishlurch is offline   Reply With Quote

Old   January 9, 2010, 16:41
Unhappy additional question
  #2
New Member
 
Steffen K.
Join Date: Jan 2010
Posts: 11
Rep Power: 16
fishlurch is on a distinguished road
Hi again,


it seems to me that icoFOAM bases on the Navier-Stokes Equation, which I need. But...

... is the continuity equation also included there?
... how can I set up additional boundary and starting conditions? Do I need to write them into any part of the C Code and recompile the Files or is it possible to set them up into the "normal" config files?
... again - how can I make OpenFOAM use cylindrical Coordinates? So I have to change and recompile the code for that or can I set that up in any of the config files?
... If I have to change so many things on an existing project, will it be better/ easier to built a project by myself?

Thanks a lot - I am a little "overextended" because of the huge power and possibilities of the program.


Greez
Steffen
fishlurch is offline   Reply With Quote

Old   January 9, 2010, 19:06
Default
  #3
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
Quote:
Originally Posted by fishlurch View Post
can I "teach" OpenFOAM to use another system than the cathesian one?
I don't think so. Prove me wrong, developers ...
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"
sega is offline   Reply With Quote

Old   January 9, 2010, 19:13
Default
  #4
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
Quote:
Originally Posted by fishlurch View Post
... is the continuity equation also included there?
Yes. icoFoam uses the PISO-algorithm which includes the numerical treatment of the continuity equation.

Quote:
Originally Posted by fishlurch View Post
... how can I set up additional boundary and starting conditions?
What are "additional" boundary and starting conditions for you?

Quote:
Originally Posted by fishlurch View Post
... again - how can I make OpenFOAM use cylindrical Coordinates?
I'm not sure this is possible. If you want to simulate within an axisymmetric coordinate system you can use the wedge-boundary condition!
Have a look at Fig. 5.4 in the User Guide.

Quote:
Originally Posted by fishlurch View Post

... If I have to change so many things on an existing project, will it be better/ easier to built a project by myself?
Are you talking about a single simulation or the whole OpenFOAM when you say "project"?
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"
sega is offline   Reply With Quote

Old   January 10, 2010, 09:05
Default
  #5
New Member
 
Steffen K.
Join Date: Jan 2010
Posts: 11
Rep Power: 16
fishlurch is on a distinguished road
Boundaries:
For solving a DiffEq one needs boundary and starting conditions, like e.g. U(t=0)=0 or p(x=0)=0; How and where are such conditions set up in a simulation (=project) (as e.g. icoFOAM)? And If I want to change such conditions in an existing project, where can I do so? Do I have to touch the C code or can it be realized via changing parameters in the already compiled files (as one can find in the tutorials folder).

Sorry if my questions are not posed very precisely, but it is because I just started with OpenFOAM.


Thanks a lot
Greez
Steffen
fishlurch is offline   Reply With Quote

Old   January 10, 2010, 15:33
Default
  #6
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
Quote:
Originally Posted by fishlurch View Post
Boundaries:
For solving a DiffEq one needs boundary and starting conditions, like e.g. U(t=0)=0 or p(x=0)=0; How and where are such conditions set up in a simulation (=project) (as e.g. icoFOAM)? And If I want to change such conditions in an existing project, where can I do so? Do I have to touch the C code or can it be realized via changing parameters in the already compiled files (as one can find in the tutorials folder).

Sorry if my questions are not posed very precisely, but it is because I just started with OpenFOAM.


Thanks a lot
Greez
Steffen
Did you have a look at the tutorial cases, like mentioned in the User Guide?
Initial and boundary conditions for each fields are stored within the case directory's subdirectory '0' (corresponsing to time = 0).

Like: 0/U (Velocity) or 0/p (Pressure)

You don't have to touch the OpenFOAM code, but simply run the icoFoam on a case. But if you haven't figured that out yet I supposed you haven't had a look into the User Guide. I suggest you do that in the next step.
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"
sega is offline   Reply With Quote

Old   January 11, 2010, 04:42
Default
  #7
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by fishlurch View Post
I just started learning OpenFOAM and somewhere on the first manual pages it is mentioned, that OpenFOAM uses the carthesian coordinate system by default. I want to simulate the flow through a cylinder and so want to set up my equations in cylindrical coordinates
Just because your geometry is cylindrical why do you need to solve the governing equations in a cylindrical coordinate system?
olesen is offline   Reply With Quote

Old   January 11, 2010, 05:52
Default
  #8
New Member
 
Steffen K.
Join Date: Jan 2010
Posts: 11
Rep Power: 16
fishlurch is on a distinguished road
As a first approxomation for my diploma thesis I want to simulate the flow through a pipe (=cylinder), which has specific properties. When using a cylindrical coordinate system, the equations look much easier than in carthesian coordinates. For sure I could use the carthesian one, but then the equations become quite ugly...

@ Mark: Do you think it makes sense to make OpenFOAM use another coordinate system? (I found this: http://openfoamwiki.net/index.php/Si...ry_/_Tutorials). If I used the carthesian system, my boundary conditions become quite complicated (e.g. describe a condition on the wall of the cylinder...)

@ Sebastian: I read the user guide's chapters about boundaries, but it is still unclear how to handle them. Now I know that somehow the "boundary" file and the "p" and "U" files correspond, but I still dont understand in which way... e.g. If I simply wanted to say: "U_x(x=0,y,z,t)=0" or "p(t=0,x,y,z)=p_start", how could I set this up?


Perhaps one can explain my problem with a little example:

"boundary file":
movingWall
{
type wall;
nFaces 20;
startFace 760;
}

"/0/p file":
movingWall
{
type zeroGradient;
}

Does that mean that the moving wall (specified in polyMeshDict) has a zeroGradient (in what?) for all the time? And what does nFaces and startFaces mean?


Sorry for this huge postings - but I am really interested in OpenFOAM and this unclearity in my brain drives me crazy

Thank you!
fishlurch is offline   Reply With Quote

Old   January 11, 2010, 06:39
Default
  #9
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by fishlurch View Post
As a first approxomation for my diploma thesis I want to simulate the flow through a pipe (=cylinder), which has specific properties. When using a cylindrical coordinate system, the equations look much easier than in carthesian coordinates. For sure I could use the carthesian one, but then the equations become quite ugly...

@ Mark: Do you think it makes sense to make OpenFOAM use another coordinate system?
Cylindrical coordinates may make it easier to formulate your boundary conditions, but I would not agree that governing equations (Navier-Stokes) look much easier - cf. http://en.wikipedia.org/wiki/Navier%E2%80%93Stokes_equations#Cylindrical_coordi nates
... not even considering how something like the Reynolds' stresses would look like in cylindrical coordinates!
Also consider that the code would internally need different definitions for the gradient, divergence, laplacian etc. operators, as well as cell positions, volume calculations etc. And of course, your cylindrical domain would always need to be exactly coincide with the global coordinates .... I hope you can see why Cartesian coordinates are used for general purpose CFD codes (commercial or open source).

If you wish to solve your problem with OpenFOAM, STAR-CD, Fluent, CFX, etc. just get used to the idea that you need to solve in Cartesian coordinates. Of course you are still free to transform your final results back into cylindrical if that's what you need.
olesen is offline   Reply With Quote

Old   January 11, 2010, 06:49
Default
  #10
New Member
 
Steffen K.
Join Date: Jan 2010
Posts: 11
Rep Power: 16
fishlurch is on a distinguished road
Oh all right - I see the problem... thanks for advice :-)

At the moment I am trying to simulate a simple Hagen-Poisseuilles Flow in a cylindrical tube - just for Practice...

If I wanted to extend this first test to a non-rigid (= extesible tube), how do I have to build up my mesh? Does it have to be variable in size? Or is there any "common" technique for that?


Thx and Greez
Steffen
fishlurch is offline   Reply With Quote

Old   January 11, 2010, 07:48
Default
  #11
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
Quote:
Originally Posted by fishlurch View Post
As a first approxomation for my diploma thesis I want to simulate the flow through a pipe (=cylinder), which has specific properties. When using a cylindrical coordinate system, the equations look much easier than in carthesian coordinates. For sure I could use the carthesian one, but then the equations become quite ugly...

@ Mark: Do you think it makes sense to make OpenFOAM use another coordinate system? (I found this: http://openfoamwiki.net/index.php/Si...ry_/_Tutorials). If I used the carthesian system, my boundary conditions become quite complicated (e.g. describe a condition on the wall of the cylinder...)

@ Sebastian: I read the user guide's chapters about boundaries, but it is still unclear how to handle them. Now I know that somehow the "boundary" file and the "p" and "U" files correspond, but I still dont understand in which way... e.g. If I simply wanted to say: "U_x(x=0,y,z,t)=0" or "p(t=0,x,y,z)=p_start", how could I set this up?


Perhaps one can explain my problem with a little example:

"boundary file":
movingWall
{
type wall;
nFaces 20;
startFace 760;
}

"/0/p file":
movingWall
{
type zeroGradient;
}

Does that mean that the moving wall (specified in polyMeshDict) has a zeroGradient (in what?) for all the time? And what does nFaces and startFaces mean?


Sorry for this huge postings - but I am really interested in OpenFOAM and this unclearity in my brain drives me crazy

Thank you!
You are investigating in the right direction!
First of all you mesh with the blockMesh tool.
This is where you specify the boundary conditions, like wall in you example.
blockMesh writes the boundary file which should not be touched by you at this moment.

All you have to do is to manipulate the 0/U file!
Code:
movingWall      
    {
type wall;
    }
Looks a little bit like a repetition of the blockMeshDict file...
Well, at least for such a simple boundary condition this may be true.

Wall corresponds to U=0 at this boundary.
If you have specified wall as boundary condition in the blockMesh file zeroGradient (velocity gradient normal to the boundary) would not be possible as it is allready set to U=0 from blockMesh and written to the boundary file.
Still with me?
Make sure you understand that you specify the boundaries within the blockMeshDict and in the field file as well and they have to correspond.

Example (besides the many in the tutorial cases):

To set up a Neuman boundary condition, select patch in the blockMeshDict file and select zeroGradient in the field file.

To select a moving Wall, select patch in the blockMeshDict file
and select type fixedValue; value uniform(0 1 0) corresponding to the velocity direction you wall is moving.
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"
sega is offline   Reply With Quote

Old   March 26, 2010, 01:27
Default Advantage of cylindrical coordinates
  #12
New Member
 
amedlin's Avatar
 
Andrew Medlin
Join Date: Mar 2010
Posts: 1
Rep Power: 0
amedlin is on a distinguished road
The main advantage of cylindrical coordinates as I see it is that you can more easily exploit rotational symmetry in your problem to make it more computationally tractable.

For example, if your 3D geometry is axisymmetric, you could write your equations in cylindrical coordinates and reduce it to a 2D problem. A 2D simulation domain is likely to run orders of magnitude faster than the same thing modelled in 3D.

I'm not sure if OpenFOAM supports it, but even with your mesh in cartesian coordinates you could effectively solve it in a 2D domain if the solver implements angular cyclic boundary conditions. In this case your mesh dimension in the theta direction could be 1 cell, effectively turning it into a 2D problem.
amedlin is offline   Reply With Quote

Old   March 26, 2010, 04:11
Default
  #13
Senior Member
 
sega's Avatar
 
Sebastian Gatzka
Join Date: Mar 2009
Location: Frankfurt, Germany
Posts: 729
Rep Power: 20
sega is on a distinguished road
Quote:
Originally Posted by amedlin View Post
I'm not sure if OpenFOAM supports it, but even with your mesh in cartesian coordinates you could effectively solve it in a 2D domain if the solver implements angular cyclic boundary conditions. In this case your mesh dimension in the theta direction could be 1 cell, effectively turning it into a 2D problem.
No, OpenFOAM does not support cylindrical coordinates.
It's all 3D cartesian!
__________________
Schrödingers wife: "What did you do to the cat? It's half dead!"
sega is offline   Reply With Quote

Old   June 8, 2010, 11:09
Default
  #14
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Quote:
Originally Posted by sega View Post
No, OpenFOAM does not support cylindrical coordinates.
It's all 3D cartesian!
For sake of completeness:
It's all 3D cartesian, but it is possible to specify a wedge boundary condition (angular cyclic) as amedlin described to effectively reduce your computation to 2D.
akidess is offline   Reply With Quote

Old   January 4, 2012, 11:51
Default
  #15
New Member
 
Join Date: Jul 2011
Location: Berlin, Germany
Posts: 8
Rep Power: 15
skynet4ever is on a distinguished road
Hi,

sorry i resurrect this old Thread but I have exactly the same question as the original poster, plus the answers of akidess & amedlin go in the direction I want:

My problem has cylinder symmetry which reduces my 3D Problem to 2D. My Problem is now to design a solver with the governing equations which of cause differ a little from their Cartesian form. My equations read:

momentum equation:
r\Omega^2 - \frac{GM r}{\left(r^2+z^2\right)^{3/2}}-\frac{1}{\rho}\frac{\partial P}{\partial r}= 0 (radial direction)
\frac{GM z}{\left(r^2+z^2\right)^{3/2}}-\frac{1}{\rho}\frac{\partial P}{\partial r}= 0 (vertical direction)

together with the mass conservation:
\frac{\partial \rho}{\partial t}+\frac{1}{r}\frac{\partial}{\partial r}\left( r \rho \mathbf{v}_r \right) + \frac{\partial}{\partial z} \left(\rho \mathbf{v}_z \right)= 0

whereas:
r,z are coordinate variable names
G,M are constants
P is the pressure field
rho is the density field

Now how do I formulate this in the OF language? In particular how do I use the coordinate position in the formulation of the equations? Can I write something like:
Code:
volScalarField temp1(r*rho & v_r);
volScalarField temp2(rho & v_z);

solve (      fvm::ddt(rho)    + 1/r * fvm::grad(temp1) + fvm::grad(temp2)      ==    - fvc::grad(p) );
I know this is probably (very very) wrong, but I hope you know what I mean.

I would really like to use OpenFOAM for this because I like C++ and the OO programming style. I also think OpenFOAM knowledge can be a key ability for later jobs. If you like to know where the equations come from: It is going to be the simulation of a solar nebula in its disk phase.

Thank you for helping!

p.s.: The singularity at r=0 is no problem because I stop the simulation before the Sun starts ;-)

Last edited by skynet4ever; January 4, 2012 at 12:01. Reason: clarification
skynet4ever is offline   Reply With Quote

Old   January 12, 2012, 08:08
Default
  #16
New Member
 
Join Date: Jul 2011
Location: Berlin, Germany
Posts: 8
Rep Power: 15
skynet4ever is on a distinguished road
Hi Foamers,

can't somebody give me a hint? I have done a sketch of my problem which I appended as an attachment.

I have already constructed a grid using wedge boundary conditions. Which can be found in this Thread http://www.cfd-online.com/Forums/ope...wo-blocks.html

as I read in multiple Threads I can't use equations in cylindrical symetry, right? (please answer) So I have to transform my equations. But as my grid is only 2D I see no point in giving an expression for the symmetric Coordinate. If that is so can I simply replace r->x and z->z? Or dose the wedge boundary internally need the full equation? The continuity equation is straightforward but I have trouble with the momentum equation...
I also could really need some help for the construction of the corresponding field from the equation above. I found some useful code in the tutorial "Flow around a cylinder" from the programmers guide:
Code:
           Info<< "\nEvaluating analytical solution" << endl;

            const volVectorField& centres = UA.mesh().C();
            volScalarField magCentres(mag(centres));
            volScalarField theta(acos((centres & vector(1,0,0))/magCentres));

            volVectorField cs2theta
            (
                cos(2*theta)*vector(1,0,0)
              + sin(2*theta)*vector(0,1,0)
            );

            UA = uInfX*(dimensionedVector(vector(1,0,0))
              - pow((radius/magCentres),2)*cs2theta);
can I use this to construct an appropriate Vectorfield which can be used by differential operators? Or can I solve the problem in the CS and transform it afterwards? Please help. I think the rotational symmetry problems are of general interest (when looking at the read-numbers)

From the http://openfoamwiki.net/index.php/Si...ry_/_Tutorials I learn that it is at least possible to introduce a Cylindrical Coordinate Systems...

Thanks in advance.
Philipp
Attached Images
File Type: png gas+dust_small.png (37.0 KB, 88 views)

Last edited by skynet4ever; January 12, 2012 at 11:04. Reason: mistakes
skynet4ever 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
Guide: Writing Equations in LaTeX on the CFD Online Forums pete Site Help, Feedback & Discussions 27 May 19, 2022 04:19
benchmark: flow over a circular cylinder goodegg Main CFD Forum 12 January 22, 2013 12:47
Moving a Cylinder in cross flow after solving Dynamics equations of motion maruthamuthu_venkatraman OpenFOAM 1 November 19, 2009 14:55
rotating cylinder using sliding mesh Tim Daly FLUENT 1 November 10, 2008 00:02
Turbulent steady flow around a circular cylinder Mirek Kabacinski FLUENT 0 July 23, 2003 19:40


All times are GMT -4. The time now is 03:30.