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

Lagrangian data - particle velocity post processing

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Ake
  • 1 Post By Ake

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 8, 2019, 10:14
Question Lagrangian data - particle velocity post processing
  #1
Ake
New Member
 
Kevin
Join Date: May 2018
Posts: 6
Rep Power: 7
Ake is on a distinguished road
Hi everyone,


i am doing LES and i just added lagrangian particles to pimpleFoam (openfoam 7). But now i am struggeling with the post processing, which isn't as easy as I thought/expected.

I am able to see the lagrangian data in paraView. But i have no idea how to sample the particle velocity to get (for example) an axial particle velocity profile. Additionally i need the average of the particle velocity, what could be done easily in the controlDict if i have a field. So what i need is a field of the particle velocity with that i am able to create the time average.


In the Cloudfunction "VoidFraction" (VoidFraction.C) there is lagrangian data "written in a field" i guess.
--> theta[p.cell()] += dt*p.nParticle()*p.volume();

So i have tried to do it the same way and edit the VoidFraction cloudfunction with this or something similar
--> Uparticle[p.cell()] += dt*mag(p.U());
but this didnt work properly. The solver compiles but the magnitude of the velocity of the created field is much too high (about 10⁹). I think there is something wrong in the transfer of the "point" velocity to the "cell" velocity.




Does anyone have any idea how this could work?

I'm not sure this is the right way. Maybe someone has a better idea to sample the particle velocity at any position? Is there an existing CloudFunction which can be used for that?


Thanks in advance
sourav90 likes this.
Ake is offline   Reply With Quote

Old   November 11, 2019, 05:01
Default
  #2
Senior Member
 
Join Date: Aug 2014
Location: UK
Posts: 213
Rep Power: 12
fresty is on a distinguished road
Have you tried using 'calculate' to acquire p.U(component) and 'integrate variables' in ParaView?
fresty is offline   Reply With Quote

Old   November 13, 2019, 06:35
Default
  #3
Ake
New Member
 
Kevin
Join Date: May 2018
Posts: 6
Rep Power: 7
Ake is on a distinguished road
Quote:
Originally Posted by fresty View Post
Have you tried using 'calculate' to acquire p.U(component) and 'integrate variables' in ParaView?
Thanks for your answer. I havent tried it that way. But finally, I solved my problem myself. Here is my solution for all those who are interested.



I created a new vector field 'UPar' in the file KinematicCloudI.H similar to the given scalar field 'theta'. Additionally i created a scalar field of the particles sum 'SumPar' (=parcels sum). I need this field because it is possible that one cell contains more than one particle and then the averaged velocity is calculated.


Code:
template<class CloudType>
inline const Foam::tmp<Foam::volVectorField>
Foam::KinematicCloud<CloudType>::UPar() const
{
    tmp<volVectorField> tUPar
    (
        volVectorField::New
        (
            this->name() + ":UPar",
            mesh_,
            dimensionedVector(dimVelocity, vector(0,0,0)),
            extrapolatedCalculatedFvPatchVectorField::typeName
        )
    );


    volVectorField& UPar = tUPar.ref();
    forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
    {
        const parcelType& p = iter();
        const label celli = p.cell();
        UPar[celli] += (p.U())/(p.nParticle());
    }
    UPar.primitiveFieldRef() /= 1;//mesh_.V();
    UPar.correctBoundaryConditions();

    return tUPar;
}



  
template<class CloudType>
inline const Foam::tmp<Foam::volScalarField>
Foam::KinematicCloud<CloudType>::SumPar() const
{
    tmp<volScalarField> tSumPar
    (
        volScalarField::New
        (
            this->name() + ":SumPar",
            mesh_,
            dimensionedScalar(dimless, 0),
            extrapolatedCalculatedFvPatchScalarField::typeName
        )
    );


    volScalarField& SumPar = tSumPar.ref();
    forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
    {
        const parcelType& p = iter();
        const label celli = p.cell();
        SumPar[celli] += p.nParticle();
    
    }

    SumPar.primitiveFieldRef() /= 1;//mesh_.V();
    SumPar.correctBoundaryConditions();

    return tSumPar;
}
Afterwards 'UPar' is divided by 'SumPar' in in my pimpleLPT.C file if there is at least one particle in it.


Code:
        

    volScalarField SumParTemp=(kinematicCloud.SumPar())();
    volVectorField UParTemp=(kinematicCloud.UPar())();

    forAll(mesh.C(), i)
    {
    if(SumParTemp[i]>0)
        {
            UPar[i] = UParTemp[i]/SumParTemp[i];
        }
    else
        {
            UPar[i] = UParTemp[i];
        }    
    }
    UPar.correctBoundaryConditions();  
    SumPar = kinematicCloud.SumPar();
    SumPar.correctBoundaryConditions();
But be carefull.... in paraview the point data is not correct. This is because of the interpolation of the velocities. You have to look at the 'cell data'.



This solution seems to be very good for my investigations. Nevertheless, if you have suggestions for improvement, I would be happy if you share them.
rezaeimahdi likes this.
Ake is offline   Reply With Quote

Old   March 3, 2020, 02:55
Default
  #4
New Member
 
CHEUNG WING KI
Join Date: May 2017
Posts: 16
Rep Power: 8
as020002 is on a distinguished road
Quote:
Originally Posted by Ake View Post
Thanks for your answer. I havent tried it that way. But finally, I solved my problem myself. Here is my solution for all those who are interested.



I created a new vector field 'UPar' in the file KinematicCloudI.H similar to the given scalar field 'theta'. Additionally i created a scalar field of the particles sum 'SumPar' (=parcels sum). I need this field because it is possible that one cell contains more than one particle and then the averaged velocity is calculated.


Code:
template<class CloudType>
inline const Foam::tmp<Foam::volVectorField>
Foam::KinematicCloud<CloudType>::UPar() const
{
    tmp<volVectorField> tUPar
    (
        volVectorField::New
        (
            this->name() + ":UPar",
            mesh_,
            dimensionedVector(dimVelocity, vector(0,0,0)),
            extrapolatedCalculatedFvPatchVectorField::typeName
        )
    );


    volVectorField& UPar = tUPar.ref();
    forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
    {
        const parcelType& p = iter();
        const label celli = p.cell();
        UPar[celli] += (p.U())/(p.nParticle());
    }
    UPar.primitiveFieldRef() /= 1;//mesh_.V();
    UPar.correctBoundaryConditions();

    return tUPar;
}



  
template<class CloudType>
inline const Foam::tmp<Foam::volScalarField>
Foam::KinematicCloud<CloudType>::SumPar() const
{
    tmp<volScalarField> tSumPar
    (
        volScalarField::New
        (
            this->name() + ":SumPar",
            mesh_,
            dimensionedScalar(dimless, 0),
            extrapolatedCalculatedFvPatchScalarField::typeName
        )
    );


    volScalarField& SumPar = tSumPar.ref();
    forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
    {
        const parcelType& p = iter();
        const label celli = p.cell();
        SumPar[celli] += p.nParticle();
    
    }

    SumPar.primitiveFieldRef() /= 1;//mesh_.V();
    SumPar.correctBoundaryConditions();

    return tSumPar;
}
Afterwards 'UPar' is divided by 'SumPar' in in my pimpleLPT.C file if there is at least one particle in it.


Code:
        

    volScalarField SumParTemp=(kinematicCloud.SumPar())();
    volVectorField UParTemp=(kinematicCloud.UPar())();

    forAll(mesh.C(), i)
    {
    if(SumParTemp[i]>0)
        {
            UPar[i] = UParTemp[i]/SumParTemp[i];
        }
    else
        {
            UPar[i] = UParTemp[i];
        }    
    }
    UPar.correctBoundaryConditions();  
    SumPar = kinematicCloud.SumPar();
    SumPar.correctBoundaryConditions();
But be carefull.... in paraview the point data is not correct. This is because of the interpolation of the velocities. You have to look at the 'cell data'.



This solution seems to be very good for my investigations. Nevertheless, if you have suggestions for improvement, I would be happy if you share them.
Hi Kevin,

This is very helpful, may I ask where did you put the second code in pimpleLPT.C? I added it below the "parcels.evolve" within the runTime.run loop and it didn't work.

Thanks,
RIck
as020002 is offline   Reply With Quote

Old   March 3, 2020, 03:17
Default
  #5
Ake
New Member
 
Kevin
Join Date: May 2018
Posts: 6
Rep Power: 7
Ake is on a distinguished road
Hi Rick,


I put it in the same place. Within the runtime loop and outside the pimple loop.


Maybe you can try it without the temporary fields and the particle sum in a first step. Just add a velocity vectorfield "UPar2" in the createFieldsDict and then add this below the .evolve in your pimpleLPT.C file:

Code:
UPar2 = kinematicCloud.UPar();
Ake is offline   Reply With Quote

Old   March 3, 2020, 08:41
Default
  #6
New Member
 
CHEUNG WING KI
Join Date: May 2017
Posts: 16
Rep Power: 8
as020002 is on a distinguished road
Quote:
Originally Posted by Ake View Post
Hi Rick,


I put it in the same place. Within the runtime loop and outside the pimple loop.


Maybe you can try it without the temporary fields and the particle sum in a first step. Just add a velocity vectorfield "UPar2" in the createFieldsDict and then add this below the .evolve in your pimpleLPT.C file:

Code:
UPar2 = kinematicCloud.UPar();
Dear Kevin,

Yes I think the code in .C file is fine but I still haven't figured out where the problems are, could you post your createFields.H? It would be very appreciated.

Cheers,
Rick
as020002 is offline   Reply With Quote

Old   March 3, 2020, 09:27
Default
  #7
New Member
 
CHEUNG WING KI
Join Date: May 2017
Posts: 16
Rep Power: 8
as020002 is on a distinguished road
I think I should post my error message here:
Attached Images
File Type: jpg error.jpg (77.6 KB, 80 views)
as020002 is offline   Reply With Quote

Old   March 3, 2020, 10:13
Default
  #8
Ake
New Member
 
Kevin
Join Date: May 2018
Posts: 6
Rep Power: 7
Ake is on a distinguished road
It could be the name of your Cloud (.evolve)


The name of my kinematicCloud is kinematicCloud. This is my evolve in the .C file:
Code:
kinematicCloud.evolve();
And this is my createFieldsDict:
Code:
const word kinematicCloudName
(
    args.optionLookupOrDefault<word>("cloudName", "kinematicCloud")
);
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;
basicKinematicCollidingCloud kinematicCloud
(
    kinematicCloudName,
    rho,
    U,
    mu,
    g
);
Ake is offline   Reply With Quote

Old   March 3, 2020, 11:19
Default
  #9
New Member
 
CHEUNG WING KI
Join Date: May 2017
Posts: 16
Rep Power: 8
as020002 is on a distinguished road
Quote:
Originally Posted by Ake View Post
It could be the name of your Cloud (.evolve)


The name of my kinematicCloud is kinematicCloud. This is my evolve in the .C file:
Code:
kinematicCloud.evolve();
And this is my createFieldsDict:
Code:
const word kinematicCloudName
(
    args.optionLookupOrDefault<word>("cloudName", "kinematicCloud")
);
Info<< "Constructing kinematicCloud " << kinematicCloudName << endl;
basicKinematicCollidingCloud kinematicCloud
(
    kinematicCloudName,
    rho,
    U,
    mu,
    g
);
Dear Kevin,

Thank you it successfully compiled. However I tested it with some cases it ended up like another error, it's like there are problems in dimension:, and my createFields.H is of attachment.

Cheers,
Rick
as020002 is offline   Reply With Quote

Old   March 3, 2020, 11:20
Default
  #10
New Member
 
CHEUNG WING KI
Join Date: May 2017
Posts: 16
Rep Power: 8
as020002 is on a distinguished road
Sorry, I forgot to attach the image, there is it.
Attached Images
File Type: png error.png (42.8 KB, 85 views)
as020002 is offline   Reply With Quote

Old   March 4, 2020, 03:14
Default
  #11
New Member
 
CHEUNG WING KI
Join Date: May 2017
Posts: 16
Rep Power: 8
as020002 is on a distinguished road
After I correct some minor syntax mistakes and make some declaration in source code files, now it works perfectly now.

Thank you Kevin
as020002 is offline   Reply With Quote

Old   August 16, 2020, 07:24
Default
  #12
New Member
 
Join Date: Nov 2019
Posts: 4
Rep Power: 6
arch.mr is on a distinguished road
Dear Cheung Wing Ki
I also tried to create a scalar field of the particles sum (particle number per unit volume)
I followed Kevin's codes and tried to compile

kinematicCloudI.H

Code:
template<class CloudType>
inline const Foam::tmp<Foam::volScalarField>
Foam::KinematicCloud<CloudType>::SumPar() const
{
    tmp<volScalarField> tSumPar
    (
        volScalarField::New
        (
            this->name() + ":SumPar",
            mesh_,
            dimensionedScalar(dimless, 0),
            extrapolatedCalculatedFvPatchScalarField::typeName
        )
    );


    volScalarField& SumPar = tSumPar.ref();
    forAllConstIter(typename KinematicCloud<CloudType>, *this, iter)
    {
        const parcelType& p = iter();
        const label celli = p.cell();
        SumPar[celli] += p.nParticle();
    
    }

    SumPar.primitiveFieldRef() /= mesh_.V(); // 1;
    SumPar.correctBoundaryConditions();

    return tSumPar;
}
and add this right after rhoEff
KinematicCloud.H

Code:
inline const tmp<volScalarField> rhoEff() const;

inline const tmp<volScalarField> SumPar() const;
but I got following error message...
intL4Foam.C: In function ‘int main(int, char**)’:
intL4Foam.C:188:9: error: ‘SumPar’ was not declared in this scope
SumPar = kinematicCloud.SumPar();
^~~~~~
intL4Foam.C:188:33: error: ‘Foam::basicKinematicCollidingCloud {aka class Foam::CollidingCloud<Foam::KinematicCloud<Foam::Cl oud<Foam::CollidingParcel<Foam::KinematicParcel<Fo am:article> > > > >}’ has no member named ‘SumPar’
SumPar = kinematicCloud.SumPar();
^~~~~~


Does anybody can help me?
Thank you
Attached Images
File Type: jpg captur.jpg (30.4 KB, 14 views)
arch.mr is offline   Reply With Quote

Old   August 16, 2020, 07:54
Default
  #13
New Member
 
Join Date: Nov 2019
Posts: 4
Rep Power: 6
arch.mr is on a distinguished road
I tried to get particle density output per volume
Add code in kinematicCloud.H, kinematicCloudI.H, main.C file and createFields.H
And got following error messages..

Anybody please can help me?


Thank you
Attached Images
File Type: jpg capture2.JPG (34.8 KB, 30 views)
arch.mr is offline   Reply With Quote

Reply

Tags
lagrangian data, large eddy simulation, post processing


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
[OpenFOAM] Plotting velocity of Lagrangian particle over time/direction thintn222 ParaView 0 April 25, 2019 21:43
How to create velocity profile for falling ball in fluent CFD post processing valr FLUENT 2 June 13, 2018 06:18
Exporting Particle Data prX411 CFX 4 April 3, 2018 12:00
Post processing of Lagrangian particle field marialhm OpenFOAM Post-Processing 0 October 8, 2017 22:02
Post processing data zz744 FLUENT 0 February 19, 2014 06:35


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