-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Perform all mesh-doctor checks at once #100
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
Open
alexbenedicto
wants to merge
16
commits into
main
Choose a base branch
from
benedicto/feature/mesh-doctor-checks-in-one
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5c87d4c
Change folder named "checks" for "actions" to be less ambiguous about…
alexbenedicto 3f240fc
First version without results
alexbenedicto 892f9f1
Improve logging functionality across main mesh-doctor scripts
alexbenedicto 4e4a9bb
Improve logging across other scripts + better argparse variable name …
alexbenedicto 54c3cdf
First version of all_checks without "supported_elements" check
alexbenedicto 3d0552e
supported_elements action corrected and now included in all_checks
alexbenedicto 964a094
Update tests
alexbenedicto 1ebccdf
Add test for all_checks + bug fix
alexbenedicto cb63ad8
Update documentation
alexbenedicto a4fe9d6
yapf format
alexbenedicto 9f62b7f
Merge remote-tracking branch 'origin/main' into benedicto/feature/mes…
alexbenedicto 44d0ba7
Remove automatic documentation + yapf
alexbenedicto a8e4a7c
ruff checking
alexbenedicto a502e23
Add RESULTS log level to Logger
alexbenedicto c05762f
Replace logger by setup_logger + use of new "results" attribute
alexbenedicto 9c9efb9
typing and restore constant name Logger
alexbenedicto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
GEOS Mesh tools | ||
==================== | ||
|
||
**geos-mesh** is a Python package that contains several tools and utilities to handle processing and quality checks of meshes. | ||
|
||
.. toctree:: | ||
:maxdepth: 5 | ||
:maxdepth: 1 | ||
:caption: Contents: | ||
|
||
./geos_mesh_docs/home.rst | ||
./geos_mesh_docs/doctor | ||
|
||
./geos_mesh_docs/converter | ||
|
||
./geos_mesh_docs/io | ||
|
||
./geos_mesh_docs/model | ||
|
||
./geos_mesh_docs/processing | ||
|
||
./geos_mesh_docs/stats | ||
|
||
./geos_mesh_docs/modules.rst | ||
./geos_mesh_docs/utils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,20 +5,29 @@ Mesh Doctor | |||||
``mesh-doctor`` is organized as a collection of modules with their dedicated sets of options. | ||||||
The current page will introduce those modules, but the details and all the arguments can be retrieved by using the ``--help`` option for each module. | ||||||
|
||||||
Prerequisites | ||||||
^^^^^^^^^^^^^ | ||||||
|
||||||
To use mesh-doctor, you first need to have installed the ``geos-mesh`` package using the following command: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
python -m pip install --upgrade ./geos-mesh | ||||||
|
||||||
Once done, you can call ``mesh-doctor`` in your command line as presented in the rest of this documentation. | ||||||
|
||||||
Modules | ||||||
^^^^^^^ | ||||||
|
||||||
To list all the modules available through ``mesh-doctor``, you can simply use the ``--help`` option, which will list all available modules as well as a quick summary. | ||||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py --help | ||||||
$ mesh-doctor --help | ||||||
usage: mesh_doctor.py [-h] [-v] [-q] -i VTK_MESH_FILE | ||||||
{collocated_nodes,element_volumes,fix_elements_orderings,generate_cube,generate_fractures,generate_global_ids,non_conformal,self_intersecting_elements,supported_elements} | ||||||
... | ||||||
|
||||||
Inspects meshes for GEOSX. | ||||||
|
||||||
positional arguments: | ||||||
{collocated_nodes,element_volumes,fix_elements_orderings,generate_cube,generate_fractures,generate_global_ids,non_conformal,self_intersecting_elements,supported_elements} | ||||||
Modules | ||||||
|
@@ -40,14 +49,12 @@ To list all the modules available through ``mesh-doctor``, you can simply use th | |||||
Checks if the faces of the elements are self intersecting. | ||||||
supported_elements | ||||||
Check that all the elements of the mesh are supported by GEOSX. | ||||||
|
||||||
options: | ||||||
-h, --help | ||||||
show this help message and exit | ||||||
-v Use -v 'INFO', -vv for 'DEBUG'. Defaults to 'WARNING'. | ||||||
-q Use -q to reduce the verbosity of the output. | ||||||
-i VTK_MESH_FILE, --vtk-input-file VTK_MESH_FILE | ||||||
|
||||||
Note that checks are dynamically loaded. | ||||||
An option may be missing because of an unloaded module. | ||||||
Increase verbosity (-v, -vv) to get full information. | ||||||
|
@@ -57,9 +64,8 @@ For example | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py collocated_nodes --help | ||||||
$ mesh-doctor collocated_nodes --help | ||||||
usage: mesh_doctor.py collocated_nodes [-h] --tolerance TOLERANCE | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--tolerance TOLERANCE [float]: The absolute distance between two nodes for them to be considered collocated. | ||||||
|
@@ -78,6 +84,34 @@ You can solve this issue by installing the dependencies of ``mesh-doctor`` defin | |||||
|
||||||
Here is a list and brief description of all the modules available. | ||||||
|
||||||
``all_checks`` | ||||||
"""""""""""""" | ||||||
|
||||||
``mesh-doctor`` modules are called ``actions`` and they can be splitted into 2 different categories: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
``check actions`` that will give you a feedback on a .vtu mesh that you would like to use in GEOS. | ||||||
``operate actions`` that will either create a new mesh or modify a mesh. | ||||||
|
||||||
``all_checks`` aims at applying every single ``check`` action in one single command. The list is the following: | ||||||
``collocated_nodes``, ``element_volumes``, ``non_conformal``, ``self_intersecting_elements``, ``supported_elements``. | ||||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ mesh-doctor all_checks --help | ||||||
usage: mesh-doctor all_checks [-h] [--checks_to_perform CHECKS_TO_PERFORM] [--set_parameters SET_PARAMETERS] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--checks_to_perform CHECKS_TO_PERFORM | ||||||
Comma-separated list of mesh-doctor checks to perform. If no input was given, all of the following checks will be executed by default: | ||||||
['collocated_nodes', 'element_volumes', 'non_conformal', 'self_intersecting_elements', 'supported_elements']. | ||||||
If you want to choose only certain of them, you can name them individually. | ||||||
Example: --checks_to_perform collocated_nodes,element_volumes (default: ) | ||||||
--set_parameters SET_PARAMETERS | ||||||
Comma-separated list of parameters to set for the checks (e.g., 'param_name:value'). These parameters override the defaults. | ||||||
Default parameters are: For collocated_nodes: tolerance:0.0. For element_volumes: min_volume:0.0. For non_conformal: angle_tolerance:10.0, point_tolerance:0.0, face_tolerance:0.0. | ||||||
For self_intersecting_elements: min_distance:2.220446049250313e-16. For supported_elements: chunk_size:1, nproc:8. | ||||||
Example: --set_parameters parameter_name:10.5,other_param:25 (default: ) | ||||||
|
||||||
``collocated_nodes`` | ||||||
"""""""""""""""""""" | ||||||
|
||||||
|
@@ -86,9 +120,8 @@ It is not uncommon to define multiple nodes for the exact same position, which w | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py collocated_nodes --help | ||||||
$ mesh-doctor collocated_nodes --help | ||||||
usage: mesh_doctor.py collocated_nodes [-h] --tolerance TOLERANCE | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--tolerance TOLERANCE [float]: The absolute distance between two nodes for them to be considered collocated. | ||||||
|
@@ -101,9 +134,8 @@ Cells with negative volumes will typically be an issue for ``geos`` and should b | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py element_volumes --help | ||||||
$ mesh-doctor element_volumes --help | ||||||
usage: mesh_doctor.py element_volumes [-h] --min 0.0 | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--min 0.0 [float]: The minimum acceptable volume. Defaults to 0.0. | ||||||
|
@@ -117,12 +149,11 @@ This can be convenient if you cannot regenerate the mesh. | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py fix_elements_orderings --help | ||||||
$ mesh-doctor fix_elements_orderings --help | ||||||
usage: mesh_doctor.py fix_elements_orderings [-h] [--Hexahedron 1,6,5,4,7,0,2,3] [--Prism5 8,2,0,7,6,9,5,1,4,3] | ||||||
[--Prism6 11,2,8,10,5,0,9,7,6,1,4,3] [--Pyramid 3,4,0,2,1] | ||||||
[--Tetrahedron 2,0,3,1] [--Voxel 1,6,5,4,7,0,2,3] | ||||||
[--Wedge 3,5,4,0,2,1] --output OUTPUT [--data-mode binary, ascii] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--Hexahedron 1,6,5,4,7,0,2,3 | ||||||
|
@@ -148,11 +179,10 @@ This tool can also be useful to generate a trial mesh that will later be refined | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py generate_cube --help | ||||||
$ mesh-doctor generate_cube --help | ||||||
usage: mesh_doctor.py generate_cube [-h] [--x 0:1.5:3] [--y 0:5:10] [--z 0:1] [--nx 2:2] [--ny 1:1] [--nz 4] | ||||||
[--fields name:support:dim [name:support:dim ...]] [--cells] [--no-cells] | ||||||
[--points] [--no-points] --output OUTPUT [--data-mode binary, ascii] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--x 0:1.5:3 [list of floats]: X coordinates of the points. | ||||||
|
@@ -179,10 +209,9 @@ The ``generate_fractures`` module will split the mesh and generate the multi-blo | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py generate_fractures --help | ||||||
$ mesh-doctor generate_fractures --help | ||||||
usage: mesh_doctor.py generate_fractures [-h] --policy field, internal_surfaces [--name NAME] [--values VALUES] --output OUTPUT | ||||||
[--data-mode binary, ascii] [--fractures_output_dir FRACTURES_OUTPUT_DIR] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--policy field, internal_surfaces | ||||||
|
@@ -210,10 +239,9 @@ The ``generate_global_ids`` can generate `global ids` for the imported ``vtk`` m | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py generate_global_ids --help | ||||||
$ mesh-doctor generate_global_ids --help | ||||||
usage: mesh_doctor.py generate_global_ids [-h] [--cells] [--no-cells] [--points] [--no-points] --output OUTPUT | ||||||
[--data-mode binary, ascii] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--cells [bool]: Generate global ids for cells. Defaults to true. | ||||||
|
@@ -234,10 +262,9 @@ This module can be a bit time consuming. | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py non_conformal --help | ||||||
$ mesh-doctor non_conformal --help | ||||||
usage: mesh_doctor.py non_conformal [-h] [--angle_tolerance 10.0] [--point_tolerance POINT_TOLERANCE] | ||||||
[--face_tolerance FACE_TOLERANCE] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--angle_tolerance 10.0 [float]: angle tolerance in degrees. Defaults to 10.0 | ||||||
|
@@ -254,9 +281,8 @@ This module will display the elements that have faces intersecting. | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py self_intersecting_elements --help | ||||||
$ mesh-doctor self_intersecting_elements --help | ||||||
usage: mesh_doctor.py self_intersecting_elements [-h] [--min 2.220446049250313e-16] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--min 2.220446049250313e-16 | ||||||
|
@@ -275,9 +301,8 @@ It will also verify that the ``VTK_POLYHEDRON`` cells can effectively get conver | |||||
|
||||||
.. code-block:: | ||||||
|
||||||
$ python src/geos/mesh/doctor/mesh_doctor.py supported_elements --help | ||||||
$ mesh-doctor supported_elements --help | ||||||
usage: mesh_doctor.py supported_elements [-h] [--chunck_size 1] [--nproc 8] | ||||||
|
||||||
options: | ||||||
-h, --help show this help message and exit | ||||||
--chunck_size 1 [int]: Defaults chunk size for parallel processing to 1 | ||||||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from dataclasses import dataclass | ||
from geos.mesh.doctor.register import __load_module_action | ||
from geos.mesh.doctor.parsing.cli_parsing import setup_logger | ||
|
||
|
||
@dataclass( frozen=True ) | ||
class Options: | ||
checks_to_perform: list[ str ] | ||
checks_options: dict[ str, any ] | ||
check_displays: dict[ str, any ] | ||
|
||
|
||
@dataclass( frozen=True ) | ||
class Result: | ||
check_results: dict[ str, any ] | ||
|
||
|
||
def action( vtk_input_file: str, options: Options ) -> list[ Result ]: | ||
check_results: dict[ str, any ] = dict() | ||
for check_name in options.checks_to_perform: | ||
check_action = __load_module_action( check_name ) | ||
setup_logger.info( f"Performing check '{check_name}'." ) | ||
option = options.checks_options[ check_name ] | ||
check_result = check_action( vtk_input_file, option ) | ||
check_results[ check_name ] = check_result | ||
return Result( check_results=check_results ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we do a dedicated PR to change all the GEOSX to GEOS ? I see there are several left in mesh-doctor, maybe somewhere else also...