diff --git a/.travis.yml b/.travis.yml index 9acfc0e0..76a3f553 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,8 @@ install: - git lfs pull - pip install -e .[full] - pip install -r doc/requirements.txt + # for pygmsh >= 7.0 + # - sudo apt install libglu1 script: - set -e diff --git a/doc/requirements.txt b/doc/requirements.txt index 918c12b3..11883eed 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,4 +1,4 @@ -pygmsh +pygmsh==6.1.1 seaborn sphinx sphinx-argparse diff --git a/doc/source/api/io.rst b/doc/source/api/io.rst index 2b4bc320..891ed1ed 100644 --- a/doc/source/api/io.rst +++ b/doc/source/api/io.rst @@ -8,6 +8,8 @@ Input parameters .. autofunction:: toughio.write_input +.. autofunction:: toughio.register_input + Simulation outputs ------------------ @@ -17,3 +19,5 @@ Simulation outputs .. autofunction:: toughio.read_output .. autofunction:: toughio.write_output + +.. autofunction:: toughio.register_output diff --git a/doc/source/api/mesh.rst b/doc/source/api/mesh.rst index 0a7ef762..c5cc00be 100644 --- a/doc/source/api/mesh.rst +++ b/doc/source/api/mesh.rst @@ -12,6 +12,8 @@ I/O .. autofunction:: toughio.write_mesh +.. autofunction:: toughio.register_mesh + .. autofunction:: toughio.read_time_series .. autofunction:: toughio.write_time_series diff --git a/examples/co2_leakage_along_a_fault/1_generate_mesh_in_python_with_gmsh.py b/examples/co2_leakage_along_a_fault/1_generate_mesh_in_python_with_gmsh.py index 2b432634..270fb42f 100644 --- a/examples/co2_leakage_along_a_fault/1_generate_mesh_in_python_with_gmsh.py +++ b/examples/co2_leakage_along_a_fault/1_generate_mesh_in_python_with_gmsh.py @@ -6,7 +6,7 @@ .. code-block:: bash - pip install pygmsh --user + pip install pygmsh==6.1.1 --user The mesh can also be generated from scratch directly in Gmsh either using its GUI and/or its internal scripting language. diff --git a/toughio/__about__.py b/toughio/__about__.py index 1eb94176..bd2771d9 100644 --- a/toughio/__about__.py +++ b/toughio/__about__.py @@ -1,4 +1,4 @@ -__version__ = "1.4.2" +__version__ = "1.4.3" __author__ = "Keurfon Luu" __author_email__ = "keurfonluu@lbl.gov" __website__ = "https://github.com/keurfonluu/toughio" diff --git a/toughio/__init__.py b/toughio/__init__.py index 3f14c4f6..ca5ae67b 100644 --- a/toughio/__init__.py +++ b/toughio/__init__.py @@ -11,12 +11,15 @@ read_history, read_input, read_output, + register_input, + register_output, write_input, write_output, ) from ._mesh import CellBlock, Mesh, from_meshio, from_pyvista from ._mesh import read as read_mesh from ._mesh import read_time_series +from ._mesh import register as register_mesh from ._mesh import write as write_mesh from ._mesh import write_time_series @@ -25,6 +28,9 @@ "CellBlock", "Output", "meshmaker", + "register_input", + "register_output", + "register_mesh", "read_history", "read_input", "read_output", diff --git a/toughio/_io/__init__.py b/toughio/_io/__init__.py index 556f1eee..aa97fe2c 100644 --- a/toughio/_io/__init__.py +++ b/toughio/_io/__init__.py @@ -1,12 +1,16 @@ from .input import read as read_input +from .input import register as register_input from .input import write as write_input from .output import Output from .output import read as read_output from .output import read_history +from .output import register as register_output from .output import write as write_output __all__ = [ "Output", + "register_input", + "register_output", "read_input", "write_input", "read_output", diff --git a/toughio/_io/input/__init__.py b/toughio/_io/input/__init__.py index f2ec4105..e4b9e1a7 100644 --- a/toughio/_io/input/__init__.py +++ b/toughio/_io/input/__init__.py @@ -1,7 +1,8 @@ from . import json, tough -from ._helpers import read, write +from ._helpers import read, register, write __all__ = [ + "register", "read", "write", ] diff --git a/toughio/_io/input/_helpers.py b/toughio/_io/input/_helpers.py index d98047ad..2c7b2219 100644 --- a/toughio/_io/input/_helpers.py +++ b/toughio/_io/input/_helpers.py @@ -1,6 +1,7 @@ from ..._common import filetype_from_filename, register_format __all__ = [ + "register", "read", "write", ] @@ -12,7 +13,21 @@ def register(file_format, extensions, reader, writer=None): - """Register a new format.""" + """ + Register a new input format. + + Parameters + ---------- + file_format : str + File format to register. + extensions : array_like + List of extensions to associate to the new format. + reader : callable + Read fumction. + writer : callable or None, optional, default None + Write function. + + """ register_format( fmt=file_format, ext_to_fmt=_extension_to_filetype, diff --git a/toughio/_io/output/__init__.py b/toughio/_io/output/__init__.py index e84cd33f..9dd04a09 100644 --- a/toughio/_io/output/__init__.py +++ b/toughio/_io/output/__init__.py @@ -1,9 +1,10 @@ from . import csv, petrasim, save, tecplot, tough from ._common import Output -from ._helpers import read, read_history, write +from ._helpers import read, read_history, register, write __all__ = [ "Output", + "register", "read", "write", "read_history", diff --git a/toughio/_io/output/_helpers.py b/toughio/_io/output/_helpers.py index d247a1d8..cb6c0dd2 100644 --- a/toughio/_io/output/_helpers.py +++ b/toughio/_io/output/_helpers.py @@ -6,6 +6,7 @@ from ._common import Output __all__ = [ + "register", "read", "write", "read_history", @@ -18,7 +19,21 @@ def register(file_format, extensions, reader, writer=None): - """Register a new format.""" + """ + Register a new output format. + + Parameters + ---------- + file_format : str + File format to register. + extensions : array_like + List of extensions to associate to the new format. + reader : callable + Read fumction. + writer : callable or None, optional, default None + Write function. + + """ register_format( fmt=file_format, ext_to_fmt=_extension_to_filetype, diff --git a/toughio/_mesh/__init__.py b/toughio/_mesh/__init__.py index c5af21c0..2ca37257 100644 --- a/toughio/_mesh/__init__.py +++ b/toughio/_mesh/__init__.py @@ -1,10 +1,11 @@ import meshio from . import avsucd, flac3d, pickle, tecplot, tough -from ._helpers import read, read_time_series, write, write_time_series +from ._helpers import read, read_time_series, register, write, write_time_series from ._mesh import CellBlock, Mesh, from_meshio, from_pyvista __all__ = [ + "register", "read", "write", "read_time_series", diff --git a/toughio/_mesh/_helpers.py b/toughio/_mesh/_helpers.py index 92660cdd..08e3f478 100644 --- a/toughio/_mesh/_helpers.py +++ b/toughio/_mesh/_helpers.py @@ -7,6 +7,7 @@ from ._mesh import from_meshio __all__ = [ + "register", "read", "write", "read_time_series", @@ -21,7 +22,23 @@ def register(file_format, extensions, reader, writer=None, material=None): - """Register a new format.""" + """ + Register a new mesh format. + + Parameters + ---------- + file_format : str + File format to register. + extensions : array_like + List of extensions to associate to the new format. + reader : callable + Read fumction. + writer : callable or None, optional, default None + Write function. + material : str or None, optional, default None + Cell data key associated to material. + + """ register_format( fmt=file_format, ext_to_fmt=_extension_to_filetype,