From: Luca Heltai Date: Sun, 20 Feb 2022 08:40:15 +0000 (+0000) Subject: Fixed bug in gmsh api. X-Git-Tag: v9.4.0-rc1~461^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bea0fdd579155faae337ecf41ce9cc27196ebe9;p=dealii.git Fixed bug in gmsh api. --- diff --git a/doc/news/changes/minor/20220220LucaHeltai b/doc/news/changes/minor/20220220LucaHeltai new file mode 100644 index 0000000000..bd30c7c87c --- /dev/null +++ b/doc/news/changes/minor/20220220LucaHeltai @@ -0,0 +1,3 @@ +Fixed: GridOut::write_msh() with gmsh api now works also with non standard combinations of boundary and manifold ids. +
+(Luca Heltai, 2022/02/20) diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index a08cf304aa..6296ea4491 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -1595,10 +1595,6 @@ GridOut::write_msh(const Triangulation &tria, all_element_nodes); } - // Make sure nodes belong to the right entities. - gmsh::model::mesh::reclassifyNodes(); - gmsh::model::mesh::removeDuplicateNodes(); - // Now for each individual pair of dim and entry, add a physical group, if // necessary for (const auto &it : dim_entity_tag) diff --git a/tests/gmsh/gmsh_api_05.cc b/tests/gmsh/gmsh_api_05.cc new file mode 100644 index 0000000000..aec31c2e7e --- /dev/null +++ b/tests/gmsh/gmsh_api_05.cc @@ -0,0 +1,66 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2021 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + +// Check that gmsh api correctly reads and writes a mesh with manifold +// information, in all coordinate dimensions + +#include +#include +#include +#include +#include + +#include "../tests.h" + +template +void +test() +{ + deallog << "Testing hypercube in dimensions " << '<' << dim << ',' << spacedim + << '>' << std::endl; + + Triangulation tria; + GridGenerator::hyper_cube(tria, 0, 1, true); + tria.begin()->face(0)->set_manifold_id(1); + + GridOut go; + go.write_msh(tria, "output.msh"); + + Triangulation tria2; + GridIn gi(tria2); + gi.read_msh("output.msh"); + go.write_msh(tria2, "output2.msh"); + + deallog << "Original mesh: " << std::endl; + cat_file("output.msh"); + deallog << "Regenerated mesh: " << std::endl; + cat_file("output2.msh"); +} + +int +main() +{ + initlog(); + + // Generate and print all hypercubes in all dimension combinations + test<1, 1>(); + test<1, 2>(); + test<1, 3>(); + + test<2, 2>(); + test<2, 3>(); + + test<3, 3>(); +} diff --git a/tests/gmsh/gmsh_api_05.with_gmsh_with_api=on.output b/tests/gmsh/gmsh_api_05.with_gmsh_with_api=on.output new file mode 100644 index 0000000000..7e79e16f60 --- /dev/null +++ b/tests/gmsh/gmsh_api_05.with_gmsh_with_api=on.output @@ -0,0 +1,870 @@ + +DEAL::Testing hypercube in dimensions <1,1> +DEAL::Original mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +2 +0 1 "ManifoldID:1" +0 2 "BoundaryID:1" +$EndPhysicalNames +$Entities +2 1 0 0 +1 0 0 0 1 1 +3 0 0 0 1 2 +2 0 0 0 1 0 0 1 3 0 +$EndEntities +$Nodes +3 6 1 2 +0 1 0 2 +1 +2 +0 0 0 +1 0 0 +0 3 0 2 +1 +2 +0 0 0 +1 0 0 +1 2 0 2 +1 +2 +0 0 0 +1 0 0 +$EndNodes +$Elements +1 1 1 1 +1 2 1 1 +1 1 2 +$EndElements + +DEAL::Regenerated mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +1 +0 1 "BoundaryID:1" +$EndPhysicalNames +$Entities +1 1 0 0 +2 0 0 0 1 1 +1 0 0 0 1 0 0 1 2 0 +$EndEntities +$Nodes +2 4 1 2 +0 2 0 2 +1 +2 +0 0 0 +1 0 0 +1 1 0 2 +1 +2 +0 0 0 +1 0 0 +$EndNodes +$Elements +1 1 1 1 +1 1 1 1 +1 1 2 +$EndElements + +DEAL::Testing hypercube in dimensions <1,2> +DEAL::Original mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +2 +0 1 "ManifoldID:1" +0 2 "BoundaryID:1" +$EndPhysicalNames +$Entities +2 1 0 0 +1 0 0 0 1 1 +3 0 0 0 1 2 +2 0 0 0 1 0 0 1 3 0 +$EndEntities +$Nodes +3 6 1 2 +0 1 0 2 +1 +2 +0 0 0 +1 0 0 +0 3 0 2 +1 +2 +0 0 0 +1 0 0 +1 2 0 2 +1 +2 +0 0 0 +1 0 0 +$EndNodes +$Elements +1 1 1 1 +1 2 1 1 +1 1 2 +$EndElements + +DEAL::Regenerated mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +1 +0 1 "BoundaryID:1" +$EndPhysicalNames +$Entities +1 1 0 0 +2 0 0 0 1 1 +1 0 0 0 1 0 0 1 2 0 +$EndEntities +$Nodes +2 4 1 2 +0 2 0 2 +1 +2 +0 0 0 +1 0 0 +1 1 0 2 +1 +2 +0 0 0 +1 0 0 +$EndNodes +$Elements +1 1 1 1 +1 1 1 1 +1 1 2 +$EndElements + +DEAL::Testing hypercube in dimensions <1,3> +DEAL::Original mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +2 +0 1 "ManifoldID:1" +0 2 "BoundaryID:1" +$EndPhysicalNames +$Entities +2 1 0 0 +1 0 0 0 1 1 +3 0 0 0 1 2 +2 0 0 0 1 0 0 1 3 0 +$EndEntities +$Nodes +3 6 1 2 +0 1 0 2 +1 +2 +0 0 0 +1 0 0 +0 3 0 2 +1 +2 +0 0 0 +1 0 0 +1 2 0 2 +1 +2 +0 0 0 +1 0 0 +$EndNodes +$Elements +1 1 1 1 +1 2 1 1 +1 1 2 +$EndElements + +DEAL::Regenerated mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +1 +0 1 "BoundaryID:1" +$EndPhysicalNames +$Entities +1 1 0 0 +2 0 0 0 1 1 +1 0 0 0 1 0 0 1 2 0 +$EndEntities +$Nodes +2 4 1 2 +0 2 0 2 +1 +2 +0 0 0 +1 0 0 +1 1 0 2 +1 +2 +0 0 0 +1 0 0 +$EndNodes +$Elements +1 1 1 1 +1 1 1 1 +1 1 2 +$EndElements + +DEAL::Testing hypercube in dimensions <2,2> +DEAL::Original mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +4 +1 1 "ManifoldID:1" +1 2 "BoundaryID:1" +1 3 "BoundaryID:2" +1 4 "BoundaryID:3" +$EndPhysicalNames +$Entities +0 4 1 0 +1 0 0 0 0 1 0 1 1 0 +3 1 0 0 1 1 0 1 2 0 +4 0 0 0 1 0 0 1 3 0 +5 0 1 0 1 1 0 1 4 0 +2 0 0 0 1 1 0 1 5 0 +$EndEntities +$Nodes +5 20 1 4 +1 1 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 3 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 4 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 5 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +2 2 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +$EndNodes +$Elements +5 5 1 5 +1 1 1 1 +2 1 3 +1 3 1 1 +3 2 4 +1 4 1 1 +4 1 2 +1 5 1 1 +5 3 4 +2 2 3 1 +1 1 2 4 3 +$EndElements + +DEAL::Regenerated mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +4 +1 1 "ManifoldID:1" +1 2 "BoundaryID:1" +1 3 "BoundaryID:2" +1 4 "BoundaryID:3" +$EndPhysicalNames +$Entities +0 4 1 0 +1 0 0 0 0 1 0 1 1 0 +3 1 0 0 1 1 0 1 2 0 +4 0 0 0 1 0 0 1 3 0 +5 0 1 0 1 1 0 1 4 0 +2 0 0 0 1 1 0 1 5 0 +$EndEntities +$Nodes +5 20 1 4 +1 1 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 3 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 4 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 5 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +2 2 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +$EndNodes +$Elements +5 5 1 5 +1 1 1 1 +2 1 3 +1 3 1 1 +3 2 4 +1 4 1 1 +4 1 2 +1 5 1 1 +5 3 4 +2 2 3 1 +1 1 2 4 3 +$EndElements + +DEAL::Testing hypercube in dimensions <2,3> +DEAL::Original mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +4 +1 1 "ManifoldID:1" +1 2 "BoundaryID:1" +1 3 "BoundaryID:2" +1 4 "BoundaryID:3" +$EndPhysicalNames +$Entities +0 4 1 0 +1 0 0 0 0 1 0 1 1 0 +3 1 0 0 1 1 0 1 2 0 +4 0 0 0 1 0 0 1 3 0 +5 0 1 0 1 1 0 1 4 0 +2 0 0 0 1 1 0 1 5 0 +$EndEntities +$Nodes +5 20 1 4 +1 1 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 3 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 4 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 5 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +2 2 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +$EndNodes +$Elements +5 5 1 5 +1 1 1 1 +2 1 3 +1 3 1 1 +3 2 4 +1 4 1 1 +4 1 2 +1 5 1 1 +5 3 4 +2 2 3 1 +1 1 2 4 3 +$EndElements + +DEAL::Regenerated mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +4 +1 1 "ManifoldID:1" +1 2 "BoundaryID:1" +1 3 "BoundaryID:2" +1 4 "BoundaryID:3" +$EndPhysicalNames +$Entities +0 4 1 0 +1 0 0 0 0 1 0 1 1 0 +3 1 0 0 1 1 0 1 2 0 +4 0 0 0 1 0 0 1 3 0 +5 0 1 0 1 1 0 1 4 0 +2 0 0 0 1 1 0 1 5 0 +$EndEntities +$Nodes +5 20 1 4 +1 1 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 3 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 4 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +1 5 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +2 2 0 4 +1 +2 +3 +4 +0 0 0 +1 0 0 +0 1 0 +1 1 0 +$EndNodes +$Elements +5 5 1 5 +1 1 1 1 +2 1 3 +1 3 1 1 +3 2 4 +1 4 1 1 +4 1 2 +1 5 1 1 +5 3 4 +2 2 3 1 +1 1 2 4 3 +$EndElements + +DEAL::Testing hypercube in dimensions <3,3> +DEAL::Original mesh: +$MeshFormat +4.1 0 8 +$EndMeshFormat +$PhysicalNames +6 +2 1 "ManifoldID:1" +2 2 "BoundaryID:1" +2 3 "BoundaryID:2" +2 4 "BoundaryID:3" +2 5 "BoundaryID:4" +2 6 "BoundaryID:5" +$EndPhysicalNames +$Entities +0 0 6 1 +1 0 0 0 0 1 1 1 1 0 +3 1 0 0 1 1 1 1 2 0 +4 0 0 0 1 0 1 1 3 0 +5 0 1 0 1 1 1 1 4 0 +6 0 0 0 1 1 0 1 5 0 +7 0 0 1 1 1 1 1 6 0 +2 0 0 0 1 1 1 1 7 0 +$EndEntities +$Nodes +7 56 1 8 +2 1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