vtk

89 views
Skip to first unread message

王艺康

unread,
Nov 12, 2024, 11:31:51 PM11/12/24
to deal.II User Group
Hello, everyone:
I would like to inquire if dealii can only input vtk3.0

Wolfgang Bangerth

unread,
Nov 13, 2024, 9:49:41 AM11/13/24
to dea...@googlegroups.com
On 11/12/24 21:31, 王艺康 wrote:
>
> I would like to inquire if dealii can only input vtk3.0

Hi,
Is your question whether VTK is the only possible input format for meshes, or
whether 3.0 is the only supported version for reading VTK?

The answer to the first question is of course no. Take a look at the GridIn
class to see which formats are supported. For the second question, you can
link against the VTK library and I believe that then you can read whatever
version the VTK library supports (but I'm not entirely sure about that).

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


王艺康

unread,
Nov 23, 2024, 10:35:30 PM11/23/24
to deal.II User Group
I am using gridin, read vtk file, in read_vtk to verify the line 1.2.3.4 in the vtk file, the first line must be # vtk DataFile Version 3.0, because of the update of the vtk version, I am now using the new version 5.1 to read and write, I can only write the old version # vtk DataFile Version 4.2, 4.2 and 3.0 are in the same format, when I manually change 4.2 to 3.0, dealii still reports an error, # vtk DataFile Version 3.0 is not recognized.
1.vtk

王艺康

unread,
Nov 24, 2024, 1:27:37 AM11/24/24
to deal.II User Group
When I write python and then manually write the beginning of the file, dealii reports an error


----------------------------------------------------
Exception on processing:

--------------------------------------------------------
An error occurred in line <273> of file </home/wyk/dealii-candi/tmp/unpack/deal.II-v9.5.1/source/grid/grid_in.cc> in function
    void dealii::GridIn<dim, spacedim>::read_vtk(std::istream&) [with int dim = 3; int spacedim = 3; std::istream = std::basic_istream<char>]
The violated condition was:
    subcelldata.boundary_quads.size() == 0 && subcelldata.boundary_lines.size() == 0
Additional information:
    You are trying to use functionality in deal.II that is currently not
    implemented. In many cases, this indicates that there simply didn't
    appear much of a need for it, or that the author of the original code
    did not have the time to implement a particular case. If you hit this
    exception, it is therefore worth the time to look into the code to
    find out whether you may be able to implement the missing
    functionality. If you do, please consider providing a patch to the
    deal.II development sources (see the deal.II website on how to
    contribute).

Stacktrace:
-----------
#0  /home/wyk/dealii-candi/tmp/build/deal.II-v9.5.1/lib/libdeal_II.g.so.9.5.1: dealii::GridIn<3, 3>::read_vtk(std::istream&)
#1  ./step-54: Step54::TriangulationOnCAD::run()
#2  ./step-54: main
--------------------------------------------------------

Aborting!
----------------------------------------------------
make[3]: *** [CMakeFiles/run.dir/build.make:71:CMakeFiles/run] 错误 1
make[2]: *** [CMakeFiles/Makefile2:116:CMakeFiles/run.dir/all] 错误 2
make[1]: *** [CMakeFiles/Makefile2:123:CMakeFiles/run.dir/rule] 错误 2
make: *** [Makefile:137:run] 错误 2

output.vtk

Wolfgang Bangerth

unread,
Dec 12, 2024, 1:56:45 PM12/12/24
to dea...@googlegroups.com
On 11/23/24 20:35, 王艺康 wrote:
> I am using gridin, read vtk file, in read_vtk to verify the line 1.2.3.4 in
> the vtk file, the first line must be # vtk DataFile Version 3.0, because of
> the update of the vtk version, I am now using the new version 5.1 to read and
> write, I can only write the old version # vtk DataFile Version 4.2, 4.2 and
> 3.0 are in the same format, when I manually change 4.2 to 3.0, dealii still
> reports an error, # vtk DataFile Version 3.0 is not recognized.

I am not entirely sure I understand what you are saying. Are you saying that
if you change the header to say version 3.0, deal.II still complains that only
version 3.0 is recognized? That seems unlikely.

Or are you saying that if you change the header to say that you are using
version 3.0, but the body of the file is actually following version 4.2, then
deal.II complains? That seems more likely. What you are finding is that the
file formats 3.0 and 4.2 really *are* different, and that only changing the
number at the top does not actually fix the issue that deal.II can only read
version 3.0.

You have two solutions:
(i) You find a way to convert the file into 3.0 format.
(ii) You extend the reader in GridIn::read_vtk() to also read newer VTK file
formats. Presumably, this should not be terribly difficult as long as you can
find a description of how the file format versions differ somewhere. We would
of course be happy to assist.

Best
WB
Reply all
Reply to author
Forward
0 new messages