|
[Sponsors] |
How to write IOField variable particle position |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 5, 2013, 11:35 |
How to write IOField variable particle position
|
#1 |
Member
Join Date: Nov 2012
Location: Liverpool, UK
Posts: 51
Rep Power: 14 |
Hello,
I am using the solid particle library and have looked at solidParticleFoam. I saw 'positions', 'd' and 'U' in the directory of 'lagragian/defaultCloud' in the tutorial case. I am dealing with thousands of particles, just wondering how could I generate the 'positions' file for the particles? I think the particle position belongs to IOField<vector>, but how can I determine the positions and write them into a file using OpenFOAM? Any suggestions would be really appreciated. Thanks a lot in advance. Best Wishes, Sophie |
|
June 12, 2013, 08:25 |
|
#2 | |||
Member
Join Date: Nov 2012
Location: Liverpool, UK
Posts: 51
Rep Power: 14 |
Hello,
To the question above, I defined Quote:
Quote:
Here is the file header I generated. On the 3rd to 6th line, '\\' is supposed to be the right format, however only '\' is generated. On the line 'location 0;', "" is not allowed to be in the output. Quote:
|
||||
June 13, 2013, 05:52 |
|
#3 |
New Member
Arun Appadurai
Join Date: Apr 2010
Posts: 8
Rep Power: 16 |
Hi Sophie,
I'm stuck at the same problem too.As a quick workaround, I'm planning to use excel to generate a csv file of positions and copy-paste it onto the existing positions file.Not sure if it will work but hope it helps! Arun |
|
June 13, 2013, 07:13 |
|
#4 |
Member
Join Date: Nov 2012
Location: Liverpool, UK
Posts: 51
Rep Power: 14 |
Hi Arun,
I think it should work. But I am thinking to take this practice as the first step to dig into the code. I think it is worth trying to work out the values of the position vector and use Cloud<solidParticle> to call the standard write function. However, I'm in a mess doing this. Have you got some ideas on this? best, Sophie |
|
June 13, 2013, 07:40 |
|
#5 |
New Member
Arun Appadurai
Join Date: Apr 2010
Posts: 8
Rep Power: 16 |
Hi Sophie,
This is going to be my next thing to do, after I get the csv file import working. I see you've got a head start in this. May be you have checked this thread http://www.cfd-online.com/Forums/openfoam-post-processing/66619-output-file-openfoam-header.html . ? |
|
June 13, 2013, 08:27 |
|
#6 |
Member
Join Date: Nov 2012
Location: Liverpool, UK
Posts: 51
Rep Power: 14 |
Hi Arun,
I just looked at it and it's pretty useful to me. Thank you! Actually I've thought to modify IOobjectWriteHeader.C, but just being afraid it will have global impact on all the others. Another concern is that in the file 'positions', we have to write both the position vector and the corresponding cell number on the same line. |
|
June 13, 2013, 14:39 |
|
#7 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Hi Sophie,
I would do something along the following lines. Also note that I have chosen vectorField instead of List<vector>: Code:
label n = 100; vectorField initPositions(n, vector::zero); forAll(initPositions, pointi ) { // Set the initial positions initPosition[pointi] = <something> } IOField<vector> writePositions ( IOobject ( "<name required by model, e.g. positions>", "<path, e.g. mesh.time().constant() or mesh.time().timeName()>", mesh, IOobject::NO_READ, IOobject::NO_WRITE ), initPosition ); writePosition.write(); Kind regards Niels |
|
June 13, 2013, 18:15 |
|
#8 | |
Member
Join Date: Nov 2012
Location: Liverpool, UK
Posts: 51
Rep Power: 14 |
Hi Niels,
Thanks a lot! The code snippet works well. However, the file 'positions' is supposed to be of the format below Quote:
Thank you in advance, Sophie |
||
June 14, 2013, 02:01 |
|
#9 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
Good morning Sophie,
I see the problem. I do not have a "correct" solution right now, however the following utility, which I wrote some time ago might be helpful: http://sourceforge.net/p/openfoam-ex...veParameters.C Especially the part where the header is written, since I also needed to do everything by hand: Code:
// Write the OF banner wOut.writeBanner( os ); // Write the file information. Class name is not correct when // using wOut.writeHeader( os ); hence manual entries os << "FoamFile" << nl; os << token::BEGIN_BLOCK << incrIndent << nl; os << indent << "version" << tab << IOstream::currentVersion << token::END_STATEMENT << nl; os << indent << "format" << tab << "ascii;" << nl; os << indent << "class" << tab << "dictionary;" << nl; os << indent << "object" << tab << "waveProperties;" << nl; os << decrIndent << indent << token::END_BLOCK << nl; // Write the divider wOut.writeDivider( os ); os << nl; Code:
os << initPositions.size() << nl << "(" << endl; forAll( initPositions, pointi ) os << initPositions[pointi] << " " or tab << processorNumber[pointi] << endl; os << ");" << nl << endl; Niels |
|
June 14, 2013, 13:06 |
|
#10 |
Member
Join Date: Nov 2012
Location: Liverpool, UK
Posts: 51
Rep Power: 14 |
Hi Niels,
It works perfectly! Thanks! Sophie |
|
January 13, 2016, 20:26 |
Particle tracking
|
#11 |
Member
HM
Join Date: Apr 2015
Posts: 30
Rep Power: 11 |
Hello everyone,
I have been stuck to a problem with particle tracking. In openfoam, all the solvers are designed to inject particles from a certain location for all time steps. But I want to inject particles form different cells, at each time step. Lets say we have a temperature field calculated at each time step. I want to inject particles at each time step from cells with certain temperature (e.g. T=200K). Can anyone help me with this. Thanks in advance. |
|
December 11, 2017, 13:05 |
|
#12 | ||
New Member
Sandip Wadekar
Join Date: Oct 2014
Posts: 17
Rep Power: 12 |
Hello Foamer
I am using OF2.2.x I have similar problem when reading file lagrangian/sprayCloud/positions, because this file contains position vector, cell id and having header class "Cloud<basicSprayParcel>" Example: Quote:
Quote:
Posible solution: 1. Is there any way to read the file 'lagrangian/sprayCloud/positions' when cell id is also present there ? 2. Is there any way to create the separate file that contains only particle position ? Please suggest any of the possible solution. Thanks in advance. |
|||
June 15, 2019, 06:25 |
|
#13 | |
New Member
Join Date: May 2014
Posts: 5
Rep Power: 12 |
Quote:
Dear wadekar, Have you found any solution to this problem you proposed? I am also very interested in this question. How can we index the particles to the cells they are in? |
||
Tags |
iofield, particle, position, write to file |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
dispersion model with lagragian particle tracking model for incompressible flows | eelcovv | OpenFOAM Running, Solving & CFD | 54 | April 10, 2018 10:36 |
OpenFoam-1.6-ext Allwmake compilation error - one last barrier | Pat84 | OpenFOAM Installation | 15 | July 25, 2012 22:49 |
how to know position of particle in PTK | areriko | CFX | 0 | November 19, 2007 22:19 |
Particle position | Neser | CFX | 0 | March 7, 2005 13:11 |
Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 21:09 |