|
[Sponsors] |
March 30, 2020, 12:45 |
Reading Lagrangian Position Data
|
#1 |
Member
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 36
Rep Power: 6 |
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 Code:
(0.08930289 0.6773368 0.1431805 0.09017981) 1135715 3437655 1 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 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] Code:
injectorPosition = [1.01, -0.15, 0.414] 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 |
|
March 30, 2020, 14:28 |
|
#2 |
Member
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 36
Rep Power: 6 |
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,
__________________
Conor Crickmore PhD Researcher in Automotive Aerodynamics Aeronautical and Automotive Engineering Loughborough University LE11 3TU |
|
March 31, 2020, 11:16 |
|
#3 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
__________________
https://openfoam.top |
|
April 2, 2020, 09:54 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
https://discourse.paraview.org/t/par...penfoam/3456/8 |
||
April 2, 2020, 10:15 |
|
#5 | |
Member
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 36
Rep Power: 6 |
Quote:
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 |
||
April 2, 2020, 16:27 |
|
#6 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
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. |
||
April 3, 2020, 13:36 |
|
#7 |
Member
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 36
Rep Power: 6 |
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 Code:
if (this->db().time().writeTime()) { outputProperties_.writeObject ( IOstream::ASCII, IOstream::currentVersion, this->db().time().writeCompression(), true ); } 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(); } 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 Code:
case/time/lagrangian/kinematicCloud 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 |
|
April 6, 2020, 15:31 |
|
#8 | |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 51 |
Quote:
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 |
||
April 6, 2020, 15:49 |
|
#9 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
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 |
|
April 6, 2020, 16:47 |
|
#10 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 51 |
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 |
|
April 6, 2020, 16:53 |
|
#11 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
The pvreader is -- at least for openfoam 7 -- in $FOAM_APP/utilities/postProcessing/graphics/PVReaders. I agree that it should be compiled automatically.
Caelan |
|
April 18, 2020, 14:01 |
|
#13 |
Member
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 36
Rep Power: 6 |
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 Code:
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C // cjc96 { // Store current global position p.globalPos() = p.position(); // cjc96 } 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 |
|
September 14, 2021, 05:35 |
|
#14 | |
New Member
Morteza Mousavi
Join Date: Jul 2019
Location: Lund, Sweden
Posts: 15
Rep Power: 7 |
Quote:
Thanks Yan, your solution was helpful as always! I have compiled and used lagrangianExtraFunctionObjects in OF7 and it works in a serial case to generate positions.orig, which I need for post-processing. However, I have problems when I run a parallel case. I have "positions" and "positions.orig" files in each processor directory. However, when I reconstruct the case, I only get the reconstructed "positions" file. Any insights on how to reconstruct the "positions.orig" which has the cartesian coordinates? / Morteza |
||
November 30, 2021, 20:17 |
|
#15 | |
New Member
Luis Felipe López
Join Date: Apr 2020
Posts: 7
Rep Power: 6 |
Quote:
Same problem here . If any of you know how to reconstruct with the "positions.orig" file, please let us know. Thanks, Luis. |
||
December 1, 2021, 04:07 |
|
#16 | |
Member
Conor Crickmore
Join Date: Jan 2020
Location: Leicestershire, United Kingdom
Posts: 36
Rep Power: 6 |
Quote:
Luis, you can always do as I did and compile your own, local versions of the relevant Code:
src/lagrangian Assuming you are using OpenFOAM v7, these files being: 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
__________________
Conor Crickmore PhD Researcher in Automotive Aerodynamics Aeronautical and Automotive Engineering Loughborough University LE11 3TU |
||
January 11, 2022, 03:37 |
|
#17 | |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
Quote:
I also had this issue. For this, I just run a post-processing step in serial to get positions.orig. i.e. Code:
mpirun -np 4 MPPICFoam -parallel MPPICFoam -postProcess |
||
September 26, 2022, 06:57 |
|
#18 | |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 365
Rep Power: 8 |
Quote:
after executing foamToVTK the "positions"-file is not converted, including other data, please find attached screenshot. am i missing something? how do i make the particles visible? i could not find any good tutorial. |
||
September 26, 2022, 14:37 |
|
#19 |
Senior Member
Josh Williams
Join Date: Feb 2021
Location: Scotland
Posts: 113
Rep Power: 5 |
You can visualise particles using the 'Glyph' option in paraview.
If you wish to colour particles by their position (e.g. maybe by initial z coordinate for some reason), I guess you could use paraview calculator and select "coordsZ" in the scalars toolbar. I guess the coords does not come up in an option in the toolbar you show as this is for colouring by some scalar field, and it is rare that people colour particles by their position in space. |
|
July 29, 2023, 21:19 |
|
#20 | |
New Member
Join Date: Mar 2022
Posts: 2
Rep Power: 0 |
Quote:
Thanks for sharing your idea, cjc96. However, when i followed all your comment above and compiled my new intermediate, there was always an error message "class 'Foam::KinematicParcel<parceltype>'does not have any field named globalpos". I have no idea how to deal with this. could you please tell us more details of your idea? |
||
|
|
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 |