Skip to content

Commit

Permalink
Merge pull request #86 from simbilod/fix_resolution
Browse files Browse the repository at this point in the history
Fix resolution
  • Loading branch information
simbilod authored Nov 4, 2024
2 parents 093604d + 5668a60 commit 45c56f6
Show file tree
Hide file tree
Showing 3 changed files with 17,732 additions and 19,039 deletions.
51 changes: 46 additions & 5 deletions meshwell/labeledentity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class LabeledEntities(BaseModel):
keep: bool
boundaries: List[int] = []
interfaces: List = []
mesh_edge_name_interfaces: List = []

model_config = ConfigDict(arbitrary_types_allowed=True)

Expand Down Expand Up @@ -70,6 +71,24 @@ def filter_tags_by_target_dimension(self, target_dimension):

return tags

def filter_mesh_boundary_tags_by_target_dimension(self, target_dimension):
match self.dim - target_dimension:
case 0:
raise ValueError("Not a boundary!")
case 1:
tags = self.mesh_edge_name_interfaces
case 2 | 3:
tags = [
c
for b in self.mesh_edge_name_interfaces
for cs in self.model.occ.getCurveLoops(b)[1]
for c in cs
]
case -1:
raise ValueError("Not a boundary!")

return tags

def filter_by_mass(self, target_dimension: int, min_mass, max_mass):
def filter_by_target_and_tags(target_dimension, tags, min_mass, max_mass):
# Returns tags and masses
Expand Down Expand Up @@ -140,26 +159,48 @@ def add_refinement_fields_to_model(
for other_name, other_entity in all_entities_dict.items():
# If itself
if all(item in other_name for item in self.physical_name):
tags = self.filter_tags_by_target_dimension(
resolutionspec.target_dimension
)
if not include_boundary:
tags = set(tags) - set(
self.filter_mesh_boundary_tags_by_target_dimension(
resolutionspec.target_dimension
)
)
for tag in self.tags:
if tag in entities_mass_dict:
entities_mass_dict_sharing[tag] = entities_mass_dict[
tag
]
continue
if any(item in other_name for item in superset):
other_tags = other_entity.filter_tags_by_target_dimension(
resolutionspec.target_dimension
)
# Special case if other tag contains a boundary line also shared with self
if (
not include_boundary
and resolutionspec.target_dimension == 1
):
other_tags = set(other_tags) - (
set(
other_entity.filter_mesh_boundary_tags_by_target_dimension(
resolutionspec.target_dimension
)
)
& set(
self.filter_mesh_boundary_tags_by_target_dimension(
resolutionspec.target_dimension
)
)
)
for tag in other_tags:
if tag in entities_mass_dict:
entities_mass_dict_sharing[tag] = entities_mass_dict[
tag
]

if include_boundary:
for tag in self.boundaries:
if tag in entities_mass_dict:
entities_mass_dict_sharing[tag] = entities_mass_dict[tag]

if entities_mass_dict_sharing:
new_field_indices, n = resolutionspec.apply(
model=self.model,
Expand Down
1 change: 1 addition & 0 deletions meshwell/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def tag_boundaries(
continue
dim = entity.dim - 1
boundaries = list(set(entity.boundaries) - set(entity.interfaces))
entity.mesh_edge_name_interfaces.extend(boundaries)
for entity_physical_name in entity.physical_name:
boundary_name = (
f"{entity_physical_name}{boundary_delimiter}{mesh_edge_name}"
Expand Down
Loading

0 comments on commit 45c56f6

Please sign in to comment.