diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToElmer/fluent3DMeshToElmer.L b/applications/utilities/mesh/conversion/fluent3DMeshToElmer/fluent3DMeshToElmer.L index 02a76d7e5..ba216790a 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToElmer/fluent3DMeshToElmer.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToElmer/fluent3DMeshToElmer.L @@ -1380,9 +1380,10 @@ int main(int argc, char *argv[]) excludePattern.compile(wordRe::DETECT_NOCASE); Info<< nl << "Writing Elmer mesh ..." << endl; - meshWriters::Elmer writer(mesh,scaleFactor,&excludePattern); + meshWriters::Elmer writer(mesh, excludePattern, scaleFactor); writer.write("elmerMesh"); Info<< nl << "End" << endl; + return 0; } diff --git a/applications/utilities/mesh/conversion/foamMeshToElmer/foamMeshToElmer.C b/applications/utilities/mesh/conversion/foamMeshToElmer/foamMeshToElmer.C index 7d763168a..a76103a8f 100644 --- a/applications/utilities/mesh/conversion/foamMeshToElmer/foamMeshToElmer.C +++ b/applications/utilities/mesh/conversion/foamMeshToElmer/foamMeshToElmer.C @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) argList::noParallel(); timeSelector::addOptions(); - argList::validOptions.insert("scale" , "factor" ); + argList::validOptions.insert("scale", "factor"); argList::validOptions.insert("exclude", "pattern"); # include "setRootCase.H" @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) if (!timeI || state != polyMesh::UNCHANGED) { - meshWriters::Elmer writer(mesh, scaleFactor,&excludePattern); + meshWriters::Elmer writer(mesh, excludePattern, scaleFactor); fileName dirName("elmerMesh"); if (state != polyMesh::UNCHANGED) { @@ -108,7 +108,9 @@ int main(int argc, char *argv[]) } if (!writer.write(dirName)) + { break; // Conversion failed + } } Info << nl << endl; diff --git a/src/conversion/meshWriter/elmer/ElmerMeshWriter.C b/src/conversion/meshWriter/elmer/ElmerMeshWriter.C index e5d04e3a9..53057a6e8 100644 --- a/src/conversion/meshWriter/elmer/ElmerMeshWriter.C +++ b/src/conversion/meshWriter/elmer/ElmerMeshWriter.C @@ -145,10 +145,12 @@ void Foam::meshWriters::Elmer::getCellTable() } } -// -// Get the Elmer face element type ID based on the number of vertices of a face -// -Foam::label Foam::meshWriters::Elmer::getFaceType(const label nvert, const word &zname) const + +Foam::label Foam::meshWriters::Elmer::getFaceType +( + const label nvert, + const word& zname +) const { switch(nvert) { @@ -167,17 +169,14 @@ Foam::label Foam::meshWriters::Elmer::getFaceType(const label nvert, const word } -// -// Save the mesh.names file containing the names of all zones & patches -// void Foam::meshWriters::Elmer::writeNames() const { OFstream os("mesh.names"); - const cellZoneMesh& czones = mesh_.cellZones(); - const faceZoneMesh& fzones = mesh_.faceZones(); + const cellZoneMesh& czones = mesh_.cellZones(); + const faceZoneMesh& fzones = mesh_.faceZones(); const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - label boundaryID = 0; + label boundaryID = 0; Info<< "Writing " << os.name() << "." << endl; @@ -197,37 +196,31 @@ void Foam::meshWriters::Elmer::writeNames() const os << "! ----- Names for interior boundaries -----" << nl; forAll(fzones, fzoneI) { - if (!faceZoneExcludePattern || !faceZoneExcludePattern->match(fzones[fzoneI].name())) + if (!faceZoneExcludePattern.match(fzones[fzoneI].name())) { os << "$ " << fzones[fzoneI].name() << " = " << ++boundaryID << nl; } } - os.flush(); } -// -// Save the mesh.header file containing the global counters -// bool Foam::meshWriters::Elmer::writeHeader() const { - OFstream os("mesh.header"); - - const pointField& points = mesh_.points(); - const cellList& cells = mesh_.cells(); - const faceList& faces = mesh_.faces(); - const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - const faceZoneMesh& fzones = mesh_.faceZones(); - label extZones = 0; // Count exterior boundary zones - label extFaces = 0; // Count exterior boundary faces - label intZones = 0; // Used interior boundary zones - label intFaces = 0; // Used interior boundary faces + const pointField& points = mesh_.points(); + const cellList& cells = mesh_.cells(); + const faceList& faces = mesh_.faces(); + const polyBoundaryMesh& patches = mesh_.boundaryMesh(); + const faceZoneMesh& fzones = mesh_.faceZones(); + label extZones = 0; // Count exterior boundary zones + label extFaces = 0; // Count exterior boundary faces + label intZones = 0; // Used interior boundary zones + label intFaces = 0; // Used interior boundary faces // Count the different cell types - hexMatcher hex; + hexMatcher hex; prismMatcher pri; - pyrMatcher pyr; - tetMatcher tet; + pyrMatcher pyr; + tetMatcher tet; label nHex = 0; label nPri = 0; @@ -238,14 +231,11 @@ bool Foam::meshWriters::Elmer::writeHeader() const label nBad = 0; - - Info<< "Writing " << os.name() << "." << endl; - // Count all exterior boundary zone + faces + the types forAll(patches, patchI) { const label patchStart = patches[patchI].start(); - const label patchEnd = patchStart + patches[patchI].size(); + const label patchEnd = patchStart + patches[patchI].size(); extZones++; extFaces += patches[patchI].size(); @@ -264,11 +254,14 @@ bool Foam::meshWriters::Elmer::writeHeader() const } } - // Count all interior boundary zones + faces with names not matching the exclude pattern + // Count all interior boundary zones + faces with names not matching + // the exclude pattern forAll(fzones, fzoneI) { - if (faceZoneExcludePattern && faceZoneExcludePattern->match(fzones[fzoneI].name())) + if (faceZoneExcludePattern.match(fzones[fzoneI].name())) + { continue; + } const faceZone& fzone = fzones[fzoneI]; @@ -289,22 +282,42 @@ bool Foam::meshWriters::Elmer::writeHeader() const } } - os << points.size() << " " - << cells.size() << " " - << extFaces+intFaces << nl; - // Count the volume element types for(label cellI = 0; cellI < mesh_.nCells(); cellI++) { - if (hex.isA(mesh_, cellI)) nHex++; - else if (tet.isA(mesh_, cellI)) nTet++; - else if (pyr.isA(mesh_, cellI)) nPyr++; - else if (pri.isA(mesh_, cellI)) nPri++; - else nBad++; // No valid element type for Elmer + if (hex.isA(mesh_, cellI)) + { + nHex++; + } + else if (tet.isA(mesh_, cellI)) + { + nTet++; + } + else if (pyr.isA(mesh_, cellI)) + { + nPyr++; + } + else if (pri.isA(mesh_, cellI)) + { + nPri++; + } + else + { + nBad++; // Not a valid element type for Elmer + } } + OFstream os("mesh.header"); + + os << points.size() << " " + << cells.size() << " " + << extFaces+intFaces << nl; + + Info<< "Writing " << os.name() << "." << endl; + // Save the number of different element types used - os << (nTet>0) + (nPri>0) + (nPyr>0) + (nHex>0) + (nQua>0) + (nTri>0) + (nBad>0) << endl; + os << (nTet>0) + (nPri>0) + (nPyr>0) + + (nHex>0) + (nQua>0) + (nTri>0) + (nBad>0) << endl; // Save type and count if count > 0 if (nTet > 0) os << ELMER_ETYPE_TET << " " << nTet << endl; @@ -324,20 +337,18 @@ bool Foam::meshWriters::Elmer::writeHeader() const << " Tetrahedra : " << nTet << nl << " Polyhedra : " << nBad << nl << " Regions : " << mesh_.cellZones().size() << nl - << " Ext. boundaries: " << extZones << ", " << extFaces << " faces" << nl - << " Int. boundaries: " << intZones << ", " << intFaces << " faces" << nl + << " Ext. boundaries: " << extZones << ", " + << extFaces << " faces" << nl + << " Int. boundaries: " << intZones << ", " + << intFaces << " faces" << nl << " Tri faces : " << nTri << nl << " Quad faces : " << nQua << nl << endl; - os.flush(); - return (!nBad); // Conversion impossble if nBad > 0 + return !nBad; } -// -// Save the mesh.nodes file -// void Foam::meshWriters::Elmer::writeNodes() const { OFstream os("mesh.nodes"); @@ -354,32 +365,27 @@ void Foam::meshWriters::Elmer::writeNodes() const forAll(points, ptI) { - os << ptI + 1 << " -1 " - << scaleFactor_ * points[ptI].x() << " " - << scaleFactor_ * points[ptI].y() << " " - << scaleFactor_ * points[ptI].z() << nl; + os << ptI + 1 << " -1 " + << scaleFactor_ * points[ptI].x() << " " + << scaleFactor_ * points[ptI].y() << " " + << scaleFactor_ * points[ptI].z() << nl; } - os.flush(); } -// -// Save the mesh.elements file. This file contains only the volume elements, not the -// faces on the boundaries -// void Foam::meshWriters::Elmer::writeElements() const { OFstream os("mesh.elements"); // map foam cellModeller index -> Elmer element types Map