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

BUG: extraneous brackets after Fluent cell types (fixes #1872)

ENH: limit output to 25 cell types per line for readability

- makes it easier to trace potential format errors etc

STYLE: downgrade warning about polyhedrals to a simple info message

- can assume that polyhedral support is widespread enough to not
  warrant a warning.
parent 810e4a11
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
...@@ -62,13 +63,13 @@ void Foam::fluentFvMesh::writeFluentMesh() const ...@@ -62,13 +63,13 @@ void Foam::fluentFvMesh::writeFluentMesh() const
/ time().caseName() + ".msh" / time().caseName() + ".msh"
); );
Info<< "Writing Header" << endl; Info<< "Writing Fluent Mesh" << endl;
fluentMeshFile fluentMeshFile
<< "(0 \"FOAM to Fluent Mesh File\")" << std::endl << std::endl << "(0 \"OpenFOAM to Fluent Mesh File\")" << nl << nl
<< "(0 \"Dimension:\")" << std::endl << "(0 \"Dimension:\")" << nl
<< "(2 3)" << std::endl << std::endl << "(2 3)" << nl << nl
<< "(0 \"Grid dimensions:\")" << std::endl; << "(0 \"Grid dimensions:\")" << nl;
// Writing number of points // Writing number of points
fluentMeshFile fluentMeshFile
...@@ -217,8 +218,8 @@ void Foam::fluentFvMesh::writeFluentMesh() const ...@@ -217,8 +218,8 @@ void Foam::fluentFvMesh::writeFluentMesh() const
// Writing cells // Writing cells
fluentMeshFile fluentMeshFile
<< "(12 (1 1 " << "(12 (1 1 " << nCells() << " 1 0)" << nl
<< nCells() << " 1 0)(" << std::endl; << '(';
const cellModel& hex = cellModel::ref(cellModel::HEX); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = cellModel::ref(cellModel::PRISM); const cellModel& prism = cellModel::ref(cellModel::PRISM);
...@@ -227,44 +228,59 @@ void Foam::fluentFvMesh::writeFluentMesh() const ...@@ -227,44 +228,59 @@ void Foam::fluentFvMesh::writeFluentMesh() const
const cellShapeList& cells = cellShapes(); const cellShapeList& cells = cellShapes();
bool hasWarned = false; label nPolys = 0;
int nElemPerLine = 25; // Start with linebreak and indent
forAll(cells, celli) forAll(cells, celli)
{ {
if (nElemPerLine == 25)
{
// 25 elements per line with initial indent (readability)
fluentMeshFile << "\n ";
nElemPerLine = 0;
}
else if (!(nElemPerLine % 5))
{
// Format in blocks of 5 (readability)
fluentMeshFile << token::SPACE;
}
fluentMeshFile << token::SPACE;
++nElemPerLine;
if (cells[celli].model() == tet) if (cells[celli].model() == tet)
{ {
fluentMeshFile << " " << 2; fluentMeshFile << 2;
} }
else if (cells[celli].model() == hex) else if (cells[celli].model() == hex)
{ {
fluentMeshFile << " " << 4; fluentMeshFile << 4;
} }
else if (cells[celli].model() == pyr) else if (cells[celli].model() == pyr)
{ {
fluentMeshFile << " " << 5; fluentMeshFile << 5;
} }
else if (cells[celli].model() == prism) else if (cells[celli].model() == prism)
{ {
fluentMeshFile << " " << 6; fluentMeshFile << 6;
} }
else else
{ {
if (!hasWarned) fluentMeshFile << 7;
{ ++nPolys;
hasWarned = true;
WarningInFunction
<< "foamMeshToFluent: cell shape for cell "
<< celli << " only supported by Fluent polyhedral meshes."
<< nl
<< " Suppressing any further messages for polyhedral"
<< " cells." << endl;
}
fluentMeshFile << " " << 7;
} }
} }
fluentMeshFile << ")())" << std::endl; fluentMeshFile
<< nl << "))" << nl;
if (nPolys)
{
Info<< "Mesh had " << nPolys << " polyhedrals." << endl;
}
// Return to dec // Return to dec
fluentMeshFile.setf(ios::dec, ios::basefield); fluentMeshFile.setf(ios::dec, ios::basefield);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment