Skip to content

Commit

Permalink
flag for doing random conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
otvam committed Aug 21, 2024
1 parent e6daf7a commit 5d50cdb
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/format/file_geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
# compute (or not) the connections between the domains
"check_connection": true

# random resolution of the conflicts between the domains
# - the duplicated voxels are randomly assigned to a unique domain
# - the random resolution is performed after the manual conflict resolution
"random_resolution": false

# definition of the conflict resolution between domains
# - during the voxelization, the same voxel can be assigned to several domains
# - the shared voxels are located at the boundaries between domain
Expand Down
1 change: 1 addition & 0 deletions examples/examples_png/gerber/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["coil"], "domain_keep": ["src"]}
- {"domain_resolve": ["coil"], "domain_keep": ["sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_png/inductor_gap/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"cond": {"domain_group": [["coil"], ["src"], ["sink"]], "connected": true}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_png/inductor_pot/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"cond": {"domain_group": [["coil"], ["src"], ["sink"]], "connected": true}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_png/inductor_spiral/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"connect": {"domain_group": [["coil"], ["src"], ["sink"]], "connected": true}
1 change: 1 addition & 0 deletions examples/examples_png/iron_core/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"cond": {"domain_group": [["wire"], ["src"], ["sink"]], "connected": true}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_png/shield/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"cond": {"domain_group": [["coil"], ["src"], ["sink"]], "connected": true}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_shape/busbar/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["copper"], "domain_keep": ["src"]}
- {"domain_resolve": ["copper"], "domain_keep": ["sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_shape/coplanar/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["copper"], "domain_keep": ["src_a", "sink_a"]}
- {"domain_resolve": ["copper"], "domain_keep": ["src_b", "sink_b"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_shape/parallel/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["wire"], "domain_keep": ["src_1", "src_2"]}
- {"domain_resolve": ["wire"], "domain_keep": ["sink_1", "sink_2"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_shape/trace/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["copper"], "domain_keep": ["src_front"]}
- {"domain_resolve": ["copper"], "domain_keep": ["src_back"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_shape/wire/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["wire"], "domain_keep": ["src"]}
- {"domain_resolve": ["wire"], "domain_keep": ["sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_stl/inductor_air/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["coil"], "domain_keep": ["src"]}
- {"domain_resolve": ["coil"], "domain_keep": ["sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_stl/inductor_core/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["coil"], "domain_keep": ["src"]}
- {"domain_resolve": ["coil"], "domain_keep": ["sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_stl/inductor_toroid/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["wire"], "domain_keep": ["src"]}
- {"domain_resolve": ["wire"], "domain_keep": ["sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_stl/transformer/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["pri_coil"], "domain_keep": ["pri_src"]}
- {"domain_resolve": ["pri_coil"], "domain_keep": ["pri_sink"]}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_voxel/anisotropic/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"connect": {"domain_group": [["cond"], ["src"], ["sink"]], "connected": true}
1 change: 1 addition & 0 deletions examples/examples_voxel/core/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"connect": {"domain_group": [["cond"], ["src"], ["sink"]], "connected": true}
Expand Down
1 change: 1 addition & 0 deletions examples/examples_voxel/distributed/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"connect": {"domain_group": [["cond"], ["src"], ["sink"]], "connected": true}
1 change: 1 addition & 0 deletions examples/examples_voxel/logo/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"connect": {"domain_group": [["coil"], ["src"], ["sink"]], "connected": true}
1 change: 1 addition & 0 deletions examples/examples_voxel/slab/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"connect": {"domain_group": [["cond"], ["src"], ["sink"]], "connected": true}
1 change: 1 addition & 0 deletions examples/examples_voxel/transformer/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict": []
"domain_connection":
"pri": {"domain_group": [["pri"], ["src"], ["sink"]], "connected": true}
Expand Down
1 change: 1 addition & 0 deletions examples/tutorial/geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"check_cloud": true
"check_conflict": true
"check_connection": true
"random_resolution": false
"domain_conflict":
- {"domain_resolve": ["trace"], "domain_keep": ["src"]}
- {"domain_resolve": ["trace"], "domain_keep": ["sink"]}
Expand Down
3 changes: 3 additions & 0 deletions pypeec/lib_check/check_data_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def check_data_geometry(data_geometry):
"check_cloud",
"check_conflict",
"check_connection",
"random_resolution",
"domain_conflict",
"domain_connection",
"pts_cloud",
Expand All @@ -117,6 +118,7 @@ def check_data_geometry(data_geometry):
check_cloud = data_geometry["check_cloud"]
check_conflict = data_geometry["check_conflict"]
check_connection = data_geometry["check_connection"]
random_resolution = data_geometry["random_resolution"]
domain_conflict = data_geometry["domain_conflict"]
domain_connection = data_geometry["domain_connection"]
pts_cloud = data_geometry["pts_cloud"]
Expand All @@ -126,6 +128,7 @@ def check_data_geometry(data_geometry):
datachecker.check_boolean("check_cloud", check_cloud)
datachecker.check_boolean("check_conflict", check_conflict)
datachecker.check_boolean("check_connection", check_connection)
datachecker.check_boolean("random_resolution", random_resolution)

# check the mesher
if mesh_type == "png":
Expand Down
8 changes: 5 additions & 3 deletions pypeec/lib_mesher/voxel_conflict.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ def _get_resolution(domain_def):
raise RuntimeError("invalid domain: domain indices should be unique")


def get_conflict(domain_def, domain_conflict):
def get_conflict(domain_def, domain_conflict, random_resolution):
"""
Detect and remove shared indices (conflict) between domains.
The direction of the conflict resolution (between two domains) is specified by the user.
At the end, check that all shared indices have been removed.
After the rule-based resolution, a random resolution can be performed (if desired)
At the end, the unicity of the voxel indices is checked.
"""

# resolve the conflicts for all the specified domain pairs
Expand All @@ -94,7 +95,8 @@ def get_conflict(domain_def, domain_conflict):
domain_def = _get_solve_overlap(domain_def, domain_resolve, domain_keep)

# random assignment of the duplicates
domain_def = _get_random(domain_def)
if random_resolution:
domain_def = _get_random(domain_def)

# check that the conflicts are resolved
_get_resolution(domain_def)
Expand Down
3 changes: 2 additions & 1 deletion pypeec/run/mesher.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def _run_resample_graph(reference, data_internal, data_geometry):
check_cloud = data_geometry["check_cloud"]
check_conflict = data_geometry["check_conflict"]
check_connection = data_geometry["check_connection"]
random_resolution = data_geometry["random_resolution"]
domain_connection = data_geometry["domain_connection"]
domain_conflict = data_geometry["domain_conflict"]
pts_cloud = data_geometry["pts_cloud"]
Expand All @@ -176,7 +177,7 @@ def _run_resample_graph(reference, data_internal, data_geometry):

if check_conflict:
with log.BlockTimer(LOGGER, "voxel_conflict"):
domain_def = voxel_conflict.get_conflict(domain_def, domain_conflict)
domain_def = voxel_conflict.get_conflict(domain_def, domain_conflict, random_resolution)

if check_connection:
with log.BlockTimer(LOGGER, "voxel_connection"):
Expand Down

0 comments on commit 5d50cdb

Please sign in to comment.