diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index f7beae2f7c0dcd154712c4ad53c80ff23b53d95c..40182bbb29e1925c41d4342e4f2b7d02c7202ddd 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -30,8 +30,6 @@ $(surfaceFormats)/nas/NASsurfaceFormatRunTime.C $(surfaceFormats)/obj/OBJsurfaceFormatRunTime.C $(surfaceFormats)/obj/OBJstream.C $(surfaceFormats)/off/OFFsurfaceFormatRunTime.C -$(surfaceFormats)/ofs/OFSsurfaceFormatCore.C -$(surfaceFormats)/ofs/OFSsurfaceFormatRunTime.C $(surfaceFormats)/smesh/SMESHsurfaceFormatRunTime.C $(surfaceFormats)/starcd/STARCDsurfaceFormatCore.C $(surfaceFormats)/starcd/STARCDsurfaceFormatRunTime.C diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.H b/src/surfMesh/MeshedSurface/MeshedSurface.H index 3ff8eb73b410b52895587aadd9dfc6de13eac81e..c30686f6b484d026f68e8bf1e6ac9d503cda3c00 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.H +++ b/src/surfMesh/MeshedSurface/MeshedSurface.H @@ -500,6 +500,7 @@ public: // IOstream Operators //- Read MeshedSurface from Istream. + // Avoid using to read/write file content (fragile). friend Istream& operator>> <Face> ( Istream&, @@ -508,6 +509,7 @@ public: //- Write MeshedSurface to Ostream. + // Avoid using to read/write file content (fragile). friend Ostream& operator<< <Face> ( Ostream&, diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H index 68a78888d4e6d623c2e179a4fd00f79a66026991..9be2e3151d18c6e25e939580d0b579fd707e4bd2 100644 --- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H +++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.H @@ -403,6 +403,7 @@ public: // IOstream Operators //- Read UnsortedMeshedSurface from Istream. + // Avoid using to read/write file content (fragile). friend Istream& operator>> <Face> ( Istream&, @@ -411,6 +412,7 @@ public: //- Write UnsortedMeshedSurface to Ostream. + // Avoid using to read/write file content (fragile). friend Ostream& operator<< <Face> ( Ostream&, diff --git a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.C b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.C deleted file mode 100644 index 203a4653c73a9c547ec13d90f1880bb1ecbe2c96..0000000000000000000000000000000000000000 --- a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.C +++ /dev/null @@ -1,243 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. -------------------------------------------------------------------------------- -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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "OFSsurfaceFormat.H" -#include "IFstream.H" -#include "IStringStream.H" -#include "ListOps.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template<class Face> -Foam::fileFormats::OFSsurfaceFormat<Face>::OFSsurfaceFormat -( - const fileName& filename -) -{ - read(filename); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class Face> -bool Foam::fileFormats::OFSsurfaceFormat<Face>::read -( - const fileName& filename -) -{ - this->clear(); - - IFstream is(filename); - if (!is.good()) - { - FatalErrorInFunction - << "Cannot read file " << filename - << exit(FatalError); - } - - // read surfZones: - is >> this->storedZones(); - - // read points: - is >> this->storedPoints(); - - // must triangulate? - if (MeshedSurface<Face>::isTri()) - { - // read faces as 'face' and transcribe to 'triFace' - List<face> faceLst(is); - - MeshedSurface<face> surf - ( - xferMove(this->storedPoints()), - xferMove(faceLst), - xferMove(this->storedZones()) - ); - - this->transcribe(surf); - } - else - { - // read faces directly - is >> this->storedFaces(); - } - - return true; -} - - -template<class Face> -bool Foam::fileFormats::OFSsurfaceFormat<Face>::read -( - Istream& is, - pointField& pointLst, - List<Face>& faceLst, - List<surfZone>& zoneLst -) -{ - if (!is.good()) - { - FatalErrorInFunction - << "read error " - << exit(FatalError); - } - - // read surfZones: - is >> zoneLst; - - // read points: - is >> pointLst; - - // must triangulate? - if (MeshedSurface<Face>::isTri()) - { - // read faces as 'face' and transcribe to 'triFace' - List<face> origFaces(is); - - MeshedSurface<face> origSurf - ( - xferMove(pointLst), - xferMove(origFaces), - xferMove(zoneLst) - ); - - MeshedSurface<Face> surf; - surf.transcribe(origSurf); - } - else - { - // read faces directly - is >> faceLst; - } - - return true; -} - - -template<class Face> -bool Foam::fileFormats::OFSsurfaceFormat<Face>::read -( - Istream& is, - MeshedSurface<Face>& surf -) -{ - surf.clear(); - - if (!is.good()) - { - FatalErrorInFunction - << "read error " - << exit(FatalError); - } - - pointField pointLst; - List<Face> faceLst; - List<surfZone> zoneLst; - - read(is, pointLst, faceLst, zoneLst); - - surf.reset - ( - xferMove(pointLst), - xferMove(faceLst), - xferMove(zoneLst) - ); - - return true; -} - - -template<class Face> -bool Foam::fileFormats::OFSsurfaceFormat<Face>::read -( - Istream& is, - UnsortedMeshedSurface<Face>& surf -) -{ - surf.clear(); - MeshedSurface<Face> origSurf(is); - surf.transfer(origSurf); - - return true; -} - - - -template<class Face> -void Foam::fileFormats::OFSsurfaceFormat<Face>::write -( - const fileName& filename, - const MeshedSurfaceProxy<Face>& surf -) -{ - const List<Face>& faceLst = surf.surfFaces(); - const List<label>& faceMap = surf.faceMap(); - - OFstream os(filename); - if (!os.good()) - { - FatalErrorInFunction - << "Cannot open file for writing " << filename - << exit(FatalError); - } - - - OFSsurfaceFormatCore::writeHeader(os, surf.points(), surf.surfZones()); - - const List<surfZone>& zones = surf.surfZones(); - const bool useFaceMap = (surf.useFaceMap() && zones.size() > 1); - - if (useFaceMap) - { - os << "\n// faces:" << nl - << faceLst.size() << token::BEGIN_LIST << nl; - - label facei = 0; - forAll(zones, zoneI) - { - // Print all faces belonging to this zone - const surfZone& zone = zones[zoneI]; - - forAll(zone, localFacei) - { - os << faceLst[faceMap[facei++]] << nl; - } - } - os << token::END_LIST << nl; - } - else - { - os << "\n// faces:" << nl << faceLst << nl; - } - - IOobject::writeDivider(os); - - // Check state of Ostream - os.check("OFSsurfaceFormat<Face>::write(Ostream&)"); -} - - -// ************************************************************************* // diff --git a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H deleted file mode 100644 index 33ab7212a52a4de87002c452c129db0f74e6cb07..0000000000000000000000000000000000000000 --- a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormat.H +++ /dev/null @@ -1,155 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Class - Foam::fileFormats::OFSsurfaceFormat - -Description - Provide a means of reading/writing the single-file OpenFOAM surface format. - -Note - This class provides more methods than the regular surface format interface. - -SourceFiles - OFSsurfaceFormat.C - -\*---------------------------------------------------------------------------*/ - -#ifndef OFSsurfaceFormat_H -#define OFSsurfaceFormat_H - -#include "Ostream.H" -#include "OFstream.H" -#include "MeshedSurface.H" -#include "MeshedSurfaceProxy.H" -#include "UnsortedMeshedSurface.H" -#include "OFSsurfaceFormatCore.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace fileFormats -{ - -/*---------------------------------------------------------------------------*\ - Class OFSsurfaceFormat Declaration -\*---------------------------------------------------------------------------*/ - -template<class Face> -class OFSsurfaceFormat -: - public MeshedSurface<Face>, - public OFSsurfaceFormatCore -{ - // Private Member Functions - - //- Disallow default bitwise copy construct - OFSsurfaceFormat(const OFSsurfaceFormat<Face>&); - - //- Disallow default bitwise assignment - void operator=(const OFSsurfaceFormat<Face>&); - - -public: - - // Constructors - - //- Construct from file name - OFSsurfaceFormat(const fileName&); - - - // Selectors - - //- Read file and return surface - static autoPtr<MeshedSurface<Face>> New(const fileName& name) - { - return autoPtr<MeshedSurface<Face>> - ( - new OFSsurfaceFormat<Face>(name) - ); - } - - - //- Destructor - virtual ~OFSsurfaceFormat() - {} - - - - // Member Functions - - //- Read surface mesh components - static bool read - ( - Istream&, - pointField&, - List<Face>&, - List<surfZone>& - ); - - //- Read MeshedSurface - static bool read - ( - Istream&, - MeshedSurface<Face>& - ); - - //- Read UnsortedMeshedSurface - // The output is sorted by zones - static bool read - ( - Istream&, - UnsortedMeshedSurface<Face>& - ); - - //- Write surface mesh components by proxy - static void write(const fileName&, const MeshedSurfaceProxy<Face>&); - - //- Read from file - virtual bool read(const fileName&); - - //- Write object - virtual void write(const fileName& name) const - { - write(name, MeshedSurfaceProxy<Face>(*this)); - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fileFormats -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "OFSsurfaceFormat.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatCore.C deleted file mode 100644 index 89ab4290956bf6d958a0a6d0814a3fdb5699691e..0000000000000000000000000000000000000000 --- a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatCore.C +++ /dev/null @@ -1,71 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "OFSsurfaceFormatCore.H" -#include "clock.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::fileFormats::OFSsurfaceFormatCore::writeHeader -( - Ostream& os, - const pointField& pointLst, - const UList<surfZone>& zoneLst -) -{ - // just emit some information until we get a nice IOobject - IOobject::writeBanner(os) - << "// OpenFOAM Surface Format - written " - << clock::dateTime().c_str() << nl - << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl << nl - << "// surfZones:" << nl; - - - // treat a single zone as being unzoned - if (zoneLst.size() <= 1) - { - os << "0" << token::BEGIN_LIST << token::END_LIST << nl << nl; - } - else - { - os << zoneLst.size() << nl << token::BEGIN_LIST << incrIndent << nl; - - forAll(zoneLst, zoneI) - { - zoneLst[zoneI].writeDict(os); - } - os << decrIndent << token::END_LIST << nl << nl; - } - - // Note: write with global point numbering - - IOobject::writeDivider(os) - << "\n// points:" << nl << pointLst << nl; - - IOobject::writeDivider(os); -} - - -// ************************************************************************* // diff --git a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatCore.H b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatCore.H deleted file mode 100644 index 65e93f274e9a98b3908485369db485f83e35290f..0000000000000000000000000000000000000000 --- a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatCore.H +++ /dev/null @@ -1,79 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Class - Foam::fileFormats::OFSsurfaceFormatCore - -Description - Internal class used by the OFSsurfaceFormat - -SourceFiles - OFSsurfaceFormatCore.C - -\*---------------------------------------------------------------------------*/ - -#ifndef OFSsurfaceFormatCore_H -#define OFSsurfaceFormatCore_H - -#include "Ostream.H" -#include "OFstream.H" -#include "MeshedSurface.H" -#include "UnsortedMeshedSurface.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace fileFormats -{ - -/*---------------------------------------------------------------------------*\ - Class OFSsurfaceFormatCore Declaration -\*---------------------------------------------------------------------------*/ - -class OFSsurfaceFormatCore -{ -protected: - - // Protected Member Functions - - //- Write header information and surfZoneList - static void writeHeader - ( - Ostream&, - const pointField&, - const UList<surfZone>& - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fileFormats -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatRunTime.C b/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatRunTime.C deleted file mode 100644 index 1f1069f0aba4893e6ddea66233221fb7fd6433fc..0000000000000000000000000000000000000000 --- a/src/surfMesh/surfaceFormats/ofs/OFSsurfaceFormatRunTime.C +++ /dev/null @@ -1,81 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "OFSsurfaceFormat.H" - -#include "addToRunTimeSelectionTable.H" -#include "addToMemberFunctionSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ -namespace fileFormats -{ - -// read MeshedSurface -addNamedTemplatedToRunTimeSelectionTable -( - MeshedSurface, - OFSsurfaceFormat, - face, - fileExtension, - ofs -); -addNamedTemplatedToRunTimeSelectionTable -( - MeshedSurface, - OFSsurfaceFormat, - triFace, - fileExtension, - ofs -); - - -// write MeshedSurfaceProxy -addNamedTemplatedToMemberFunctionSelectionTable -( - MeshedSurfaceProxy, - OFSsurfaceFormat, - face, - write, - fileExtension, - ofs -); -addNamedTemplatedToMemberFunctionSelectionTable -( - MeshedSurfaceProxy, - OFSsurfaceFormat, - triFace, - write, - fileExtension, - ofs -); - - -} -} - -// ************************************************************************* //