From ee0a22d08183cb335fccbe2a9ccdeae34a803039 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Fri, 4 May 2018 20:13:31 +0200 Subject: [PATCH] Fixed comments by WB and DD. --- include/deal.II/gmsh/utilities.h | 2 +- source/gmsh/utilities.cc | 65 ++++++++++++++++++++++++-------- tests/gmsh/create_tria_02.cc | 2 +- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/include/deal.II/gmsh/utilities.h b/include/deal.II/gmsh/utilities.h index 4e3045a05d..38afe15bee 100644 --- a/include/deal.II/gmsh/utilities.h +++ b/include/deal.II/gmsh/utilities.h @@ -81,7 +81,7 @@ namespace Gmsh #ifdef DEAL_II_WITH_OPENCASCADE /** - * Given a smooth closed curve, creates a triangulation from it, using + * Given a smooth closed curve creates a triangulation from it using * Gmsh. * * The input curve @p boundary should be closed. diff --git a/source/gmsh/utilities.cc b/source/gmsh/utilities.cc index bd790dac6f..2f363bdc01 100644 --- a/source/gmsh/utilities.cc +++ b/source/gmsh/utilities.cc @@ -1,3 +1,18 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 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 at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + #include #include @@ -42,11 +57,17 @@ namespace Gmsh if (base_name == "") base_name = std::tmpnam(nullptr); - dealii::OpenCASCADE::write_IGES(boundary, base_name+".iges"); + const std::string iges_file_name = base_name+".iges"; + const std::string geo_file_name = base_name+".geo"; + const std::string msh_file_name = base_name+".msh"; + const std::string log_file_name = base_name+".log"; + const std::string warnings_file_name = base_name+"_warn.log"; + + dealii::OpenCASCADE::write_IGES(boundary, iges_file_name); ofstream geofile; - geofile.open( base_name+".geo"); - geofile << "Merge \"" << base_name << ".iges\";" << std::endl + geofile.open(geo_file_name); + geofile << "Merge \"" << iges_file_name << "\";" << std::endl << "Line Loop (2) = {1};" << std::endl << "Plane Surface (3) = {2};" << std::endl << "Characteristic Length { 1 } = " << prm.characteristic_length << ";" << std::endl @@ -55,18 +76,17 @@ namespace Gmsh geofile.close(); - // std::system("gmsh -2 -algo front3d temp_model.geo 1>temp_out.log 2>temp_warn.log"); std::stringstream command; command << DEAL_II_GMSH_EXECUTABLE_PATH << " -2 " - << base_name << ".geo 1> " - << base_name << ".log 2> " - << base_name << "_warn.log"; + << geo_file_name << " 1> " + << log_file_name << " 2> " + << warnings_file_name; - auto ret_value = std::system(command.str().c_str()); + const auto ret_value = std::system(command.str().c_str()); AssertThrow(ret_value == 0, - ExcMessage("Gmsh failed to run. Check the "+base_name+".log file.")); + ExcMessage("Gmsh failed to run. Check the "+log_file_name+" file.")); - std::ifstream grid_file(base_name+".msh"); + std::ifstream grid_file(msh_file_name); Assert(grid_file, ExcIO()); GridIn<2,spacedim> gridin; @@ -75,11 +95,26 @@ namespace Gmsh if (base_name != prm.output_base_name) { - std::remove((base_name + ".geo").c_str()); - std::remove((base_name + ".log").c_str()); - std::remove((base_name + "_warn.log").c_str()); - std::remove((base_name + ".msh").c_str()); - std::remove((base_name + ".iges").c_str()); + { + const auto ret_value = std::remove(iges_file_name.c_str()); + AssertThrow(ret_value == 0, ExcMessage("Failed to remove "+iges_file_name)); + } + { + const auto ret_value = std::remove(geo_file_name.c_str()); + AssertThrow(ret_value == 0, ExcMessage("Failed to remove "+geo_file_name)); + } + { + const auto ret_value = std::remove(msh_file_name.c_str()); + AssertThrow(ret_value == 0, ExcMessage("Failed to remove "+msh_file_name)); + } + { + const auto ret_value = std::remove(log_file_name.c_str()); + AssertThrow(ret_value == 0, ExcMessage("Failed to remove "+log_file_name)); + } + { + const auto ret_value = std::remove(warnings_file_name.c_str()); + AssertThrow(ret_value == 0, ExcMessage("Failed to remove "+warnings_file_name)); + } } } #endif diff --git a/tests/gmsh/create_tria_02.cc b/tests/gmsh/create_tria_02.cc index d75c98caa2..929bac328e 100644 --- a/tests/gmsh/create_tria_02.cc +++ b/tests/gmsh/create_tria_02.cc @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2014 - 2018 by the deal.II authors +// Copyright (C) 2018 by the deal.II authors // // This file is part of the deal.II library. // -- 2.39.5