CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] Postprocessing a specific boundary

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 16, 2007, 10:23
Default Postprocessing a specific boundary
  #1
Member
 
Christian Lindbäck
Join Date: Mar 2009
Posts: 55
Rep Power: 17
christian is on a distinguished road
To postprocess my data I would need help to do the following:

1) I want to write the following to separate text files:

i) The pressure data of each wall cell face of a specific boundary.
ii) The coordinates of the wall faces in that boundary.
iii) The area of each wall face.

2) I want to sum the wall pressure times face area of the specific boundary. How can I do this without using the text files created in (1)?

I'm a rookie using OpenFOAM. This means you can't be too clear when answering my questions. All answers, even if you answer only one of my questions, are very welcome.

Best regards,
Christian
christian is offline   Reply With Quote

Old   March 16, 2007, 10:42
Default Should be easy. - make an o
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Should be easy.

- make an object of type OFstream, giving it the file name

- pick out the patch you want to write in (I will call its index patchID)

- write:

Before main(), add:

#include "OFstream.H"

and at the point where you want to write:

OFstream of("myFile.txt");

of << p.boundaryField()[patchID] << endl;
of << mesh.C().boundaryField()[patchID] << endl;
of << mesh.Sf().boundaryField()[patchID] << endl;


If you want each into a separate file, make yourself multiple OFstream objects

For the sum, do:

vector sumForce = sum(p.boundaryField()[patchID]*mesh.Sf().boundaryField()[patchID]);

Could it be easier?

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   March 16, 2007, 11:19
Default Thank you very much. First of
  #3
Member
 
Christian Lindbäck
Join Date: Mar 2009
Posts: 55
Rep Power: 17
christian is on a distinguished road
Thank you very much. First of all I wonder where am I supposed to learn about how to do the things you just taught me?

Now to some questions regarding your reply:

1) In which file am I supposed to insert the lines you suggested me?

2) Let's talk about writing the wall face pressure data, wall face coordinates and size. How is each value connected to a specific wall face? Is there a column next to the data value column saying face no 2 of cell no 21345? I mean, I need to be able to keep track of which face area that belongs to which face pressure. The values will of course be listed in the same order, but assume I want to pick a specific cell face by its number.

3) Why is the data type vector in "vector sumForce = sum(..."? The answer will be a real value. I haven't been using C++ before.

4) Assume instead I want to find data values of the cells of the boundary (not the faces). What command will I use then?

5) I've created a cut plane through my boundary where a do a contour plot. Now I simply want to step through my time steps and create an animation. How do you suggest me to do this? Should I save images and use some other software to create an animation (which?) or should I create an .mp2 animation right away? I want to run the animation on a Windows system.

Best regards,
Christian
christian is offline   Reply With Quote

Old   March 16, 2007, 13:55
Default ...where am I supposed to lear
  #4
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
...where am I supposed to learn...

The obvious answer is to look for examples in OpenFOAM, because I or other people must have done something similar already. If you need to be better at this, you can attend some training, come to the Workshop or (especially if you are working in a company using OF for commercial work) get some OpenFOAM support to help you produce quality results on time. Feel free to send me an E-mail if you want to talk about this.

Anyway, the level of things you are looking for is still easy: so, play, try to guess, learn by example etc. It's not that hard, really.

How is each value connected...

In the example, I am writing the values for all boundary faces. Face centres, face areas and everything else will be ordered in the same manner. Thus the first pressure belongs to the first face and the first face centre - all the lists are ordered the same.

data type vector in "vector sumForce = sum(..."...

Physics, physics! Pressure is a scalar and it acts normal to the surface, right? Therefore, force is a vector because it depends on the orientation of the surface - you really *should* know this.

...find data values of the cells...

The cell values are in p.internalField(). If you ask the patch for faceCells(), it will give you a cell index next to each boundary face. You know the rest...

...and create an animation...

Create a series of images, and convert them into an animation using some package. I am using convert on Linux, which is a part of ImageMagick and make an mpeg video.

Enough for now I think...

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   March 22, 2007, 03:26
Default I see. My first question conce
  #5
Member
 
Christian Lindbäck
Join Date: Mar 2009
Posts: 55
Rep Power: 17
christian is on a distinguished road
I see. My first question concerned writing pressure data, coordinates and area of specific boundary faces to a file. I was given the lines necessary to do this. Now, I'm wondering the following:

1) Assume I'm running simpleFoam. I want to find a steady-state solution. Will I then, using the lines I was given, write a file at every iteration or only after the final iteration? How can I control this to achieve both scenarios?

2) Assume I'm running turbFoam. I'm solving a transient case. Will I then, using the lines I was given, write a file at every time step or only after the final time step? How can I control this to achieve both scenarios?

Best regards,
Christian
christian is offline   Reply With Quote

Old   March 22, 2007, 03:39
Default You'll have to code it yoursel
  #6
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
You'll have to code it yourself.

1) $FOAM_SOLVERS/incompressible/simpleFoam/simpleFoam.C

2)$FOAM_SOLVERS/incompressible/turbFoam/turbFoam.C
mattijs is offline   Reply With Quote

Old   March 30, 2007, 07:12
Default Sorry the link didnt lead wher
  #7
Member
 
Erik Arlemark
Join Date: Mar 2009
Location: Eindhoven, Netherlands
Posts: 47
Rep Power: 17
Erik is on a distinguished road
Sorry the link didnt lead where I thought it would.

Here is a thread I saved from the forum:

Continuity Eq: div(U) = 0
and with source term: div(U) = S

Discretised momentum eq. A*U = H - grad(p)
->
U = H/A -(1/A)*grad(p) = Ustar - (1/A)*grad(p)
H/A is the momentum-predictor value of U, ie Ustar.
if we insert this in the continuity eq. it yields

div(U) = div(Ustar - (1/A)*grad(p)) = S
->
div(Ustar) - laplacian(1/A, p) = S
or
laplacian(1/A, p) = -S + div(phi)
where phi is Ustar evaluated on faces.
have a look at icoFoam and you will easily see where to insert S.

/Erik
Erik is offline   Reply With Quote

Old   July 12, 2007, 08:34
Default I'm running parallel and use p
  #8
Member
 
Christian Lindbäck
Join Date: Mar 2009
Posts: 55
Rep Power: 17
christian is on a distinguished road
I'm running parallel and use p.boundaryField()[patchID] to access the pressure of each wall cell face of a certain boundary. I write this data to a file. However, it ends up in all processor directories, being zero in the partitions not containing my boundary. How do you suggest me to make the code write this data only if the boundary of interest is in the current partition (processor directory)?

Best regards,
Christian Svensson
christian is offline   Reply With Quote

Old   July 12, 2007, 10:22
Default Just a guess (havn't looked at
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Just a guess (havn't looked at the source). As far as I remember the probes-functionObject collects all the data on the first processor and writes it there. I guess that would be even more convenient for you. Have a look at that source, it might give you some hints.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   June 10, 2008, 07:26
Default hi all, i want to check that
  #10
Member
 
davey david
Join Date: Mar 2009
Posts: 54
Rep Power: 17
suredross is on a distinguished road
hi all,
i want to check that mass is conserved in my simulation?so i want to get the data for my inlet and outlet.can someone please help here.

cheers
davey
suredross is offline   Reply With Quote

Old   June 10, 2008, 08:05
Default Hi Davey Without trying it,
  #11
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Davey

Without trying it, I believe something like this should work:

scalar checkMass(0.0);

forAll(phi.boundaryField(),patchID)
{
checkMass += sum(phi.boundaryField()[patchID]);
}
Info << "checkMass: " << checkMass << endl;

Best regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   June 10, 2008, 08:18
Default hi all, managed to fix it.sor
  #12
Member
 
davey david
Join Date: Mar 2009
Posts: 54
Rep Power: 17
suredross is on a distinguished road
hi all,
managed to fix it.sorry i was a bit impatient in scanning the forum!
thanks anyway

davey
suredross 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
Setting the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 22:43
Centrifugal fan j0hnny CFX 13 October 1, 2019 14:55
Problem in setting Boundary Condition Madhatter92 CFX 12 January 12, 2016 05:39
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 07:20
error message cuteapathy CFX 14 March 20, 2012 07:45


All times are GMT -4. The time now is 06:33.