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,7 +1809,7 @@ 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 ):
@@ -2591,7 +2612,7 @@ def create(self):
2591
2612
logging .info (f"Define temperature at { type } { id } ." )
2592
2613
2593
2614
2594
- class RigidwallCylinder :
2615
+ class RigidwallCylinder ( BaseObj ) :
2595
2616
"""Defines a rigid wall with a cylinder form.
2596
2617
2597
2618
Parameters
@@ -2617,6 +2638,7 @@ def __init__(self, tail=Point(0, 0, 0), head=Point(0, 0, 0), radius=1, length=10
2617
2638
self .motion = - 1
2618
2639
self .lcid = 0
2619
2640
self .dir = Direction (1 , 0 , 0 )
2641
+ self .type = "rigidwall_cylinder"
2620
2642
2621
2643
def set_motion (self , curve , motion = RWMotion .VELOCITY , dir = Direction (1 , 0 , 0 )):
2622
2644
"""Set the prescribed motion."""
@@ -2625,6 +2647,21 @@ def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
2625
2647
self .motion = motion .value
2626
2648
self .dir = dir
2627
2649
2650
+ def get_data (self ) -> List :
2651
+ """Get the rigidwall data."""
2652
+ data = [
2653
+ self .type ,
2654
+ self .tail .x ,
2655
+ self .tail .y ,
2656
+ self .tail .z ,
2657
+ self .head .x ,
2658
+ self .head .y ,
2659
+ self .head .z ,
2660
+ self .radius ,
2661
+ self .length ,
2662
+ ]
2663
+ return data
2664
+
2628
2665
def create (self ):
2629
2666
"""Create a rigidwall cylinder."""
2630
2667
parameter = [
@@ -2652,7 +2689,7 @@ def create(self):
2652
2689
logging .info ("Cylinder Rigidwall Created..." )
2653
2690
2654
2691
2655
- class RigidwallSphere :
2692
+ class RigidwallSphere ( BaseObj ) :
2656
2693
"""Defines a rigid wall with a sphere form.
2657
2694
2658
2695
Parameters
@@ -2676,6 +2713,7 @@ def __init__(self, center=Point(0, 0, 0), orient=Point(0, 0, 0), radius=1):
2676
2713
self .motion = - 1
2677
2714
self .lcid = 0
2678
2715
self .dir = Direction (1 , 0 , 0 )
2716
+ self .type = "rigidwall_sphere"
2679
2717
2680
2718
def set_motion (self , curve , motion = RWMotion .VELOCITY , dir = Direction (1 , 0 , 0 )):
2681
2719
"""Set the prescribed motion."""
@@ -2684,6 +2722,20 @@ def set_motion(self, curve, motion=RWMotion.VELOCITY, dir=Direction(1, 0, 0)):
2684
2722
self .motion = motion .value
2685
2723
self .dir = dir
2686
2724
2725
+ def get_data (self ) -> List :
2726
+ """Get the rigidwall data."""
2727
+ data = [
2728
+ self .type ,
2729
+ self .center .x ,
2730
+ self .center .y ,
2731
+ self .center .z ,
2732
+ self .orient .x ,
2733
+ self .orient .y ,
2734
+ self .orient .z ,
2735
+ self .radius ,
2736
+ ]
2737
+ return data
2738
+
2687
2739
def create (self ):
2688
2740
"""Create a rigidwall sphere."""
2689
2741
parameter = [
@@ -2710,7 +2762,7 @@ def create(self):
2710
2762
logging .info ("Sphere Rigidwall Created..." )
2711
2763
2712
2764
2713
- class RigidwallPlanar :
2765
+ class RigidwallPlanar ( BaseObj ) :
2714
2766
"""Defines planar rigid walls with either finite or infinite size.
2715
2767
2716
2768
Parameters
@@ -2730,6 +2782,12 @@ def __init__(self, tail=Point(0, 0, 0), head=Point(0, 0, 0), coulomb_friction_co
2730
2782
self .tail = tail
2731
2783
self .head = head
2732
2784
self .fric = coulomb_friction_coefficient
2785
+ self .type = "rigidwall_planar"
2786
+
2787
+ def get_data (self ) -> List :
2788
+ """Get the rigidwall data."""
2789
+ data = [self .type , self .tail .x , self .tail .y , self .tail .z , self .head .x , self .head .y , self .head .z ]
2790
+ return data
2733
2791
2734
2792
def create (self ):
2735
2793
"""Create planar rigid walls."""
@@ -2753,7 +2811,7 @@ class GravityOption(Enum):
2753
2811
DIR_Z = "Z"
2754
2812
2755
2813
2756
- class Gravity :
2814
+ class Gravity ( BaseObj ) :
2757
2815
"""Defines body force loads using global axes directions.
2758
2816
2759
2817
Body force loads are due to a prescribed base acceleration or
0 commit comments