Skip to content

Commit

Permalink
Merge pull request #78 from simbilod/sampling2
Browse files Browse the repository at this point in the history
create less size fields, calculate sampling differently
  • Loading branch information
simbilod authored Oct 31, 2024
2 parents a2982c4 + d70b82b commit 8edd685
Show file tree
Hide file tree
Showing 4 changed files with 8,474 additions and 11,175 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# [Changelog](https://keepachangelog.com/en/1.0.0/)

## 1.2.6

- apply resolution fields to groups of entities, keep some sampling calculation [PR#78](https://github.com/simbilod/meshwell/pull/78)

## 1.2.5

- resolution on points based on curve length [PR#77](https://github.com/simbilod/meshwell/pull/77)
Expand Down
58 changes: 35 additions & 23 deletions meshwell/labeledentity.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ def add_refinement_fields_to_model(
boundary_sizemax = resolutionspec.sizemax_surfaces
boundary_distmax = resolutionspec.distmax_surfaces
boundary_sigmoid = resolutionspec.surface_sigmoid
boundaries_samplings = {
boundary: resolutionspec.calculate_sampling_surface(
# NOTE: currently using for the number of sampling points the desired density and largest entity; resulting NSampling is then applied to all entities
boundary_surface = max(
[
self.model.occ.getMass(2, boundary)
)
for boundary in boundaries
}
for boundary in boundaries
]
)
boundaries_samplings = (
resolutionspec.calculate_sampling_surface(boundary_surface)
)

# Check condition on surface curves
if resolutionspec.resolution_curves is None:
Expand All @@ -136,12 +140,18 @@ def add_refinement_fields_to_model(
boundary_lines_sizemax = resolutionspec.sizemax_curves
boundary_lines_distmax = resolutionspec.distmax_curves
boundary_line_sigmoid = resolutionspec.curve_sigmoid
boundary_lines_samplings = {
boundary_line: resolutionspec.calculate_sampling_curve(
self.model.occ.getMass(1, boundary_line)
# NOTE: currently using for the number of sampling points the desired density and largest entity; resulting NSampling is then applied to all entities
boundary_lines_length = max(
[
self.model.occ.getMass(1, boundary)
for boundary in boundary_lines
]
)
boundary_lines_samplings = (
resolutionspec.calculate_sampling_curve(
boundary_lines_length
)
for boundary_line in boundary_lines
}
)

# Check condition on surface curve points
if resolutionspec.resolution_points is None:
Expand Down Expand Up @@ -208,12 +218,16 @@ def add_refinement_fields_to_model(
boundary_sizemax = resolutionspec.sizemax_curves
boundary_distmax = resolutionspec.distmax_curves
boundary_sigmoid = resolutionspec.curve_sigmoid
boundaries_samplings = {
boundary: resolutionspec.calculate_sampling_curve(
# NOTE: currently using for the number of sampling points the desired density and largest entity; resulting NSampling is then applied to all entities
boundary_surface = max(
[
self.model.occ.getMass(1, boundary)
)
for boundary in boundaries
}
for boundary in boundaries
]
)
boundaries_samplings = (
resolutionspec.calculate_sampling_surface(boundary_surface)
)

if resolutionspec.resolution_points is not None:
raise ValueError(
Expand All @@ -240,12 +254,10 @@ def add_refinement_fields_to_model(
refinement_field_indices.extend((n + 1,))
n += 2

for boundary in boundaries:
if boundaries:
self.model.mesh.field.add("Distance", n)
self.model.mesh.field.setNumbers(n, boundary_str, [boundary])
self.model.mesh.field.setNumber(
n, "Sampling", boundaries_samplings[boundary]
)
self.model.mesh.field.setNumbers(n, boundary_str, boundaries)
self.model.mesh.field.setNumber(n, "Sampling", boundaries_samplings)
self.model.mesh.field.add("Threshold", n + 1)
self.model.mesh.field.setNumber(n + 1, "InField", n)
self.model.mesh.field.setNumber(
Expand All @@ -266,11 +278,11 @@ def add_refinement_fields_to_model(
refinement_field_indices.extend((n + 1,))
n += 2

for boundary_line in boundary_lines:
if boundary_lines:
self.model.mesh.field.add("Distance", n)
self.model.mesh.field.setNumbers(n, curves_str, [boundary_line])
self.model.mesh.field.setNumbers(n, curves_str, boundary_lines)
self.model.mesh.field.setNumber(
n, "Sampling", boundary_lines_samplings[boundary_line]
n, "Sampling", boundary_lines_samplings
)
self.model.mesh.field.add("Threshold", n + 1)
self.model.mesh.field.setNumber(n + 1, "InField", n)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
]
version="1.2.5"
version="1.2.6"
authors = [
{name = "Simon Bilodeau", email = "[email protected]"},
]
Expand Down
Loading

0 comments on commit 8edd685

Please sign in to comment.