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

Write cells and data intersecting a plane cuttingPlane

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree2Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   February 27, 2008, 07:27
Default ...and by the way, to close th
  #21
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
...and by the way, to close the problem: in order to put back results from a parallel computation, I used mergeMeshes for the mesh and mapFields for the fields:

dmoroian is offline   Reply With Quote

Old   February 28, 2008, 15:18
Default Hi Dragos, thank! But how c
  #22
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Hi Dragos,

thank! But how can one know this from the error message?

Fabian
braennstroem is offline   Reply With Quote

Old   February 29, 2008, 02:44
Default Hi Fabian, Well the error com
  #23
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Hi Fabian,
Well the error comes from the linker because it belongs to an object file not to a source file:
Make/linux64GccDPOpt/no_avg_oodles.o(.text+0x31c2): In function `main':
: undefined reference to `Foam::cuttingPlane::cells() const'

Then, a little bit trickier is to find the library that contains the missing function (in this case cuttingPlane::cells()). For that I first go to the source directory of OpenFOAM, and then search for the class cuttingPlane:

home2/dragosm> src
OpenFOAM-1.4.1/src> find ./ -name cuttingPlane.C
./sampling/cuttingPlane/cuttingPlane.C
./sampling/lnInclude/cuttingPlane.C

...so it is in the sampling directory. Go there and list it:

OpenFOAM-1.4.1/src> cd sampling/
src/sampling> ls
cuttingPlane
include
Make
probes
graphField
lnInclude
meshToMeshInterpolation
samplingLine

As seen above, a Make directory exists. Let see what does it produce:

src/sampling> cat Make/files
probes/probes.C
probes/probesFunctionObject/probesFunctionObject.C
probes/IOprobes.C

samplingLine/pointAddressing.C
samplingLine/samplingLine.C

cuttingPlane/cuttingPlane.C

graphField/writePatchGraph.C
graphField/writeCellGraph.C
graphField/makeGraph.C

meshToMesh = meshToMeshInterpolation/meshToMesh
$(meshToMesh)/meshToMesh.C
$(meshToMesh)/calculateMeshToMeshAddressing.C
$(meshToMesh)/calculateMeshToMeshWeights.C

LIB = $(FOAM_LIBBIN)/libsampling


So all it generates is a library called libsampling. In this library you will find the requested function, which means that you need to include it in your own options file, if you want the compilation to be completed.

I hope this is usefull,
Dragos
dmoroian is offline   Reply With Quote

Old   February 29, 2008, 09:06
Default Hi, great, thanks for the e
  #24
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Hi,

great, thanks for the explanation!

Fabian
braennstroem is offline   Reply With Quote

Old   March 31, 2008, 06:23
Default Hi Dragos, i am writing a
  #25
New Member
 
Fabian Korn
Join Date: Mar 2009
Location: Heilbronn, Germany
Posts: 21
Rep Power: 8
fabian_korn is on a distinguished road
Hi Dragos,

i am writing a Bachlor thesis at Lth, i have a probelm with the code you posted.
I am really new with openFOAM and i am running a LES over a 2 cylinder flow.

My problem is, in which file should i ionclude your code?
And did i understand it correctly, that it creates an output at every timestep for one defined slice of the field for all the variables

Thanks for help

Fabian
fabian_korn is offline   Reply With Quote

Old   March 31, 2008, 06:48
Default Hi Fabian, The code goes in t
  #26
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Hi Fabian,
The code goes in the main top solver. For simplicity you can put it entirely in the main time loop. That means it will construct and save the slice every time step.
It is true, it saves every time step but only the variables that you tell it to save. For instance, if you want pressure you have to use something like:
scalarNames[0] = "p"

Dragos
dmoroian is offline   Reply With Quote

Old   March 31, 2008, 07:23
Default Hi Dragos, do you have a hi
  #27
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Hi Dragos,

do you have a hint, how to write out more than one plane at a time? I tried using the same code twice with different names, which does not work. I think 'subsetter' makes some problems!?

Regards!
Fabian
braennstroem is offline   Reply With Quote

Old   March 31, 2008, 08:07
Default Hm, it is strange! I would exp
  #28
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Hm, it is strange! I would expect it to work. You have 2 subsetters, right? One for each slice, as well as with the rest of the variables.
dmoroian is offline   Reply With Quote

Old   March 31, 2008, 10:03
Default Yes, I have 2 subsetters like
  #29
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Yes, I have 2 subsetters like this:

#--------------------------------------------
// Plane 1
point pnt(0,25,0);
vector direction(0,1,1);
plane pl1(pnt,direction);
cuttingPlane cutPlane1(mesh,pl1);
const labelList& cutCells1 = cutPlane1.cells();
word setName("someCells");
cellSet currentSet1(mesh, setName, cutCells1);

// Create mesh subsetting engine
fvMeshSubset subsetter1(mesh);
label patchI = -1;
subsetter1.setLargeCellSubset(currentSet1, patchI, true);


wordList scalarNames(1);
scalarNames[0] = "p";
PtrList<volscalarfield> scalarFlds1(scalarNames.size());

wordList vectorNames(1);
vectorNames[0] = "U";
PtrList<volvectorfield> vectorFlds1(vectorNames.size());

// Plane 2
point pnt2(0,25,25);
vector direction2(0,1,1);
plane pl2(pnt2,direction2);
cuttingPlane cutPlane2(mesh,pl2);
const labelList& cutCells2 = cutPlane2.cells();
word setName2("someCells2");
cellSet currentSet2(mesh, setName2, cutCells2);

// Create mesh subsetting engine
fvMeshSubset subsetter2(mesh);
label patchI2 = -1;
subsetter2.setLargeCellSubset(currentSet2, patchI2, true);

//wordList scalarNames(1);
scalarNames[0] = "p";
PtrList<volscalarfield> scalarFlds2(scalarNames.size());

//wordList vektorNames(1);
vectorNames[0] = "U";
PtrList<volvectorfield> vectorFlds2(vectorNames.size());



...


scalarFlds1.set(0, subsetter1.interpolate(p));
vectorFlds1.set(0, subsetter1.interpolate(U));
scalarFlds2.set(0, subsetter2.interpolate(p));
vectorFlds2.set(0, subsetter2.interpolate(U));

Info<< "Writing subsetted mesh and fields to time " << runTime.value()
<< endl;
subsetter1.subMesh().write();
subsetter2.subMesh().write();
forAll(scalarFlds1, i)
{
scalarFlds1[i].write();
}
forAll(vectorFlds1, i)
{
vectorFlds1[i].write();
}

forAll(vectorFlds2, i)
{
vectorFlds2[i].write();
}

#--------------------------------------------


but I just get one subsetP and one subsetU in my time directory. Strange...
mm.abdollahzadeh likes this.
braennstroem is offline   Reply With Quote

Old   March 31, 2008, 10:57
Default Both slices have the same name
  #30
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Both slices have the same name: subsetp and subsetU, and they get overwritten.
You have to rename them for one of them (let say subset1p and subset1U) before you save them with scalarFlds1[i].write() and vectorFlds1[i].write().
For renaming check the ~/OpenFOAM/OpenFOAM-1.4.1/applications/utilities/mesh/manipulation/subsetMesh/su bsetMesh.C from line 242 and below.

Dragos
dmoroian is offline   Reply With Quote

Old   March 31, 2008, 11:36
Default Thanks for the file hint, but
  #31
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 10
braennstroem is on a distinguished road
Thanks for the file hint, but it does not work due to the different number of cells in the two planes, because it writes just one 'polyMesh' for both planes. Maybe, there is a chance to write it in vtk format, just like in sampleSurf!? Or even 'better' one somehow integrates sampleSurf; then one could use the sampleSurfDict as well...

Fabian
braennstroem is offline   Reply With Quote

Old   March 31, 2008, 11:51
Default Hi Dragos, thanks for the fa
  #32
New Member
 
Fabian Korn
Join Date: Mar 2009
Location: Heilbronn, Germany
Posts: 21
Rep Power: 8
fabian_korn is on a distinguished road
Hi Dragos,
thanks for the fast answer,
Now a second question how did you mamage it to reconnect the meshes after a parrallel run with 4 processors. I saw you used the mergeMesh command, but how does it work?
Hopefully the question is not to stupid.

Thanks Fabian
fabian_korn is offline   Reply With Quote

Old   April 1, 2008, 02:05
Default Hello Fabian B. Indeed you ar
  #33
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Hello Fabian B.
Indeed you are right, the polyMesh gets rewritten too. Beside your excellent ideas, another one would be to collect both planes in one set and write that down, maybe write sets information to be able to extract later the planes separately.

Hi Fabian K.
To put together two pieces of mesh you can use the mergeMesh. Check this answer on how to do it: mergeMesh. When you will be ready with that you have to "merge" the data too. For that you have to use mapFields... but first fix the merging part.

Dragos
dmoroian is offline   Reply With Quote

Old   April 2, 2008, 02:37
Default Hi, hopefully the last que
  #34
New Member
 
Fabian Korn
Join Date: Mar 2009
Location: Heilbronn, Germany
Posts: 21
Rep Power: 8
fabian_korn is on a distinguished road
Hi,

hopefully the last question, during compiling i got the follwing massage, i gues caused by PtrList. Here is the the entry of oodles.C

wordList scalarNames(1);
scalarNames[0] = "c";
PtrList<volscalarfield>

and the Error massage

oodles.C: In function 'int main(int, char**)':
oodles.C:98: error: 'volscalarfield' was not declared in this scope
oodles.C:98: error: template argument 1 is invalid
oodles.C:98: error: invalid type in declaration before '(' token
oodles.C:102: error: 'volvectorfield' was not declared in this scope
oodles.C:102: error: template argument 1 is invalid
oodles.C:102: error: invalid type in declaration before '(' token
oodles.C:98: warning: unused variable 'scalarFlds1'
oodles.C:102: warning: unused variable 'vectorFlds1'
make: *** [Make/linuxGccDPOpt/oodles.o] Error 1


Thank you again
fabian_korn is offline   Reply With Quote

Old   April 2, 2008, 03:07
Default Hi Fabian, On short: volscala
  #35
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Hi Fabian,
On short: volscalarfield -> volScalarField
I don't know why is written in the wrong way all over the thread, because is wrong, and when I put the above example I've just extracted it from a working code.

Dragos
dmoroian is offline   Reply With Quote

Old   April 2, 2008, 06:10
Default Hi again, it is possible n
  #36
New Member
 
Fabian Korn
Join Date: Mar 2009
Location: Heilbronn, Germany
Posts: 21
Rep Power: 8
fabian_korn is on a distinguished road
Hi again,

it is possible not to write every timestep, but let us say every 100 timestep?
fabian_korn is offline   Reply With Quote

Old   April 2, 2008, 08:13
Default Sorry for asking again, i h
  #37
New Member
 
Fabian Korn
Join Date: Mar 2009
Location: Heilbronn, Germany
Posts: 21
Rep Power: 8
fabian_korn is on a distinguished road
Sorry for asking again,

i hope it is not too much. When compiling int i get

oodles.C: In function 'int main(int, char**)':
oodles.C:111: error: 'samplingCount' was not declared in this scope
make: *** [Make/linuxGccDPOpt/oodles.o] Error 1

I tried to find a library to find an idea how to fix it, but i do not have any guess.

Thanks again
fabian_korn is offline   Reply With Quote

Old   April 2, 2008, 08:53
Default Don't appologise, if I'm getti
  #38
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
Don't appologise, if I'm getting disturbed I won't write
The solution: you have to declare this variable somewhere; one place is imediately after the main function.
Quote:
main(...){
label samplingCount = 0;
...
Dragos
dmoroian is offline   Reply With Quote

Old   April 2, 2008, 11:21
Default Hi Dragos, first hte good t
  #39
New Member
 
Fabian Korn
Join Date: Mar 2009
Location: Heilbronn, Germany
Posts: 21
Rep Power: 8
fabian_korn is on a distinguished road
Hi Dragos,

first hte good thing, it compiles.
But when i run my case this happens.


Courant Number mean: 0.00138039 max: 0.0242767
DILUPBiCG: Solving for Ux, Initial residual = 0.00148907, Final residual = 3.64592e-09, No Iterations 1
DILUPBiCG: Solving for Uy, Initial residual = 0.00176973, Final residual = 7.19327e-09, No Iterations 1
--> FOAM Warning :
From function Foam::cuttingPlane::walkCell
in file cuttingPlane/cuttingPlane.C at line 189
Did not find closed walk along surface of cell 1646 starting from edge 9894 in 0 iterations.
Collected cutPoints so far:1(88)
--> FOAM Warning :
From function Foam::cuttingPlane::walkCell
in file cuttingPlane/cuttingPlane.C at line 189
Did not find closed walk along surface of cell 1647 starting from edge 9911 in 1 iterations.
Collected cutPoints so far:2(89 38)
DICPCG: Solving for p, Initial residual = 0.0217737, Final residual = 0.00108258, No Iterations 9
time step continuity errors : sum local = 1.70955e-10, global = -7.82466e-21, cumulative = 4.23193e-20
DICPCG: Solving for p, Initial residual = 0.00648299, Final residual = 8.2598e-07, No Iterations 93
time step continuity errors : sum local = 1.28292e-13, global = -1.27384e-21, cumulative = 4.10454e-20
ExecutionTime = 4.37 s ClockTime = 5 s

it generates a solution, but it slowes down the simulation and if i run my real big case, than the list of Collected cutPoints so far:2(89 38) is really long.

Any guess?
fabian_korn is offline   Reply With Quote

Old   April 3, 2008, 01:32
Default It happens the same thing in m
  #40
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 647
Rep Power: 11
dmoroian is on a distinguished road
It happens the same thing in my case. Just a wild guess is that some cells have a face exactly in that plane and the solver doesn't know which of the two cells sharing the face should be picked. To speed up the process, I separate the cell set construction from the interpolation and writing. I put the construction part. For instance, if you take the code from cuttingSlice I put everything above scalarFlds.set(0, subsetter.interpolate(c)) outside the time loop, and kept the rest inside. In this way I get only once those warnings.

I hope this is helpful,
Dragos
dmoroian is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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


All times are GMT -4. The time now is 01:50.