Skip to content

Commit

Permalink
fix: Fix BOUNDARY_PRESCRIBED_MOTION and CONSTRAINED_BEAM_IN_SOLID (#668)
Browse files Browse the repository at this point in the history
Co-authored-by: Mohamed Koubaa <[email protected]>
Co-authored-by: pyansys-ci-bot <[email protected]>
  • Loading branch information
3 people authored Jan 14, 2025
1 parent 9992597 commit f5ac5cc
Show file tree
Hide file tree
Showing 21 changed files with 173 additions and 74 deletions.
28 changes: 19 additions & 9 deletions codegen/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,17 @@ class Insertion:
card: typing.Dict = None


def get_card(source: str, identity: str):
if source != "additional-cards":
# TODO - allow getting option from elsewhere, like a given keywords/card index
# or a new location entirely
raise Exception()
return ADDITIONAL_CARDS[identity]
def get_card(setting: typing.Dict[str, str]):
source = setting["source"]
if source == "kwd-data":
data = KWDM_INSTANCE.get_keyword_data_dict(setting["keyword-name"])
card = data[setting["card-index"]]
return card

if source == "additional-cards":
return ADDITIONAL_CARDS[setting["card-name"]]

raise Exception()


def get_classname(keyword: str):
Expand Down Expand Up @@ -190,15 +195,15 @@ def handle_card_sets(kwd_data, settings):
def handle_replace_cards(kwd_data, settings):
for card_settings in settings:
index = card_settings["index"]
replacement = get_card(card_settings["card"]["source"], card_settings["card"]["card-name"])
replacement = get_card(card_settings["card"])
replacement["index"] = index
kwd_data["cards"][index] = replacement


def handle_insert_cards(kwd_data, settings):
for card_settings in settings:
index = card_settings["index"]
card = get_card(card_settings["card"]["source"], card_settings["card"]["card-name"])
card = get_card(card_settings["card"])
insertion = Insertion(index, "", card)
kwd_data["card_insertions"].append(insertion)

Expand Down Expand Up @@ -280,6 +285,8 @@ def handle_override_field(kwd_data, settings):
field["default"] = setting["default"]
if "options" in setting:
field["options"] = setting["options"]
if "new-name" in setting:
field["name"] = setting["new-name"]

def handle_rename_property(kwd_data, settings):
for setting in settings:
Expand Down Expand Up @@ -311,7 +318,7 @@ def handle_override_subkeyword(kwd_data, settings) -> None:

def handle_add_option(kwd_data, settings):
def expand(card):
card = get_card(card["source"], card["card-name"])
card = get_card(card)
if "active" in card:
card["func"] = card["active"]
return card
Expand Down Expand Up @@ -672,7 +679,10 @@ def get_loader():

def match_wildcard(keyword, wildcard):
assert wildcard["type"] == "prefix"
exclusions = set(wildcard.get("exclusions", []))
for pattern in wildcard["patterns"]:
if keyword in exclusions:
continue
if keyword.startswith(f"{pattern}"):
return True
return False
Expand Down
40 changes: 40 additions & 0 deletions codegen/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
]
}
},
{
"type": "prefix",
"patterns": ["BOUNDARY_PRESCRIBED_MOTION"],
"exclusions": ["BOUNDARY_PRESCRIBED_MOTION_SET_SEGMENT"],
"generation-options": {
"conditional-card": [
{
"index": 1,
"func": "abs(self.dof) in [9, 10, 11] or self.vad==4"
}
]
}
},
{
"type": "prefix",
"patterns": ["CONSTRAINED_NODAL_RIGID_BODY"],
Expand Down Expand Up @@ -95,6 +108,33 @@
}
}
],
"CONSTRAINED_BEAM_IN_SOLID": {
"generation-options": {
"add-option": [
{
"card-order": 1,
"title-order": 0,
"cards": [
{
"source": "kwd-data",
"keyword-name": "CONSTRAINED_BEAM_IN_SOLID",
"card-index": 0
}
],
"option-name": "ID"
}
],
"skip-card": 0,
"override-field": [
{
"index": 1,
"name": "ncoup ",
"new-name": "ncoup"
}
]
},
"comment": "TODO - the option name is either ID or TITLE, but there is no way in pydyna to have a union option"
},
"DEFINE_TRANSFORMATION": {
"generation-options": {
"duplicate-card": [
Expand Down
1 change: 1 addition & 0 deletions doc/changelog/668.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: Fix BOUNDARY_PRESCRIBED_MOTION and CONSTRAINED_BEAM_IN_SOLID
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def __init__(self, **kwargs):
kwargs.get("lcbchk", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, **kwargs):
kwargs.get("node2", 0 if use_lspp_defaults() else None)
),
],
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
),
Card(
[
Expand Down
Loading

0 comments on commit f5ac5cc

Please sign in to comment.