26#ifdef DEAL_II_WITH_GMSH
28# ifdef DEAL_II_WITH_OPENCASCADE
29# include <TopoDS_Edge.hxx>
37 const double characteristic_length,
38 const std::string &output_base_name)
39 : characteristic_length(characteristic_length)
40 , output_base_name(output_base_name)
51 "Keep empty, if you want the program to generate "
52 "temporary files, and then remove them when they "
53 "are no longer used.");
58# ifdef DEAL_II_WITH_OPENCASCADE
59 template <
int spacedim>
71 char tmp_dir_name[] =
"ctfbc-XXXXXX";
74 const char *temp = mkdtemp(tmp_dir_name);
76 ExcMessage(
"Creating temporary directory failed!"));
81 const std::string iges_file_name = base_name +
".iges";
82 const std::string geo_file_name = base_name +
".geo";
83 const std::string msh_file_name = base_name +
".msh";
84 const std::string log_file_name = base_name +
".log";
85 const std::string warnings_file_name = base_name +
"_warn.log";
89 std::ofstream geofile;
90 geofile.open(geo_file_name);
91 geofile <<
"Merge \"" << iges_file_name <<
"\";" << std::endl
92 <<
"Line Loop (2) = {1};" << std::endl
93 <<
"Plane Surface (3) = {2};" << std::endl
96 <<
"Mesh.RecombineAll = 1;" << std::endl
97 <<
"Mesh.SubdivisionAlgorithm = 1;" << std::endl;
100 std::stringstream command;
102 << log_file_name <<
" 2> " << warnings_file_name;
104 const auto ret_value = std::system(command.str().c_str());
106 ExcMessage(
"Gmsh failed to run. Check the " + log_file_name +
109 std::ifstream grid_file(msh_file_name);
125 const std::array<const std::string *, 5> filenames{
130 &warnings_file_name}};
131 for (
const std::string *filename : filenames)
133 const auto ret_value = std::remove(filename->c_str());
139 const auto ret_value = std::remove(tmp_dir_name);
142 std::string(tmp_dir_name)));
148# ifdef DEAL_II_WITH_OPENCASCADE
154# include "gmsh/utilities.inst"
void add_parameters(ParameterHandler &prm)
std::string output_base_name
AdditionalParameters(const double characteristic_length=1.0, const std::string &output_base_name="")
double characteristic_length
void attach_triangulation(Triangulation< dim, spacedim > &tria)
void read_msh(std::istream &in)
void add_parameter(const std::string &entry, ParameterType ¶meter, const std::string &documentation="", const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< ParameterType >::to_pattern(), const bool has_to_be_set=false)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_GMSH_EXECUTABLE_PATH
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void create_triangulation_from_boundary_curve(const TopoDS_Edge &boundary, Triangulation< 2, spacedim > &tria, const AdditionalParameters &prm=AdditionalParameters())
void write_IGES(const TopoDS_Shape &shape, const std::string &filename)