Skip to content

Commit a268ac8

Browse files
committed
Merge branch 'main' into release/0.4
2 parents 81f4c7e + 9fc2058 commit a268ac8

File tree

12 files changed

+200
-34
lines changed

12 files changed

+200
-34
lines changed

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ dependencies = ["ansys-dpf-core>=0.7.2",
3333
[project.optional-dependencies]
3434
tests = [
3535
"pyvista==0.43.3",
36-
"matplotlib==3.8.2",
37-
"numpy==1.26.3",
36+
"matplotlib==3.8.3",
37+
"numpy==1.26.4",
3838
"pytest==8.0.1",
3939
"pytest-cov==4.1.0",
4040
"joblib==1.3.2",
4141
"pandas==2.2.0",
4242
"openpyxl==3.1.2",
43-
"scikit-learn==1.4.0",
43+
"scikit-learn==1.4.1.post1",
4444
"pytest-xdist==3.5.0",
45-
"ipython==8.21.0",
45+
"ipython==8.22.1",
4646
]
4747
doc = [
4848
"recommonmark==0.7.1",
49-
"matplotlib==3.8.2",
49+
"matplotlib==3.8.3",
5050
"imageio==2.34.0",
5151
"imageio-ffmpeg==0.4.9",
5252
"pyvista==0.43.3",
@@ -64,9 +64,9 @@ doc = [
6464
"nbsphinx==0.9.3",
6565
"ipywidgets==8.1.2",
6666
"joblib==1.3.2",
67-
"scikit-learn==1.4.0",
68-
"ipython==8.21.0",
69-
"jupyterlab==4.1.1",
67+
"scikit-learn==1.4.1.post1",
68+
"ipython==8.22.1",
69+
"jupyterlab==4.1.2",
7070
"sphinx-jinja==2.0.2",
7171
"sphinx-autoapi==3.0.0",
7272
]

src/ansys/dyna/core/pre/dynabase.py

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
from ansys.api.dyna.v0.kwprocess_pb2 import * # noqa : F403
1515
from ansys.api.dyna.v0.kwprocess_pb2_grpc import * # noqa : F403
1616

17+
# from .kwprocess_pb2 import *
18+
# from .kwprocess_pb2_grpc import *
19+
1720

1821
class Motion(Enum):
1922
VELOCITY = 0
@@ -259,6 +262,18 @@ def __init__(self, x=0, y=0, z=0):
259262
self.z = z
260263

261264

265+
class BaseObj:
266+
"""Define the base object."""
267+
268+
def __init__(self):
269+
self.type = ""
270+
self.subtype = ""
271+
272+
def get_data(self) -> List:
273+
"""Get the data of the object."""
274+
return None
275+
276+
262277
class DynaBase:
263278
"""Contains methods for creating a general LS-DYNA keyword."""
264279

@@ -804,6 +819,12 @@ def create_general_keyword(self, opcode, keyworddata):
804819

805820
def add(self, obj):
806821
"""Add entities to an object."""
822+
823+
if obj.type == "rigidwall_cylinder" or obj.type == "rigidwall_sphere" or obj.type == "rigidwall_planar":
824+
data = obj.get_data()
825+
if data != None:
826+
model = self._parent.model
827+
model.add_rigidwall(data)
807828
self.entities.append(obj)
808829

809830
def set_transform(self, filename=None, idnoff=0, ideoff=0, idpoff=0, idmoff=0, idsoff=0, idfoff=0, transform=None):
@@ -1788,14 +1809,15 @@ class ThermalAnalysisTimestep(Enum):
17881809
VARIABLE = 1
17891810

17901811

1791-
class ThermalAnalysis:
1812+
class ThermalAnalysis(BaseObj):
17921813
"""Activates thermal analysis and defines associated control parameters."""
17931814

17941815
def __init__(self):
17951816
self.defined_solver = False
17961817
self.defined_timestep = False
17971818
self.defined_nonlinear = False
17981819
self.stub = DynaBase.get_stub()
1820+
self.type = "analysis_thermal"
17991821

18001822
def set_timestep(self, timestep_control=ThermalAnalysisTimestep.FIXED, initial_timestep=0):
18011823
"""Set time step controls for the thermal solution in a thermal only or coupled structural/thermal analysis.
@@ -2591,7 +2613,7 @@ def create(self):
25912613
logging.info(f"Define temperature at {type} {id}.")
25922614

25932615

2594-
class RigidwallCylinder:
2616+
class RigidwallCylinder(BaseObj):
25952617
"""Defines a rigid wall with a cylinder form.
25962618
25972619
Parameters
@@ -2617,6 +2639,7 @@ def __init__(self, tail=Point(0, 0, 0), head=Point(0, 0, 0), radius=1, length=10
26172639
self.motion = -1
26182640
self.lcid = 0
26192641
self.dir = Direction(1, 0, 0)
2642+
self.type = "rigidwall_cylinder"
26202643

26212644
def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
26222645
"""Set the prescribed motion."""
@@ -2625,6 +2648,21 @@ def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
26252648
self.motion = motion.value
26262649
self.dir = dir
26272650

2651+
def get_data(self) -> List:
2652+
"""Get the rigidwall data."""
2653+
data = [
2654+
self.type,
2655+
self.tail.x,
2656+
self.tail.y,
2657+
self.tail.z,
2658+
self.head.x,
2659+
self.head.y,
2660+
self.head.z,
2661+
self.radius,
2662+
self.length,
2663+
]
2664+
return data
2665+
26282666
def create(self):
26292667
"""Create a rigidwall cylinder."""
26302668
parameter = [
@@ -2652,7 +2690,7 @@ def create(self):
26522690
logging.info("Cylinder Rigidwall Created...")
26532691

26542692

2655-
class RigidwallSphere:
2693+
class RigidwallSphere(BaseObj):
26562694
"""Defines a rigid wall with a sphere form.
26572695
26582696
Parameters
@@ -2676,6 +2714,7 @@ def __init__(self, center=Point(0, 0, 0), orient=Point(0, 0, 0), radius=1):
26762714
self.motion = -1
26772715
self.lcid = 0
26782716
self.dir = Direction(1, 0, 0)
2717+
self.type = "rigidwall_sphere"
26792718

26802719
def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
26812720
"""Set the prescribed motion."""
@@ -2684,6 +2723,20 @@ def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
26842723
self.motion = motion.value
26852724
self.dir = dir
26862725

2726+
def get_data(self) -> List:
2727+
"""Get the rigidwall data."""
2728+
data = [
2729+
self.type,
2730+
self.center.x,
2731+
self.center.y,
2732+
self.center.z,
2733+
self.orient.x,
2734+
self.orient.y,
2735+
self.orient.z,
2736+
self.radius,
2737+
]
2738+
return data
2739+
26872740
def create(self):
26882741
"""Create a rigidwall sphere."""
26892742
parameter = [
@@ -2710,7 +2763,7 @@ def create(self):
27102763
logging.info("Sphere Rigidwall Created...")
27112764

27122765

2713-
class RigidwallPlanar:
2766+
class RigidwallPlanar(BaseObj):
27142767
"""Defines planar rigid walls with either finite or infinite size.
27152768
27162769
Parameters
@@ -2730,6 +2783,12 @@ def __init__(self, tail=Point(0, 0, 0), head=Point(0, 0, 0), coulomb_friction_co
27302783
self.tail = tail
27312784
self.head = head
27322785
self.fric = coulomb_friction_coefficient
2786+
self.type = "rigidwall_planar"
2787+
2788+
def get_data(self) -> List:
2789+
"""Get the rigidwall data."""
2790+
data = [self.type, self.tail.x, self.tail.y, self.tail.z, self.head.x, self.head.y, self.head.z]
2791+
return data
27332792

27342793
def create(self):
27352794
"""Create planar rigid walls."""
@@ -2753,7 +2812,7 @@ class GravityOption(Enum):
27532812
DIR_Z = "Z"
27542813

27552814

2756-
class Gravity:
2815+
class Gravity(BaseObj):
27572816
"""Defines body force loads using global axes directions.
27582817
27592818
Body force loads are due to a prescribed base acceleration or
@@ -2764,6 +2823,7 @@ def __init__(self, dir=GravityOption.DIR_Z, load=Curve(x=[0, 0], y=[0, 0])):
27642823
self.stub = DynaBase.get_stub()
27652824
self.dir = dir.value
27662825
self.load = load
2826+
self.type = "gravity"
27672827

27682828
def create(self):
27692829
"""Define a body force."""

src/ansys/dyna/core/pre/dynadem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ def save_file(self):
112112
DynaBase.save_file(self)
113113

114114

115-
class DEMAnalysis:
115+
class DEMAnalysis(BaseObj):
116116
"""Activates DEM analysis and defines associated control parameters."""
117117

118118
def __init__(self):
119119
self.defined_des = False
120120
self.stub = DynaBase.get_stub()
121+
self.type = "analysis_dem"
121122

122123
def set_des(
123124
self,

src/ansys/dyna/core/pre/dynaem.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def create(self):
719719
return self.id
720720

721721

722-
class RogoCoil:
722+
class RogoCoil(BaseObj):
723723
"""Measures the total current flowing through a given section of the conductor.
724724
725725
Parameters
@@ -732,6 +732,7 @@ def __init__(self, set=None):
732732
self.stub = DynaBase.get_stub()
733733
self.set = set
734734
self.id = 0
735+
self.type = "rogocoil"
735736

736737
def create(self):
737738
"""Create a Rogowsky coil."""

src/ansys/dyna/core/pre/dynaicfd.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class ICFD_CouplingDirection(Enum):
246246
TWO_WAY_WEAK_COUPLING = 3
247247

248248

249-
class ICFDAnalysis:
249+
class ICFDAnalysis(BaseObj):
250250
"""Activates an ICFD analysis and defines associated control parameters."""
251251

252252
def __init__(self):
@@ -260,6 +260,7 @@ def __init__(self):
260260
self.defined_coupling_dem = False
261261
self.defined_mesh_adapt = False
262262
self.stub = DynaBase.get_stub()
263+
self.type = "analysis_icfd"
263264

264265
def set_type(self, analysis_type=ICFD_AnalysisType.TRANSIENT_ANALYSIS):
265266
"""Set the type of the CFD analysis.
@@ -733,7 +734,7 @@ def create(self):
733734
return ret
734735

735736

736-
class MeshedVolume:
737+
class MeshedVolume(BaseObj):
737738
"""Defines the volume space to mesh.
738739
739740
Parameters
@@ -749,6 +750,7 @@ def __init__(self, surfaces):
749750
self.embeded_surf = []
750751
self.meshsize_surf = []
751752
self.fluid_interfaces = []
753+
self.type = "meshedvolume"
752754

753755
def embed_shell(self, embeded):
754756
"""Define surfaces that the mesher is to embed inside the volume mesh.

src/ansys/dyna/core/pre/dynamech.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def save_file(self, defaultsetting=1):
320320
DynaBase.save_file(self)
321321

322322

323-
class Airbag:
323+
class Airbag(BaseObj):
324324
"""Defines an airbag or control volume.
325325
326326
Parameters
@@ -377,6 +377,7 @@ def __init__(
377377
self.sidtyp = 0
378378
else:
379379
self.sidtyp = 1
380+
self.type = "airbag"
380381

381382
def create(self):
382383
"""Create an airbag."""

src/ansys/dyna/core/pre/dynanvh.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ class ResponseType(Enum):
5555
NODAL_FORCE = 3
5656

5757

58-
class FrequencyDomain:
58+
class FrequencyDomain(BaseObj):
5959
"""Provides a way of defining and solving frequency domain vibration and acoustic problems."""
6060

6161
def __init__(self):
6262
self.stub = DynaBase.get_stub()
6363
self.defined_frf = False
64+
self.type = "frequency_domain"
6465

6566
def set_frequency_response_function(
6667
self,

src/ansys/dyna/core/pre/dynasale.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, number, position, ratio):
4242
self.ratio = ratio
4343

4444

45-
class StructuredMesh:
45+
class StructuredMesh(BaseObj):
4646
"""Generates a structured 2D or 3D mesh and invokes the S-ALE solver."""
4747

4848
def __init__(self, control_points_x, control_points_y, control_points_z):
@@ -54,6 +54,7 @@ def __init__(self, control_points_x, control_points_y, control_points_z):
5454
self.refine_factor_y = 1
5555
self.refine_factor_z = 1
5656
self.fillings = []
57+
self.type = "structured_mesh"
5758

5859
def fill(
5960
self,

src/ansys/dyna/core/pre/dynasolution.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
from ansys.dyna.core.pre.model import Model
2121

22+
# from .kwprocess_pb2 import *
23+
# from .kwprocess_pb2_grpc import *
24+
25+
2226
# from .launcher import * # noqa : F403
2327

2428
CHUNK_SIZE = 1024 * 1024

0 commit comments

Comments
 (0)