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 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 27 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
18 changes: 18 additions & 0 deletions tools/ogstools/Converter/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: suite_ogs_tools
owner: ufz
description: A suite of tools for OpenGeoSys (ogs)
long_description: |
A suite of tools for ogs.
categories:
- Ecology
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to find a fitting category. I'm going to ask Lars.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: A suite of tools for OpenGeoSys (ogs)
suite:
name: suite_ogs_tools
description: A suite of tools for ogs.
long_description: |
A suite of tools for ogs.
23 changes: 23 additions & 0 deletions tools/ogstools/Converter/macros.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<macros>
<token name="@TOOL_VERSION@">0.4.0</token>
<token name="@PROFILE@">23.0</token>
<token name="@VERSION_SUFFIX@">0</token>

<xml name="ogs_requirement">
<requirement type="package" version="@TOOL_VERSION@">ogstools</requirement>
<yield/>

</xml>
bernt-matthias marked this conversation as resolved.
Show resolved Hide resolved

<xml name="ogs_citation">
<citations>
<citation type="doi">10.5281/zenodo.13685289</citation>
</citations>
</xml>

<xml name="creator">
<creator>
<organization name="Helmholtz Centre for Environmental Research - UFZ" url ="https://www.ufz.de/"/>
</creator>
</xml>
</macros>
99 changes: 99 additions & 0 deletions tools/ogstools/Converter/msh2vtu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@

<tool id="msh2vtu" name="ogstools msh2vtu" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
<description>
Convert msh to UnstructuredGrid (vtk)
</description>
<macros>
<import>macros.xml</import>
<token name="@VERSION_SUFFIX@">0</token>
</macros>
<expand macro="creator"/>
<requirements>
bernt-matthias marked this conversation as resolved.
Show resolved Hide resolved
bernt-matthias marked this conversation as resolved.
Show resolved Hide resolved
<expand macro="ogs_requirement"/>
</requirements>
bernt-matthias marked this conversation as resolved.
Show resolved Hide resolved
<command detect_errors="exit_code"><![CDATA[
ln -s '$input_file' input_file.msh &&
msh2vtu input_file.msh
-d '$dim'
$delz $swapxy $reindex $keep_ids $ascii
-l '$log_level'
]]></command>
<inputs>
<param name="input_file" type="data" format="GMSH" label="Input GMSH File"/>
<param name="dim" type="select" label="Set dimensionality of the mesh" argument="-d">
<option value="1">1D</option>
<option value="2">2D</option>
<option value="3">3D</option>
</param>
<param name="delz" type="boolean" value="false" truevalue="-z" falsevalue="" label="Delete Z Coordinate" optional="true" argument="-z"/>
<param name="swapxy" type="boolean" value="false" truevalue="-s" falsevalue="" label="Swap XY Coordinates" optional="true" argument="-s"/>
<param name="reindex" type="boolean" value="false" truevalue="-r" falsevalue="" label="Reindex" optional="true" argument="-r"/>
<param name="keep_ids" type="boolean" value="false" truevalue="-k" falsevalue="" label="Keep IDs" optional="true" argument="-k"/>
<param name="ascii" type="boolean" value="false" truevalue="-a" falsevalue="" label="ASCII Output" optional="true" argument="-a"/>
<param name="log_level" type="select" label="Log Level" argument="-l">
<option value="ERROR" selected="true">ERROR</option>
<option value="DEBUG">DEBUG</option>
<option value="INFO">INFO</option>
<option value="WARNING">WARNING</option>
</param>
</inputs>
<outputs>
<data name="boundary" format="xml" label="${tool.name}: boundary" from_work_dir="input_file_boundary.vtu" />
<data name="domain" format="xml" label="${tool.name}: domain" from_work_dir="input_file_domain.vtu" />
<data name="physical_group_Bottom" format="xml" label="${tool.name}: physical_group_Bottom" from_work_dir="input_file_physical_group_Bottom.vtu" />
<data name="physical_group_Left" format="xml" label="${tool.name}: physical_group_Left" from_work_dir="input_file_physical_group_Left.vtu" />
<data name="physical_group_Right" format="xml" label="${tool.name}: physical_group_Right" from_work_dir="input_file_physical_group_Right.vtu" />
<data name="physical_group_RockBed" format="xml" label="${tool.name}: physical_group_RockBed" from_work_dir="input_file_physical_group_RockBed.vtu" />
<data name="physical_group_SedimentLayer1" format="xml" label="${tool.name}: physical_group_SedimentLayer1" from_work_dir="input_file_physical_group_SedimentLayer1.vtu" />
<data name="physical_group_SedimentLayer2" format="xml" label="${tool.name}: physical_group_SedimentLayer2" from_work_dir="input_file_physical_group_SedimentLayer2.vtu" />
<data name="physical_group_SedimentLayer3" format="xml" label="${tool.name}: physical_group_SedimentLayer3" from_work_dir="input_file_physical_group_SedimentLayer3.vtu" />
<data name="physical_group_Top" format="xml" label="${tool.name}: physical_group_Top" from_work_dir="input_file_physical_group_Top.vtu" />
</outputs>
<tests>
<test>
<param name="input_file" value="geolayers_2d.msh"/>
<param name="dim" value="2"/>
<param name="delz" value="True"/>
<param name="swapxy" value="True"/>
<param name="reindex" value="True"/>
<param name="keep_ids" value="True"/>
<param name="ascii" value="True"/>
<param name="log_level" value="DEBUG"/>
<output name="boundary" file="input_file_boundary.vtu"/>
<output name="domain" file="input_file_domain.vtu"/>
<output name="physical_group_Bottom" file="input_file_physical_group_Bottom.vtu"/>
<output name="physical_group_Left" file="input_file_physical_group_Left.vtu"/>
<output name="physical_group_Right" file="input_file_physical_group_Right.vtu"/>
<output name="physical_group_RockBed" file="input_file_physical_group_RockBed.vtu"/>
<output name="physical_group_SedimentLayer1" file="input_file_physical_group_SedimentLayer1.vtu"/>
<output name="physical_group_SedimentLayer2" file="input_file_physical_group_SedimentLayer2.vtu"/>
<output name="physical_group_SedimentLayer3" file="input_file_physical_group_SedimentLayer3.vtu"/>
<output name="physical_group_Top" file="input_file_physical_group_Top.vtu"/>
</test>
</tests>
<help><![CDATA[
**Overview:**

msh2vtu is a application that converts a Gmsh (.msh) file for use in OGS by extracting domain-, boundary- and physical group-submeshes and saves them in a set of files in the vtu format.
Supported element types:
- lines (linear and quadratic) in 1D
- triangles and quadrilaterals (linear and quadratic) in 2D
- tetra- and hexahedrons (linear and quadratic) in 3D

**Inputs:**

1. **Input GMSH File:** The GMSH (.msh) file to be converted.
2. **Mesh Dimension (dim):** Select the desired mesh dimension (1, 2, or 3).
3. **Delete Z Coordinate (delz):** Boolean flag to remove the Z coordinate from the mesh (for 2D meshes with z=0).
4. **Swap XY Coordinates (swapxy):** Boolean flag to swap the X and Y coordinates.
5. **Reindex (reindex):** Renumber physical group / region / Material IDs to be renumbered beginning with zero.
6. **Keep IDs (keep_ids):** By default, rename gmsh:physical to MaterialIDs and change type of corresponding cell data to INT32. If True, this is skipped.
7. **ASCII Output (ascii):** Boolean flag to output the file in ASCII format instead of binary.
8. **Log Level (log_level):** Set the level of logging details (DEBUG, INFO, WARNING, ERROR).

**Outputs:**

**Output VTU Files:** The converted mesh file as a set of files with VTU format.
]]></help>
<expand macro="ogs_citation"/>
</tool>
71 changes: 71 additions & 0 deletions tools/ogstools/Converter/shp2msh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<tool id="shp2msh" name="ogstools shp2msh" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
<description>
Convert shp to msh
</description>
<macros>
<import>macros.xml</import>
<token name="@VERSION_SUFFIX@">0</token>
</macros>
<expand macro="creator"/>
<requirements>
bernt-matthias marked this conversation as resolved.
Show resolved Hide resolved
<expand macro="ogs_requirement"/>
</requirements>
bernt-matthias marked this conversation as resolved.
Show resolved Hide resolved
<command detect_errors="exit_code"><![CDATA[
export SHAPE_RESTORE_SHX=YES &&
ln -s '$input_shp' input.shp &&
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="Input SHP File" 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" from_work_dir="output.vtu"/>
</outputs>
<tests>
<test>
<param name="input_shp" value="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>
<test>
<param name="input_shp" value="circle.shp"/>
<param name="meshing" value= "gmsh"/>
<param name="simplify" value="original"/>
<output name="output" value="output2.vtu"/>
</test>
</tests>
<help><![CDATA[
**Overview:**
This tool takes a shapefile (.shp) 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.

**Inputs:**

1. **Input Shape File:** The .shp file to be converted.
2. **Cellsize:** Select the desired cellsize min=40.
3. **Meshing:** Choose either triangle or gmsh.
4. **Simplify:** Either the shapefiles are kept unchanged or they can be simplified. Choose between original and simplified.

**Outputs:**

**Output VTU Files:** The converted mesh as a VTU file.
]]></help>
<expand macro="ogs_citation"/>
</tool>
Binary file added tools/ogstools/Converter/test-data/circle.shp
Binary file not shown.
Loading
Loading