CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Sampling lagrangian data (http://www.cfd-online.com/Forums/openfoam-post-processing/63124-sampling-lagrangian-data.html)

farbfilm March 30, 2009 05:31

Sampling lagrangian data
 
Hi,

I tried to sample lagrangian data from a simulation with dieselFoam with the sample utility (i.e. with a sampleDict-File). I defined a plane under the keyword 'surfaces' and wanted to sample the diameter of the particles, i.e. choose d under the keyword 'Fields to sample'! When I'm running the utility no date are written!!!

When I choose U instead of d everything works fine!! So, it seems that only the sampling of the lagrangian data doesn't work!!

Has anybody some hints???

Thanks, Michael

niklas March 30, 2009 08:34

you have to write your own evaluation code if you want to do that kind of thing

farbfilm March 31, 2009 07:27

oh, well, I have no idea of doing something like that...

I'm wondering that nobody else has that problem! Or is there another/better way to sample the langrangian data like the droplet sizes??

farbfilm April 7, 2009 06:14

Doesn't anybody have a hint how to postprocess lagrangian data??
For example, one of my request is to get the data of the diameter of the droplets in a arbitrary plane! Then, I want this date to use in Matlab!!

I hope somebody can help me...

Thanks, Michael

gschaider April 7, 2009 08:03

Hi Michael!

The "best" way to postprocess the raw lagrangian data WITHOUT PROGRAMMING is:

1. start paraFoam
2. load the lagrangian data in addition to the "regular" data
3. "Split off" the lagrangian data using the "Extract Block"-filter
4. Open a new view on the result and make that view a "Spreadsheet view". In that view you will see the raw lagrangian data
5. File->Export that view to a CSV-file

The CSV can be imported into most programs (OpenOffice-Calc, Origin and I guess also MATLAB)

Bernhard

farbfilm April 8, 2009 09:48

Thank you, Bernhard!

That's definitely a way to do it!! For the moment that's fine! Thanks again!
But I think in the future, I'll don't get out of programming something when I'm dealing with lots of data!

So, if there is somebody who has a "more comfortable" solution (i.e. with programming) for that problem I would be still interested!!!

Michael

gschaider April 8, 2009 17:53

Quote:

Originally Posted by farbfilm (Post 212341)
But I think in the future, I'll don't get out of programming something when I'm dealing with lots of data!

So, if there is somebody who has a "more comfortable" solution (i.e. with programming) for that problem I would be still interested!!!

Best example how to read/filter/rewrite lagrangian data in C++ might still be mapLagrangianFields.C in the sources of the mapFields-utility.
For myself, if there is not too much data (some thousant particles without history data) I use the PyFoam-library to parse/process it. But I may be biased, because I'm on quite good speaking terms with the author so the lack of documentation for the programming interface isn't that big a problem for me

Bernhard

matejfor April 9, 2009 02:56

Hi,
I'm using KinematicParticle class for Lagrangian particles and there is even everything ready for you. The function is called dumpParticlePositions() and you may find it around line 500 in the file: src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C

Calling this function along with kinematicCloud1.evolve(); in your solver will give you
every time step one file with whatever you tell the function to print for all the particles in the coud.
I was actually post-processing these files in matlab 2 days ago...

good luck
matej

farbfilm April 9, 2009 05:32

Hi,

using KinematicParticle sounds quite good!
Could you please give me some details of how to build this function in my solver and how to tell the function what quantities it should write??

Sorry for so many questions!

Thanks, Michael

matejfor April 9, 2009 05:59

it's quite simple, but not for 5 lines.
you may have a look at rhoTurbTwinParcelFoam tutorial which comes with 1.5.x installation for your inpiration. there is a solver calling intermediate clases like kinematicCloud and thermoCloud for solving Lagrangian phase.

if you want to print out the data, you can add as I've written previously kinematicCloud1.dumpParticlePositions(); to the main solver where you call kinematicCloud1.evolve();

To specify what to print, you look for that function in src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C file.
For example my line n this function looks like:
pObj<< "v " << p.d() <<" "<< p.nParticle() <<" "<< p.stk()<<" "<< p.Ur() <<" "<< p.position().x() << " " << p.position().y() << " "

where for example p.stk is particle Stokes number, which I defined as an inline function in: parcels/Templates/KinematicParcel/KinematicParcel.H
and specified in:
parcels/Templates/KinematicParcel/KinematicParcelI.H

there you will find other variables which you may be interested in.

hope it helps you.
good luck
matej

az1362f August 18, 2009 10:29

Viewing Re number and relative velocity
 
Hi,

I want to write relative velocity and Reynolds number of each particle and then plot them,Is there any way?

please help me

regard

matejfor August 19, 2009 05:28

if you want to plot it in the paraview, the simple way is to calculate it in paraview by constructing your own filter. you can use the available variables in a calculator to construct your own new variable and plot it the paraview.

if you want it to be calculated during the run and written to the field for postprocessing, you have to inicialise the variable and write it at the end of the lagrangian calculation. How to do it would mean to trace in for variable like diameter and do the same for the relative Re.

good luck

matej

az1362f August 21, 2009 04:23

sampling lagrangian data
 
Hello Dear matej;

Thank you for your suggestion.I used calculator filter to made a new variable by name of Urel=U(droplet)-U(gas) but just exist U(droplet) in the vector variables and U(gas) is not active and does not exist in the vector variables.

For your second suggestion I traced in for variable like diameter and
I saw these lines in the parcelIO.C and I think that these lines write output files of particles properties,could you say me how can I add Urel and Re to these properties(d,T,m,y,.....)?
I want to write Urel and Re in addition to these values.


void Foam:: parcel::writeFields
(
const Cloud<parcel>& c
)
{
Particle<parcel>::writeFields(c);

label np = c.size();

IOField<scalar> d(c.fieldIOobject("d"), np);
IOField<scalar> T(c.fieldIOobject("T"), np);
IOField<scalar> m(c.fieldIOobject("m"), np);
IOField<scalar> y(c.fieldIOobject("y"), np);
IOField<scalar> yDot(c.fieldIOobject("yDot"), np);
IOField<scalar> ct(c.fieldIOobject("ct"), np);
IOField<scalar> ms(c.fieldIOobject("ms"), np);
IOField<scalar> tTurb(c.fieldIOobject("tTurb"), np);
IOField<scalar> liquidCore(c.fieldIOobject("liquidCore"), np);
IOField<scalar> injector(c.fieldIOobject("injector"), np);

IOField<vector> U(c.fieldIOobject("U"), np);
IOField<vector> Uturb(c.fieldIOobject("Uturb"), np);
IOField<vector> n(c.fieldIOobject("n"), np);

label i = 0;
forAllConstIter(Cloud<parcel>, c, iter)
{
const parcel& p = iter();

d[i] = p.d_;
T[i] = p.T_;
m[i] = p.m_;
y[i] = p.y_;
yDot[i] = p.yDot_;
ct[i] = p.ct_;
ms[i] = p.ms_;
tTurb[i] = p.tTurb_;
liquidCore[i] = p.liquidCore_;
injector[i] = p.injector_;

U[i] = p.U_;
Uturb[i] = p.Uturb_;
n[i] = p.n_;

i++;
}

d.write();
T.write();
m.write();
y.write();
yDot.write();
ct.write();
ms.write();
tTurb.write();
liquidCore.write();
injector.write();

U.write();
Uturb.write();
n.write();

// write the liquid molar fractions
if (np > 0)
{
Cloud<parcel>::const_iterator iter = c.begin();
const parcel& p0 = iter();

label nX = p0.X().size();
const List<word>& names = p0.liquidNames();

for (label j=0; j<nX; j++)
{
IOField<scalar> X(c.fieldIOobject(names[j]), np);

label i = 0;
forAllConstIter(Cloud<parcel>, c, iter)
{
const parcel& p = iter();
X[i++] = p.X()[j];
}

X.write();
}
}
}

az1362f August 22, 2009 15:14

sampling lagrangian data
 
Hello Dear matej;

Thank you for your suggestion.I used calculator filter to made a new variable by name of Urel=U(droplet)-U(gas) but just exist U(droplet) in the vector variables and U(gas) is not active and does not exist in the vector variables.

For your second suggestion I traced in for variable like diameter and
I saw these lines in the parcelIO.C and I think that these lines write output files of particles properties,could you say me how can I add Urel and Re to these properties(d,T,m,y,.....)?
I want to write Urel and Re in addition to these values.


void Foam:: parcel::writeFields
(
const Cloud<parcel>& c
)
{
Particle<parcel>::writeFields(c);

label np = c.size();

IOField<scalar> d(c.fieldIOobject("d"), np);
IOField<scalar> T(c.fieldIOobject("T"), np);
IOField<scalar> m(c.fieldIOobject("m"), np);
IOField<scalar> y(c.fieldIOobject("y"), np);
IOField<scalar> yDot(c.fieldIOobject("yDot"), np);
IOField<scalar> ct(c.fieldIOobject("ct"), np);
IOField<scalar> ms(c.fieldIOobject("ms"), np);
IOField<scalar> tTurb(c.fieldIOobject("tTurb"), np);
IOField<scalar> liquidCore(c.fieldIOobject("liquidCore"), np);
IOField<scalar> injector(c.fieldIOobject("injector"), np);

IOField<vector> U(c.fieldIOobject("U"), np);
IOField<vector> Uturb(c.fieldIOobject("Uturb"), np);
IOField<vector> n(c.fieldIOobject("n"), np);

label i = 0;
forAllConstIter(Cloud<parcel>, c, iter)
{
const parcel& p = iter();

d[i] = p.d_;
T[i] = p.T_;
m[i] = p.m_;
y[i] = p.y_;
yDot[i] = p.yDot_;
ct[i] = p.ct_;
ms[i] = p.ms_;
tTurb[i] = p.tTurb_;
liquidCore[i] = p.liquidCore_;
injector[i] = p.injector_;

U[i] = p.U_;
Uturb[i] = p.Uturb_;
n[i] = p.n_;

i++;
}

d.write();
T.write();
m.write();
y.write();
yDot.write();
ct.write();
ms.write();
tTurb.write();
liquidCore.write();
injector.write();

U.write();
Uturb.write();
n.write();

// write the liquid molar fractions
if (np > 0)
{
Cloud<parcel>::const_iterator iter = c.begin();
const parcel& p0 = iter();

label nX = p0.X().size();
const List<word>& names = p0.liquidNames();

for (label j=0; j<nX; j++)
{
IOField<scalar> X(c.fieldIOobject(names[j]), np);

label i = 0;
forAllConstIter(Cloud<parcel>, c, iter)
{
const parcel& p = iter();
X[i++] = p.X()[j];
}

X.write();
}
}
}

az1362f August 24, 2009 07:47

sampling lagrangian
 
any body can help me.
I am still waiting for a response.

matejfor August 28, 2009 11:41

OK if we stick to kinematicCloud class you need to do few thinkg there.

I've played around a bit and here is what you should do:
(I'm using 1.5-dev Foam version)

In parcels/Templates/KinematicParcel/KinematicParcelI.H :

define inline function for your relative Reynolds number,
In KinematicParcel.H add this function to a member function list.

now you need to tell the code to write this Re number out, so you need to edit KinematicParcelIO.C where you will find two member function - one is for reading the fields and the other is for writting. All you have to do now is to add IOField specification (around line 158) and then add {ReynoldsNumber function name}.write(); line compile and enjoy.

I guess about the same you can do also with other particle classes, not only with kinematic one.
If I do miss something here, hopefully someone more skilled will correct me.

I should add do not do all of this in the main src code. You will make some errors for sure and you want at least something to work. For example I have my local intermediateWORK library which I play around with.


good luck

matej

az1362f August 28, 2009 17:45

sampling lagrangian
 
Hello Dear

I try to do your suggustion.
There is an inline function to describe Urel like this in parcelI.H:

inline vector parcel::Urel(const vector& U) const
{
return U_ - U;
}

the problem is to define vector U(gas velocity) in every iteration to inline function for returning Ugas.

I add this line from parcel.C :

vector Up = sDB.UInterpolator().interpolate(position(), cell())
+ Uturb();

after these lines in parcelIO.C file:

forAllConstIter(Cloud<parcel>, c, iter)
{
const parcel& p = iter();

and add these lines to write function of parcelIO.C:

IOField<vector> Urel(c.fieldIOobject("Urel"), np);
Urel[i] = p.Urel(Up)
Urel.write();

exactly like parcelIO.C method, But because I did not declare Up and Uturb() I face errors when I try to compile it.

how can I add U (gas velocity) to Urel function[Urel(const vector& U)] when I call it for every iteration?

Tariq Ahmed May 8, 2015 11:11

Lagrangian particle velocity
 
Hi,
I am experiencing the same kind of problem in sprayFOAM solver. I want to sample droplet velocity and droplet diameter so I can postprocess in Matlab but I cant seem to find how to sample the lagrangian data since sample cmd works only for eularian phase.

Also I cant seem to find 'kinematicCloud1.dumpParticlePositions()' in KinematicCloud.C file. Any help would be really appreciated

Tariq

Tariq Ahmed May 11, 2015 05:55

Hope somebody is able to help me in the topic

Subhasree February 11, 2016 02:31

Hi Everyone!

I am using icoLagrangianFoam solver of foam extend 3.1 in which I have used patch injection method to insert particles over an object. I need to calculate the number of particles getting deposited on the object surface.

Can I use function lib in controlDict file for this?


All times are GMT -4. The time now is 10:40.