diff --git a/README.md b/README.md index dfc6be6..5ebcf98 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ PyVista. For example, you could plot the resulting mesh. Here's a full example u >>> grid.plot(color="w", smooth_shading=True, show_edges=True) ``` -![Yaris Static Suspension Mesh](https://github.com/akaszynski/lsdyna-mesh-reader/blob/main/docs/source/images/yaris-mesh.png) +![Yaris Static Suspension Mesh](https://github.com/akaszynski/lsdyna-mesh-reader/raw/main/docs/source/images/yaris-mesh.png) ### Caveats and Limitations @@ -181,6 +181,7 @@ Additionally, this reader only supports the following keywords: * `*NODE` * `*ELEMENT_SHELL` * `*ELEMENT_SOLID` +* `*ELEMENT_TSHELL` (note: sections encoded as solid sections) The VTK UnstructuredGrid contains only the linear element conversion of the underlying LS-DYNA elements, and only supports `VTK_QUAD`, `VTK_TRIANGLE`, diff --git a/docs/source/api.rst b/docs/source/api.rst index 16eb013..a8d81fa 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -3,6 +3,8 @@ API Reference The following section contains the API reference for ``lsdyna-mesh-reader``. +**Reader** + .. autosummary:: :toctree: _autosummary :template: custom-class-template.rst @@ -11,3 +13,10 @@ The following section contains the API reference for ``lsdyna-mesh-reader``. lsdyna_mesh_reader._deck.NodeSection lsdyna_mesh_reader._deck.ElementShellSection lsdyna_mesh_reader._deck.ElementSolidSection + +**Examples** + +.. autosummary:: + :toctree: _autosummary + + lsdyna_mesh_reader.examples diff --git a/pyproject.toml b/pyproject.toml index 66463ea..b35c204 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ Repository = "https://github.com/akaszynski/lsdyna-mesh-reader" [tool.cibuildwheel] archs = ["auto64"] # 64-bit only skip = "cp38-* cp313-* pp* *musllinux*" # 3.9-3.12 and no PyPy and musl-based wheels -test-command = "pytest {project}/tests" +test-command = "pytest {project}/tests -v" test-requires = "pytest pyvista" [tool.cibuildwheel.macos] diff --git a/src/deck.cpp b/src/deck.cpp index 7e25245..70ef831 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -201,8 +201,12 @@ class MemoryMappedFile { } } + // True when at end of file bool eof() { return current >= start + size; } + // True when at end of line (DOS and UNIX EOF) + bool eol() { return *current == '\n' || *current == '\r'; } + bool read_line() { line.clear(); if (current >= start + size) { @@ -355,15 +359,12 @@ struct NodeSection { NDArray tc; NDArray rc; int n_nodes = 0; - bool _has_constraints; // Default constructor NodeSection() {} NodeSection(std::vector nid_vec, std::vector nodes_vec, - std::vector tc_vec, std::vector rc_vec, - bool has_constraints) { - _has_constraints = has_constraints; + std::vector tc_vec, std::vector rc_vec) { n_nodes = nid_vec.size(); std::array nid_shape = {static_cast(n_nodes)}; std::array coord_shape = {static_cast(n_nodes), 3}; @@ -371,10 +372,8 @@ struct NodeSection { // Wrap vectors as NDArrays nid = WrapVectorAsNDArray(std::move(nid_vec), nid_shape); coord = WrapVectorAsNDArray(std::move(nodes_vec), coord_shape); - if (has_constraints) { - tc = WrapVectorAsNDArray(std::move(tc_vec), nid_shape); - rc = WrapVectorAsNDArray(std::move(rc_vec), nid_shape); - } + tc = WrapVectorAsNDArray(std::move(tc_vec), nid_shape); + rc = WrapVectorAsNDArray(std::move(rc_vec), nid_shape); } int Length() { return n_nodes; } @@ -403,10 +402,9 @@ struct NodeSection { << std::setw(15) << std::scientific << std::setprecision(8) << coord(i, 2) << " "; // Z - if (_has_constraints) { - oss << std::setw(8) << tc(i) << " " // tc - << std::setw(8) << rc(i); // rc - } + // constraints + oss << std::setw(8) << tc(i) << " " // tc + << std::setw(8) << rc(i); // rc oss << "\n"; } @@ -669,8 +667,6 @@ class Deck { std::cout << "Reading node section" << std::endl; #endif - bool has_constraints = true; // assume true - // Since we don't know the total number of nodes, we'll use vectors here, // even though a malloc would be more efficient. Seems they don't store the // total number of nodes per section. @@ -722,24 +718,32 @@ class Deck { std::cout << "Done reading coordinates " << std::endl; #endif - // constraints - if (memmap[0] == '\n') { - has_constraints = false; - } - - if (has_constraints) { + // Populate constraints. These may be missing from the node section, and + // if they are, populate a zero. + if (memmap.eol()) { +#ifdef DEBUG + std::cout << "EOL on tc" << std::endl; +#endif + tc.push_back(0); + } else { tc.push_back(fast_atoi(memmap.current, 8)); memmap += 8; + } + + if (memmap.eol()) { +#ifdef DEBUG + std::cout << "EOL on rc" << std::endl; +#endif + rc.push_back(0); + } else { rc.push_back(fast_atoi(memmap.current, 8)); - memmap += 8; } // skip remainder of the line memmap.seek_eol(); } - NodeSection *node_section = - new NodeSection(nid, coord, tc, rc, has_constraints); + NodeSection *node_section = new NodeSection(nid, coord, tc, rc); node_sections.push_back(*node_section); return; @@ -831,10 +835,11 @@ class Deck { } first_char = memmap[0]; - // #ifdef DEBUG - // std::cout << "Read character: " << - // static_cast(first_char) << std::endl; - // #endif +#ifdef DEBUG + std::cout << "Read character: " << static_cast(first_char) + << std::endl; +#endif + // Check if line contains a keyword if (first_char != '*') { memmap.seek_eol(); @@ -848,6 +853,8 @@ class Deck { ReadElementSolidSection(); } else if (memmap.line.compare(0, 14, "*ELEMENT_SHELL") == 0) { ReadElementShellSection(); + } else if (memmap.line.compare(0, 15, "*ELEMENT_TSHELL") == 0) { + ReadElementSolidSection(); } } } diff --git a/src/lsdyna_mesh_reader/deck.py b/src/lsdyna_mesh_reader/deck.py index d888ffa..2741b20 100644 --- a/src/lsdyna_mesh_reader/deck.py +++ b/src/lsdyna_mesh_reader/deck.py @@ -14,12 +14,12 @@ class Deck: - """LS-DYNA deck. + r"""LS-DYNA deck. Parameters ---------- filename : str | pathlib.Path - Path to the keyword file (\*.k, \*.key, \*.dyn). + Path to the keyword file (`*.k`, `*.key`, `*.dyn`). Examples -------- diff --git a/src/lsdyna_mesh_reader/examples/__init__.py b/src/lsdyna_mesh_reader/examples/__init__.py index 410acaf..5539866 100644 --- a/src/lsdyna_mesh_reader/examples/__init__.py +++ b/src/lsdyna_mesh_reader/examples/__init__.py @@ -1,7 +1,9 @@ -"""LS-DYNA examples module. +"""LS-DYNA Mesh Reader examples module. Content reused based on the following implicit open to use license from -https://www.dynaexamples.com/ +`LS-DYNA Examples `_. + +**Usage Notice from LS-DYNA** The input files and several class notes are available for download. The download is free of charge, a login is not required. All examples are @@ -11,6 +13,96 @@ The content is prepared for educational purposes. Hence, material properties and other parameters might be non-physic for simplification. + Copyright (c) 2014 DYNAmore GmbH (www.dynamore.de) + Copying for non-commercial usage allowed, if this notice is included. + + +Example Files +^^^^^^^^^^^^^ + +.. py:data:: lsdyna_mesh_reader.examples.birdball + :annotation: = str + + Path to the `Contact Eroding I `_ example file. Usage: + + .. code:: pycon + + >>> from lsdyna_mesh_reader import examples + >>> import lsdyna_mesh_reader + >>> deck = lsdyna_mesh_reader.Deck(examples.birdball) + >>> deck + LSDYNA Deck with: + Node sections: 1 + Element Solid sections: 1 + Element Shell sections: 1 + +.. py:data:: lsdyna_mesh_reader.examples.joint_screw + :annotation: = str + + Path to the `Joint Screw `_ example file. Usage: + + .. code:: pycon + + >>> from lsdyna_mesh_reader import examples + >>> import lsdyna_mesh_reader + >>> deck = lsdyna_mesh_reader.Deck(examples.joint_screw) + >>> deck + LSDYNA Deck with: + Node sections: 1 + Element Solid sections: 1 + Element Shell sections: 1 + + +.. py:data:: lsdyna_mesh_reader.examples.wheel + :annotation: = str + + Path to the `SSD with a wheel rim `_ example file. Usage: + + .. code:: pycon + + >>> from lsdyna_mesh_reader import examples + >>> import lsdyna_mesh_reader + >>> deck = lsdyna_mesh_reader.Deck(examples.wheel) + >>> deck + LSDYNA Deck with: + Node sections: 1 + Element Solid sections: 0 + Element Shell sections: 1 + + +.. py:data:: lsdyna_mesh_reader.examples.bracket + :annotation: = str + + Path to `An aluminium bracket `_ example file. Usage: + + .. code:: pycon + + >>> from lsdyna_mesh_reader import examples + >>> import lsdyna_mesh_reader + >>> deck = lsdyna_mesh_reader.Deck(examples.bracket) + >>> deck + LSDYNA Deck with: + Node sections: 1 + Element Solid sections: 0 + Element Shell sections: 1 + + +.. py:data:: lsdyna_mesh_reader.examples.simple_plate + :annotation: = str + + Path to the `Square Plate Out-of-Plane Vibration (thick shell mesh) `_ example file. Usage: + + .. code:: pycon + + >>> from lsdyna_mesh_reader import examples + >>> import lsdyna_mesh_reader + >>> deck = lsdyna_mesh_reader.Deck(examples.simple_plate) + >>> deck + LSDYNA Deck with: + Node sections: 1 + Element Solid sections: 0 + Element Shell sections: 1 + """ import os @@ -29,9 +121,13 @@ # https://www.dynaexamples.com/nvh/example-07-01 bracket = os.path.join(dir_path, "bracket.k") +# https://www.dynaexamples.com/introduction/Introduction/example-13 +simple_plate = os.path.join(dir_path, "ex_13_thick_shell_elform_2.k") + __all__ = [ "birdball", "joint_screw", "wheel", "bracket", + "simple_plate", ] diff --git a/src/lsdyna_mesh_reader/examples/ex_13_thick_shell_elform_2.k b/src/lsdyna_mesh_reader/examples/ex_13_thick_shell_elform_2.k new file mode 100644 index 0000000..291cbe1 --- /dev/null +++ b/src/lsdyna_mesh_reader/examples/ex_13_thick_shell_elform_2.k @@ -0,0 +1,566 @@ +*KEYWORD +*TITLE +Simply Supported Square Plate: Out-of-Plane Vibration (thick shell mesh) +*CONTROL_IMPLICIT_EIGENVALUE +$# neig center lflag lftend rflag rhtend eigmth shfscl + 20 0.0 0 0.0 0 0.0 0 0.0 +*CONTROL_IMPLICIT_GENERAL +$# imflag dt0 imform nsbs igs cnstn form + 1 0.0 +*CONTROL_SHELL +$# wrpang esort irnxx istupd theory bwc miter proj + 20.00000 0 0 0 2 2 1 +$# rotascl intgrd lamsht cstyp6 tshell nfail1 nfail4 + 0.0 1 +*CONTROL_TERMINATION +$# endtim endcyc dtmin endeng endmas + 1.000000 0 0.0 0.0 0.0 +*DATABASE_BINARY_D3PLOT +$# dt/cycl lcdt/nr beam npltc psetid + 1.000000 +*ELEMENT_TSHELL +$# eid pid n1 n2 n3 n4 n5 n6 n7 n8 + 1 1 1 37 41 5 2 38 42 6 + 2 1 37 73 77 41 38 74 78 42 + 3 1 73 109 113 77 74 110 114 78 + 4 1 109 145 149 113 110 146 150 114 + 5 1 145 181 185 149 146 182 186 150 + 6 1 181 217 221 185 182 218 222 186 + 7 1 217 253 257 221 218 254 258 222 + 8 1 253 289 293 257 254 290 294 258 + 9 1 5 41 45 9 6 42 46 10 + 10 1 41 77 81 45 42 78 82 46 + 11 1 77 113 117 81 78 114 118 82 + 12 1 113 149 153 117 114 150 154 118 + 13 1 149 185 189 153 150 186 190 154 + 14 1 185 221 225 189 186 222 226 190 + 15 1 221 257 261 225 222 258 262 226 + 16 1 257 293 297 261 258 294 298 262 + 17 1 9 45 49 13 10 46 50 14 + 18 1 45 81 85 49 46 82 86 50 + 19 1 81 117 121 85 82 118 122 86 + 20 1 117 153 157 121 118 154 158 122 + 21 1 153 189 193 157 154 190 194 158 + 22 1 189 225 229 193 190 226 230 194 + 23 1 225 261 265 229 226 262 266 230 + 24 1 261 297 301 265 262 298 302 266 + 25 1 13 49 53 17 14 50 54 18 + 26 1 49 85 89 53 50 86 90 54 + 27 1 85 121 125 89 86 122 126 90 + 28 1 121 157 161 125 122 158 162 126 + 29 1 157 193 197 161 158 194 198 162 + 30 1 193 229 233 197 194 230 234 198 + 31 1 229 265 269 233 230 266 270 234 + 32 1 265 301 305 269 266 302 306 270 + 33 1 17 53 57 21 18 54 58 22 + 34 1 53 89 93 57 54 90 94 58 + 35 1 89 125 129 93 90 126 130 94 + 36 1 125 161 165 129 126 162 166 130 + 37 1 161 197 201 165 162 198 202 166 + 38 1 197 233 237 201 198 234 238 202 + 39 1 233 269 273 237 234 270 274 238 + 40 1 269 305 309 273 270 306 310 274 + 41 1 21 57 61 25 22 58 62 26 + 42 1 57 93 97 61 58 94 98 62 + 43 1 93 129 133 97 94 130 134 98 + 44 1 129 165 169 133 130 166 170 134 + 45 1 165 201 205 169 166 202 206 170 + 46 1 201 237 241 205 202 238 242 206 + 47 1 237 273 277 241 238 274 278 242 + 48 1 273 309 313 277 274 310 314 278 + 49 1 25 61 65 29 26 62 66 30 + 50 1 61 97 101 65 62 98 102 66 + 51 1 97 133 137 101 98 134 138 102 + 52 1 133 169 173 137 134 170 174 138 + 53 1 169 205 209 173 170 206 210 174 + 54 1 205 241 245 209 206 242 246 210 + 55 1 241 277 281 245 242 278 282 246 + 56 1 277 313 317 281 278 314 318 282 + 57 1 29 65 69 33 30 66 70 34 + 58 1 65 101 105 69 66 102 106 70 + 59 1 101 137 141 105 102 138 142 106 + 60 1 137 173 177 141 138 174 178 142 + 61 1 173 209 213 177 174 210 214 178 + 62 1 209 245 249 213 210 246 250 214 + 63 1 245 281 285 249 246 282 286 250 + 64 1 281 317 321 285 282 318 322 286 + 65 1 2 38 42 6 3 39 43 7 + 66 1 38 74 78 42 39 75 79 43 + 67 1 74 110 114 78 75 111 115 79 + 68 1 110 146 150 114 111 147 151 115 + 69 1 146 182 186 150 147 183 187 151 + 70 1 182 218 222 186 183 219 223 187 + 71 1 218 254 258 222 219 255 259 223 + 72 1 254 290 294 258 255 291 295 259 + 73 1 6 42 46 10 7 43 47 11 + 74 1 42 78 82 46 43 79 83 47 + 75 1 78 114 118 82 79 115 119 83 + 76 1 114 150 154 118 115 151 155 119 + 77 1 150 186 190 154 151 187 191 155 + 78 1 186 222 226 190 187 223 227 191 + 79 1 222 258 262 226 223 259 263 227 + 80 1 258 294 298 262 259 295 299 263 + 81 1 10 46 50 14 11 47 51 15 + 82 1 46 82 86 50 47 83 87 51 + 83 1 82 118 122 86 83 119 123 87 + 84 1 118 154 158 122 119 155 159 123 + 85 1 154 190 194 158 155 191 195 159 + 86 1 190 226 230 194 191 227 231 195 + 87 1 226 262 266 230 227 263 267 231 + 88 1 262 298 302 266 263 299 303 267 + 89 1 14 50 54 18 15 51 55 19 + 90 1 50 86 90 54 51 87 91 55 + 91 1 86 122 126 90 87 123 127 91 + 92 1 122 158 162 126 123 159 163 127 + 93 1 158 194 198 162 159 195 199 163 + 94 1 194 230 234 198 195 231 235 199 + 95 1 230 266 270 234 231 267 271 235 + 96 1 266 302 306 270 267 303 307 271 + 97 1 18 54 58 22 19 55 59 23 + 98 1 54 90 94 58 55 91 95 59 + 99 1 90 126 130 94 91 127 131 95 + 100 1 126 162 166 130 127 163 167 131 + 101 1 162 198 202 166 163 199 203 167 + 102 1 198 234 238 202 199 235 239 203 + 103 1 234 270 274 238 235 271 275 239 + 104 1 270 306 310 274 271 307 311 275 + 105 1 22 58 62 26 23 59 63 27 + 106 1 58 94 98 62 59 95 99 63 + 107 1 94 130 134 98 95 131 135 99 + 108 1 130 166 170 134 131 167 171 135 + 109 1 166 202 206 170 167 203 207 171 + 110 1 202 238 242 206 203 239 243 207 + 111 1 238 274 278 242 239 275 279 243 + 112 1 274 310 314 278 275 311 315 279 + 113 1 26 62 66 30 27 63 67 31 + 114 1 62 98 102 66 63 99 103 67 + 115 1 98 134 138 102 99 135 139 103 + 116 1 134 170 174 138 135 171 175 139 + 117 1 170 206 210 174 171 207 211 175 + 118 1 206 242 246 210 207 243 247 211 + 119 1 242 278 282 246 243 279 283 247 + 120 1 278 314 318 282 279 315 319 283 + 121 1 30 66 70 34 31 67 71 35 + 122 1 66 102 106 70 67 103 107 71 + 123 1 102 138 142 106 103 139 143 107 + 124 1 138 174 178 142 139 175 179 143 + 125 1 174 210 214 178 175 211 215 179 + 126 1 210 246 250 214 211 247 251 215 + 127 1 246 282 286 250 247 283 287 251 + 128 1 282 318 322 286 283 319 323 287 + 129 1 3 39 43 7 4 40 44 8 + 130 1 39 75 79 43 40 76 80 44 + 131 1 75 111 115 79 76 112 116 80 + 132 1 111 147 151 115 112 148 152 116 + 133 1 147 183 187 151 148 184 188 152 + 134 1 183 219 223 187 184 220 224 188 + 135 1 219 255 259 223 220 256 260 224 + 136 1 255 291 295 259 256 292 296 260 + 137 1 7 43 47 11 8 44 48 12 + 138 1 43 79 83 47 44 80 84 48 + 139 1 79 115 119 83 80 116 120 84 + 140 1 115 151 155 119 116 152 156 120 + 141 1 151 187 191 155 152 188 192 156 + 142 1 187 223 227 191 188 224 228 192 + 143 1 223 259 263 227 224 260 264 228 + 144 1 259 295 299 263 260 296 300 264 + 145 1 11 47 51 15 12 48 52 16 + 146 1 47 83 87 51 48 84 88 52 + 147 1 83 119 123 87 84 120 124 88 + 148 1 119 155 159 123 120 156 160 124 + 149 1 155 191 195 159 156 192 196 160 + 150 1 191 227 231 195 192 228 232 196 + 151 1 227 263 267 231 228 264 268 232 + 152 1 263 299 303 267 264 300 304 268 + 153 1 15 51 55 19 16 52 56 20 + 154 1 51 87 91 55 52 88 92 56 + 155 1 87 123 127 91 88 124 128 92 + 156 1 123 159 163 127 124 160 164 128 + 157 1 159 195 199 163 160 196 200 164 + 158 1 195 231 235 199 196 232 236 200 + 159 1 231 267 271 235 232 268 272 236 + 160 1 267 303 307 271 268 304 308 272 + 161 1 19 55 59 23 20 56 60 24 + 162 1 55 91 95 59 56 92 96 60 + 163 1 91 127 131 95 92 128 132 96 + 164 1 127 163 167 131 128 164 168 132 + 165 1 163 199 203 167 164 200 204 168 + 166 1 199 235 239 203 200 236 240 204 + 167 1 235 271 275 239 236 272 276 240 + 168 1 271 307 311 275 272 308 312 276 + 169 1 23 59 63 27 24 60 64 28 + 170 1 59 95 99 63 60 96 100 64 + 171 1 95 131 135 99 96 132 136 100 + 172 1 131 167 171 135 132 168 172 136 + 173 1 167 203 207 171 168 204 208 172 + 174 1 203 239 243 207 204 240 244 208 + 175 1 239 275 279 243 240 276 280 244 + 176 1 275 311 315 279 276 312 316 280 + 177 1 27 63 67 31 28 64 68 32 + 178 1 63 99 103 67 64 100 104 68 + 179 1 99 135 139 103 100 136 140 104 + 180 1 135 171 175 139 136 172 176 140 + 181 1 171 207 211 175 172 208 212 176 + 182 1 207 243 247 211 208 244 248 212 + 183 1 243 279 283 247 244 280 284 248 + 184 1 279 315 319 283 280 316 320 284 + 185 1 31 67 71 35 32 68 72 36 + 186 1 67 103 107 71 68 104 108 72 + 187 1 103 139 143 107 104 140 144 108 + 188 1 139 175 179 143 140 176 180 144 + 189 1 175 211 215 179 176 212 216 180 + 190 1 211 247 251 215 212 248 252 216 + 191 1 247 283 287 251 248 284 288 252 + 192 1 283 319 323 287 284 320 324 288 +*NODE +$# nid x y z tc rc + 1 0.0 0.0 0.0 3 + 2 0.0 0.0 0.33333334 + 3 0.0 0.0 0.66666669 + 4 0.0 0.0 1.00000000 + 5 0.0 1.25000000 0.0 3 + 6 0.0 1.25000000 0.33333334 + 7 0.0 1.25000000 0.66666669 + 8 0.0 1.25000000 1.00000000 + 9 0.0 2.50000000 0.0 3 + 10 0.0 2.50000000 0.33333334 + 11 0.0 2.50000000 0.66666669 + 12 0.0 2.50000000 1.00000000 + 13 0.0 3.75000000 0.0 3 + 14 0.0 3.75000000 0.33333334 + 15 0.0 3.75000000 0.66666669 + 16 0.0 3.75000000 1.00000000 + 17 0.0 5.00000000 0.0 3 + 18 0.0 5.00000000 0.33333334 + 19 0.0 5.00000000 0.66666669 + 20 0.0 5.00000000 1.00000000 + 21 0.0 6.25000000 0.0 3 + 22 0.0 6.25000000 0.33333334 + 23 0.0 6.25000000 0.66666669 + 24 0.0 6.25000000 1.00000000 + 25 0.0 7.50000000 0.0 3 + 26 0.0 7.50000000 0.33333334 + 27 0.0 7.50000000 0.66666669 + 28 0.0 7.50000000 1.00000000 + 29 0.0 8.75000000 0.0 3 + 30 0.0 8.75000000 0.33333334 + 31 0.0 8.75000000 0.66666669 + 32 0.0 8.75000000 1.00000000 + 33 0.0 10.00000000 0.0 3 + 34 0.0 10.00000000 0.33333334 + 35 0.0 10.00000000 0.66666669 + 36 0.0 10.00000000 1.00000000 + 37 1.25000000 0.0 0.0 3 + 38 1.25000000 0.0 0.33333334 + 39 1.25000000 0.0 0.66666669 + 40 1.25000000 0.0 1.00000000 + 41 1.25000000 1.25000000 0.0 + 42 1.25000000 1.25000000 0.33333334 + 43 1.25000000 1.25000000 0.66666669 + 44 1.25000000 1.25000000 1.00000000 + 45 1.25000000 2.50000000 0.0 + 46 1.25000000 2.50000000 0.33333334 + 47 1.25000000 2.50000000 0.66666669 + 48 1.25000000 2.50000000 1.00000000 + 49 1.25000000 3.75000000 0.0 + 50 1.25000000 3.75000000 0.33333334 + 51 1.25000000 3.75000000 0.66666669 + 52 1.25000000 3.75000000 1.00000000 + 53 1.25000000 5.00000000 0.0 + 54 1.25000000 5.00000000 0.33333334 + 55 1.25000000 5.00000000 0.66666669 + 56 1.25000000 5.00000000 1.00000000 + 57 1.25000000 6.25000000 0.0 + 58 1.25000000 6.25000000 0.33333334 + 59 1.25000000 6.25000000 0.66666669 + 60 1.25000000 6.25000000 1.00000000 + 61 1.25000000 7.50000000 0.0 + 62 1.25000000 7.50000000 0.33333334 + 63 1.25000000 7.50000000 0.66666669 + 64 1.25000000 7.50000000 1.00000000 + 65 1.25000000 8.75000000 0.0 + 66 1.25000000 8.75000000 0.33333334 + 67 1.25000000 8.75000000 0.66666669 + 68 1.25000000 8.75000000 1.00000000 + 69 1.25000000 10.00000000 0.0 3 + 70 1.25000000 10.00000000 0.33333334 + 71 1.25000000 10.00000000 0.66666669 + 72 1.25000000 10.00000000 1.00000000 + 73 2.50000000 0.0 0.0 3 + 74 2.50000000 0.0 0.33333334 + 75 2.50000000 0.0 0.66666669 + 76 2.50000000 0.0 1.00000000 + 77 2.50000000 1.25000000 0.0 + 78 2.50000000 1.25000000 0.33333334 + 79 2.50000000 1.25000000 0.66666669 + 80 2.50000000 1.25000000 1.00000000 + 81 2.50000000 2.50000000 0.0 + 82 2.50000000 2.50000000 0.33333334 + 83 2.50000000 2.50000000 0.66666669 + 84 2.50000000 2.50000000 1.00000000 + 85 2.50000000 3.75000000 0.0 + 86 2.50000000 3.75000000 0.33333334 + 87 2.50000000 3.75000000 0.66666669 + 88 2.50000000 3.75000000 1.00000000 + 89 2.50000000 5.00000000 0.0 + 90 2.50000000 5.00000000 0.33333334 + 91 2.50000000 5.00000000 0.66666669 + 92 2.50000000 5.00000000 1.00000000 + 93 2.50000000 6.25000000 0.0 + 94 2.50000000 6.25000000 0.33333334 + 95 2.50000000 6.25000000 0.66666669 + 96 2.50000000 6.25000000 1.00000000 + 97 2.50000000 7.50000000 0.0 + 98 2.50000000 7.50000000 0.33333334 + 99 2.50000000 7.50000000 0.66666669 + 100 2.50000000 7.50000000 1.00000000 + 101 2.50000000 8.75000000 0.0 + 102 2.50000000 8.75000000 0.33333334 + 103 2.50000000 8.75000000 0.66666669 + 104 2.50000000 8.75000000 1.00000000 + 105 2.50000000 10.00000000 0.0 3 + 106 2.50000000 10.00000000 0.33333334 + 107 2.50000000 10.00000000 0.66666669 + 108 2.50000000 10.00000000 1.00000000 + 109 3.75000000 0.0 0.0 3 + 110 3.75000000 0.0 0.33333334 + 111 3.75000000 0.0 0.66666669 + 112 3.75000000 0.0 1.00000000 + 113 3.75000000 1.25000000 0.0 + 114 3.75000000 1.25000000 0.33333334 + 115 3.75000000 1.25000000 0.66666669 + 116 3.75000000 1.25000000 1.00000000 + 117 3.75000000 2.50000000 0.0 + 118 3.75000000 2.50000000 0.33333334 + 119 3.75000000 2.50000000 0.66666669 + 120 3.75000000 2.50000000 1.00000000 + 121 3.75000000 3.75000000 0.0 + 122 3.75000000 3.75000000 0.33333334 + 123 3.75000000 3.75000000 0.66666669 + 124 3.75000000 3.75000000 1.00000000 + 125 3.75000000 5.00000000 0.0 + 126 3.75000000 5.00000000 0.33333334 + 127 3.75000000 5.00000000 0.66666669 + 128 3.75000000 5.00000000 1.00000000 + 129 3.75000000 6.25000000 0.0 + 130 3.75000000 6.25000000 0.33333334 + 131 3.75000000 6.25000000 0.66666669 + 132 3.75000000 6.25000000 1.00000000 + 133 3.75000000 7.50000000 0.0 + 134 3.75000000 7.50000000 0.33333334 + 135 3.75000000 7.50000000 0.66666669 + 136 3.75000000 7.50000000 1.00000000 + 137 3.75000000 8.75000000 0.0 + 138 3.75000000 8.75000000 0.33333334 + 139 3.75000000 8.75000000 0.66666669 + 140 3.75000000 8.75000000 1.00000000 + 141 3.75000000 10.00000000 0.0 3 + 142 3.75000000 10.00000000 0.33333334 + 143 3.75000000 10.00000000 0.66666669 + 144 3.75000000 10.00000000 1.00000000 + 145 5.00000000 0.0 0.0 3 + 146 5.00000000 0.0 0.33333334 + 147 5.00000000 0.0 0.66666669 + 148 5.00000000 0.0 1.00000000 + 149 5.00000000 1.25000000 0.0 + 150 5.00000000 1.25000000 0.33333334 + 151 5.00000000 1.25000000 0.66666669 + 152 5.00000000 1.25000000 1.00000000 + 153 5.00000000 2.50000000 0.0 + 154 5.00000000 2.50000000 0.33333334 + 155 5.00000000 2.50000000 0.66666669 + 156 5.00000000 2.50000000 1.00000000 + 157 5.00000000 3.75000000 0.0 + 158 5.00000000 3.75000000 0.33333334 + 159 5.00000000 3.75000000 0.66666669 + 160 5.00000000 3.75000000 1.00000000 + 161 5.00000000 5.00000000 0.0 + 162 5.00000000 5.00000000 0.33333334 + 163 5.00000000 5.00000000 0.66666669 + 164 5.00000000 5.00000000 1.00000000 + 165 5.00000000 6.25000000 0.0 + 166 5.00000000 6.25000000 0.33333334 + 167 5.00000000 6.25000000 0.66666669 + 168 5.00000000 6.25000000 1.00000000 + 169 5.00000000 7.50000000 0.0 + 170 5.00000000 7.50000000 0.33333334 + 171 5.00000000 7.50000000 0.66666669 + 172 5.00000000 7.50000000 1.00000000 + 173 5.00000000 8.75000000 0.0 + 174 5.00000000 8.75000000 0.33333334 + 175 5.00000000 8.75000000 0.66666669 + 176 5.00000000 8.75000000 1.00000000 + 177 5.00000000 10.00000000 0.0 3 + 178 5.00000000 10.00000000 0.33333334 + 179 5.00000000 10.00000000 0.66666669 + 180 5.00000000 10.00000000 1.00000000 + 181 6.25000000 0.0 0.0 3 + 182 6.25000000 0.0 0.33333334 + 183 6.25000000 0.0 0.66666669 + 184 6.25000000 0.0 1.00000000 + 185 6.25000000 1.25000000 0.0 + 186 6.25000000 1.25000000 0.33333334 + 187 6.25000000 1.25000000 0.66666669 + 188 6.25000000 1.25000000 1.00000000 + 189 6.25000000 2.50000000 0.0 + 190 6.25000000 2.50000000 0.33333334 + 191 6.25000000 2.50000000 0.66666669 + 192 6.25000000 2.50000000 1.00000000 + 193 6.25000000 3.75000000 0.0 + 194 6.25000000 3.75000000 0.33333334 + 195 6.25000000 3.75000000 0.66666669 + 196 6.25000000 3.75000000 1.00000000 + 197 6.25000000 5.00000000 0.0 + 198 6.25000000 5.00000000 0.33333334 + 199 6.25000000 5.00000000 0.66666669 + 200 6.25000000 5.00000000 1.00000000 + 201 6.25000000 6.25000000 0.0 + 202 6.25000000 6.25000000 0.33333334 + 203 6.25000000 6.25000000 0.66666669 + 204 6.25000000 6.25000000 1.00000000 + 205 6.25000000 7.50000000 0.0 + 206 6.25000000 7.50000000 0.33333334 + 207 6.25000000 7.50000000 0.66666669 + 208 6.25000000 7.50000000 1.00000000 + 209 6.25000000 8.75000000 0.0 + 210 6.25000000 8.75000000 0.33333334 + 211 6.25000000 8.75000000 0.66666669 + 212 6.25000000 8.75000000 1.00000000 + 213 6.25000000 10.00000000 0.0 3 + 214 6.25000000 10.00000000 0.33333334 + 215 6.25000000 10.00000000 0.66666669 + 216 6.25000000 10.00000000 1.00000000 + 217 7.50000000 0.0 0.0 3 + 218 7.50000000 0.0 0.33333334 + 219 7.50000000 0.0 0.66666669 + 220 7.50000000 0.0 1.00000000 + 221 7.50000000 1.25000000 0.0 + 222 7.50000000 1.25000000 0.33333334 + 223 7.50000000 1.25000000 0.66666669 + 224 7.50000000 1.25000000 1.00000000 + 225 7.50000000 2.50000000 0.0 + 226 7.50000000 2.50000000 0.33333334 + 227 7.50000000 2.50000000 0.66666669 + 228 7.50000000 2.50000000 1.00000000 + 229 7.50000000 3.75000000 0.0 + 230 7.50000000 3.75000000 0.33333334 + 231 7.50000000 3.75000000 0.66666669 + 232 7.50000000 3.75000000 1.00000000 + 233 7.50000000 5.00000000 0.0 + 234 7.50000000 5.00000000 0.33333334 + 235 7.50000000 5.00000000 0.66666669 + 236 7.50000000 5.00000000 1.00000000 + 237 7.50000000 6.25000000 0.0 + 238 7.50000000 6.25000000 0.33333334 + 239 7.50000000 6.25000000 0.66666669 + 240 7.50000000 6.25000000 1.00000000 + 241 7.50000000 7.50000000 0.0 + 242 7.50000000 7.50000000 0.33333334 + 243 7.50000000 7.50000000 0.66666669 + 244 7.50000000 7.50000000 1.00000000 + 245 7.50000000 8.75000000 0.0 + 246 7.50000000 8.75000000 0.33333334 + 247 7.50000000 8.75000000 0.66666669 + 248 7.50000000 8.75000000 1.00000000 + 249 7.50000000 10.00000000 0.0 3 + 250 7.50000000 10.00000000 0.33333334 + 251 7.50000000 10.00000000 0.66666669 + 252 7.50000000 10.00000000 1.00000000 + 253 8.75000000 0.0 0.0 3 + 254 8.75000000 0.0 0.33333334 + 255 8.75000000 0.0 0.66666669 + 256 8.75000000 0.0 1.00000000 + 257 8.75000000 1.25000000 0.0 + 258 8.75000000 1.25000000 0.33333334 + 259 8.75000000 1.25000000 0.66666669 + 260 8.75000000 1.25000000 1.00000000 + 261 8.75000000 2.50000000 0.0 + 262 8.75000000 2.50000000 0.33333334 + 263 8.75000000 2.50000000 0.66666669 + 264 8.75000000 2.50000000 1.00000000 + 265 8.75000000 3.75000000 0.0 + 266 8.75000000 3.75000000 0.33333334 + 267 8.75000000 3.75000000 0.66666669 + 268 8.75000000 3.75000000 1.00000000 + 269 8.75000000 5.00000000 0.0 + 270 8.75000000 5.00000000 0.33333334 + 271 8.75000000 5.00000000 0.66666669 + 272 8.75000000 5.00000000 1.00000000 + 273 8.75000000 6.25000000 0.0 + 274 8.75000000 6.25000000 0.33333334 + 275 8.75000000 6.25000000 0.66666669 + 276 8.75000000 6.25000000 1.00000000 + 277 8.75000000 7.50000000 0.0 + 278 8.75000000 7.50000000 0.33333334 + 279 8.75000000 7.50000000 0.66666669 + 280 8.75000000 7.50000000 1.00000000 + 281 8.75000000 8.75000000 0.0 + 282 8.75000000 8.75000000 0.33333334 + 283 8.75000000 8.75000000 0.66666669 + 284 8.75000000 8.75000000 1.00000000 + 285 8.75000000 10.00000000 0.0 3 + 286 8.75000000 10.00000000 0.33333334 + 287 8.75000000 10.00000000 0.66666669 + 288 8.75000000 10.00000000 1.00000000 + 289 10.00000000 0.0 0.0 3 + 290 10.00000000 0.0 0.33333334 + 291 10.00000000 0.0 0.66666669 + 292 10.00000000 0.0 1.00000000 + 293 10.00000000 1.25000000 0.0 3 + 294 10.00000000 1.25000000 0.33333334 + 295 10.00000000 1.25000000 0.66666669 + 296 10.00000000 1.25000000 1.00000000 + 297 10.00000000 2.50000000 0.0 3 + 298 10.00000000 2.50000000 0.33333334 + 299 10.00000000 2.50000000 0.66666669 + 300 10.00000000 2.50000000 1.00000000 + 301 10.00000000 3.75000000 0.0 3 + 302 10.00000000 3.75000000 0.33333334 + 303 10.00000000 3.75000000 0.66666669 + 304 10.00000000 3.75000000 1.00000000 + 305 10.00000000 5.00000000 0.0 3 + 306 10.00000000 5.00000000 0.33333334 + 307 10.00000000 5.00000000 0.66666669 + 308 10.00000000 5.00000000 1.00000000 + 309 10.00000000 6.25000000 0.0 3 + 310 10.00000000 6.25000000 0.33333334 + 311 10.00000000 6.25000000 0.66666669 + 312 10.00000000 6.25000000 1.00000000 + 313 10.00000000 7.50000000 0.0 3 + 314 10.00000000 7.50000000 0.33333334 + 315 10.00000000 7.50000000 0.66666669 + 316 10.00000000 7.50000000 1.00000000 + 317 10.00000000 8.75000000 0.0 3 + 318 10.00000000 8.75000000 0.33333334 + 319 10.00000000 8.75000000 0.66666669 + 320 10.00000000 8.75000000 1.00000000 + 321 10.00000000 10.00000000 0.0 3 + 322 10.00000000 10.00000000 0.33333334 + 323 10.00000000 10.00000000 0.66666669 + 324 10.00000000 10.00000000 1.00000000 +*BOUNDARY_SPC_SET +$#nid/nsid cid dofx dofy dofz dofrx dofry dofrz + 1 0 0 0 1 +*PART +$# title +material type # 1 (Elastic) +$# pid secid mid eosid hgid grav adpopt tmid + 1 1 1 0 1 +*SECTION_TSHELL +$# secid elform shrf nip propt qr/irid icomp tshear + 1 2 0.0 5 0 0.0 +*MAT_ELASTIC +$# mid ro e pr da db not used + 1 8000.0002.0000e+11 0.300000 0.0 0.0 0.0 +*HOURGLASS +$# hgid ihq qm ibq q1 q2 qb qw + 1 4 0.1 0 0.0 0.0 0.0 0.0 +*SET_NODE_LIST +$# sid da1 da2 da3 da4 solver + 1 0.0 0.0 0.0 0.0 +$# nid1 nid2 nid3 nid4 nid5 nid6 nid7 nid8 + 1 37 73 109 145 181 217 253 + 289 293 297 301 305 309 313 317 + 321 285 249 213 177 141 105 69 + 33 29 25 21 17 13 9 5 +*END \ No newline at end of file diff --git a/tests/test_deck.py b/tests/test_deck.py index 2264309..575927c 100644 --- a/tests/test_deck.py +++ b/tests/test_deck.py @@ -1,5 +1,10 @@ +"""Test lsdyna_mesh_reader deck reader.""" + +from typing import List from pathlib import Path +import os +import pytest import numpy as np import pyvista as pv @@ -58,6 +63,17 @@ ] +def get_example_files() -> List[str]: + file_paths: List[str] = [] + for attr in dir(examples): + eval_attr = getattr(examples, attr) + if isinstance(eval_attr, str) and os.path.isfile(eval_attr): + if eval_attr.endswith(".key") or eval_attr.endswith(".k"): + file_paths.append(eval_attr) + + return file_paths + + def test_node_section(tmp_path: Path) -> None: filename = str(tmp_path / "tmp.k") with open(filename, "w") as fid: @@ -166,3 +182,24 @@ def test_read_birdball() -> None: assert len(element_shell_section.pid) == 100 assert len(element_shell_section.node_id_offsets) == 101 assert len(element_shell_section.node_ids) == 100 * 4 + + +@pytest.mark.parametrize("file_path", get_example_files()) +def test_examples(file_path: str) -> None: + assert os.path.isfile(file_path) + deck = lsdyna_mesh_reader.Deck(file_path) + grid = deck.to_grid() + grid._check_for_consistency() + + +def test_element_tshell() -> None: + """Verify we can read in ELEMENT_TSHELL.""" + deck = lsdyna_mesh_reader.Deck(examples.simple_plate) + assert len(deck.element_solid_sections) == 1 + assert len(deck.element_shell_sections) == 0 + + # node section has partial constraints, ensure that it's been populated correctly + node_section = deck.node_sections[0] + assert len(node_section) == 324 + + grid = deck.to_grid()