Reading Lagrangian Position Data
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! |
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, |
|
Quote:
https://discourse.paraview.org/t/par...penfoam/3456/8 |
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? |
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. |
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()) Code:
if (this->db().time().writeTime()) 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! |
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. |
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 |
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.
|
The pvreader is -- at least for openfoam 7 -- in $FOAM_APP/utilities/postProcessing/graphics/PVReaders. I agree that it should be compiled automatically.
Caelan |
Thanks. Compiled and it is working now.
|
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 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 Code:
lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C Hopefully this helps someone, and I'd be happy to detail each of the additions I made if someone has need for it! |
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 |
Quote:
Same problem here :(. If any of you know how to reconstruct with the "positions.orig" file, please let us know. Thanks, Luis. |
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 |
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 |
1 Attachment(s)
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. |
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. Quote:
|
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? |
All times are GMT -4. The time now is 08:21. |