VTK for 3D ParaView

2,020 views
Skip to first unread message

Miloud BenBen

unread,
Jan 5, 2017, 1:55:28 PM1/5/17
to basilisk-fr
Dear users,

I try to write vtk from basilisk using output_vtk but the problem I think is that the function is only done for 2D. So I write a version for 3D but i have large files at end and the files are not working with paraview either.
wonder if there is solution to reduce the size, when i convert from gfs is perfect excepting the bug about different (N- versus Z-) ordering conventions.

I am open to any suggestions, thank you,
Miloud
 


vtk3d.h

Andrés Castillo-Castellanos

unread,
Jan 5, 2017, 2:52:11 PM1/5/17
to basilisk-fr
Hey Miloud,

The thing with output_vtk is that data is written in plain text. This is handy, but files are usually 4 to 6 times larger, so switching to binary files would improve that. For that you could use the old VTK binary format or the newer XML based ones (vtu,vts,vtp) and so on. I have a draft for the newer format vts (also writes in ascii) that is meant to be used with multigrid in 3D. Some tweaking might be required but at least should give you an idea of this new format. For that, switching to a binary file sould be relatively straightforward.

As an alternative you could read this other post on the XDMF format that is suited for large dataset.  https://groups.google.com/d/topic/basilisk-fr/rriHZd4d1Pc/discussion

Best regards,
output_vts.h

Stanley Ling

unread,
Jan 6, 2017, 3:18:58 AM1/6/17
to Andrés Castillo-Castellanos, basilisk-fr
Hi Miloud, 

I happened to discuss with Stephane about the output yesterday. The current output_vtk is a simple and temporary fix and it cast the octree data to a structure grid. What it means is that now you pretend you have a data with a uniform Cartesian grid with the maximum level. Therefore, you can imagine if you simply extend the approach to 3D, it is not surprised to me that the data would be huge. Converting the file from ASCII to binary like Andrés suggested may help but depending on your problem, the file can still be very large. 

Ideally, we should work on developing a octree-vtk output (Stephane mentioned that it is on his to-do list, so it will take a while). Or even better, we can split the data into multiple blocks to enable parallel visualization by for example paraview. 

For the moment, there are a few compromise tricks to try: 
1, Gerris has a more sophisticated vtk writer, which can read a gfs file and cast it into vtk format. It uses unstructured mesh, so though not as good as a octree, it is for sure much better than the current output_vtk in basilisk. If you have gerris installed, they you simply need to use: 

gerris3D -e "OutputSimulation {iStep = 1} file.vtk {format=VTK variables = T} file.gfs

2, Then if the file is still too big, Stephane suggested that one may consider to limit the maximum level when he outputs with output_gfs. For example, you use maximum level 13 for calculation, but you only output the results only up to level 12. This would obviously reduce the file size and it would be useful if the fine mesh results are only important to capturing the physics but not to visualization. 

Best, 
Stanley



--
You received this message because you are subscribed to the Google Groups "basilisk-fr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to basilisk-fr+unsubscribe@googlegroups.com.
To post to this group, send email to basil...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/basilisk-fr/6f106b90-911e-48bf-bff1-2aa13bb00c24%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
"Stanley" Yue Ling  <><

Jésus lui dit: C'est moi qui suis le chemin, la vérité et la vie. - Selon Jean 14:6
Jesus said to him, "I am the way, and the truth, and the life.” - John 14:6
耶稣说:“我就是道路,真理,生命” - 约翰福音14:6

Miloud BenBen

unread,
Jan 6, 2017, 8:43:14 PM1/6/17
to basilisk-fr, thuc...@gmail.com
Hi Stanley, Hi Andrés,

I appreciate your help. I'm using "gerris3D -e "OutputSimulation {iStep = 1} file.vtk {format=VTK variables = T} file.gfs" for now, I hope for next an output_vtk,

Many thanks,
Miloud


Le vendredi 6 janvier 2017 09:18:58 UTC+1, ling.stanley a écrit :
Hi Miloud, 

I happened to discuss with Stephane about the output yesterday. The current output_vtk is a simple and temporary fix and it cast the octree data to a structure grid. What it means is that now you pretend you have a data with a uniform Cartesian grid with the maximum level. Therefore, you can imagine if you simply extend the approach to 3D, it is not surprised to me that the data would be huge. Converting the file from ASCII to binary like Andrés suggested may help but depending on your problem, the file can still be very large. 

Ideally, we should work on developing a octree-vtk output (Stephane mentioned that it is on his to-do list, so it will take a while). Or even better, we can split the data into multiple blocks to enable parallel visualization by for example paraview. 

For the moment, there are a few compromise tricks to try: 
1, Gerris has a more sophisticated vtk writer, which can read a gfs file and cast it into vtk format. It uses unstructured mesh, so though not as good as a octree, it is for sure much better than the current output_vtk in basilisk. If you have gerris installed, they you simply need to use: 

gerris3D -e "OutputSimulation {iStep = 1} file.vtk {format=VTK variables = T} file.gfs

2, Then if the file is still too big, Stephane suggested that one may consider to limit the maximum level when he outputs with output_gfs. For example, you use maximum level 13 for calculation, but you only output the results only up to level 12. This would obviously reduce the file size and it would be useful if the fine mesh results are only important to capturing the physics but not to visualization. 

Best, 
Stanley


On Thu, Jan 5, 2017 at 8:52 PM, Andrés Castillo-Castellanos <thuc...@gmail.com> wrote:
Hey Miloud,

The thing with output_vtk is that data is written in plain text. This is handy, but files are usually 4 to 6 times larger, so switching to binary files would improve that. For that you could use the old VTK binary format or the newer XML based ones (vtu,vts,vtp) and so on. I have a draft for the newer format vts (also writes in ascii) that is meant to be used with multigrid in 3D. Some tweaking might be required but at least should give you an idea of this new format. For that, switching to a binary file sould be relatively straightforward.

As an alternative you could read this other post on the XDMF format that is suited for large dataset.  https://groups.google.com/d/topic/basilisk-fr/rriHZd4d1Pc/discussion

Best regards,

Le jeudi 5 janvier 2017 19:55:28 UTC+1, Miloud BenBen a écrit :
Dear users,

I try to write vtk from basilisk using output_vtk but the problem I think is that the function is only done for 2D. So I write a version for 3D but i have large files at end and the files are not working with paraview either.
wonder if there is solution to reduce the size, when i convert from gfs is perfect excepting the bug about different (N- versus Z-) ordering conventions.

I am open to any suggestions, thank you,
Miloud
 


--
You received this message because you are subscribed to the Google Groups "basilisk-fr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to basilisk-fr...@googlegroups.com.

To post to this group, send email to basil...@googlegroups.com.

Andrés Castillo-Castellanos

unread,
Jul 6, 2017, 12:30:05 PM7/6/17
to basilisk-fr, thuc...@gmail.com
Hi Miloud,

If you are still interested in exporting your 3d fields to paraview, you can try (http://basilisk.fr/sandbox/acastillo/output_fields/output_vtu_foreach.h)
to write in ascii or binary formats. If you use it in MPI, you can write one file per PID process and then join them using a *.pvtu file. There's an exemple
here: http://basilisk.fr/sandbox/acastillo/cav2d.c

Best regards,

Miloud BenBen

unread,
Jul 7, 2017, 6:23:31 PM7/7/17
to basilisk-fr
Hi Andrés,

It's very nice, thank you, I finally succeed the last time to converte from gfs files to vtk, but i will keep that in mind for future.

Best regards, 
Miloud

Pascal Ray

unread,
Sep 20, 2018, 11:31:38 AM9/20/18
to basilisk-fr, Andrés Castillo-Castellanos
Hi Andrés,

I'm using your code for exporting 3d fields to paraview, it works fine and
I can generate my fields in vtu and pvtu formats, but what it is strange when
I open them in paraview, I cannot activate isosurface (contour) but only clip or slice.
I also tried with cav3d.c example and it is the same, I don't understand how you extract
your iso-thermal surface in paraview, I tried with the version 5, 4, and 3.98 of paraview,
it changes nothing ...
are you using some special filter ?
thanks for your help,
Pascal
> >>> <https://groups.google.com/d/msgid/basilisk-fr/6f106b90-911e-48bf-bff1-2aa13bb00c24%40googlegroups.com?utm_medium=email&utm_source=footer>
> >>> .
> >>>
> >>> For more options, visit https://groups.google.com/d/optout.
> >>>
> >>
> >>
> >>
> >> --
> >> "Stanley" Yue Ling <><
> >>
> >> Jésus lui dit: C'est moi qui suis le chemin, la vérité et la vie. - Selon
> >> Jean 14:6
> >> Jesus said to him, "I am the way, and the truth, and the life.” - John
> >> 14:6
> >> 耶稣说:“我就是道路,真理,生命” - 约翰福音14:6
> >>
> >
>
> --
> You received this message because you are subscribed to the Google Groups "basilisk-fr" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to basilisk-fr...@googlegroups.com.
> To post to this group, send email to basil...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/basilisk-fr/e0376a04-f7bc-45ea-a075-185ca1010f4c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


--
---------------------------------------------------------------------
Pascal Ray - Institut Jean Le Rond d'Alembert - UMR 7190 - T65-55, 5e
CNRS/UPMC - Boite 162, 4 place Jussieu - 75252 Paris cedex 05 -
Tel. 01 44 27 53 14 - Fax 01 44 27 52 59
---------------------------------------------------------------------

Andrés Castillo-Castellanos

unread,
Sep 20, 2018, 1:43:21 PM9/20/18
to basilisk-fr
Hi Pascal,

Paraview has two ways of storing data. As a point data and as cell data, depending on how you write the vtu file. Point data is assgined to the points of your grid, while cell data is assigned to the centre of the cell. You'll see a dot or a square next to the name of the variable, but I think the routines writes as cell data. Contours won't work with cell data, but you can convert into point data using Filters -> Point Data to Cell Data.

If you want to change the routine to write as point data you'll have to change this part
fputs ("\t\t\t <CellData Scalars=\"scalars\">\n", fp);
  for (scalar s in list) {
    fprintf (fp,"\t\t\t\t <DataArray type=\"Float64\" Name=\"%s\" format=\"ascii\">\n", s.name);
    foreach(){
      fprintf (fp, "\t\t\t\t\t %g\n", val(s));
    }
    fputs ("\t\t\t\t </DataArray>\n", fp);
  }

....

Into something like this

  fputs ("\t\t\t <PointData Scalars=\"scalars\">\n", fp);
  for (scalar s in list) {
    fprintf (fp,"\t\t\t\t <DataArray type=\"Float64\" Name=\"%s\" format=\"ascii\">\n", s.name);
    foreach_vertex(){  
 fprintf (fp, "\t\t\t\t\t %g\n", interpolate (s, x, y)); } fputs ("\t\t\t\t </DataArray>\n", fp); }
...
 fputs ("\t\t\t </
PointData>\n", fp);


Best regards,

r...@ida.upmc.fr

unread,
Sep 21, 2018, 7:41:44 AM9/21/18
to Andrés Castillo-Castellanos, basilisk-fr
Hi Andrés,

Thanks, I didn't know these filters cell2point and point2cell, now it
works fine, but you're right may be it's better to write it directly in
the code.
Thanks again for your code and your help !
Best regards,
Pascal
>> an email to basilisk-fr...@googlegroups.com <javascript:>.
>> > To post to this group, send email to basil...@googlegroups.com
>> <javascript:>.
>> > To view this discussion on the web visit
>> https://groups.google.com/d/msgid/basilisk-fr/e0376a04-f7bc-45ea-a075-185ca1010f4c%40googlegroups.com.
>>
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> ---------------------------------------------------------------------
>> Pascal Ray - Institut Jean Le Rond d'Alembert - UMR 7190 - T65-55, 5e
>> CNRS/UPMC - Boite 162, 4 place Jussieu - 75252 Paris cedex 05 -
>> Tel. 01 44 27 53 14 - Fax 01 44 27 52 59
>> ---------------------------------------------------------------------
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "basilisk-fr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to basilisk-fr...@googlegroups.com.
> To post to this group, send email to basil...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/basilisk-fr/885107ea-ad72-4c62-a963-872221c692c5%40googlegroups.com.

Øystein Lande

unread,
Sep 21, 2018, 12:54:44 PM9/21/18
to basilisk-fr
Hi Andrés,

First of all thank you for the output_fields routines. i have used them frequently and also as inspiration to derive other output routines (such as dumping the PLIC surface and iso surfaces to vtu files,etc)

I also want to make you aware of a minor bug (or inconvenience with the script) in the output_foreach routines. For high numbers, the use of %g to specify connectivity will turn into scientific notation. This is not tolerated by Paraviews vtu reader, which will result in an error message when reading vtu files containing larger amounts of data.
I made a small modification to the script which you can find here 


Its not exactly elegant, but it works for all file sizes.

best regards
Øystein Lande

Andrés Castillo-Castellanos

unread,
Sep 23, 2018, 8:23:40 AM9/23/18
to basilisk-fr
Thank you so much Øystein, I had noticed the bug, but had no idea where did it came from.

Cheers,

Sagar Patankar

unread,
Jun 3, 2019, 9:44:52 AM6/3/19
to basilisk-fr

HUI WANG

unread,
Apr 9, 2020, 10:37:38 AM4/9/20
to basilisk-fr
Hi Pascal,

I am using Andrés' s code to write vtu file now. As you mentined before, I also have the problem of showing contour in Paraview. Although the filter cell2point works, i think it is better to write the point data directly.

Did you output the point data successfully from the code?  I tried what Andrés said, but the data can not be written appropriately after i changed that part. 

Could you please give me some advice about this problem If it works for you.

Thanks
Hui 

在 2018年9月21日星期五 UTC+2下午1:41:44,r...@ida.upmc.fr写道:
Reply all
Reply to author
Forward
0 new messages