Skip to content

Commit f7c50f6

Browse files
koubaaMohamed Koubaapyansys-ci-botpre-commit-ci[bot]
authored
feat: Assign fields for duplicate cards in constructor (#716)
Co-authored-by: Mohamed Koubaa <[email protected]> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 81e43d2 commit f7c50f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+403
-78
lines changed

codegen/templates/keyword/card.j2

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
{% if card.duplicate.active_func %}
4545
lambda: {{card.duplicate.active_func}},
4646
{% endif %}
47-
data = kwargs.get("{{card.duplicate.name}}")),
47+
name="{{card.duplicate.name}}",
48+
**kwargs,
49+
),
4850
{% elif card.duplicate_group %}
4951
DuplicateCardGroup(
5052
[
@@ -76,7 +78,9 @@
7678
{% else %}
7779
None,
7880
{% endif %}
79-
data = kwargs.get("{{card.overall_name}}")),
81+
"{{card.overall_name}}",
82+
**kwargs,
83+
),
8084
{% elif card.external %}
8185
{{card.external.name}}(**kwargs)
8286
{% else %}

doc/changelog/716.documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: Assign fields for duplicate cards in constructor

examples/Buckling_Beer_Can/plot_beercan_data.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,33 @@ def write_deck(filepath):
9595
]
9696
)
9797

98-
# Append part keywords
99-
can_part = kwd.Part()
100-
can_part.parts = pd.DataFrame({"heading": ["Beer Can"], "pid": [1], "secid": [1], "mid": [1], "eosid": [0]})
101-
102-
floorPart = kwd.Part()
103-
floorPart.parts = pd.DataFrame({"heading": ["Floor"], "pid": [2], "secid": [2], "mid": [1]})
98+
# Part keywords
99+
can_part = kwd.Part(heading="Beer Can", pid=1, secid=1, mid=1, eosid=0)
100+
floor_part = kwd.Part(heading="Floor", pid=2, secid=2, mid=1)
104101

102+
# Material keywords
105103
mat_elastic = kwd.MatElastic(mid=1, ro=2.59e-4, e=1.0e7, pr=0.33, title="Aluminum")
106104
mat_elastic.options["TITLE"].active = True
107105

106+
# Section keywords
108107
can_shell = kwd.SectionShell(secid=1, elform=-16, shrf=0.8333, nip=3, t1=0.002, propt=0.0, title="Beer Can")
109108
can_shell.options["TITLE"].active = True
110109

111110
floor_shell = kwd.SectionShell(secid=2, elform=-16, shrf=0.833, t1=0.01, propt=0.0)
112111
floor_shell.options["TITLE"].active = True
113112
floor_shell.title = "Floor - Just for Contact (Rigid Wall Would Have Worked Also)"
114-
# Append material keywords
113+
115114
deck.extend(
116115
[
117116
can_part,
118117
can_shell,
119-
floorPart,
118+
floor_part,
120119
floor_shell,
121120
mat_elastic,
122121
]
123122
)
124123

124+
# Load curve
125125
load_curve = kwd.DefineCurve(lcid=1, curves=pd.DataFrame({"a1": [0.00, 1.00], "o1": [0.0, 1.000]}))
126126
load_curve.options["TITLE"].active = True
127127
load_curve.title = "Load vs. Time"

examples/John_Reid_Pendulum/plot_john_reid_pendulum.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ def write_deck(filepath):
131131

132132
spherePart = kwd.Part()
133133
spherePart.parts = pd.DataFrame({"heading": ["sphere1", "sphere2"], "pid": [1, 2], "secid": [1, 2], "mid": [1, 1]})
134-
beamPart = kwd.Part()
135-
beamPart.parts = pd.DataFrame(
136-
{"heading": ["Pendulum Wires - Elastic Beams"], "pid": [45], "secid": [45], "mid": [45]}
137-
)
134+
beamPart = kwd.Part(heading="Pendulum Wires - Elastic Beams", pid=45, secid=45, mid=45)
138135

139136
deck.extend(
140137
[

examples/John_Reid_Pipe/plot_john_pipe.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ def write_deck(filepath):
136136
)
137137

138138
# Define bracket parts and materials
139-
bracket_parts = kwd.Part()
140-
bracket_parts.parts = pd.DataFrame({"heading": ["Bracket"], "pid": [4], "secid": [4], "mid": [4]})
139+
bracket_parts = kwd.Part(heading="Bracket", pid=4, secid=4, mid=4)
141140

142141
deck.extend(
143142
[

examples/Taylor_Bar/plot_taylor_bar.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
import ansys.dpf.core as dpf
4848
import matplotlib.pyplot as plt
49-
import pandas as pd
5049

5150
from ansys.dyna.core import Deck
5251
from ansys.dyna.core import keywords as kwd
@@ -84,8 +83,7 @@ def create_input_deck(initial_velocity):
8483
sec_1.elform = 1
8584

8685
# Define part
87-
part_1 = kwd.Part()
88-
part_1.parts = pd.DataFrame({"pid": [1], "mid": [mat_1.mid], "secid": [sec_1.secid]})
86+
part_1 = kwd.Part(pid=1, mid=mat_1.mid, secid=sec_1.secid)
8987

9088
# Define coordinate system
9189
cs_1 = kwd.DefineCoordinateSystem(cid=1)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def __init__(self, **kwargs):
5252
Field("dofrz", int, 70, 10),
5353
],
5454
None,
55-
data = kwargs.get("nodes")),
55+
name="nodes",
56+
**kwargs,
57+
),
5658
OptionCardSet(
5759
option_spec = BoundarySpcNode.option_specs[0],
5860
cards = [

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def __init__(self, **kwargs):
4242
Field("nid2", int, 20, 10),
4343
],
4444
None,
45-
data = kwargs.get("constrains")),
45+
name="constrains",
46+
**kwargs,
47+
),
4648
]
4749

4850
@property

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ def __init__(self, **kwargs):
9191
],
9292
None,
9393
None,
94-
data = kwargs.get("constrained_nodal_rigid_bodies")),
94+
"constrained_nodal_rigid_bodies",
95+
**kwargs,
96+
),
9597
OptionCardSet(
9698
option_spec = ConstrainedNodalRigidBody.option_specs[0],
9799
cards = [

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def __init__(self, **kwargs):
109109
],
110110
None,
111111
None,
112-
data = kwargs.get("transformation")),
112+
"transformation",
113+
**kwargs,
114+
),
113115
]
114116

115117
@property

0 commit comments

Comments
 (0)