diff --git a/meshmode/mesh/io.py b/meshmode/mesh/io.py index 49e816f84940d4f765703a8adc53ff327e3e69a8..daaaa178695e0bb981fc551ae0137af4febf3c67 100644 --- a/meshmode/mesh/io.py +++ b/meshmode/mesh/io.py @@ -291,7 +291,8 @@ def read_gmsh(filename, force_ambient_dim=None, mesh_construction_kwargs=None): def generate_gmsh(source, dimensions=None, order=None, other_options=[], extension="geo", gmsh_executable="gmsh", force_ambient_dim=None, - output_file_name="output.msh", mesh_construction_kwargs=None): + output_file_name="output.msh", keep_tmp_dir=False, overwrite_tmp_files=True, + mesh_construction_kwargs=None): """Run :command:`gmsh` on the input given by *source*, and return a :class:`meshmode.mesh.Mesh` based on the result. @@ -299,16 +300,28 @@ def generate_gmsh(source, dimensions=None, order=None, other_options=[], :class:`LiteralSource` :arg force_ambient_dim: if not None, truncate point coordinates to this many dimensions. + :arg keep_tmp_dir: If set to True, the temporary files produced during + mesh generation will be kept under the current working directory. :arg mesh_construction_kwargs: *None* or a dictionary of keyword arguments passed to the :class:`meshmode.mesh.Mesh` constructor. """ recv = GmshMeshReceiver(mesh_construction_kwargs=mesh_construction_kwargs) + if isinstance(keep_tmp_dir, str): + tmp_files_dir = keep_tmp_dir + elif keep_tmp_dir: + tmp_files_dir = "./gmsh_tmp" + else: + tmp_files_dir = None + from gmsh_interop.runner import GmshRunner from gmsh_interop.reader import parse_gmsh with GmshRunner(source, dimensions, order=order, other_options=other_options, extension=extension, - gmsh_executable=gmsh_executable) as runner: + gmsh_executable=gmsh_executable, + output_file_name=output_file_name, + save_tmp_files_in=tmp_files_dir, + overwrite_tmp_files=overwrite_tmp_files) as runner: parse_gmsh(recv, runner.output_file, force_dimension=force_ambient_dim)