Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated points (nodes) in exported VTU file, no connectivity used? #861

Closed
lamBOOO opened this issue Jan 17, 2023 · 3 comments
Closed

Comments

@lamBOOO
Copy link

lamBOOO commented Jan 17, 2023

I noticed that the number of nodes printed by gmsh (when reading a .msh-file for example) doesn't match the "number of points" displayed in Paraview's information tab. The same behavior happens if we use the built-in CartesianDiscreteModel.

The below code shows, that exporting a (2,2)-quad triangulated unit square leads to a VTU file, which has some nodes duplicated. Instead of the required 9 nodes (see attached image), we get 16 nodes.

I think that instead of using connectivity information, the writevtk(Ω, "trian")-function simply places every element inside the "world". In contrast to this, the writevtk(model, "model") works as expected.

Is this behavior intended? Couldn't we save a lot of memory by using the connectivity information as well and not writing nodes multiple times?

Or do I have a fundamental error in thinking about unstructured meshes? 😄

using Gridap
domain = (0, 1, 0, 1)
partition = (2, 2)
model = CartesianDiscreteModel(domain, partition)
reffe = ReferenceFE(lagrangian, Float64, 1)
V = TestFESpace(model, reffe)
Ω = Triangulation(model)
f = interpolate(x->x[1] + x[2], V)
writevtk(Ω, "trian")
writevtk(model, "model")

using ReadVTK
readtrian = VTKFile("trian.vtu")
readmodel = VTKFile("model_2.vtu")

get_points(readmodel)
# 3×9 reshape(reinterpret(Float64, view(::Vector{UInt8}, 9:224)), 3, 9) with eltype Float64:
#  0.0  0.5  1.0  0.0  0.5  1.0  0.0  0.5  1.0
#  0.0  0.0  0.0  0.5  0.5  0.5  1.0  1.0  1.0
#  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0

get_points(readtrian)
# 3×16 reshape(reinterpret(Float64, view(::Vector{UInt8}, 9:392)), 3, 16) with eltype Float64:
#  0.0  0.5  0.0  0.5  0.5  1.0  0.5  1.0  0.0  0.5  0.0  0.5  0.5  1.0  0.5  1.0
#  0.0  0.0  0.5  0.5  0.0  0.0  0.5  0.5  0.5  0.5  1.0  1.0  0.5  0.5  1.0  1.0
#  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0

# FIXME: The triangulation VTU has duplicated points, is this intended?

I use Julia 1.8.2 and Gridap 0.17.16.

Screenshot 2023-01-17 at 20 45 33

@oriolcg
Copy link
Member

oriolcg commented Jan 17, 2023

I think this is an intended behavior as it enables, for instance, displaying discontinuous fields.

@lamBOOO
Copy link
Author

lamBOOO commented Jan 18, 2023

Thank you. Yes, good point, I was not thinking about discontinuous fields. 🤔

@fverdugo
Copy link
Member

Yes, the visualization grid is indeed independent from the interpolation grid. This provides extra flexibility (e.e. discontinuous fields).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants