/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2008 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 2 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, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA \*---------------------------------------------------------------------------*/ #include "surfaceFormatsCore.H" #include "IFstream.H" #include "OFstream.H" #include "Time.H" #include "SortableList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // Foam::word Foam::fileFormats::surfaceFormatsCore::meshSubDir("meshedSurface"); Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs"); // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // //- Check if file extension corresponds to 'native' surface format bool Foam::fileFormats::surfaceFormatsCore::isNative(const word& ext) { return (ext == nativeExt); } Foam::string Foam::fileFormats::surfaceFormatsCore::getLineNoComment ( IFstream& is ) { string line; do { is.getLine(line); } while ((line.size() == 0 || line[0] == '#') && is.good()); return line; } Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshInstance ( const Time& d, const word& subdirName ) { fileName foamName(d.caseName() + "." + nativeExt); // Search back through the time directories list to find the time // closest to and lower than current time instantList ts = d.times(); label i; for (i=ts.size()-1; i>=0; i--) { if (ts[i].value() <= d.timeOutputValue()) { break; } } // Noting that the current directory has already been searched // for mesh data, start searching from the previously stored time directory if (i>=0) { for (label j=i; j>=0; j--) { if (file(d.path()/ts[j].name()/subdirName/foamName)) { return ts[j].name(); } } } return "constant"; } Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshName ( const Time& d, const word& subdirName ) { fileName foamName(d.caseName() + "." + nativeExt); // Search back through the time directories list to find the time // closest to and lower than current time instantList ts = d.times(); label i; for (i=ts.size()-1; i>=0; i--) { if (ts[i].value() <= d.timeOutputValue()) { break; } } // Noting that the current directory has already been searched // for mesh data, start searching from the previously stored time directory if (i>=0) { for (label j=i; j>=0; j--) { fileName testName(d.path()/ts[j].name()/subdirName/foamName); if (file(testName)) { return testName; } } } return d.path()/"constant"/subdirName/foamName; } Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshInstance ( const Time& d ) { return findMeshInstance(d, meshSubDir); } Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshName ( const Time& d ) { return findMeshName(d, meshSubDir); } // Returns patch info. // Sets faceMap to the indexing according to patch numbers. // Patch numbers start at 0. Foam::surfGroupList Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions ( const UList