Skip to content

Commit

Permalink
example: Fix examples after AR merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Milani committed Apr 18, 2024
1 parent 1bbffcf commit 642406b
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 73 deletions.
24 changes: 24 additions & 0 deletions examples/scripts/comma_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
35 changes: 21 additions & 14 deletions examples/scripts/ex_aniso_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -180,6 +186,7 @@
goalCard,
minCard,
maxCard,
AR,
sing_card,
max_cells_in_line,
fc_iter,
Expand Down
39 changes: 24 additions & 15 deletions examples/scripts/ex_default_dualGPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#################
Expand All @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -170,6 +178,7 @@
goalCard,
minCard,
maxCard,
AR,
sing_card,
max_cells_in_line,
fc_iter,
Expand Down
35 changes: 21 additions & 14 deletions examples/scripts/ex_rae.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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,
Expand Down
39 changes: 24 additions & 15 deletions examples/scripts/ex_read_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#################
Expand All @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -179,6 +187,7 @@
goalCard,
minCard,
maxCard,
AR,
sing_card,
max_cells_in_line,
fc_iter,
Expand Down
40 changes: 25 additions & 15 deletions examples/scripts/ex_several_agglo_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#################
Expand All @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -204,6 +213,7 @@
goalCard,
minCard,
maxCard,
AR,
sing_card,
max_cells_in_line,
fc_iter,
Expand Down

0 comments on commit 642406b

Please sign in to comment.