Skip to content
Snippets Groups Projects
Commit 89e7775f authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: incorrect Nastran surface output and segmentation faults #1571

- indexing error in the output of values resulted in uniform output in
  most cases.

- allocation error for on-the-fly triangulation

ENH: changed decomposed storage from DynamicList to plain faceList for
clearer allocation control and better overhead
parent 40c713c4
No related branches found
No related tags found
No related merge requests found
......@@ -201,7 +201,7 @@ void Foam::nastranSurfaceWriter::writeGeometry
(
Ostream& os,
const meshedSurf& surf,
List<DynamicList<face>>& decomposedFaces
List<faceList>& decomposedFaces
) const
{
const pointField& points = surf.points();
......@@ -219,9 +219,9 @@ void Foam::nastranSurfaceWriter::writeGeometry
writeCoord(os, points[pointi], pointi);
}
// Write faces
// Write faces, with on-the-fly decomposition (triangulation)
decomposedFaces.clear();
decomposedFaces.setSize(faces.size());
decomposedFaces.resize(faces.size());
os << "$" << nl
<< "$ Faces" << nl
......@@ -231,30 +231,34 @@ void Foam::nastranSurfaceWriter::writeGeometry
forAll(faces, facei)
{
const face& f = faces[facei];
faceList& decomp = decomposedFaces[facei];
// 1-offset for PID
const label PID = 1 + (facei < zones.size() ? zones[facei] : 0);
if (f.size() == 3)
{
writeFace(os, "CTRIA3", f, ++nFace, PID);
decomposedFaces[facei].append(f);
decomp.resize(1);
decomp[0] = f;
}
else if (f.size() == 4)
{
writeFace(os, "CQUAD4", f, ++nFace, PID);
decomposedFaces[facei].append(f);
decomp.resize(1);
decomp[0] = f;
}
else
{
// Decompose poly face into tris
decomp.resize(f.nTriangles());
label nTri = 0;
faceList triFaces;
f.triangles(points, nTri, triFaces);
f.triangles(points, nTri, decomp);
forAll(triFaces, trii)
for (const face& f2 : decomp)
{
writeFace(os, "CTRIA3", triFaces[trii], ++nFace, PID);
decomposedFaces[facei].append(triFaces[trii]);
writeFace(os, "CTRIA3", f2, ++nFace, PID);
}
}
}
......@@ -384,7 +388,7 @@ Foam::fileName Foam::nastranSurfaceWriter::write
<< "$" << nl
<< "BEGIN BULK" << nl;
List<DynamicList<face>> decomposedFaces;
List<faceList> decomposedFaces;
writeGeometry(os, surf, decomposedFaces);
writeFooter(os, surf)
......
......@@ -130,7 +130,7 @@ private:
(
Ostream& os,
const meshedSurf& surf,
List<DynamicList<face>>& decomposedFaces
List<faceList>& decomposedFaces
) const;
//- Write the formatted keyword to the output stream
......
......@@ -187,7 +187,7 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
<< "$" << nl
<< "BEGIN BULK" << nl;
List<DynamicList<face>> decomposedFaces;
List<faceList> decomposedFaces;
writeGeometry(os, surf, decomposedFaces);
os << "$" << nl
......@@ -198,7 +198,7 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
if (isNodeValues)
{
for (const DynamicList<face>& dFaces : decomposedFaces)
for (const faceList& dFaces : decomposedFaces)
{
for (const face& f : dFaces)
{
......@@ -216,12 +216,16 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
}
else
{
for (const DynamicList<face>& dFaces : decomposedFaces)
auto valIter = values.cbegin();
for (const faceList& dFaces : decomposedFaces)
{
forAll(dFaces, facei)
{
writeFaceValue(os, format, values[facei], ++elemId);
writeFaceValue(os, format, *valIter, ++elemId);
}
++valIter;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment