14
14
from ansys .api .dyna .v0 .kwprocess_pb2 import * # noqa : F403
15
15
from ansys .api .dyna .v0 .kwprocess_pb2_grpc import * # noqa : F403
16
16
17
+ # from .kwprocess_pb2 import *
18
+ # from .kwprocess_pb2_grpc import *
19
+
17
20
18
21
class Motion (Enum ):
19
22
VELOCITY = 0
@@ -259,6 +262,18 @@ def __init__(self, x=0, y=0, z=0):
259
262
self .z = z
260
263
261
264
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
+
262
277
class DynaBase :
263
278
"""Contains methods for creating a general LS-DYNA keyword."""
264
279
@@ -804,6 +819,12 @@ def create_general_keyword(self, opcode, keyworddata):
804
819
805
820
def add (self , obj ):
806
821
"""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 )
807
828
self .entities .append (obj )
808
829
809
830
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):
1788
1809
VARIABLE = 1
1789
1810
1790
1811
1791
- class ThermalAnalysis :
1812
+ class ThermalAnalysis ( BaseObj ) :
1792
1813
"""Activates thermal analysis and defines associated control parameters."""
1793
1814
1794
1815
def __init__ (self ):
1795
1816
self .defined_solver = False
1796
1817
self .defined_timestep = False
1797
1818
self .defined_nonlinear = False
1798
1819
self .stub = DynaBase .get_stub ()
1820
+ self .type = "analysis_thermal"
1799
1821
1800
1822
def set_timestep (self , timestep_control = ThermalAnalysisTimestep .FIXED , initial_timestep = 0 ):
1801
1823
"""Set time step controls for the thermal solution in a thermal only or coupled structural/thermal analysis.
@@ -2591,7 +2613,7 @@ def create(self):
2591
2613
logging .info (f"Define temperature at { type } { id } ." )
2592
2614
2593
2615
2594
- class RigidwallCylinder :
2616
+ class RigidwallCylinder ( BaseObj ) :
2595
2617
"""Defines a rigid wall with a cylinder form.
2596
2618
2597
2619
Parameters
@@ -2617,6 +2639,7 @@ def __init__(self, tail=Point(0, 0, 0), head=Point(0, 0, 0), radius=1, length=10
2617
2639
self .motion = - 1
2618
2640
self .lcid = 0
2619
2641
self .dir = Direction (1 , 0 , 0 )
2642
+ self .type = "rigidwall_cylinder"
2620
2643
2621
2644
def set_motion (self , curve , motion = RWMotion .VELOCITY , dir = Direction (1 , 0 , 0 )):
2622
2645
"""Set the prescribed motion."""
@@ -2625,6 +2648,21 @@ def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
2625
2648
self .motion = motion .value
2626
2649
self .dir = dir
2627
2650
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
+
2628
2666
def create (self ):
2629
2667
"""Create a rigidwall cylinder."""
2630
2668
parameter = [
@@ -2652,7 +2690,7 @@ def create(self):
2652
2690
logging .info ("Cylinder Rigidwall Created..." )
2653
2691
2654
2692
2655
- class RigidwallSphere :
2693
+ class RigidwallSphere ( BaseObj ) :
2656
2694
"""Defines a rigid wall with a sphere form.
2657
2695
2658
2696
Parameters
@@ -2676,6 +2714,7 @@ def __init__(self, center=Point(0, 0, 0), orient=Point(0, 0, 0), radius=1):
2676
2714
self .motion = - 1
2677
2715
self .lcid = 0
2678
2716
self .dir = Direction (1 , 0 , 0 )
2717
+ self .type = "rigidwall_sphere"
2679
2718
2680
2719
def set_motion (self , curve , motion = RWMotion .VELOCITY , dir = Direction (1 , 0 , 0 )):
2681
2720
"""Set the prescribed motion."""
@@ -2684,6 +2723,20 @@ def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
2684
2723
self .motion = motion .value
2685
2724
self .dir = dir
2686
2725
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
+
2687
2740
def create (self ):
2688
2741
"""Create a rigidwall sphere."""
2689
2742
parameter = [
@@ -2710,7 +2763,7 @@ def create(self):
2710
2763
logging .info ("Sphere Rigidwall Created..." )
2711
2764
2712
2765
2713
- class RigidwallPlanar :
2766
+ class RigidwallPlanar ( BaseObj ) :
2714
2767
"""Defines planar rigid walls with either finite or infinite size.
2715
2768
2716
2769
Parameters
@@ -2730,6 +2783,12 @@ def __init__(self, tail=Point(0, 0, 0), head=Point(0, 0, 0), coulomb_friction_co
2730
2783
self .tail = tail
2731
2784
self .head = head
2732
2785
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
2733
2792
2734
2793
def create (self ):
2735
2794
"""Create planar rigid walls."""
@@ -2753,7 +2812,7 @@ class GravityOption(Enum):
2753
2812
DIR_Z = "Z"
2754
2813
2755
2814
2756
- class Gravity :
2815
+ class Gravity ( BaseObj ) :
2757
2816
"""Defines body force loads using global axes directions.
2758
2817
2759
2818
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])):
2764
2823
self .stub = DynaBase .get_stub ()
2765
2824
self .dir = dir .value
2766
2825
self .load = load
2826
+ self .type = "gravity"
2767
2827
2768
2828
def create (self ):
2769
2829
"""Define a body force."""
0 commit comments