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 10 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
22 changes: 22 additions & 0 deletions tools/ogstools/.shed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: suite_ogs_tools
owner: ufz
description: A suite of tools for ogs.
tStehling marked this conversation as resolved.
Show resolved Hide resolved
long_description: |
Contains at the moment just file format converter.
-msh2vtu converts .msh to .vtu/ .vtk
-shp2msh converts .shp to .vtu/ .vtk
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: A suite of tools for ogs.
suite:
name: suite_ogs_tools
description: A suite of tools for ogs.
long_description: |
Contains at the moment just file format converter.
-msh2vtu converts .msh to .vtu/ .vtk
-shp2msh converts .shp to .vtu/ .vtk
96 changes: 96 additions & 0 deletions tools/ogstools/msh2vtu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

<tool id="msh2vtu" name="ogstools msh2vtu" version="0.1.0+galaxy0" profile="21.05">
<description>
Convert msh to vtu/vtk.
tStehling marked this conversation as resolved.
Show resolved Hide resolved
</description>
<requirements>
<requirement type="package" version="0.4.0">ogstools</requirement>
</requirements>
<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="Mesh Dimension" argument="-d">
tStehling marked this conversation as resolved.
Show resolved Hide resolved
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</param>
tStehling marked this conversation as resolved.
Show resolved Hide resolved
<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>
<citations>
<citation type="doi">10.5281/zenodo.13685289</citation>
</citations>
</tool>
62 changes: 62 additions & 0 deletions tools/ogstools/shp2msh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<tool id="shp2msh" name="ogstools shp2msh" version="0.1.0+galaxy0" profile="21.05">
<description>
Convert shp to vtu.
tStehling marked this conversation as resolved.
Show resolved Hide resolved
</description>
<requirements>
<requirement type="package" version="0.4.0">ogstools</requirement>
</requirements>
<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="shp input data" argument="-i"/>
tStehling marked this conversation as resolved.
Show resolved Hide resolved
<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>
tStehling marked this conversation as resolved.
Show resolved Hide resolved
</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>
<citations>
<citation type="doi">10.5281/zenodo.13685289</citation>
</citations>
</tool>
Binary file added tools/ogstools/test-data/circle.shp
Binary file not shown.
Binary file added tools/ogstools/test-data/circle.shx
Binary file not shown.
Loading
Loading