Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap for shp2msh and msh2vtu #66

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions tools/msh2vtu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<tool id="msh2vtu" name="GMSH_To_VTU_Converter" version="0.1.0+galaxy0" python_template_version="3.5" profile="21.05">
<description>
Convert GMSH mesh files to VTU format using various options for mesh processing.
</description>
<requirements>
<requirement type="package" version="3.6">python</requirement>
<requirement type="package" version="0.5">meshio</requirement>
<requirement type="package" version="0.1">numpy</requirement>
<requirement type="package" version="0.1">ogs</requirement>
</requirements>
<command detect_errors="exit_code"><![CDATA[
ln -s '$input_file' input_file.msh &&
msh2vtu input_file.msh
-p '$prefix'
-d '$dim'
#if $delz == "true"
-z
#end if
#if $swapxy == "true"
-s
#end if
#if $reindex == "true"
-r
#end if
#if $keep_ids == "true"
-k
#end if
#if $ascii == "true"
-a
#end if
-l '$log_level'
]]></command>
<inputs>
<param name="input_file" type="data" format="GMSH" label="Input GMSH File"/>
<param name="prefix" type="text" label="Filename Prefix" argument="-p">
<validator type="regex">^(?!.*[\u003C\u003E])[a-zA-Z0-9_]+$</validator>
</param>
<param name="dim" type="select" label="Mesh Dimension" argument="-d">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</param>
<param name="delz" type="boolean" value="false" label="Delete Z Coordinate" optional="true" argument="-z"/>
<param name="swapxy" type="boolean" value="false" label="Swap XY Coordinates" optional="true" argument="-s"/>
<param name="reindex" type="boolean" value="false" label="Reindex" optional="true" argument="-r"/>
<param name="keep_ids" type="boolean" value="false" label="Keep IDs" optional="true" argument="-k"/>
<param name="ascii" type="boolean" value="false" label="ASCII Output" optional="true" argument="-a"/>
<param name="log_level" type="select" value="DEBUG" label="Log Level" argument="-l">
<option value="DEBUG">DEBUG</option>
<option value="INFO">INFO</option>
<option value="WARNING">WARNING</option>
<option value="ERROR">ERROR</option>
</param>
</inputs>
<outputs>
<data name="output_data" format="vtu" label="Output vtu file" />
</outputs>
<tests>
<test>
<param name="input_file" value="/home/stehling/.venv/lib/python3.10/site-packages/ogstools/msh2vtu/test-data/geolayers_2d.msh"/>
<param name="prefix" value="test"/>
<param name="dim" value="3"/>
<param name="delz" value="False"/>
<param name="swapxy" value="False"/>
<param name="reindex" value="False"/>
<param name="keep_ids" value="False"/>
<param name="ascii" value="True"/>
<param name="log_level" value="DEBUG"/>
<output name="output_data" file="test_output.vtu"/>
</test>
</tests>
<help><![CDATA[
**Overview:**

This Galaxy tool converts GMSH mesh files (`*.msh`) into VTU format (`*.vtu`) using the OpenGeoSys (OGS) utility. The tool offers several options for mesh processing, such as deleting the Z coordinate, swapping XY coordinates, reindexing nodes, and keeping original IDs.

**Inputs:**

1. **Input GMSH File:** The GMSH mesh file to be converted.
2. **Output Path:** (Optional) Specify the output path where the VTU file will be saved. If not specified, the current working directory is used.
3. **Filename Prefix:** Prefix to be added to the output filename.
4. **Mesh Dimension (dim):** Select the desired mesh dimension (0, 1, 2, or 3). Default is `0`.
5. **Delete Z Coordinate (delz):** Boolean flag to remove the Z coordinate from the mesh. Set to `True` to enable.
6. **Swap XY Coordinates (swapxy):** Boolean flag to swap the X and Y coordinates. Set to `True` to enable.
7. **Reindex:** Boolean flag to reindex the nodes. Set to `True` to enable.
8. **Keep IDs:** Boolean flag to keep the original node and cell IDs. Set to `True` to enable.
9. **ASCII Output:** Boolean flag to output the file in ASCII format instead of binary. Set to `True` to enable.
10. **Log Level:** Set the level of logging details (DEBUG, INFO, WARNING, ERROR). Default is `DEBUG`.

**Outputs:**

- **Output VTU File:** The converted mesh file in VTU format.

**Usage Notes:**

- This tool requires that the input file is in GMSH format (`*.msh`).
- The resulting output will be a VTU file (`*.vtu`) that can be used with visualization tools and other software supporting the VTU format.
- The output directory must be writable; otherwise, the tool will fail to save the output file.
]]></help>
<citations>
<citation type="doi">10.5281/zenodo.13685289</citation>
</citations>
</tool>
20 changes: 20 additions & 0 deletions tools/ogs_tools/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: suite_ogs_tools
owner: ufz
description: Convert GMSH mesh files to VTU format using various options for mesh processing.
long_description: |
This Galaxy tool converts GMSH mesh files (`*.msh`) into VTU format (`*.vtu`) using the OpenGeoSys (OGS) utility.
The tool offers several options for mesh processing, such as deleting the Z coordinate, swapping XY coordinates, reindexing nodes, and keeping original IDs.
categories:
- Ecology
remote_repository_url: https://gitlab.opengeosys.org/ogs/tools/ogstools
homepage_url: https://www.opengeosys.org/
type: unrestricted
auto_tool_repositories:
name_template: "{{ tool_id }}"
description_template: "Wrapper for bankfull discharge calculation function: {{ tool_name }}."
suite:
name: suite_ogs_tools
description: Convert GMSH mesh files to VTU format using various options for mesh processing.
long_description: |
This Galaxy tool converts GMSH mesh files (`*.msh`) into VTU format (`*.vtu`) using the OpenGeoSys (OGS) utility.
The tool offers several options for mesh processing, such as deleting the Z coordinate, swapping XY coordinates, reindexing nodes, and keeping original IDs.
48 changes: 48 additions & 0 deletions tools/ogs_tools/shp2msh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<tool id="shp2msh" name="shp2msh_converter" version="0.1.0+galaxy0" python_template_version="3.5" profile="21.05">
<requirements>
<requirement type="package" version="0.0.3">ogstools</requirement>
</requirements>
<command detect_errors="exit_code"><![CDATA[
export SHAPE_RESTORE_SHX=YES &&
ln -s '$input_shp' input.shp &&
cat input.shx > /home/stehling/ogs_tools/content_of_input.txt &&
shp2msh --input input.shp --output output.vtu
#if str($cellsize)!="":
--cellsize '$cellsize'
#end if
'$meshing'
'$simplify'
]]></command>
<inputs>
<param name="input_shp" type="data" format="shp" label="shp input data" argument="-i"/>
<param name="cellsize" type="float" min="40" optional="true" label="cellsize" argument="-c"/>
<param name="meshing" type="select" label="meshing">
<option value="triangle" selected="true">Triangle</option>
<option value="gmsh">Gmsh</option>
</param>
<param name="simplify" type="select" label="simplify">
<option value="simplified">Simplified</option>
<option value="original" selected="true">Original</option>
</param>
</inputs>
<outputs>
<data name="output" format="xml" label="output_data"/>
</outputs>
<tests>
<test>
<param name="input_shp" value="/home/stehling/ogs_tools/test-data/circle.shp"/>
<param name="cellsize" value="500.0"/>
<param name="meshing" value= "triangle"/>
<param name="simplify" value="simplified"/>
<output name="output" value="output.vtu"/>
</test>
</tests>
<help><![CDATA[
This tool takes a shapefile as input and creates a mesh using either the Triangle or GMSH method.
The cellsize can be optionally specified, and the shapefile can be simplified before meshing.
Output data has the format .vtu/ .vtk.
]]></help>
<citations>
<citation type="doi">10.5281/zenodo.13685289</citation>
</citations>
</tool>
Binary file added tools/ogs_tools/test-data/circle.shp
Binary file not shown.
Binary file added tools/ogs_tools/test-data/circle.shx
Binary file not shown.
Loading
Loading