szaghi / VTKFortran

pure Fortran VTK (XML) API
139 stars 51 forks source link

General polyhedrons handling #31

Open AliE89 opened 3 years ago

AliE89 commented 3 years ago

Ciao Stefano,

Hope you are doing well. This is just a question out of the box. Can VTKFortran deal with general polyhedrons?

AliE89 commented 3 years ago

Since there is no polydata support I guess I am skrewed... Would it be difficult to add?

szaghi commented 3 years ago

@AliE89

I am sorry for my delay, my bad.

Currently, it is not supported and I do not know how difficult is to add it. I cannot promise anything, but I'll try to figure out the effort necessary in the future.

AliE89 commented 3 years ago

Cool, for I have tried out something but still not found a solution. It is more the fact I cannot find a good example for that, than a VTKfortran issue. I am in the silky situation where my fvm code can ha dle polyheadral cells, but i cannot visualize the results, as consequence i must use celles woth max 6 faces... We can work a bit together on that if you like. Probably the thing a need the most is an example on how those polys are assembled in vtk.

On Fri, 12 Mar 2021, 09:09 Stefano Zaghi, @.***> wrote:

@AliE89 https://github.com/AliE89

I am sorry for my delay, my bad.

Currently, it is not supported and I do not know how difficult is to add it. I cannot promise anything, but I'll try to figure out the effort necessary in the future.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/szaghi/VTKFortran/issues/31#issuecomment-797313428, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4ZV6UU7XRDK2MAINBSUQTTDHD4RANCNFSM4UAYAOMQ .

szaghi commented 3 years ago

@AliE89

Sure, let me some days and give me a reminder in the middle of the next week, hoping I will be less busy than now.

AliE89 commented 3 years ago

Cool stuff.

Since you are a fluid dynamicist as me and a skilled fortran programmer as well, I take the occasion to share with you the code I am working on: https://flubiopetsc.github.io/flubiopetsc/index.html

Cheers!

On Fri, 12 Mar 2021, 09:19 Stefano Zaghi, @.***> wrote:

@AliE89 https://github.com/AliE89

Sure, let me some days and give me a reminder in the middle of the next week, hoping I will be less busy than now.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/szaghi/VTKFortran/issues/31#issuecomment-797318563, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL4ZV6SMP7CRPGBSY4IYXWLTDHE75ANCNFSM4UAYAOMQ .

szaghi commented 3 years ago

@AliE89

FLUBIO rocks!

szaghi commented 3 years ago

@AliE89

I am working on a totally new code for work, an AMR very high order IB solver, highly parallel (tailored to exascale on GPU cluster). Unfortunately is not FOSS, but I will like to share my experience if you are interested.

AliE89 commented 3 years ago

Oh thanks, appreciate you like it! It is currently under massive developments, basically I am alone in coding it, while my mate is more on validations and test cases. Still a lot of things to do! Feel free to jump in if you are interested in (i can add you to the repo), you should have really no issue in understanding the code!

Yes sure, feel free to send me an emai! I am not very experienced with GPUs, even if I know these days there is a fairly big push on them, especially on HO FE codes. I have a decent experience on Immersed Boundaries as I was working on that for a stint of my early academic career. I was planning to add IB in FLUBIOas well to handle elastic stuff, like membranes or filaments, even if an unstructured mesh is not the best data structure for IB (but it is good occasion to do some fancy research on the topic).

szaghi commented 3 years ago

@AliE89

I am now following FLUBIO on gitlab, I hope to find the time to study it soon. I read your paper, nice! I read that you are from Poli-Genova, we have worked a lot with Genova, maybe we can try to a web call soon or later.

Cheers

AliE89 commented 3 years ago

Ah yeah, I remember people from your lab coming to Genoa from time to time. Unfortunately, I am not working for uni anymore since early 2019, but I still do things with them (papers, discussions and so on during my free time and week ends) . Cool, keep in touch then, feel free to send me an email to this address or in gitlab as well! :)

AliE89 commented 2 years ago

Ciao Stefano,

Hope you are doing well.

It took me ages, but in the end I got polyhedron right. I think that library-wise you just need to do a very small modificiation in the function write_connectivity() in vtk_fortran_vtk_file_xml_writer_abstract.f90 to allow it to get 2 optional arrays (faces and faceoffsets).

I did like this:

`er(I4P), intent(in) :: nc !< Number of cells. integer(I4P), intent(in) :: connectivity(1:) !< Mesh connectivity. integer(I4P), intent(in) :: offset(1:) !< Cell offset. integer(I4P), optional, intent(in) :: faces(1:) !< Cell offset. integer(I4P), optional, intent(in) :: faceoffsets(1:) !< Cell offset. integer(I1P), intent(in) :: cell_type(1:) !< VTK cell type. integer(I4P) :: error !< Error status.

call self%write_start_tag(name='Cells') error = self%write_dataarray(data_name='connectivity', x=connectivity) error = self%write_dataarray(data_name='offsets', x=offset) error = self%write_dataarray(data_name='types', x=cell_type)

if(present(faces).and. present(faceoffsets)) then error = self%write_dataarray(data_name='faces', x=faces) error = self%write_dataarray(data_name='faceoffsets', x=faceoffsets) endif `

I would be happy if you like to merge this in the library or find an equivalent solution such that I can stay on thsi repo avoing tedius patching :)

Let me know your throughts!

szaghi commented 2 years ago

Dear @AliE89

I am fine thanks, I hope you are too.

Thank you very much for your help it is really appreciated. Do you like to create a Pull Request? I will happy to accept and merge your PR. In case you cannot I try to put your patch directly into the library during this week.

Cheers

AliE89 commented 2 years ago

Sure, I'll prepare and MR, no problems.

Just a couple of notes for users interested in polyhedra:

I attach an example file of 2 adjacent cubes, while you can find a good way to orient points laying on plane here: https://stackoverflow.com/questions/47949485/sorting-a-list-of-3d-points-in-clockwise-order test.vtu.txt

szaghi commented 2 years ago

@AliE89 Thank you again

AliE89 commented 2 years ago

I cannot push my branch unfortunately to your repo. I must missing some settings... I'll attach the new file here: vtk_fortran_vtk_file_xml_writer_abstract.zip

szaghi commented 2 years ago

@AliE89 I'll merge it ASAP

Cheers

szaghi commented 2 years ago

Dear @AliE89 I have just pushed a new version (v2.0.2) that integrates your patch, thank you very much for your support.

Cheers

P.S. feel free to close this issue if your patch is enough for your goal.

AliE89 commented 2 years ago

Hi Stefano, vtk_fortran_vtk_file_xml_writer_abstract.zip

sorry really my bad. I just realized there is a bug in the file a shared with you. We need to close the after faces and faceoffsets, really missed. I attached here the correct one.

Cheers

szaghi commented 2 years ago

Hi @AliE89

thank you very much for the fix. I'll patch the library ASAP.

Cheers

AliE89 commented 2 years ago

Stefano,

I am looking at adding polygons as well to represent boundaries using polyhedral meshes. It will take a while as always but eventually I'll post it here as well.

Message ID: @.***>