Merge pull request #5062 from chennes/meshImproveNastranUnitTests
[Mesh] Improve Nastran unit tests
This commit is contained in:
@@ -1808,7 +1808,27 @@ bool MeshInput::LoadNastran (std::istream &rstrIn)
|
||||
}
|
||||
|
||||
if (badElementCounter > 0) {
|
||||
Base::Console().Warning("Found bad elements while reading NASTRAN file.");
|
||||
Base::Console().Warning("Found bad elements while reading NASTRAN file.\n");
|
||||
}
|
||||
|
||||
// Check the triangles to make sure the vertices they refer to actually exist:
|
||||
for (const auto& tri : mTria) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (mNode.find(tri.second.iV[i]) == mNode.end()) {
|
||||
Base::Console().Error("CTRIA3 element refers to a node that does not exist, or could not be read.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the quads to make sure the vertices they refer to actually exist:
|
||||
for (const auto& quad : mQuad) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (mNode.find(quad.second.iV[i]) == mNode.end()) {
|
||||
Base::Console().Error("CQUAD4 element refers to a node that does not exist, or could not be read.\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float fLength[2];
|
||||
|
||||
@@ -356,5 +356,10 @@ class NastranReader(unittest.TestCase):
|
||||
self.assertEqual(m.CountPoints,4)
|
||||
self.assertEqual(m.CountFacets,2) # Quads split into two triangles
|
||||
|
||||
def testCTRIA3Element(self):
|
||||
m = Mesh.read(f"{self.test_dir}/NASTRAN_Test_GRID_CTRIA3.bdf")
|
||||
self.assertEqual(m.CountPoints,3)
|
||||
self.assertEqual(m.CountFacets,1)
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
@@ -16,14 +16,14 @@ $ Case control section
|
||||
$-------------------------------------------------------------------------------
|
||||
MAXLINES = 1000000
|
||||
TITLE = TESTCASE
|
||||
SUBTITLE = Test case for FreeCAD Mesh NASTRAN input
|
||||
SUBTITLE = Test case for FreeCAD Mesh NASTRAN input
|
||||
|
||||
GRID* 1 0.00000000000000-1.
|
||||
GRID* 1 0.00000000000000-1.
|
||||
* 0.
|
||||
GRID* 2 1.00000000000000-1.
|
||||
GRID* 2 1.00000000000000-1.
|
||||
* 0.
|
||||
GRID* 3 0.000000000000001.
|
||||
GRID* 3 0.000000000000001.
|
||||
* 0.
|
||||
GRID* 4 1.000000000000001.
|
||||
GRID* 4 1.000000000000001.
|
||||
* 0.
|
||||
CQUAD4 1 400 1 2 4 3
|
||||
|
||||
23
src/Mod/Mesh/App/TestData/NASTRAN_Test_GRID_CTRIA3.bdf
Normal file
23
src/Mod/Mesh/App/TestData/NASTRAN_Test_GRID_CTRIA3.bdf
Normal file
@@ -0,0 +1,23 @@
|
||||
$-------------------------------------------------------------------------------
|
||||
$ Nastran case control file
|
||||
$ Part of the FreeCAD unit test system. Tests the CTRIA3 grid element.
|
||||
$-------------------------------------------------------------------------------
|
||||
$ Exec control section
|
||||
$-------------------------------------------------------------------------------
|
||||
ID TESTCASE,Nastran
|
||||
APP DISP
|
||||
SOL 1
|
||||
TIME 20
|
||||
CEND
|
||||
$-------------------------------------------------------------------------------
|
||||
$ Case control section
|
||||
$-------------------------------------------------------------------------------
|
||||
MAXLINES = 1000000
|
||||
TITLE = TESTCASE
|
||||
SUBTITLE = Test case for FreeCAD Mesh NASTRAN input
|
||||
|
||||
GRID 1 0.00E+000.00E+000.00E+00
|
||||
GRID 2 0.00E+001.0000000.00E+00
|
||||
GRID 3 1.00E+001.0000000.00E+00
|
||||
CTRIA3 1 400 1 2 3
|
||||
ENDDATA
|
||||
@@ -14,6 +14,7 @@ set(MeshTestDataFiles
|
||||
App/TestData/NASTRAN_Test_GRID_CQUAD4.bdf
|
||||
App/TestData/NASTRAN_Test_Delimited_GRID_CQUAD4.bdf
|
||||
App/TestData/NASTRAN_Test_GRIDSTAR_CQUAD4.bdf
|
||||
App/TestData/NASTRAN_Test_GRID_CTRIA3.bdf
|
||||
)
|
||||
|
||||
if(BUILD_GUI)
|
||||
|
||||
Reference in New Issue
Block a user