From 00d503498f3e7882b9d604d5f4b0f1eabc447e61 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Thu, 29 Oct 2020 10:02:59 +0100 Subject: [PATCH] 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. --- .../foamMeshToFluent/fluentFvMesh.C | 66 ++++++++++++------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C b/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C index 2d3521328d6..180d18669ad 100644 --- a/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C +++ b/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,13 +63,13 @@ void Foam::fluentFvMesh::writeFluentMesh() const / time().caseName() + ".msh" ); - Info<< "Writing Header" << endl; + Info<< "Writing Fluent Mesh" << endl; fluentMeshFile - << "(0 \"FOAM to Fluent Mesh File\")" << std::endl << std::endl - << "(0 \"Dimension:\")" << std::endl - << "(2 3)" << std::endl << std::endl - << "(0 \"Grid dimensions:\")" << std::endl; + << "(0 \"OpenFOAM to Fluent Mesh File\")" << nl << nl + << "(0 \"Dimension:\")" << nl + << "(2 3)" << nl << nl + << "(0 \"Grid dimensions:\")" << nl; // Writing number of points fluentMeshFile @@ -217,8 +218,8 @@ void Foam::fluentFvMesh::writeFluentMesh() const // Writing cells fluentMeshFile - << "(12 (1 1 " - << nCells() << " 1 0)(" << std::endl; + << "(12 (1 1 " << nCells() << " 1 0)" << nl + << '('; const cellModel& hex = cellModel::ref(cellModel::HEX); const cellModel& prism = cellModel::ref(cellModel::PRISM); @@ -227,44 +228,59 @@ void Foam::fluentFvMesh::writeFluentMesh() const const cellShapeList& cells = cellShapes(); - bool hasWarned = false; + label nPolys = 0; + + int nElemPerLine = 25; // Start with linebreak and indent 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) { - fluentMeshFile << " " << 2; + fluentMeshFile << 2; } else if (cells[celli].model() == hex) { - fluentMeshFile << " " << 4; + fluentMeshFile << 4; } else if (cells[celli].model() == pyr) { - fluentMeshFile << " " << 5; + fluentMeshFile << 5; } else if (cells[celli].model() == prism) { - fluentMeshFile << " " << 6; + fluentMeshFile << 6; } else { - if (!hasWarned) - { - 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 << 7; + ++nPolys; } } - fluentMeshFile << ")())" << std::endl; + fluentMeshFile + << nl << "))" << nl; + + + if (nPolys) + { + Info<< "Mesh had " << nPolys << " polyhedrals." << endl; + } + // Return to dec fluentMeshFile.setf(ios::dec, ios::basefield); -- GitLab