diff --git a/src/Allwmake b/src/Allwmake index 43458cfc62..354aee075d 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -38,6 +38,8 @@ wmake libso genericPatchFields # Build the proper scotchDecomp, metisDecomp etc. parallel/Allwmake +wmake libso conversion + wmake libso sampling wmake libso dynamicMesh @@ -53,7 +55,6 @@ turbulenceModels/Allwmake wmake libso surfaceFilmModels lagrangian/Allwmake postProcessing/Allwmake -conversion/Allwmake mesh/Allwmake wmake libso errorEstimation diff --git a/src/conversion/Make/files b/src/conversion/Make/files index 7c5a0aa91c..563d177682 100644 --- a/src/conversion/Make/files +++ b/src/conversion/Make/files @@ -4,6 +4,7 @@ ensight/part/ensightPart.C ensight/part/ensightPartIO.C ensight/part/ensightPartCells.C ensight/part/ensightPartFaces.C +ensight/part/ensightPartNonMeshFaces.C ensight/part/ensightParts.C meshTables/boundaryRegion.C diff --git a/src/conversion/ensight/part/ensightPart.H b/src/conversion/ensight/part/ensightPart.H index 9f1fa0013e..7f674b595a 100644 --- a/src/conversion/ensight/part/ensightPart.H +++ b/src/conversion/ensight/part/ensightPart.H @@ -267,6 +267,12 @@ public: matId_ = value; } + //- simple labelList with a name + const labelListList& elemLists() const + { + return elemLists_; + } + //- offset for element ids label offset() const { @@ -285,8 +291,12 @@ public: //- write reconstruction information for the object bool writeData(Ostream&) const; - //- write geometry - void writeGeometry(ensightGeoFile&) const; + //- Write geometry + virtual void writeGeometry(ensightGeoFile&) const + {} + + //- Helper: write geometry given the pointField + void writeGeometry(ensightGeoFile&, const pointField& points) const; //- write scalar field void writeScalarField diff --git a/src/conversion/ensight/part/ensightPartCells.C b/src/conversion/ensight/part/ensightPartCells.C index 2cf06a5a98..d80995728e 100644 --- a/src/conversion/ensight/part/ensightPartCells.C +++ b/src/conversion/ensight/part/ensightPartCells.C @@ -427,4 +427,11 @@ void Foam::ensightPartCells::writeConnectivity } +void Foam::ensightPartCells::writeGeometry(ensightGeoFile& os) const +{ + const polyMesh& mesh = *meshPtr_; + ensightPart::writeGeometry(os, mesh.points()); +} + + // ************************************************************************* // diff --git a/src/conversion/ensight/part/ensightPartCells.H b/src/conversion/ensight/part/ensightPartCells.H index 949dac777c..a79b742813 100644 --- a/src/conversion/ensight/part/ensightPartCells.H +++ b/src/conversion/ensight/part/ensightPartCells.H @@ -74,6 +74,9 @@ class ensightPartCells const labelList& pointMap ) const; + //- write geometry + virtual void writeGeometry(ensightGeoFile& os) const; + protected: diff --git a/src/conversion/ensight/part/ensightPartFaces.C b/src/conversion/ensight/part/ensightPartFaces.C index fb77cc83de..49cab8bd6b 100644 --- a/src/conversion/ensight/part/ensightPartFaces.C +++ b/src/conversion/ensight/part/ensightPartFaces.C @@ -47,41 +47,18 @@ Foam::List Foam::ensightPartFaces::elemTypes_ ); -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -Foam::ensightPartFaces::ensightPartFaces -( - label partNumber, - const string& partDescription -) -: - ensightPart(partNumber, partDescription) +void Foam::ensightPartFaces::binShapes(const faceList& faces) { - isCellData_ = false; -} - - -Foam::ensightPartFaces::ensightPartFaces -( - label partNumber, - const polyMesh& pMesh, - const polyPatch& pPatch -) -: - ensightPart(partNumber, pPatch.name(), pMesh) -{ - isCellData_ = false; - offset_ = pPatch.start(); - size_ = pPatch.size(); - // count the shapes label nTri = 0; label nQuad = 0; label nPoly = 0; - forAll(pPatch, patchfaceI) + forAll(faces, faceI) { - const face& f = pMesh.faces()[patchfaceI + offset_]; + const face& f = faces[faceI]; if (f.size() == 3) { @@ -108,21 +85,21 @@ Foam::ensightPartFaces::ensightPartFaces nPoly = 0; // classify the shapes - forAll(pPatch, patchfaceI) + forAll(faces, faceI) { - const face& f = pMesh.faces()[patchfaceI + offset_]; + const face& f = faces[faceI]; if (f.size() == 3) { - triCells[nTri++] = patchfaceI; + triCells[nTri++] = faceI; } else if (f.size() == 4) { - quadCells[nQuad++] = patchfaceI; + quadCells[nQuad++] = faceI; } else { - polygonCells[nPoly++] = patchfaceI; + polygonCells[nPoly++] = faceI; } } @@ -133,10 +110,45 @@ Foam::ensightPartFaces::ensightPartFaces elemLists_[tria3Elements].transfer( triCells ); elemLists_[quad4Elements].transfer( quadCells ); elemLists_[nsidedElements].transfer( polygonCells ); + + size_ = faces.size(); } -Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces &part) +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::ensightPartFaces::ensightPartFaces +( + label partNumber, + const string& partDescription +) +: + ensightPart(partNumber, partDescription) +{ + isCellData_ = false; + offset_ = 0; + size_ = 0; +} + + +Foam::ensightPartFaces::ensightPartFaces +( + label partNumber, + const polyMesh& pMesh, + const polyPatch& pPatch +) +: + ensightPart(partNumber, pPatch.name(), pMesh) +{ + isCellData_ = false; + offset_ = pPatch.start(); + + // count the shapes + binShapes(pPatch); +} + + +Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces& part) : ensightPart(part) {} @@ -206,6 +218,7 @@ void Foam::ensightPartFaces::writeConnectivity ( ensightGeoFile& os, const word& key, + const faceList& faces, const labelList& idList, const labelList& pointMap ) const @@ -214,8 +227,6 @@ void Foam::ensightPartFaces::writeConnectivity os.write(idList.size()); os.newline(); - const faceList& meshFaces = meshPtr_->faces(); - // write (polygon) face sizes if (key == "nsided") { @@ -223,7 +234,7 @@ void Foam::ensightPartFaces::writeConnectivity forAll(idList, i) { label id = idList[i] + offset_; - const face& f = meshFaces[id]; + const face& f = faces[id]; os.write( f.size() ); os.newline(); @@ -234,7 +245,7 @@ void Foam::ensightPartFaces::writeConnectivity forAll(idList, i) { label id = idList[i] + offset_; - const face& f = meshFaces[id]; + const face& f = faces[id]; // convert global -> local index // (note: Ensight indices start with 1) @@ -247,4 +258,31 @@ void Foam::ensightPartFaces::writeConnectivity } +void Foam::ensightPartFaces::writeConnectivity +( + ensightGeoFile& os, + const word& key, + const labelList& idList, + const labelList& pointMap +) const +{ + writeConnectivity + ( + os, + key, + meshPtr_->faces(), + idList, + pointMap + ); +} + + +void Foam::ensightPartFaces::writeGeometry(ensightGeoFile& os) const +{ + const polyMesh& mesh = *meshPtr_; + const pointField& points = mesh.points(); + ensightPart::writeGeometry(os, points); +} + + // ************************************************************************* // diff --git a/src/conversion/ensight/part/ensightPartFaces.H b/src/conversion/ensight/part/ensightPartFaces.H index e0891c9b7f..8683c7d977 100644 --- a/src/conversion/ensight/part/ensightPartFaces.H +++ b/src/conversion/ensight/part/ensightPartFaces.H @@ -67,6 +67,9 @@ class ensightPartFaces const labelList& pointMap ) const; + //- write geometry + virtual void writeGeometry(ensightGeoFile& os) const; + protected: @@ -81,6 +84,19 @@ protected: // Static data members static List elemTypes_; + //- Divide the shapes, set elemLists. + void binShapes(const faceList& faces); + + //- Helper: write connectivity + void writeConnectivity + ( + ensightGeoFile& os, + const word& key, + const faceList& faces, + const labelList& idList, + const labelList& pointMap + ) const; + public: diff --git a/src/conversion/ensight/part/ensightPartIO.C b/src/conversion/ensight/part/ensightPartIO.C index c3866cdd36..264cf2beb7 100644 --- a/src/conversion/ensight/part/ensightPartIO.C +++ b/src/conversion/ensight/part/ensightPartIO.C @@ -118,15 +118,16 @@ bool Foam::ensightPart::writeData(Ostream& os) const } -void Foam::ensightPart::writeGeometry(ensightGeoFile& os) const +void Foam::ensightPart::writeGeometry +( + ensightGeoFile& os, + const pointField& points +) const { - if (size() && meshPtr_) + if (size()) { - const polyMesh& mesh = *meshPtr_; - const pointField& meshPoints = mesh.points(); - - localPoints ptList = calcLocalPoints(); - labelList& pointMap = ptList.list; + const localPoints ptList = calcLocalPoints(); + const labelList& pointMap = ptList.list; writeHeader(os, true); @@ -141,7 +142,7 @@ void Foam::ensightPart::writeGeometry(ensightGeoFile& os) const { if (pointMap[ptI] > -1) { - os.write( meshPoints[ptI].component(cmpt) ); + os.write( points[ptI].component(cmpt) ); os.newline(); } } diff --git a/src/conversion/ensight/part/ensightPartNonMeshFaces.C b/src/conversion/ensight/part/ensightPartNonMeshFaces.C new file mode 100644 index 0000000000..2c68a0d6c1 --- /dev/null +++ b/src/conversion/ensight/part/ensightPartNonMeshFaces.C @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "ensightPartNonMeshFaces.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(ensightPartNonMeshFaces, 0); + addToRunTimeSelectionTable(ensightPart, ensightPartNonMeshFaces, istream); +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::ensightPart::localPoints +Foam::ensightPartNonMeshFaces::calcLocalPoints() const +{ + localPoints ptList; + ptList.list = identity(points_.size()); + ptList.nPoints = points_.size(); + return ptList; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces +( + label partNumber, + const string& partDescription, + const faceList& faces, + const pointField& points +) +: + ensightPartFaces(partNumber, partDescription), + faces_(faces), + points_(points) +{ + binShapes(faces); +} + + +//- Construct as copy +Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces +( + const ensightPartNonMeshFaces& part +) +: + ensightPartFaces(part), + faces_(part.faces_), + points_(part.points_) +{} + + +//- Construct from Istream +Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces(Istream& is) +: + ensightPartFaces(is), + faces_(is), + points_(is) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::ensightPartNonMeshFaces::~ensightPartNonMeshFaces() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::ensightPartNonMeshFaces::writeConnectivity +( + ensightGeoFile& os, + const word& key, + const labelList& idList, + const labelList& pointMap +) const +{ + ensightPartFaces::writeConnectivity + ( + os, + key, + faces_, + idList, + pointMap + ); +} + + +void Foam::ensightPartNonMeshFaces::writeGeometry(ensightGeoFile& os) const +{ + ensightPart::writeGeometry(os, points_); +} + + +// ************************************************************************* // diff --git a/src/conversion/ensight/part/ensightPartNonMeshFaces.H b/src/conversion/ensight/part/ensightPartNonMeshFaces.H new file mode 100644 index 0000000000..86178b7eaf --- /dev/null +++ b/src/conversion/ensight/part/ensightPartNonMeshFaces.H @@ -0,0 +1,131 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::ensightPartNonMeshFaces + +Description + An implementation of ensightPart to work on self-contained faces and points + (without a mesh). + +SourceFiles + ensightPartNonMeshFaces.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ensightPartNonMeshFaces_H +#define ensightPartNonMeshFaces_H + +#include "ensightPartFaces.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ensightPartNonMeshFaces Declaration +\*---------------------------------------------------------------------------*/ + +class ensightPartNonMeshFaces +: + public ensightPartFaces +{ + // Private data + + //- faces (reference) + const faceList& faces_; + + //- points (reference) + const pointField& points_; + + + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const ensightPartNonMeshFaces&); + + //- track points used + virtual localPoints calcLocalPoints() const; + +public: + + //- Runtime type information + TypeName("ensightNonMeshFaces"); + + // Constructors + + //- Construct from faces and points + ensightPartNonMeshFaces + ( + label partNumber, + const string& partDescription, + const faceList& faces, + const pointField& points + ); + + //- Construct as copy + ensightPartNonMeshFaces(const ensightPartNonMeshFaces& part); + + //- Construct from Istream + ensightPartNonMeshFaces(Istream& is); + + //- Construct on freestore from Istream + static autoPtr New(Istream& is) + { + return autoPtr + ( + new ensightPartNonMeshFaces(is) + ); + } + + + //- Destructor + virtual ~ensightPartNonMeshFaces(); + + + // Member Functions + + //- element connectivity + virtual void writeConnectivity + ( + ensightGeoFile& os, + const word& key, + const labelList& idList, + const labelList& pointMap + ) const; + + virtual void writeGeometry(ensightGeoFile& os) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/Make/options b/src/sampling/Make/options index 0e2c6780d2..9a82299c41 100644 --- a/src/sampling/Make/options +++ b/src/sampling/Make/options @@ -3,6 +3,7 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude LIB_LIBS = \ @@ -10,4 +11,5 @@ LIB_LIBS = \ -lmeshTools \ -lsurfMesh \ -ltriSurface \ + -lconversion \ -llagrangian diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C index 81eb8510fa..dc87c8247a 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C @@ -28,119 +28,11 @@ License #include "OFstream.H" #include "OSspecific.H" #include "IOmanip.H" +#include "ensightGeoFile.H" +#include "ensightPartNonMeshFaces.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::ensightSurfaceWriter::binShapes -( - const pointField& points, - const faceList& faces, - DynamicList