-
Notifications
You must be signed in to change notification settings - Fork 7
[SCFD-2744] [SCFD-2069] Added BC completeness check #489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
78681a0
91398c5
221a4dd
8dd1272
0aa87d2
1f93112
71f575c
971359b
0d7e880
c9ecb85
8da50a5
9c234a1
a3ea7b2
c443d28
31960a0
ecf2380
093e708
f497d72
1ff683a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
validation for SimulationParams | ||
""" | ||
|
||
from typing import get_args | ||
|
||
from flow360.component.simulation.models.solver_numerics import NoneSolver | ||
from flow360.component.simulation.models.surface_models import Wall | ||
from flow360.component.simulation.models.surface_models import SurfaceModelTypes, Wall | ||
from flow360.component.simulation.models.volume_models import ( | ||
Fluid, | ||
NavierStokesInitialCondition, | ||
|
@@ -17,6 +19,7 @@ | |
VolumeOutput, | ||
) | ||
from flow360.component.simulation.primitives import ( | ||
GhostSurface, | ||
_SurfaceEntityBase, | ||
_VolumeEntityBase, | ||
) | ||
|
@@ -264,3 +267,55 @@ def _validate_cht_has_heat_transfer(params): | |
) | ||
|
||
return params | ||
|
||
|
||
def _check_complete_boundary_condition_and_unknown_surface(params): | ||
## Step 1: Get all boundaries patches from asset cache | ||
asset_boundary_entities = params.private_attribute_asset_cache.boundaries | ||
if asset_boundary_entities is None or asset_boundary_entities == []: | ||
return params | ||
asset_boundaries = {boundary.name for boundary in asset_boundary_entities} | ||
|
||
## Step 2: Collect all used boundaries from the models | ||
if len(params.models) == 1 and isinstance(params.models[0], Fluid): | ||
return params | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there are no BC defined at all, why don't we raise? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because even if user composes a SimulationParams for meshing only this validator will still get triggered. The context validator does not control when validator is called. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this validator to adapt with current validation context. We only raise if we have CASE ValidationContext |
||
|
||
used_boundaries = set() | ||
|
||
for model in params.models: | ||
if not isinstance(model, get_args(SurfaceModelTypes)): | ||
continue | ||
|
||
entities = [] | ||
# pylint: disable=protected-access | ||
if hasattr(model, "entities"): | ||
entities = model.entities._get_expanded_entities(create_hard_copy=False) | ||
elif hasattr(model, "entity_pairs"): # Periodic BC | ||
entities = [ | ||
pair for surface_pair in model.entity_pairs.items for pair in surface_pair.pair | ||
] | ||
|
||
for entity in entities: | ||
if isinstance(entity, GhostSurface): | ||
continue | ||
used_boundaries.add(entity.name) | ||
maciej-flexcompute marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Step 3: Use set operations to find missing and unknown boundaries | ||
missing_boundaries = asset_boundaries - used_boundaries | ||
unknown_boundaries = used_boundaries - asset_boundaries | ||
|
||
if missing_boundaries: | ||
missing_list = ", ".join(sorted(missing_boundaries)) | ||
raise ValueError( | ||
f"The following boundaries do not have a boundary condition: {missing_list}. " | ||
"Please add them to a model in the `models` section." | ||
benflexcompute marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
if unknown_boundaries: | ||
unknown_list = ", ".join(sorted(unknown_boundaries)) | ||
raise ValueError( | ||
f"The following boundaries are not known `Surface` " | ||
f"entities but appear in the `models` section: {unknown_list}." | ||
) | ||
|
||
return params |
Uh oh!
There was an error while loading. Please reload this page.