diff --git a/examples/scripts/comma_tools.py b/examples/scripts/comma_tools.py index fb3c9b2..62436ab 100644 --- a/examples/scripts/comma_tools.py +++ b/examples/scripts/comma_tools.py @@ -13,6 +13,30 @@ import numpy as np import numpy.typing as npt +from CoMMA import AR, Neighbourhood, SeedsPool + +AR_DESCRIPTIONS = { + AR.DIAMETER_OVER_RADIUS: "Diameter over radius", + AR.DIAMETER_OVER_MIN_EDGE: "Diameter over minimum edge", + AR.DIAMETER: "Diameter", + AR.ONE_OVER_MEASURE: "One over the measure (e.g., volume) of the cell", + AR.ONE_OVER_INTERNAL_WEIGHTS: "One over the internal weights", + AR.PERIMETER_OVER_RADIUS: "Perimeter over radius", + AR.EXTERNAL_WEIGHTS: "External weights, that is, perimeter", + AR.MAX_BARY_DIST_OVER_RADIUS: "Maximum FC-center distance from barycenter over radius", # noqa: E501 + AR.MAX_OVER_MIN_BARY_DIST: "Maximum over minimum FC-center distance from barycenter", # noqa: E501 + AR.ALGEBRAIC_PERIMETER_OVER_MEASURE: "Algebraic-like perimeter over measure, that is, external weights over cell weight", # noqa: E501 +} +NEIGHBOURHOOD_DESCRIPTIONS = { + Neighbourhood.EXTENDED: "Extended", + Neighbourhood.PURE_FRONT: "Pure front advancing", +} +SEED_ORDERING_DESCRIPTIONS = { + SeedsPool.BOUNDARY: "Boundary priority", + SeedsPool.NEIGHBOURHOOD: "Neighbourhood priority", + SeedsPool.BOUNDARY_POINT_INIT: "Boundary priority with point initialization", # noqa: E501 + SeedsPool.NEIGHBOURHOOD_POINT_INIT: "Neighbourhood priority with point initialization", # noqa: E501 +} def compute_neighbourhood_wall_distance( diff --git a/examples/scripts/ex_aniso_lines.py b/examples/scripts/ex_aniso_lines.py index ba60e51..4f1e2a7 100644 --- a/examples/scripts/ex_aniso_lines.py +++ b/examples/scripts/ex_aniso_lines.py @@ -22,23 +22,14 @@ from dualGPy.Mesh import Mesh2D from comma_tools import ( + AR_DESCRIPTIONS, + NEIGHBOURHOOD_DESCRIPTIONS, + SEED_ORDERING_DESCRIPTIONS, assign_anisotropic_line_data_to_cells, prepare_meshio_agglomeration_data, prepare_meshio_celldata, ) -neigh_type_types = { - CoMMA.Neighbourhood.EXTENDED: "Extended", - CoMMA.Neighbourhood.PURE_FRONT: "Pure front advancing", -} - -seed_ordering_types = { - CoMMA.SeedsPool.BOUNDARY: "Boundary priority", - CoMMA.SeedsPool.NEIGHBOURHOOD: "Neighbourhood priority", - CoMMA.SeedsPool.BOUNDARY_POINT_INIT: "Boundary priority with point initialization", # noqa: E501 - CoMMA.SeedsPool.NEIGHBOURHOOD_POINT_INIT: "Neighbourhood priority with point initialization", # noqa: E501 -} - # USER PARAMETERS ################# # Input-related parameters @@ -50,6 +41,20 @@ correction = False threshold_anisotropy = 1.5 odd_line_length = True +# Which type of aspect ratio to use. We give the available list below, but for more +# details refer to Documentation/AR_note.pdf, and +# include/CoMMA/{CoMMADefs.h,AR_computer.h} +# - AR.DIAMETER_OVER_RADIUS +# - AR.DIAMETER_OVER_MIN_EDGE +# - AR.DIAMETER +# - AR.ONE_OVER_MEASURE +# - AR.ONE_OVER_INTERNAL_WEIGHTS +# - AR.PERIMETER_OVER_RADIUS +# - AR.EXTERNAL_WEIGHTS +# - AR.MAX_BARY_DIST_OVER_RADIUS +# - AR.MAX_OVER_MIN_BARY_DIST +# - AR.ALGEBRAIC_PERIMETER_OVER_MEASURE +AR = CoMMA.AR.DIAMETER_OVER_RADIUS # Seeds pool ordering choices: # - SeedsPool.BOUNDARY: Boundary priority, 0 # - SeedsPool.NEIGHBOURHOOD: Neighbourhood priority, 1 @@ -90,11 +95,12 @@ print(f" * {minCard=}") print(f" * {goalCard=}") print(f" * {maxCard=}") +print(f" * aspect ratio={AR_DESCRIPTIONS[AR]}") print(f" * {correction=}") print(f" * {threshold_anisotropy=}") print(f" * {odd_line_length=}") -print(f" * neigh_type={neigh_type_types[neigh_type]}") -print(f" * seed_ordering={seed_ordering_types[seed_order]}") +print(f" * neigh_type={NEIGHBOURHOOD_DESCRIPTIONS[neigh_type]}") +print(f" * seed_ordering={SEED_ORDERING_DESCRIPTIONS[seed_order]}") print(f" * Threshold cardinality for singular cells={sing_card}") print(f" * Max cells in anisotropic line={max_cells_in_line}") print(f" * Fine-cell research iterations={fc_iter}") @@ -180,6 +186,7 @@ goalCard, minCard, maxCard, + AR, sing_card, max_cells_in_line, fc_iter, diff --git a/examples/scripts/ex_default_dualGPy.py b/examples/scripts/ex_default_dualGPy.py index 1d3e409..93b7802 100644 --- a/examples/scripts/ex_default_dualGPy.py +++ b/examples/scripts/ex_default_dualGPy.py @@ -21,19 +21,12 @@ from dualGPy.Graph import Graph2D from dualGPy.Mesh import Mesh2D, Mesh3D -from comma_tools import prepare_meshio_agglomeration_data - -neigh_type_types = { - CoMMA.Neighbourhood.EXTENDED: "Extended", - CoMMA.Neighbourhood.PURE_FRONT: "Pure front advancing", -} - -seed_ordering_types = { - CoMMA.SeedsPool.BOUNDARY: "Boundary priority", - CoMMA.SeedsPool.NEIGHBOURHOOD: "Neighbourhood priority", - CoMMA.SeedsPool.BOUNDARY_POINT_INIT: "Boundary priority with point initialization", # noqa: E501 - CoMMA.SeedsPool.NEIGHBOURHOOD_POINT_INIT: "Neighbourhood priority with point initialization", # noqa: E501 -} +from comma_tools import ( + AR_DESCRIPTIONS, + NEIGHBOURHOOD_DESCRIPTIONS, + SEED_ORDERING_DESCRIPTIONS, + prepare_meshio_agglomeration_data, +) # USER PARAMETERS ################# @@ -52,6 +45,20 @@ correction = False threshold_anisotropy = 4.0 odd_line_length = True +# Which type of aspect ratio to use. We give the available list below, but for more +# details refer to Documentation/AR_note.pdf, and +# include/CoMMA/{CoMMADefs.h,AR_computer.h} +# - AR.DIAMETER_OVER_RADIUS +# - AR.DIAMETER_OVER_MIN_EDGE +# - AR.DIAMETER +# - AR.ONE_OVER_MEASURE +# - AR.ONE_OVER_INTERNAL_WEIGHTS +# - AR.PERIMETER_OVER_RADIUS +# - AR.EXTERNAL_WEIGHTS +# - AR.MAX_BARY_DIST_OVER_RADIUS +# - AR.MAX_OVER_MIN_BARY_DIST +# - AR.ALGEBRAIC_PERIMETER_OVER_MEASURE +AR = CoMMA.AR.DIAMETER_OVER_RADIUS # Seeds pool ordering choices: # - SeedsPool.BOUNDARY: Boundary priority, 0 # - SeedsPool.NEIGHBOURHOOD: Neighbourhood priority, 1 @@ -91,12 +98,13 @@ print(f" * {minCard=}") print(f" * {goalCard=}") print(f" * {maxCard=}") +print(f" * aspect ratio={AR_DESCRIPTIONS[AR]}") print(f" * {correction=}") print(f" * {threshold_anisotropy=}") print(f" * {odd_line_length=}") -print(f" * neigh_type={neigh_type_types[neigh_type]}") print(" * Priority weights: reversed ID") -print(f" * seed_ordering={seed_ordering_types[seed_order]}") +print(f" * neigh_type={NEIGHBOURHOOD_DESCRIPTIONS[neigh_type]}") +print(f" * seed_ordering={SEED_ORDERING_DESCRIPTIONS[seed_order]}") print(f" * Threshold cardinality for singular cells={sing_card}") print(f" * Max cells in anisotropic line={max_cells_in_line}") print(f" * Fine-cell research iterations={fc_iter}") @@ -170,6 +178,7 @@ goalCard, minCard, maxCard, + AR, sing_card, max_cells_in_line, fc_iter, diff --git a/examples/scripts/ex_rae.py b/examples/scripts/ex_rae.py index a589fb2..b0302c1 100644 --- a/examples/scripts/ex_rae.py +++ b/examples/scripts/ex_rae.py @@ -23,6 +23,9 @@ from dualGPy.Mesh import Mesh2D from comma_tools import ( + AR_DESCRIPTIONS, + NEIGHBOURHOOD_DESCRIPTIONS, + SEED_ORDERING_DESCRIPTIONS, assign_anisotropic_line_data_to_cells, build_coarse_graph, compute_neighbourhood_wall_distance, @@ -45,18 +48,6 @@ def limit_line_length(idxs, cells, max_cells_in_line): return ret_idxs, ret_cells -neigh_type_types = { - CoMMA.Neighbourhood.EXTENDED: "Extended", - CoMMA.Neighbourhood.PURE_FRONT: "Pure front advancing", -} - -seed_ordering_types = { - CoMMA.SeedsPool.BOUNDARY: "Boundary priority", - CoMMA.SeedsPool.NEIGHBOURHOOD: "Neighbourhood priority", - CoMMA.SeedsPool.BOUNDARY_POINT_INIT: "Boundary priority with point initialization", # noqa: E501 - CoMMA.SeedsPool.NEIGHBOURHOOD_POINT_INIT: "Neighbourhood priority with point initialization", # noqa: E501 -} - # USER PARAMETERS ################# input_mesh, input_format = "../meshes/raebis_ansys.msh", "ansys" @@ -70,6 +61,20 @@ def limit_line_length(idxs, cells, max_cells_in_line): correction = True threshold_anisotropy = -4.0 odd_line_length = True +# Which type of aspect ratio to use. We give the available list below, but for more +# details refer to Documentation/AR_note.pdf, and +# include/CoMMA/{CoMMADefs.h,AR_computer.h} +# - AR.DIAMETER_OVER_RADIUS +# - AR.DIAMETER_OVER_MIN_EDGE +# - AR.DIAMETER +# - AR.ONE_OVER_MEASURE +# - AR.ONE_OVER_INTERNAL_WEIGHTS +# - AR.PERIMETER_OVER_RADIUS +# - AR.EXTERNAL_WEIGHTS +# - AR.MAX_BARY_DIST_OVER_RADIUS +# - AR.MAX_OVER_MIN_BARY_DIST +# - AR.ALGEBRAIC_PERIMETER_OVER_MEASURE +AR = CoMMA.AR.DIAMETER_OVER_RADIUS # Seeds pool ordering choices: # - SeedsPool.BOUNDARY: Boundary priority, 0 # - SeedsPool.NEIGHBOURHOOD: Neighbourhood priority, 1 @@ -116,11 +121,12 @@ def limit_line_length(idxs, cells, max_cells_in_line): print(f" * {minCard=}") print(f" * {goalCard=}") print(f" * {maxCard=}") +print(f" * aspect ratio={AR_DESCRIPTIONS[AR]}") print(f" * {correction=}") print(f" * {threshold_anisotropy=}") print(f" * {odd_line_length=}") -print(f" * neigh_type={neigh_type_types[neigh_type]}") -print(f" * seed_ordering={seed_ordering_types[seed_order]}") +print(f" * neigh_type={NEIGHBOURHOOD_DESCRIPTIONS[neigh_type]}") +print(f" * seed_ordering={SEED_ORDERING_DESCRIPTIONS[seed_order]}") print(f" * Threshold cardinality for singular cells={sing_card}") print(f" * Max cells in anisotropic line={max_cells_in_line}") print(f" * Fine-cell research iterations={fc_iter}") @@ -271,6 +277,7 @@ def limit_line_length(idxs, cells, max_cells_in_line): goalCard, minCard, maxCard, + AR, sing_card, max_cells_in_line, fc_iter, diff --git a/examples/scripts/ex_read_mesh.py b/examples/scripts/ex_read_mesh.py index 00b8b72..bd5dc7b 100644 --- a/examples/scripts/ex_read_mesh.py +++ b/examples/scripts/ex_read_mesh.py @@ -24,19 +24,12 @@ from dualGPy.Graph import Graph2D from dualGPy.Mesh import Mesh2D, Mesh3D -from comma_tools import prepare_meshio_agglomeration_data - -neigh_type_types = { - CoMMA.Neighbourhood.EXTENDED: "Extended", - CoMMA.Neighbourhood.PURE_FRONT: "Pure front advancing", -} - -seed_ordering_types = { - CoMMA.SeedsPool.BOUNDARY: "Boundary priority", - CoMMA.SeedsPool.NEIGHBOURHOOD: "Neighbourhood priority", - CoMMA.SeedsPool.BOUNDARY_POINT_INIT: "Boundary priority with point initialization", # noqa: E501 - CoMMA.SeedsPool.NEIGHBOURHOOD_POINT_INIT: "Neighbourhood priority with point initialization", # noqa: E501 -} +from comma_tools import ( + AR_DESCRIPTIONS, + NEIGHBOURHOOD_DESCRIPTIONS, + SEED_ORDERING_DESCRIPTIONS, + prepare_meshio_agglomeration_data, +) # USER PARAMETERS ################# @@ -57,6 +50,20 @@ correction = False threshold_anisotropy = 4.0 odd_line_length = True +# Which type of aspect ratio to use. We give the available list below, but for more +# details refer to Documentation/AR_note.pdf, and +# include/CoMMA/{CoMMADefs.h,AR_computer.h} +# - AR.DIAMETER_OVER_RADIUS +# - AR.DIAMETER_OVER_MIN_EDGE +# - AR.DIAMETER +# - AR.ONE_OVER_MEASURE +# - AR.ONE_OVER_INTERNAL_WEIGHTS +# - AR.PERIMETER_OVER_RADIUS +# - AR.EXTERNAL_WEIGHTS +# - AR.MAX_BARY_DIST_OVER_RADIUS +# - AR.MAX_OVER_MIN_BARY_DIST +# - AR.ALGEBRAIC_PERIMETER_OVER_MEASURE +AR = CoMMA.AR.DIAMETER_OVER_RADIUS # Seeds pool ordering choices: # - SeedsPool.BOUNDARY: Boundary priority, 0 # - SeedsPool.NEIGHBOURHOOD: Neighbourhood priority, 1 @@ -100,12 +107,13 @@ print(f" * {minCard=}") print(f" * {goalCard=}") print(f" * {maxCard=}") +print(f" * aspect ratio={AR_DESCRIPTIONS[AR]}") print(f" * {correction=}") print(f" * {threshold_anisotropy=}") print(f" * {odd_line_length=}") -print(f" * neigh_type={neigh_type_types[neigh_type]}") print(" * Priority weights: reversed ID") -print(f" * seed_ordering={seed_ordering_types[seed_order]}") +print(f" * neigh_type={NEIGHBOURHOOD_DESCRIPTIONS[neigh_type]}") +print(f" * seed_ordering={SEED_ORDERING_DESCRIPTIONS[seed_order]}") print(f" * Threshold cardinality for singular cells={sing_card}") print(f" * Max cells in anisotropic line={max_cells_in_line}") print(f" * Fine-cell research iterations={fc_iter}") @@ -179,6 +187,7 @@ goalCard, minCard, maxCard, + AR, sing_card, max_cells_in_line, fc_iter, diff --git a/examples/scripts/ex_several_agglo_levels.py b/examples/scripts/ex_several_agglo_levels.py index 6e86bae..1f5681a 100644 --- a/examples/scripts/ex_several_agglo_levels.py +++ b/examples/scripts/ex_several_agglo_levels.py @@ -20,19 +20,13 @@ from dualGPy.Graph import Graph2D from dualGPy.Mesh import Mesh2D, Mesh3D -from comma_tools import build_coarse_graph, prepare_meshio_agglomeration_data - -neigh_type_types = { - CoMMA.Neighbourhood.EXTENDED: "Extended", - CoMMA.Neighbourhood.PURE_FRONT: "Pure front advancing", -} - -seed_ordering_types = { - CoMMA.SeedsPool.BOUNDARY: "Boundary priority", - CoMMA.SeedsPool.NEIGHBOURHOOD: "Neighbourhood priority", - CoMMA.SeedsPool.BOUNDARY_POINT_INIT: "Boundary priority with point initialization", # noqa: E501 - CoMMA.SeedsPool.NEIGHBOURHOOD_POINT_INIT: "Neighbourhood priority with point initialization", # noqa: E501 -} +from comma_tools import ( + AR_DESCRIPTIONS, + NEIGHBOURHOOD_DESCRIPTIONS, + SEED_ORDERING_DESCRIPTIONS, + build_coarse_graph, + prepare_meshio_agglomeration_data, +) # USER PARAMETERS ################# @@ -51,6 +45,20 @@ correction = False threshold_anisotropy = 4.0 odd_line_length = True +# Which type of aspect ratio to use. We give the available list below, but for more +# details refer to Documentation/AR_note.pdf, and +# include/CoMMA/{CoMMADefs.h,AR_computer.h} +# - AR.DIAMETER_OVER_RADIUS +# - AR.DIAMETER_OVER_MIN_EDGE +# - AR.DIAMETER +# - AR.ONE_OVER_MEASURE +# - AR.ONE_OVER_INTERNAL_WEIGHTS +# - AR.PERIMETER_OVER_RADIUS +# - AR.EXTERNAL_WEIGHTS +# - AR.MAX_BARY_DIST_OVER_RADIUS +# - AR.MAX_OVER_MIN_BARY_DIST +# - AR.ALGEBRAIC_PERIMETER_OVER_MEASURE +AR = CoMMA.AR.DIAMETER_OVER_RADIUS # Seeds pool ordering choices: # - SeedsPool.BOUNDARY: Boundary priority, 0 # - SeedsPool.NEIGHBOURHOOD: Neighbourhood priority, 1 @@ -93,11 +101,12 @@ print(f" * {minCard=}") print(f" * {goalCard=}") print(f" * {maxCard=}") +print(f" * aspect ratio={AR_DESCRIPTIONS[AR]}") print(f" * {correction=}") print(f" * {threshold_anisotropy=}") print(f" * {odd_line_length=}") -print(f" * neigh_type={neigh_type_types[neigh_type]}") -print(f" * seed_ordering={seed_ordering_types[seed_order]}") +print(f" * neigh_type={NEIGHBOURHOOD_DESCRIPTIONS[neigh_type]}") +print(f" * seed_ordering={SEED_ORDERING_DESCRIPTIONS[seed_order]}") print(f" * Threshold cardinality for singular cells={sing_card}") print(f" * Max cells in anisotropic line={max_cells_in_line}") print(f" * Fine-cell research iterations={fc_iter}") @@ -204,6 +213,7 @@ goalCard, minCard, maxCard, + AR, sing_card, max_cells_in_line, fc_iter,