diff --git a/src/surfMesh/Make/files b/src/surfMesh/Make/files index c7be4a4f32..5273d67404 100644 --- a/src/surfMesh/Make/files +++ b/src/surfMesh/Make/files @@ -6,6 +6,7 @@ MeshedSurface/MeshedSurfaces.C UnsortedMeshedSurface/UnsortedMeshedSurfaces.C surfaceFormats = surfaceFormats +$(surfaceFormats)/surfaceFormatsCore.C $(surfaceFormats)/ac3d/AC3DsurfaceFormatRunTime.C $(surfaceFormats)/ftr/FTRsurfaceFormatRunTime.C $(surfaceFormats)/gts/GTSsurfaceFormatRunTime.C diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C index b7a3a2f5f9..f973379004 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.C +++ b/src/surfMesh/MeshedSurface/MeshedSurface.C @@ -41,122 +41,28 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -// File extension for 'native' raw format -#undef nativeSurfaceExt -#define nativeSurfaceExt "ofs" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // template Foam::fileName Foam::MeshedSurface::triSurfInstance(const Time& d) { - fileName foamName(d.caseName() + "." + nativeSurfaceExt); - - // 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()/typeName/foamName)) - { - if (debug) - { - Pout<< " MeshedSurface::triSurfInstance(const Time& d)" - << "reading " << foamName - << " from " << ts[j].name()/typeName - << endl; - } - - return ts[j].name(); - } - } - } - - if (debug) - { - Pout<< " MeshedSurface::triSurfInstance(const Time& d)" - << "reading " << foamName - << " from constant/" << endl; - } - - return "constant"; + return triSurfInstance(d, typeName); } template Foam::fileName Foam::MeshedSurface::triSurfName(const Time& d) { - fileName foamName(d.caseName() + "." + nativeSurfaceExt); - - // 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()/typeName/foamName); - - if (file(testName)) - { - if (debug) - { - Pout<< " MeshedSurface::triSurfName(const Time& d)" - << "reading " << foamName - << " from " << ts[j].name()/typeName - << endl; - } - - return testName; - } - } - } - - if (debug) - { - Pout<< " MeshedSurface::triSurfName(const Time& d)" - << "reading " << foamName - << " from constant/" << endl; - } - - return d.path()/"constant"/typeName/foamName; + return triSurfName(d, typeName); } + template bool Foam::MeshedSurface::canRead(const word& ext, const bool verbose) { // handle 'native' format directly - if (ext == nativeSurfaceExt) + if (isNative(ext)) { return true; } @@ -178,7 +84,7 @@ bool Foam::MeshedSurface::canWrite(const word& ext, const bool verbose) } // handle 'native' format directly - if (fExt == nativeSurfaceExt) + if (isNative(fExt)) { return true; } @@ -197,7 +103,7 @@ bool Foam::MeshedSurface::canWrite(const word& ext, const bool verbose) Info<<"Unknown file extension for writing: " << fExt << nl; // compact output: - Info<<"Valid types: ( " << nativeSurfaceExt; + Info<<"Valid types: ( " << nativeExt; forAll(known, i) { Info<<" " << known[i]; @@ -229,7 +135,7 @@ void Foam::MeshedSurface::write const word ext = fName.ext(); // handle 'native' format directly - if (ext == nativeSurfaceExt) + if (isNative(ext)) { surf.write(OFstream(fName)()); return; @@ -899,7 +805,7 @@ bool Foam::MeshedSurface::read const word ext = fName.ext(); // handle 'native' format directly - if (ext == nativeSurfaceExt) + if (isNative(ext)) { return read(IFstream(fName)()); } @@ -923,7 +829,7 @@ bool Foam::MeshedSurface::read clear(); // handle 'native' format directly - if (ext == nativeSurfaceExt) + if (isNative(ext)) { return read(IFstream(fName)()); } @@ -975,6 +881,4 @@ void Foam::MeshedSurface::operator=(const MeshedSurface& surf) #include "MeshedSurfaceIO.C" #include "MeshedSurfaceNew.C" -#undef nativeSurfaceExt - // ************************************************************************* // diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.H b/src/surfMesh/MeshedSurface/MeshedSurface.H index bc7e59a1b1..6e1851b1b1 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.H +++ b/src/surfMesh/MeshedSurface/MeshedSurface.H @@ -48,6 +48,7 @@ SourceFiles #include "PrimitivePatchExtra.H" #include "boolList.H" #include "surfGroupList.H" +#include "surfaceFormatsCore.H" #include "xfer.H" #include "face.H" #include "triFace.H" @@ -78,7 +79,8 @@ template template class MeshedSurface : - public PrimitivePatchExtra + public PrimitivePatchExtra, + public fileFormats::surfaceFormatsCore { friend class UnsortedMeshedSurface; diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C index 1e20018eae..0280a2f354 100644 --- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C +++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C @@ -37,128 +37,19 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -// File extension for 'native' raw format -#undef nativeSurfaceExt -#define nativeSurfaceExt "ofs" - // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -template -Foam::string Foam::UnsortedMeshedSurface::getLineNoComment(IFstream& is) -{ - string line; - do - { - is.getLine(line); - } - while ((line.size() == 0 || line[0] == '#') && is.good()); - - return line; -} - template Foam::fileName Foam::UnsortedMeshedSurface::triSurfInstance(const Time& d) { - fileName foamName(d.caseName() + "." + nativeSurfaceExt); - - // 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()/typeName/foamName)) - { - if (debug) - { - Pout<< " UnsortedMeshedSurface::triSurfInstance(const Time& d)" - << "reading " << foamName - << " from " << ts[j].name()/typeName - << endl; - } - - return ts[j].name(); - } - } - } - - if (debug) - { - Pout<< " UnsortedMeshedSurface::triSurfInstance(const Time& d)" - << "reading " << foamName - << " from constant/" << endl; - } - - return "constant"; + return triSurfInstance(d, typeName); } template Foam::fileName Foam::UnsortedMeshedSurface::triSurfName(const Time& d) { - fileName foamName(d.caseName() + "." + nativeSurfaceExt); - - // 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()/typeName/foamName); - - if (file(testName)) - { - if (debug) - { - Pout<< " UnsortedMeshedSurface::triSurfName(const Time& d)" - << "reading " << foamName - << " from " << ts[j].name()/typeName - << endl; - } - - return testName; - } - } - } - - if (debug) - { - Pout<< " UnsortedMeshedSurface::triSurfName(const Time& d)" - << "reading " << foamName - << " from constant/" << endl; - } - - return d.path()/"constant"/typeName/foamName; + return triSurfName(d, typeName); } @@ -179,7 +70,7 @@ bool Foam::UnsortedMeshedSurface::canRead } // handle 'native' format directly - if (fExt == nativeSurfaceExt) + if (isNative(fExt)) { return true; } @@ -199,7 +90,7 @@ bool Foam::UnsortedMeshedSurface::canRead Info<<"Unknown file extension for reading: " << fExt << nl; // compact output: - Info<<"Valid types: ( " << nativeSurfaceExt; + Info<<"Valid types: ( " << nativeExt; forAll(known, i) { Info<<" " << known[i]; @@ -230,7 +121,7 @@ bool Foam::UnsortedMeshedSurface::canWrite } // handle 'native' format directly - if (fExt == nativeSurfaceExt) + if (isNative(fExt)) { return true; } @@ -249,7 +140,7 @@ bool Foam::UnsortedMeshedSurface::canWrite Info<<"Unknown file extension for writing: " << fExt << nl; // compact output: - Info<<"Valid types: ( " << nativeSurfaceExt; + Info<<"Valid types: ( " << nativeExt; forAll(known, i) { Info<<" " << known[i]; @@ -281,7 +172,7 @@ void Foam::UnsortedMeshedSurface::write const word ext = fName.ext(); // handle 'native' format directly - if (ext == nativeSurfaceExt) + if (isNative(ext)) { surf.write(OFstream(fName)()); return; @@ -306,92 +197,6 @@ void Foam::UnsortedMeshedSurface::write } -// Returns patch info. -// Sets faceMap to the indexing according to patch numbers. -// Patch numbers start at 0. -template -Foam::surfGroupList Foam::UnsortedMeshedSurface::sortedRegions -( - const UList