Forums › NastPad Discussions › Regular Expressions › Nastran model mirroring
- This topic has 0 replies, 1 voice, and was last updated July 24, 2017 by admin.
-
AuthorPosts
-
-
July 24, 2017 at 11:35 pm #241adminKeymaster
In bygone days when computer processing time was costly, Nastran models would often use symmetrical boundary constraints. These days there is much less concern for processing time, and so more often Nastran models are full body models. It can be cumbersome maintaining two largely symmetrical halves of a model in a pre-processor, as any change made to one side needs to be reflected on the other side. But what if you could mirror the Nastran bdf cards instead? It’s easier than you think…
Here are some example enhanced regular expressions that can be used in NastPad to mirror a model about the global Y axis (for short fixed card format).
Note: whenever modifying real numbers in Nastran bdf files, it’s best to use the built-in ‘get_real()’ and ‘put_real()’ functions, as Nastran files often omit the exponent symbol ‘e’, which will run afoul with the standard scripting engine.GRID cards simply need to reverse the sign of the y-coordinate:
Find what:^(GRID {4}.{24})(.{8})
Replace with:\1~put_real(-1*get_real(\2))~
CORD2 entries can be mirrored like the GRID cards, by reversing the y-coordinate for each of the 3 points:
Find what:^(CORD2[RCS] {2}.{24})(.{8})(.{16})(.{8})(.+\n.{16})(.{8})(.+)
Replace with:\1~put_real(-1*get_real(\2))~\3~put_real(-1*get_real(\4))~\5~put_real(-1*get_real(\6))~\7
Mirroring the nodes and coordinates takes care of the topology, but what about shell element normals? Reversing normals is easily done by re-arranging the nodes in the CQUAD and CTRIA cards. Traditionally for a CQUAD this is done by keeping G1 and reversing the order of the nodes e.g. [1,2,3,4] becomes [1,4,3,2]. But this will clock the element coordinate system approx. 90 degrees, which can affect properties and results. Further more, if THETA is used to define a material direction, then it will be wrong. The solution is to reverse and clock the order of the nodes so that G1 and G2 are on the same element edge [1,2,3,4] becomes [2,1,4,3]. Then reverse the sign of THETA to maintain the same material axis. This can all be done in one search expression:
Find what:^(CQUAD4 {2}.{16})(.{8})(.{8})(.{8})(.{1,8})(.{0,8})
Replace with:\1\3\2\5\4~(!"\6".trim()) ? "\6" : put_real(-1*get_real(\6))~
and similarly for CTRIA cards…
Find what:^(CTRIA3 {2}.{16})(.{8})(.{8})(.{1,8})(.{0,8})
Replace with:\1\3\2\4~(!"\6".trim()) ? "\6" : put_real(-1*get_real(\5))~
Note: there is a javascript conditional (ternary) operator used above (which is basically an if-else statement) to ensure empty fields (whitespace only) are not replaced with a “0.”
Other element types can be reversed using similar methods.
Use the Batch Searching feature of NastPad to do multiple searches on multiple files and reverse the entire model in one go!- This topic was modified 7 years ago by admin.
- This topic was modified 5 years ago by admin.
- This topic was modified 5 years ago by admin.
- This topic was modified 5 years ago by admin.
-
-
AuthorPosts
- You must be logged in to reply to this topic.