blueCFD / Core

Coordination repository for the blueCFD-Core: Issue tracking, Wiki, project webpage and miscellaneous scripts
http://bluecfd.github.io/Core
53 stars 10 forks source link

Particle data cannot be read in Paraview #111

Closed kyounes14 closed 2 years ago

kyounes14 commented 6 years ago

The issue seems to be coming from the positions file written at each time step of a Lagrangian simulation.

Notable references/previous issues include: https://gitlab.kitware.com/paraview/paraview/issues/17038 https://gitlab.kitware.com/paraview/paraview/issues/16833 https://bugs.openfoam.org/view.php?id=2196

Error message reads: Expected punctuation token ')', found []

Has the output of a Lagrangian simulation change in the most recent release? I noticed that the position data is no longer 3 scalar values followed with a cellID, but 4 scalar values instead. I was previously running OpenFOAM 4.x on Paraview 5.1.2 with no problems (blueCFD-Core 2016-1).

I tried outputting in both binary and ascii and the error persists. I also installed Paraview 5.1.2 to check if the error is in recent Paraview releases, but it did not go away. My current workaround is running foamToVTK after every simulation and post-processing, but it is time consuming. I would like to use the default paraFoam function right away.

Steps to reproduce: 1- Go to $FOAM_Tutorials\lagrangian\sprayFoam\aachenBomb 2- Run using sprayFoam for at least one time step (5e-005) 3- Post-process using paraFoam 4- Error pops up after clicking Apply in Paraview 5.4.1

wyldckat commented 6 years ago

This is because of the Barycentric implementation that was implemented in OpenFOAM-dev and released in OpenFOAM 5: https://cfd.direct/openfoam/free-software/barycentric-tracking/

The workaround is to use foamToVTK to export the files and then open the files within the VTK/lagrangian folder in ParaView.

I have not checked this yet, but perhaps the latest ParaView 5.5.2 has this issue already resolved. You can find instructions on how to use another version of ParaView with blueCFD-Core on this FAQ page: http://bluecfd.github.io/Core/FAQ/how-to-use-another-version-of-ParaView/

kyounes14 commented 6 years ago

I tried it on ParaView 5.5.0 and 5.5.2, and it didn't work. I will report this to KitWare for the next ParaView release.

wyldckat commented 6 years ago

If you're willing to try, ParaView 5.6.0-RC1 was announced yesterday, roughly 6h after your comment here. More details here: https://discourse.paraview.org/t/paraview-5-6-0-release-candidate-1-available-for-download/573

AlexLadino commented 5 years ago

wyldkcat. I tried 5.6.0 (without MPI since several installer used MPI2015, etc... and i dont want a MPI conflict -as many i have tried to solve-) but no works. Any suggestion please? Because it is really time, CPU and hard disk consuming. In fact, blueCFD 2016-2 comes with OF4x and the DPMFoam dispersionModel only has "none" but i can postprocess particle positions and blueCFD 2017-1 comes with OF5x with two dispersionModels but i cant fluently postprocess the particle position... Suggestions or fixings?

wyldckat commented 5 years ago

@AlexLadino: Many thanks for reporting this! I wasn't aware that ParaView 5.6 did not support the barycentric positions...

OK, as a workaround, you can run the following command:

foamToVTK -fields '()' -noInternal -excludePatches '(".*")'

This will keep the data export to VTK files down to a minimum, namely it only exports the Lagrangian data files to VTK format and places it inside the folder "VTK". This procedure saved more than 2x the disk space that I needed when I let it export with the default options. The test was done with the tutorial case lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState.

It's not a perfect solution, but at least you should be able to load and see the data in the majority of the versions of ParaView. For example, you can open the file VTK/lagrangian/kinematicCloud/kinematicCloud_..vtk, which will let ParaView know that it should open all VTK files as a time series that you can control with the conventional time controls.

Please let us know if this worked or not for you.

AlexLadino commented 5 years ago

wyldckat: Thank you very much for your suggestion. However this solution takes a lot of postprocessing time while in the past OF version the position files were read perfect by paraview. I found other alternative which was to add the function (based on DPMFoam): kinematicCloud.writePositions() I put this before runTime.write(); inside the run loop. And i get an output in a *.obj file and looks like these:

v -0.122725 0.0308523 -5.42101e-020 v -0.1234 0.0280845 2.1684e-019 v -0.123604 0.0621041 -3.25261e-019

Which are x y z (Global coordinates) for each 1,2,3.. particle ID. This file is very easy to manipulate for computations and so on...

But my problem is that the file during runTime is written at the ./case/kinematicCloud_Positions.obj and not written every time Step in every ./case/

I am not have any programming skills inside the OpenFoam structure (in fact if any can me learn or provide documentation at least to learn HOW TO READ the cpp OF documentation ans SRC would be helpfull), hope anybody than help me. I did not have found any solution to global positions in new OF version, and I am sure if any solve this would be very helpfull for all.

wyldckat commented 5 years ago

@AlexLadino: Then do you only need the positions of the particles?

Or do you also need the other properties, such as the velocity of each particle?

It's just that it's two somewhat different approaches, namely the need to only export the positions into the correct folders, versus the need to also have all particle data.

AlexLadino commented 5 years ago

@wyldckat The particular problem is that when OF 4x and later writes the lagrangian properties in ./case/

  1. Find the way (class and functions) in which positions were saved in past versions in order to add it to the lagrangian solvers. If there exsit and approach in which i can get all the particleData, keeoing the format symply and in globall coordiantes et.c.... awesome and...
  2. I have found that lagrangian particle is very weak in postprocessing utilities (just the scarce info in log. and the field kinematicCloudTheta)... so for example i need to perform 1st and 2nd order statistics for particles at particular positions of a domain for example:

image

So in order to due that i need define a plane, a window width, divide it, find the IDparticles of particles that are inside the window (so i need global POSITIONS) at EVERY time step, recover their velocity and average... so in order to do that i need global POSITIONS.

I dont know how can i do that, but at least if a i have a file with global x,y,z positions of particles and each velocity at each time step, i can postprocess it in matlab (i dont know if paraview can but would be helpful). This is my concern about the positions format...

wyldckat commented 5 years ago

@AlexLadino OpenFOAM does provide specialized function objects specifically for the Lagrangian models, which is configured in the cloudFunctions section in the *CloudProperties file, e.g.: https://github.com/OpenFOAM/OpenFOAM-5.x/blob/master/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties#L134 - line 134.

Here you can file the list of Cloud Function Objects available:

From your description, it's possible that any of the following may be applicable for what you want to do:

As for opening the files in ParaView with the .foam extension, I'll try to create ASAP a function object that does this.

wyldckat commented 5 years ago

@AlexLadino I've now finished creating a new function object library that can be used to generate the positions.orig file for each time step. Instructions on how to do download, compile and use with blueCFD-Core 2017 are provided here: https://github.com/blueCFD/lagrangianExtraFunctionObjects/tree/blueCFD-Core-2017#how-to-getbuild-lagrangianextrafunctionobjects

The instructions also indicate how to rename the files so that you can then open the cases properly with paraFoam, namely with the file extension .foam in ParaView.

Furthermore, if you look into this the method write here: https://github.com/blueCFD/lagrangianExtraFunctionObjects/blob/blueCFD-Core-2017/writeCloudOldStyle/writeCloudOldStyle.C#L109 - you'll see an example of how to access and write the particle data into the screen. Writing to others files is left to you as an exercise, if you want to.

@kyounes14 I don't know if you still need this feature or not, so please let me know if you need this for another solver and if you do, please let me know which solver exactly. This is because right now I've only implemented the support for the basicKinematicCollidingCloud cloud type, but it's fairly easy to make this compatible with other types of cloud.

wyldckat commented 2 years ago

Mentioned in Q&A #190.