1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "objectRegistry.H"
27 #include "surfaceFormatsCore.H"
32 #include "SortableList.H"
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
39 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
41 Foam::string Foam::fileFormats::surfaceFormatsCore::getLineNoComment
51 while ((line.empty() || line[0] == '#') && is.good());
58 Foam::fileName Foam::fileFormats::surfaceFormatsCore::localMeshFileName
63 const word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
67 surfaceRegistry::prefix/name/surfMesh::meshSubDir
68 / name + "." + nativeExt
73 Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshInstance
79 fileName localName = localMeshFileName(surfName);
81 // Search back through the time directories list to find the time
82 // closest to and lower than current time
84 instantList ts = t.times();
87 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
89 if (ts[instanceI].value() <= t.timeOutputValue())
95 // Noting that the current directory has already been searched
96 // for mesh data, start searching from the previously stored time directory
100 for (label i = instanceI; i >= 0; --i)
102 if (isFile(t.path()/ts[i].name()/localName))
113 Foam::fileName Foam::fileFormats::surfaceFormatsCore::findMeshFile
119 fileName localName = localMeshFileName(surfName);
121 // Search back through the time directories list to find the time
122 // closest to and lower than current time
124 instantList ts = t.times();
127 for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
129 if (ts[instanceI].value() <= t.timeOutputValue())
135 // Noting that the current directory has already been searched
136 // for mesh data, start searching from the previously stored time directory
140 for (label i = instanceI; i >= 0; --i)
142 fileName testName(t.path()/ts[i].name()/localName);
144 if (isFile(testName))
151 // fallback to "constant"
152 return t.path()/"constant"/localName;
157 bool Foam::fileFormats::surfaceFormatsCore::checkSupport
159 const wordHashSet& available,
162 const word& functionName
165 if (available.found(ext))
171 wordList toc = available.toc();
172 SortableList<word> known(toc.xfer());
174 Info<<"Unknown file extension for " << functionName
175 << " : " << ext << nl
180 Info<<" " << known[i];
189 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
191 Foam::fileFormats::surfaceFormatsCore::surfaceFormatsCore()
195 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
197 Foam::fileFormats::surfaceFormatsCore::~surfaceFormatsCore()
201 // ************************************************************************* //