|
[Sponsors] |
July 18, 2011, 12:20 |
Access particle data in main function
|
#1 |
New Member
Join Date: Oct 2010
Posts: 13
Rep Power: 16 |
Hello,
I would like to write a post processing tool for Euler-Lagrange-Simulations that reads particle properties and stores for each cell the particle mass weighted velocity of all particles located in the respective cell. I created a vector field: Code:
volVectorField effU ( IOobject ( "effU", mesh.time().timeName(), U.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector("effU", dimensionSet(0,1,-1,0,0,0,0), vector(0,0,0)) ); Code:
forAll(parcels, pI) { Info << pI << endl; } Code:
forAll(parcels, pI) { Foam::label cellI = parcels[pI].cell(); effU[cellI] += parcels[pI].Volume()*parcels[pI].rho()*parcels[parcelI].U(); w[cellI] += parcels[pI].Volume()*parcels[pI].rho(); } effU = effU/w; I am sorry that I ask such a basic question but I have never programmed on that level in OpenFOAM. Thank you for any help! All the best, Moritz Remark: The template solver for my post processing tool is porousExplicitSourceReactingParcelFoam from OF 2.0.x. |
|
September 12, 2017, 04:54 |
|
#2 |
New Member
Join Date: Aug 2017
Posts: 10
Rep Power: 9 |
hello,
I know its a really old thread, but I have exactly the same problem.. So here again: How is it possible access the particle data in the main function? Code:
int main(int argc, char *argv[]) { ... solidParticleCloud particles(mesh); ... forAll(particles, pIter) { Info << "pIter " << pIter << endl; Info << "Particle velocity " << particles.U()[pIter] << endl; //pseudo code } ... } Because the field U is defined in solidParticle.H, but when compiling the code above, I get the error, that Code:
»class Foam::solidParticleCloud« has no element named »U« |
|
September 15, 2017, 11:31 |
|
#3 |
New Member
Join Date: Aug 2017
Posts: 10
Rep Power: 9 |
Maybe this helps somebody:
Code:
const Cloud<solidParticle>& a = U.mesh().lookupObject<Cloud<solidParticle>>("defaultCloud"); solidParticleCloud * q = (solidParticleCloud*) &a; forAllIter(solidParticleCloud, *q, pIter) { Info << " " << pIter().position() << endl; Info << " " << pIter().d() << endl; } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile problem | ivanyao | OpenFOAM Running, Solving & CFD | 1 | October 12, 2012 10:31 |
Error with Wmake | skabilan | OpenFOAM Installation | 3 | July 28, 2009 01:35 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |
Saving particle (DPM) data to file? | Philip | FLUENT | 2 | June 12, 2006 02:41 |
How to update polyPatchbs localPoints | liu | OpenFOAM Running, Solving & CFD | 6 | December 30, 2005 18:27 |