43
43
get_coupled_nodes_to_master_map as _get_coupled_nodes_to_master_map ,
44
44
)
45
45
from meshpy .core .node import NodeCosserat as _NodeCosserat
46
- from meshpy .four_c .element_beam import Beam3rHerm2Line3 as _Beam3rHerm2Line3
47
- from meshpy .four_c .element_beam import Beam3rLine2Line2 as _Beam3rLine2Line2
48
46
from meshpy .utils .nodes import get_nodal_coordinates as _get_nodal_coordinates
49
47
50
48
@@ -58,80 +56,26 @@ def __init__(self, coordinates, rotation, time, **kwargs):
58
56
super ().__init__ (coordinates , rotation , ** kwargs )
59
57
self .time = time
60
58
61
- def _get_dat (self ):
62
- """Return the line that represents this node in the input file.
63
-
64
- For now, we add time to the z-dimension. In the future, we could
65
- add the time to the element description, similar to the rotation
66
- vectors
67
- """
68
-
69
- space_time_coordinates = self .coordinates .copy ()
70
- space_time_coordinates [2 ] += self .time
71
-
72
- coordinate_string = " " .join (
73
- [
74
- (
75
- _mpy .dat_precision .format (component + 0 )
76
- if _np .abs (component ) >= _mpy .eps_pos
77
- else "0"
78
- )
79
- for component in space_time_coordinates
80
- ]
81
- )
82
- return f"NODE { self .i_global } COORD { coordinate_string } "
83
-
84
59
85
60
class SpaceTimeElement (_VolumeElement ):
86
61
"""A general beam space-time surface element."""
87
62
88
- def __init__ (
89
- self ,
90
- nodes ,
91
- * ,
92
- dat_pre_nodes = "DUMMY" ,
93
- dat_post_nodes = "POST_DUMMY" ,
94
- ** kwargs ,
95
- ):
96
- super ().__init__ (
97
- nodes = nodes ,
98
- dat_pre_nodes = dat_pre_nodes ,
99
- dat_post_nodes = dat_post_nodes ,
100
- ** kwargs ,
101
- )
102
-
103
- def _get_dat (self ):
104
- """Return the dat line for this element."""
105
-
106
- # String with the node ids.
107
- nodes_string = ""
108
- for node in self .nodes :
109
- nodes_string += f"{ node .i_global } "
110
-
111
- # Rotation vector string
112
- rotation_vectors = []
113
- for node in self .nodes :
114
- rotation_vectors .extend (node .rotation .get_rotation_vector ())
115
- rotation_vectors = map (str , rotation_vectors )
116
-
117
- # Return the dat line.
118
- return f"{ self .i_global } { self .dat_pre_nodes } { self .four_c_name } { nodes_string } { self .dat_post_nodes } { ' ' .join (rotation_vectors )} "
63
+ def __init__ (self , nodes , ** kwargs ):
64
+ super ().__init__ (nodes = nodes , ** kwargs )
119
65
120
66
121
67
class SpaceTimeElementQuad4 (SpaceTimeElement ):
122
68
"""A space-time element with 4 nodes."""
123
69
124
70
vtk_cell_type = _vtk .vtkQuad
125
71
vtk_topology = list (range (4 ))
126
- four_c_name = "QUAD4"
127
72
128
73
129
74
class SpaceTimeElementQuad9 (SpaceTimeElement ):
130
75
"""A space-time element with 9 nodes."""
131
76
132
77
vtk_cell_type = _vtk .vtkQuadraticQuad
133
78
vtk_topology = list (range (9 ))
134
- four_c_name = "QUAD9"
135
79
136
80
137
81
def beam_to_space_time (
@@ -143,27 +87,26 @@ def beam_to_space_time(
143
87
) -> _Tuple [_Mesh , _GeometryName ]:
144
88
"""Convert a MeshPy beam mesh to a surface space-time mesh.
145
89
146
- Args
147
- ----
148
- mesh_space_or_generator:
149
- Either a fixed spatial Mesh object or a function that returns the
150
- spatial mesh for a given time. If this is a generator, the topology
151
- of the mesh at the initial time is chosen for all times, only the
152
- positions and rotations are updated.
153
- time_duration:
154
- Total time increment to be solved with the space-time mesh
155
- number_of_elements_in_time:
156
- Number of elements in time direction
157
- time_start:
158
- Starting time for the space-time mesh. Can be used to create time slaps.
159
- Return
160
- ----
161
- space_time_mesh:
162
- The space time mesh. Be aware that translating / rotating this mesh
163
- might lead to unexpected results.
164
- return_set:
165
- The nodes sets to be returned for the space time mesh:
166
- "start", "end", "left", "right", "surface"
90
+ Args:
91
+ mesh_space_or_generator:
92
+ Either a fixed spatial Mesh object or a function that returns the
93
+ spatial mesh for a given time. If this is a generator, the topology
94
+ of the mesh at the initial time is chosen for all times, only the
95
+ positions and rotations are updated.
96
+ time_duration:
97
+ Total time increment to be solved with the space-time mesh
98
+ number_of_elements_in_time:
99
+ Number of elements in time direction
100
+ time_start:
101
+ Starting time for the space-time mesh. Can be used to create time slaps.
102
+ Returns:
103
+ Tuple (space_time_mesh, return_set)
104
+ - space_time_mesh:
105
+ The space time mesh. Be aware that translating / rotating this mesh
106
+ might lead to unexpected results.
107
+ - return_set:
108
+ The nodes sets to be returned for the space time mesh:
109
+ "start", "end", "left", "right", "surface"
167
110
"""
168
111
169
112
# Get the "reference" spatial mesh
@@ -186,11 +129,11 @@ def beam_to_space_time(
186
129
space_time_element_type : _Union [
187
130
_Type [SpaceTimeElementQuad4 ], _Type [SpaceTimeElementQuad9 ]
188
131
]
189
- if element_type == _Beam3rLine2Line2 :
132
+ if len ( element_type . nodes_create ) == 2 :
190
133
number_of_copies_in_time = number_of_elements_in_time + 1
191
134
time_increment_between_nodes = time_duration / number_of_elements_in_time
192
135
space_time_element_type = SpaceTimeElementQuad4
193
- elif element_type == _Beam3rHerm2Line3 :
136
+ elif len ( element_type . nodes_create ) == 3 :
194
137
number_of_copies_in_time = 2 * number_of_elements_in_time + 1
195
138
time_increment_between_nodes = time_duration / (2 * number_of_elements_in_time )
196
139
space_time_element_type = SpaceTimeElementQuad9
0 commit comments