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

Write cells and data intersecting a plane cuttingPlane

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 28, 2008, 11:57
Default Hi, I would like to save durin
  #1
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi, I would like to save during the run time, data (and cells) that intersect a plane. I saw the cuttingPlane class, but is there a code snippet on the web showing how to save those cells in a top level solver?
I want later on to be able to read those files with paraFoam or paraview.

Dragos
dmoroian is offline   Reply With Quote

Old   January 28, 2008, 12:48
Default Hi Dragos, yes, check this th
  #2
Member
 
ville vuorinen
Join Date: Mar 2009
Posts: 67
Rep Power: 17
ville is on a distinguished road
Hi Dragos,
yes, check this thread. In case you need further
advice please continue the thread and I'll help
you. The cutting plane is very practical if you
like to take your data to matlab, gnuplot etc for
further analysis.

http://www.cfd-online.com/OpenFOAM_D...tml?1197913395

best regards,
Ville
Pagoda likes this.
ville is offline   Reply With Quote

Old   January 29, 2008, 03:14
Default Hi Ville, Actually your answe
  #3
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Ville,
Actually your answer was the source of my information in the first place. There you show how to access the cells and data, but I am interested in saving them in openfoam format. Can you show me how to do that?
If you help me, I promise to put toghether a wiki page so other people would benefit from it.

Dragos
dmoroian is offline   Reply With Quote

Old   January 29, 2008, 05:41
Default Hi, unfortunately I doubt if
  #4
Member
 
ville vuorinen
Join Date: Mar 2009
Posts: 67
Rep Power: 17
ville is on a distinguished road
Hi,
unfortunately I doubt if that is possible since
the cutting plane option is needed to extract data from the mesh so that connectivity information (which the post processor should need) is lost..
-Ville
ville is offline   Reply With Quote

Old   January 29, 2008, 05:57
Default Get the cells from the cutting
  #5
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Get the cells from the cutting plane and construct a cellSet from them. Something like

const labelList& cutCells = cutPlane.cells();

cellSet someCells(mesh, "someCells", cutCells);

someCells.write();

Then use foamToVTK with -cellSet option.
mm.abdollahzadeh likes this.
mattijs is offline   Reply With Quote

Old   January 29, 2008, 15:58
Default Thanks both of you! This is w
  #6
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Thanks both of you!
This is what I was after.
dmoroian is offline   Reply With Quote

Old   January 30, 2008, 02:40
Default ...me again. The following co
  #7
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
...me again.
The following code works very well:

point pnt(0.5,0.25,-0.25);
vector direction(1,0,0);
plane pl1(pnt,direction);
cuttingPlane cutPlane(mesh,pl1);
const labelList& cutCells = cutPlane.cells();
cellSet someCells(mesh, "someCells", cutCells);
someCells.write();


Here is a slice obtained with it:

... but I would like more. Is it possible to save together with the above cell set also the data associated to it at a certain time?

Dragos
dmoroian is offline   Reply With Quote

Old   January 30, 2008, 11:17
Default Hi Dragos Thanks for the co
  #8
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Hi Dragos

Thanks for the code.

Could you also please post the list of include files so that this code compiles successfully. I put the code in my post processing routine exactly as you have psoted


point pnt(0.0,0.0,0.04);
vector direction(1,0,0);
plane pl1(pnt,direction);
cuttingPlane cutPlane(mesh,pl1);
const labelList& cutCells = cutPlane.cells();
cellSet someCells(mesh, "someCells", cutCells);
someCells.write();

and get the following error:

postProcessing.C:654: error: 'plane' was not declared in this scope
postProcessing.C:654: error: expected `;' before 'pl1'
postProcessing.C:655: error: 'cuttingPlane' was not declared in this scope
postProcessing.C:655: error: expected `;' before 'cutPlane'
postProcessing.C:656: error: 'cutPlane' was not declared in this scope
postProcessing.C:657: error: 'cellSet' was not declared in this scope
postProcessing.C:657: error: expected `;' before 'someCells'
postProcessing.C:658: error: 'someCells' was not declared in this scope
postProcessing.C:656: warning: unused variable 'cutCells'


The list of files I have already included are:

#include "fvCFD.H"
#include "wallFvPatch.H"
#include "interfaceProperties.H"
#include "twoPhaseMixture.H"
#include "incompressible/turbulenceModel/turbulenceModel.H"
#include "nearWallDist.H"
#include "fixedValuePointPatchFields.H"


Thanks alot

With Kind Regards
Jaswinder
jaswi is offline   Reply With Quote

Old   January 30, 2008, 11:37
Default Hi Dragos I just checked o
  #9
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Hi Dragos

I just checked out the cuttingPlane code and it has a member function called


//- Sample the cell field
template<class>
tmp<field<type> > sample(const Field<type>&) const;

It seems that if you add the following to your code snippet

point pnt(0.0,0.0,0.04);
vector direction(1,0,0);
plane pl1(pnt,direction);
cuttingPlane cutPlane(mesh,pl1);
const labelList& cutCells = cutPlane.cells();

----------------
volScalarField slicedDesiredField = cutPlane.sample(desiredField);
-----------------

cellSet someCells(mesh, "someCells", cutCells);
someCells.write();

You might be able to extract the field you want.

I could not test whether if it works as i am unable to compile the original code offered by you.

With Kind Regards
Jaswinder
jaswi is offline   Reply With Quote

Old   January 30, 2008, 12:51
Default Hi Dragos I have solved the
  #10
Senior Member
 
Join Date: Mar 2009
Posts: 248
Rep Power: 18
jaswi is on a distinguished road
Hi Dragos

I have solved the compilation problem but now I have problem visualizing it.

I give the following command:

foamToVTK <root> <case> -cellSet someCells

and it writes


Exec : foamToVTK . 7_flask_10ml_320rpm -cellSet someCells
Date : Jan 30 2008
Time : 17:48:12
Host : taifun
PID : 5343
Root : <root>
Case : <case>
Nprocs : 1
Create time

Number of cells in new mesh : 6034
Number of faces in new mesh : 24264
Number of points in new mesh: 12342


--> FOAM FATAL IO ERROR : cannot open file

file: /scratch1/power_consumption_sims/1st_10ml/7_flask_10ml_320rpm/system/subsetSubse t/fvSchemes at line 0.

From function regIOobject::readStream(const word&)
in file db/regIOobject/regIOobjectRead.C at line 66.

FOAM exiting


Could you please give me a clue what is missing

With kind Regards
Jaswinder
jaswi is offline   Reply With Quote

Old   January 30, 2008, 16:42
Default Hi Jaswinder, Thanks for the
  #11
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Jaswinder,
Thanks for the information, I'll definitely try it (I have to check if volScalarField class can write down the data). On the other hand I have no idea why you get that error.

Dragos
dmoroian is offline   Reply With Quote

Old   January 30, 2008, 17:09
Default foamToVTK .. cavity -cellSet c
  #12
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
foamToVTK .. cavity -cellSet c0

works for me (1.4.1):

Time constant

Internal : "../cavity/VTK/c0_0.vtk"
Original cells:5 points:24 Additional cells:0 additional points:0

Patch : "../cavity/VTK/movingWall/c0_0.vtk"
Patch : "../cavity/VTK/fixedWalls/c0_0.vtk"
Patch : "../cavity/VTK/frontAndBack/c0_0.vtk"
Patch : "../cavity/VTK/oldInternalFaces/c0_0.vtk"
mattijs is offline   Reply With Quote

Old   January 31, 2008, 02:46
Default Hi Mattijs, Will you give me
  #13
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Mattijs,
Will you give me a clue on how to get only the slice (both geometry and data)? I don't want to save the entire domain and then to get the slice.

Dragos
dmoroian is offline   Reply With Quote

Old   January 31, 2008, 06:04
Default pull out the bits of code from
  #14
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
pull out the bits of code from subsetMesh. It takes a cellSet and creates a whole new fvMesh from it and subsets the cells as well.
mattijs is offline   Reply With Quote

Old   February 1, 2008, 11:40
Default Ok, new questions... In the s
  #15
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Ok, new questions...
In the subsetMesh utility the following lines read the mesh and the volume scalars from a specific time directory:

IOobjectList objects(mesh, runTime.timeName());
wordList scalarNames(objects.names(volScalarField::typeName ));
PtrList<volscalarfield> scalarFlds(scalarNames.size());


then a subset of it is constructed by

subsetVolFields(subsetter, scalarNames, scalarFlds);

Now my question is: how do I construct the subset from the variables I have in memory (during the calculation) and not read them from a dictionary?

Dragos
dmoroian is offline   Reply With Quote

Old   February 5, 2008, 06:41
Default wiki: TurbPlaneCutFoam
  #16
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
wiki: TurbPlaneCutFoam
manuc likes this.
dmoroian is offline   Reply With Quote

Old   February 5, 2008, 06:59
Default Hmm, I need an idea: how to ma
  #17
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hmm, I need an idea: how to make it run in parallel?
Anybody can give me a clue?
This is the log file with the error I get when I run the solver in parallel:
channel_par.log

Dragos
dmoroian is offline   Reply With Quote

Old   February 6, 2008, 10:25
Default Hello again, Running in paral
  #18
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hello again,
Running in parallel and getting the slices saved, seems to be ok. But how should I reconstruct the plane back from each processor? For instance, two processors will give me two pieces like in the following image:

How should I put them together?
reconstructPar doesn't seem to work for the cells saved from the cuttingPlane.
I can merge the mesh using mergeMeshes, but how can I merge the data?

Dragos
dmoroian is offline   Reply With Quote

Old   February 26, 2008, 14:06
Default Hi Dragos, I tried your cod
  #19
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi Dragos,

I tried your code snip, but have some problems compiling it:

-lincompressibleLESmodels -lincompressibleTransportModels -lfiniteVolume -lmeshTools -lOpenFOAM -liberty -ldl -lm -o /home/gcae504/OpenFOAM/gcae504-1.4.1/applications/bin/linux64GccDPOpt/no_avg_ood les
Make/linux64GccDPOpt/no_avg_oodles.o(.text+0x31b5): In function `main':
: undefined reference to `Foam::cuttingPlane::cuttingPlane(Foam::primitiveM esh const&, Foam::plane const&)'
Make/linux64GccDPOpt/no_avg_oodles.o(.text+0x31c2): In function `main':
: undefined reference to `Foam::cuttingPlane::cells() const'
collect2: ld returned 1 exit status
make: *** [/home/gcae504/OpenFOAM/gcae504-1.4.1/applications/bin/linux64GccDPOpt/no_avg_oo dles] Error 1

I added these libraries to the oodles solver:

#include "plane.H"
#include "cuttingPlane.H"
#include "cellSet.H"
#include "fvMeshSubset.H"

Would be nice, if you have a hint, how to compile it!?

Regards!
Fabian
braennstroem is offline   Reply With Quote

Old   February 27, 2008, 06:09
Default Hi Fabian, It seems that you
  #20
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Fabian,
It seems that you have all the correct "#include" directives, since the error is from the link stage and not from compilation. What you basically need is the "-lsampling" option. Here is how my options file looks like:

EXE_INC = \
-I$(LIB_SRC)/LESmodels \
-I$(LIB_SRC)/LESmodels/LESdeltas/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude

EXE_LIBS = \
-lincompressibleLESmodels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lmeshTools \
-lsampling

dmoroian 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
UDF to write a data file lichun Dong FLUENT 2 August 4, 2005 12:21
write transient data of plane Fabian CFX 2 June 27, 2005 03:38
UDF TO WRITE OUT DATA!! Aishwarya FLUENT 1 August 14, 2004 11:32
UDF TO WRITE OUT DATA!! Aishwarya FLUENT 0 August 12, 2004 11:11
UDF to read and write data Mcgregor FLUENT 4 June 9, 2003 14:21


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