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

Reading Lagrangian Position Data

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes
  • 1 Post By cjc96
  • 2 Post By zhangyan
  • 2 Post By olesen
  • 1 Post By olesen
  • 1 Post By clapointe

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 30, 2020, 12:45
Default Reading Lagrangian Position Data
  #1
New Member
 
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 28
Rep Power: 2
cjc96 is on a distinguished road
Hello everyone,

I'm currently working on a custom (PISO-based) Eulerian-Lagrangian Solver in OpenFOAM 7, primarily based on this presentation and existing work carried out by my department in OpenFOAM 2.4.

I'm trying to extract the data for post-processing in MATLAB, OpenFOAMs built-in 'particleTracks' function doesn't seem overly versatile, unless I am missing something here also.

My problem is reading the position data from:

Code:
*/lagrangian/kinematicCloud/positions
My data is of the format:

Code:
(0.08930289 0.6773368 0.1431805 0.09017981) 1135715 3437655 1
As you can see, there are seemingly four 'position' values

Whereas data I have from the work in 2.4 (albeit from a different problem) is formatted as so:

Code:
(-0.189055 -0.169927 0.157027) 22739688
Which has three 'position' values, as one would expect

Taking a rather crude measurement (using the ruler) of the corresponding particle position in ParaView shows an actual position of:

Code:
expectedPosition = [1.50022 0.031163 0.56261]
I've tried to manipulate the numbers based on an initial injection point of:

Code:
injectorPosition = [1.01, -0.15, 0.414]
But even then I can't get the numbers to add up.

If anyone has any experience in this regard I would be extremely grateful!
__________________
Conor Crickmore
PhD Researcher in Automotive Aerodynamics
Aeronautical and Automotive Engineering
Loughborough University
LE11 3TU
cjc96 is online now   Reply With Quote

Old   March 30, 2020, 14:28
Default
  #2
New Member
 
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 28
Rep Power: 2
cjc96 is on a distinguished road
On further inspection, I think the issue is stemming from OpenFOAMs move to Barycentric Tracking in 2017.

So, that begs the question, how does one convert from these Barycentric Co-ordinates to the Global system? Or, as a less ideal alternative, configure the 'particleTracks' function to properly evolve over time and colour according to other Lagrangian parameters, such as diameter?

Thanks again,
Tobi likes this.
__________________
Conor Crickmore
PhD Researcher in Automotive Aerodynamics
Aeronautical and Automotive Engineering
Loughborough University
LE11 3TU
cjc96 is online now   Reply With Quote

Old   March 31, 2020, 11:16
Default
  #3
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 114
Rep Power: 8
zhangyan is on a distinguished road
https://github.com/blueCFD/lagrangia...unctionObjects
Tobi and cjc96 like this.
__________________
https://openfoam.top
zhangyan is offline   Reply With Quote

Old   April 2, 2020, 09:54
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 955
Rep Power: 26
olesen will become famous soon enougholesen will become famous soon enough
Quote:
Originally Posted by cjc96 View Post
On further inspection, I think the issue is stemming from OpenFOAMs move to Barycentric Tracking in 2017.

So, that begs the question, how does one convert from these Barycentric Co-ordinates to the Global system?
Similar issue when reading with paraview, as discussed here:

https://discourse.paraview.org/t/par...penfoam/3456/8
Tobi and cjc96 like this.
olesen is offline   Reply With Quote

Old   April 2, 2020, 10:15
Default
  #5
New Member
 
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 28
Rep Power: 2
cjc96 is on a distinguished road
Quote:
Originally Posted by olesen View Post
Similar issue when reading with paraview, as discussed here:

https://discourse.paraview.org/t/par...penfoam/3456/8
Hey Olesen,
Thanks for the reply.

While that is indeed the source of my problem, I have no problems actually opening and viewing the Lagrangian data in ParaView (OF 7, PV 5.6). I'm not overly versed in this area, but is that because I'm using paraFoam as opposed to the native client?
__________________
Conor Crickmore
PhD Researcher in Automotive Aerodynamics
Aeronautical and Automotive Engineering
Loughborough University
LE11 3TU
cjc96 is online now   Reply With Quote

Old   April 2, 2020, 16:27
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 955
Rep Power: 26
olesen will become famous soon enougholesen will become famous soon enough
Quote:
Originally Posted by cjc96 View Post
While that is indeed the source of my problem, I have no problems actually opening and viewing the Lagrangian data in ParaView (OF 7, PV 5.6). I'm not overly versed in this area, but is that because I'm using paraFoam as opposed to the native client?

Yes exactly. As you may realize, "paraFoam" is simply a script to touch a file and start paraview, under the assumption that an additional combined reader plugin is loadable that is compiled with OpenFOAM and ParaView sources.
cjc96 likes this.
olesen is offline   Reply With Quote

Old   April 3, 2020, 13:36
Default
  #7
New Member
 
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 28
Rep Power: 2
cjc96 is on a distinguished road
As an update,

zhangyan's suggestion of lagrangianExtraFunctionObjects doesn't currently fulfil my needs, it seems that it is written in such a way that you add additional code for each solver used, of which my custom solver is of course not one of.

While I am sure that the function can be modified to work with my solver, my (naive and inexperienced) impression, is that its functionality could be added to my user-attributed Lagrangian directory.

I've already made some small progress by modifying a section of my custom version of:

Code:
src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C
from:

Code:
    if (this->db().time().writeTime())
    {
        outputProperties_.writeObject
        (
            IOstream::ASCII,
            IOstream::currentVersion,
            this->db().time().writeCompression(),
            true
        );
    }
to:

Code:
    if (this->db().time().writeTime())
    {
        outputProperties_.writeObject
        (
            IOstream::ASCII,
            IOstream::currentVersion,
            this->db().time().writeCompression(),
            true
        );

		// Conor
		Info << "Temporary Position Write" << nl << endl;
		this->writePositions();
    }
which writes the Cartesian position of each particle to an unformatted .obj file that is overwritten each write interval, but at least I know the data can be extracted.

My first thought was to look at 'outputProperties' to see if I could stitch on a new output, but from what I could find using some rather inelegant grep searches, it seems to be responsible for the contents of:

Code:
case/time/uniform
as opposed to the desired:

Code:
case/time/lagrangian/kinematicCloud
I am aware that this is becoming a rather broad "can you do it for me?" type thread, but could anyone point me towards a tutorial on how to add new data outputs to the source code? I'm hoping I'd be able to use such a guide to create my own 'positionsXYZ' output.

While I expect this exercise to be rather beneficial in the long run, due to my current inexperience, I've spent the better part of this week aimlessly searching through the Lagrangian source code, and it's becoming somewhat demoralising.

Again, thanks for your help!
__________________
Conor Crickmore
PhD Researcher in Automotive Aerodynamics
Aeronautical and Automotive Engineering
Loughborough University
LE11 3TU
cjc96 is online now   Reply With Quote

Old   April 6, 2020, 15:31
Default
  #8
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,436
Blog Entries: 6
Rep Power: 43
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Quote:
Originally Posted by cjc96 View Post
Hey Olesen,
Thanks for the reply.

While that is indeed the source of my problem, I have no problems actually opening and viewing the Lagrangian data in ParaView (OF 7, PV 5.6). I'm not overly versed in this area, but is that because I'm using paraFoam as opposed to the native client?

Hi, since I am checking out some new simulation, I focused this problem too. As Mark already mentioned, I also went through the thread from paraview. However, I cannot watch any field of the Lagragian data in OF 7 and PV 5.8. I am wondering why you can view this data. Even using paraFoam does not work in my case. Maybe the problem is that I have to start paravFoam -builtin.


I will check it.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 6, 2020, 15:49
Default
  #9
Senior Member
 
Join Date: Aug 2015
Posts: 418
Rep Power: 11
clapointe is on a distinguished road
Hi all,

I have encountered similar problems in the past, and figured I might weigh in. I use paraview 5.4 and most recently OpenFOAM-7. With the openfoam reader I can view my particles without any problem -- this seems to be in agreement with Conor's experience. That said, I have seen the previous error (e.g. with precompiled paraview binaries or on an hpc) -- the only time I've had no problems viewing particles is when I compile everything myself. But I know that this is often not an option. When using the built in reader (either by calling paraview directly, or with paraFoam -builtin) is unavoidable, the foamToVTK work-around has worked for me. It does make the visualization process a bit clunky, but there is a foamSequenceVTKFiles utility that can help.

As for saving data, saving it through paraview (e.g. position, velocity) has been sufficient for me (assuming that you're able to load them in the first place).

Caelan
clapointe is offline   Reply With Quote

Old   April 6, 2020, 16:47
Default
  #10
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,436
Blog Entries: 6
Rep Power: 43
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
My problem (as I always compile everything myself to be conform with the latest dev-line) is that I do not have the PVReader compiled and I cannot figure out how / where to compile that plugin. In former times, I remember that it was automatically compiled or at least a information popped out at the end of compiling or while calling paraFoam. Now, while starting paraFoam I get the info, that the reader plugin is not available.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 6, 2020, 16:53
Default
  #11
Senior Member
 
Join Date: Aug 2015
Posts: 418
Rep Power: 11
clapointe is on a distinguished road
The pvreader is -- at least for openfoam 7 -- in $FOAM_APP/utilities/postProcessing/graphics/PVReaders. I agree that it should be compiled automatically.

Caelan
Tobi likes this.
clapointe is offline   Reply With Quote

Old   April 6, 2020, 17:13
Default
  #12
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Augsburg
Posts: 2,436
Blog Entries: 6
Rep Power: 43
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Thanks. Compiled and it is working now.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   April 18, 2020, 14:01
Default
  #13
New Member
 
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 28
Rep Power: 2
cjc96 is on a distinguished road
Hey guys,

Just thought I'd post an update as I figured at some point, someone else will be trying to do the same thing. I have successfully modified OpenFOAM 7 to output global Cartesian position data, alongside the barycentric data. It's worth mentioning that this is specifically for 'kinematicCloud' based solvers and that I recommend making your own user-defined 'src' directory (and pointing your solver to that) as opposed to making these changes to the main OpenFOAM source files.

The modification consisted of minor additions to the following:

Code:
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C
lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C


In each of these files, I made reference to my own custom field 'globalPos' in much the same way as the other particle properties ('active', 'age', 'd' etc.) are referenced, such as the following :

Code:
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C

ParcelType(p),
active_(p.active_),
typeId_(p.typeId_),
nParticle_(p.nParticle_),
d_(p.d_),
dTarget_(p.dTarget_),
U_(p.U_),
rho_(p.rho_),
age_(p.age_),
tTurb_(p.tTurb_),
UTurb_(p.UTurb_),
globalPos_(p.globalPos_) // cjc96
And then defined the field at the end of the 'move' function
Code:
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C

// cjc96 {
// Store current global position
p.globalPos() = p.position();
// cjc96 }
In hindsight, I think it may have been overkill to define my own field, when 'p.position' already existed, and it is likely simpler (and less expensive) to force the solver to write 'p.position' directly. However, the exercise was very useful in identifying the methods of actually adding a field, enabling me to do so with those that aren't already sitting hidden in the solver.

Hopefully this helps someone, and I'd be happy to detail each of the additions I made if someone has need for it!
__________________
Conor Crickmore
PhD Researcher in Automotive Aerodynamics
Aeronautical and Automotive Engineering
Loughborough University
LE11 3TU
cjc96 is online now   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Lagrangian particle position data at runtime vishwesh OpenFOAM Programming & Development 3 July 11, 2018 09:48
CFD by anderson, chp 10.... supersonic flow over flat plate varunjain89 Main CFD Forum 18 May 11, 2018 07:31
Tecplot reading particle data error ali hemmati FLUENT 1 February 13, 2016 06:17
Cht tutorial in 15 braennstroem OpenFOAM Running, Solving & CFD 197 June 10, 2015 03:02
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52


All times are GMT -4. The time now is 11:31.