Skip to content

Commit f5ac5cc

Browse files
koubaaMohamed Koubaapyansys-ci-bot
authored
fix: Fix BOUNDARY_PRESCRIBED_MOTION and CONSTRAINED_BEAM_IN_SOLID (#668)
Co-authored-by: Mohamed Koubaa <[email protected]> Co-authored-by: pyansys-ci-bot <[email protected]>
1 parent 9992597 commit f5ac5cc

21 files changed

+173
-74
lines changed

codegen/generate.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,17 @@ class Insertion:
100100
card: typing.Dict = None
101101

102102

103-
def get_card(source: str, identity: str):
104-
if source != "additional-cards":
105-
# TODO - allow getting option from elsewhere, like a given keywords/card index
106-
# or a new location entirely
107-
raise Exception()
108-
return ADDITIONAL_CARDS[identity]
103+
def get_card(setting: typing.Dict[str, str]):
104+
source = setting["source"]
105+
if source == "kwd-data":
106+
data = KWDM_INSTANCE.get_keyword_data_dict(setting["keyword-name"])
107+
card = data[setting["card-index"]]
108+
return card
109+
110+
if source == "additional-cards":
111+
return ADDITIONAL_CARDS[setting["card-name"]]
112+
113+
raise Exception()
109114

110115

111116
def get_classname(keyword: str):
@@ -190,15 +195,15 @@ def handle_card_sets(kwd_data, settings):
190195
def handle_replace_cards(kwd_data, settings):
191196
for card_settings in settings:
192197
index = card_settings["index"]
193-
replacement = get_card(card_settings["card"]["source"], card_settings["card"]["card-name"])
198+
replacement = get_card(card_settings["card"])
194199
replacement["index"] = index
195200
kwd_data["cards"][index] = replacement
196201

197202

198203
def handle_insert_cards(kwd_data, settings):
199204
for card_settings in settings:
200205
index = card_settings["index"]
201-
card = get_card(card_settings["card"]["source"], card_settings["card"]["card-name"])
206+
card = get_card(card_settings["card"])
202207
insertion = Insertion(index, "", card)
203208
kwd_data["card_insertions"].append(insertion)
204209

@@ -280,6 +285,8 @@ def handle_override_field(kwd_data, settings):
280285
field["default"] = setting["default"]
281286
if "options" in setting:
282287
field["options"] = setting["options"]
288+
if "new-name" in setting:
289+
field["name"] = setting["new-name"]
283290

284291
def handle_rename_property(kwd_data, settings):
285292
for setting in settings:
@@ -311,7 +318,7 @@ def handle_override_subkeyword(kwd_data, settings) -> None:
311318

312319
def handle_add_option(kwd_data, settings):
313320
def expand(card):
314-
card = get_card(card["source"], card["card-name"])
321+
card = get_card(card)
315322
if "active" in card:
316323
card["func"] = card["active"]
317324
return card
@@ -672,7 +679,10 @@ def get_loader():
672679

673680
def match_wildcard(keyword, wildcard):
674681
assert wildcard["type"] == "prefix"
682+
exclusions = set(wildcard.get("exclusions", []))
675683
for pattern in wildcard["patterns"]:
684+
if keyword in exclusions:
685+
continue
676686
if keyword.startswith(f"{pattern}"):
677687
return True
678688
return False

codegen/manifest.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@
1919
]
2020
}
2121
},
22+
{
23+
"type": "prefix",
24+
"patterns": ["BOUNDARY_PRESCRIBED_MOTION"],
25+
"exclusions": ["BOUNDARY_PRESCRIBED_MOTION_SET_SEGMENT"],
26+
"generation-options": {
27+
"conditional-card": [
28+
{
29+
"index": 1,
30+
"func": "abs(self.dof) in [9, 10, 11] or self.vad==4"
31+
}
32+
]
33+
}
34+
},
2235
{
2336
"type": "prefix",
2437
"patterns": ["CONSTRAINED_NODAL_RIGID_BODY"],
@@ -95,6 +108,33 @@
95108
}
96109
}
97110
],
111+
"CONSTRAINED_BEAM_IN_SOLID": {
112+
"generation-options": {
113+
"add-option": [
114+
{
115+
"card-order": 1,
116+
"title-order": 0,
117+
"cards": [
118+
{
119+
"source": "kwd-data",
120+
"keyword-name": "CONSTRAINED_BEAM_IN_SOLID",
121+
"card-index": 0
122+
}
123+
],
124+
"option-name": "ID"
125+
}
126+
],
127+
"skip-card": 0,
128+
"override-field": [
129+
{
130+
"index": 1,
131+
"name": "ncoup ",
132+
"new-name": "ncoup"
133+
}
134+
]
135+
},
136+
"comment": "TODO - the option name is either ID or TITLE, but there is no way in pydyna to have a union option"
137+
},
98138
"DEFINE_TRANSFORMATION": {
99139
"generation-options": {
100140
"duplicate-card": [

doc/changelog/668.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fix: Fix BOUNDARY_PRESCRIBED_MOTION and CONSTRAINED_BEAM_IN_SOLID

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
]
137138

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion_edge_uvw.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
Card(
137138
[

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion_face_xyz.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
Card(
137138
[

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion_node.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
]
137138

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion_point_uvw.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
Card(
137138
[

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion_rigid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
]
137138

src/ansys/dyna/core/keywords/keyword_classes/auto/boundary_prescribed_motion_rigid_bndout2dynain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def __init__(self, **kwargs):
132132
kwargs.get("node2", 0 if use_lspp_defaults() else None)
133133
),
134134
],
135+
lambda: abs(self.dof) in [9, 10, 11] or self.vad==4,
135136
),
136137
Card(
137138
[

0 commit comments

Comments
 (0)