NASTRAN file format question

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

NASTRAN file format question

Post by chennes »

I'm hoping someone here can enlighten me on a sort of esoteric NASTRAN file format question. In our source code (src/Mod/Mesh/App/Core/MeshIO.cpp line 1659) we have small section of code that looks like this:

Code: Select all

        if (line.find("GRID*") == 0) {
        }
        else if (line.find('*') == 0) {
        }
        else if (line.find("GRID") == 0) {
            // Actually do stuff in this one...
        ...
I've looked through the NASTRAN95 user manual, and a bunch of input files, trying to figure out in particular what that "GRID*" search is supposed to be accomplishing. I can't find any evidence that the literal text "GRID*" (that is, the word GRID followed by an asterisk) is valid NASTRAN input, and I am wondering if it's possible that what that code is intended to do is eliminate the GRIDS and GRIDF elements. That's not what it's doing... but is that maybe what it's supposed to be doing? (I should note that because GRID element itself is parsed via regular expressions, this test would be purely an optimization if that was its intent, the regex would reject a line with the asterisk in it).

As a follow on, what does it mean for a line to begin with an asterisk, that we're bypassing the regex checks and skipping the line entirely?

Finally, if these are important optimizations, isn't using string::find to see if a string starts with an asterisk basically the slowest possible way of doing that?

(As a side note, I'm only bringing this up because LGTM complains about the empty blocks, so I was going to drop comments in there explaining why we're skipping those lines... then I started looking at them!)
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: NASTRAN file format question

Post by johnwang »

* means long format which is 16 digits for a variable. Two lines for one point.

Code: Select all

GRID*    126907                         18.10000228881845.39999997615814
*        0.
Without *, is a short format which is 8 digits. Only one line.

Code: Select all

GRID     100000          0.      0.      0.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: NASTRAN file format question

Post by chennes »

Thanks - so then what the above code is doing is explicitly ignoring that structure, we don't support that format, right?

ETA: Do you have a file that contains both GRID and GRID* elements that I could use for testing?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: NASTRAN file format question

Post by johnwang »

chennes wrote: Sun Sep 19, 2021 3:14 pm Thanks - so then what the above code is doing is explicitly ignoring that structure, we don't support that format, right?

ETA: Do you have a file that contains both GRID and GRID* elements that I could use for testing?
I don't know Mesh WB.

I have one code in FEM WB. But haven't tested with Long format. Even short format are tested limited.
https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L1612
My readNastran95() is copied from readNastran(). Nastran has a few vendors, so the formats are a little different.

Try one from https://www.fea-academy.com/index.php/resources
Chapter 20 - Linear Static Analysis
Stiffened_Panel_Linear_Static.bdf
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: NASTRAN file format question

Post by chennes »

Perfect, thanks! I didn't realize we had multiple Nastran importers, it looks like the one in FEM does a better job of supporting this sort of thing.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: NASTRAN file format question

Post by chennes »

OK, I've taken a stab at implementing support for GRID* in the Mesh importer as well:
https://github.com/FreeCAD/FreeCAD/pull/5047

It works well on the test file you linked (I think), but it's hard to test because that's a volume mesh, and Mesh only supports surface meshes!
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: NASTRAN file format question

Post by johnwang »

Excellent.

File/Open can open an Nastran95 inp file directly.
"if an inp file is given then FreeCAD first tries the Abaqus importer and if afterwards the mesh is empty (i.e. it has no nodes) the Nastran-95 imported is used."
https://forum.freecadweb.org/viewtopic. ... 20#p485474

Haven't used Mesh WB. So it is for importing into Mesh WB only?
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
johnwang
Veteran
Posts: 1339
Joined: Sun Jan 27, 2019 12:41 am

Re: NASTRAN file format question

Post by johnwang »

chennes wrote: Mon Sep 20, 2021 4:03 am It works well on the test file you linked (I think), but it's hard to test because that's a volume mesh, and Mesh only supports surface meshes!
It uses CQUAD4. It is a surface mesh.
hfc series CAE workbenches for FreeCAD (hfcNastran95, hfcMystran, hfcFrame3DD, hfcSU2 and more)
User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: NASTRAN file format question

Post by chennes »

johnwang wrote: Mon Sep 20, 2021 5:41 am Haven't used Mesh WB. So it is for importing into Mesh WB only?
Yes, the Mesh WB is strange, it has its own "import" command, separate from the normal FreeCAD import. I don't know why that is. I really only got into this to solve a small static analyzer issue, but then the problem looked interesting. :D
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3868
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: NASTRAN file format question

Post by chennes »

johnwang wrote: Mon Sep 20, 2021 5:44 am It uses CQUAD4. It is a surface mesh.
I must have been looking at the wrong file then, I only saw HEXA elements in there. I'll review...
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply