From 7de967774bdcf92a683baa41ac27a36a4ccadc2f Mon Sep 17 00:00:00 2001 From: Jaewook Lee Date: Tue, 23 Apr 2024 18:51:18 +0200 Subject: [PATCH] fname then mesh for io --- gustaf/io/meshio.py | 9 +++++---- gustaf/io/mfem.py | 4 ++-- gustaf/io/mixd.py | 2 +- gustaf/io/nutils.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/gustaf/io/meshio.py b/gustaf/io/meshio.py index ad66e6ebc..c2706ae48 100644 --- a/gustaf/io/meshio.py +++ b/gustaf/io/meshio.py @@ -84,7 +84,7 @@ def load(fname): return meshes[0] if len(meshes) == 1 else meshes -def export(mesh, fname, submeshes=None, **kwargs): +def export(fname, mesh, submeshes=None, **kwargs): """Export mesh elements and vertex data into meshio and use its write function. The definition of submeshes with identical vertex coordinates is possible. In that case vertex numbering and data from the main mesh @@ -132,10 +132,10 @@ def export(mesh, fname, submeshes=None, **kwargs): Parameters ------------ - mesh: Edges, Faces or Volumes - Input mesh fname: Union[str, pathlib.Path] File to save the mesh in. + mesh: Edges, Faces or Volumes + Input mesh submeshes: Iterable Submeshes where the vertices are identical to the main mesh. The element type can be identical to mesh.elements or lower-dimensional (e.g. @@ -164,7 +164,8 @@ def export(mesh, fname, submeshes=None, **kwargs): cells = [] # Merge main mesh and submeshes in one list - meshes = [mesh] + meshes = mesh if isinstance(mesh, list) else [mesh] + if submeshes is not None: meshes.extend(submeshes) diff --git a/gustaf/io/mfem.py b/gustaf/io/mfem.py index 1b38ac711..c4ca9e890 100644 --- a/gustaf/io/mfem.py +++ b/gustaf/io/mfem.py @@ -107,15 +107,15 @@ def extract_values(fname, start_index, n_lines, total_lines, dtype): return mesh -def export(mesh, fname): +def export(fname, mesh): """Export mesh in MFEM format. Supports 2D triangle and quadrilateral meshes. Does not support different element attributes or difference in vertex dimension and mesh dimension. Parameters ------------ - mesh: Faces fname: str + mesh: Faces Returns ------------ diff --git a/gustaf/io/mixd.py b/gustaf/io/mixd.py index 60025d8dc..e873e54ce 100644 --- a/gustaf/io/mixd.py +++ b/gustaf/io/mixd.py @@ -116,8 +116,8 @@ def load( def export( - mesh, fname, + mesh, space_time=False, dual=False, ): diff --git a/gustaf/io/nutils.py b/gustaf/io/nutils.py index b5915c462..f12d359e2 100644 --- a/gustaf/io/nutils.py +++ b/gustaf/io/nutils.py @@ -61,14 +61,14 @@ def load(fname): return mesh -def export(mesh, fname): +def export(fname, mesh): """Export in Nutils format. Files are saved as np.savez(). Supports triangle,and tetrahedron Meshes. Parameters ----------- - mesh: Faces or Volumes fname: str + mesh: Faces or Volumes Returns --------