CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Access particle data in main function

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 18, 2011, 12:20
Default Access particle data in main function
  #1
New Member
 
Join Date: Oct 2010
Posts: 13
Rep Power: 16
moritzhoefert is on a distinguished road
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))
    );
I was also able to create a loop through something that is related to the particles:
Code:
    
forAll(parcels, pI) 
    {   
        Info << pI << endl;
    }
Within that loop I would like to do someting like this ("pseudocode")
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;
How can I access particle velocities, diameters and IDs of the cells the particles are located in within the above loop or rather how can I make the above idea work in OF?

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.
moritzhoefert is offline   Reply With Quote

Old   September 12, 2017, 04:54
Default
  #2
New Member
 
Join Date: Aug 2017
Posts: 10
Rep Power: 9
schf is on a distinguished road
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
    }
   ...
}
Is it just a syntax problem or do I have a fundamental misunderstanding about accessing the values in the Lagrangian field?

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«
Thanks for your help in advance!
schf is offline   Reply With Quote

Old   September 15, 2017, 11:31
Default
  #3
New Member
 
Join Date: Aug 2017
Posts: 10
Rep Power: 9
schf is on a distinguished road
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;
}
It works, but isn't perfect. So if you have a better solution I would be happy for your help!
schf 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
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


All times are GMT -4. The time now is 18:47.