diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C index a51428f8b47c6408460670ace46a14c18be27d76..0606860e64a4da677e4b4c6eeb72c36c9ed5f0dd 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.C +++ b/src/surfMesh/MeshedSurface/MeshedSurface.C @@ -3,7 +3,7 @@ \\ / 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. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,10 +129,10 @@ void Foam::MeshedSurface<Face>::write if (mfIter == writefileExtensionMemberFunctionTablePtr_->end()) { - // no direct writer, delegate to proxy if possible - wordHashSet supported = ProxyType::writeTypes(); + // No direct writer, delegate to proxy if possible + const wordHashSet& delegate = ProxyType::writeTypes(); - if (supported.found(ext)) + if (delegate.found(ext)) { MeshedSurfaceProxy<Face>(surf).write(name); } @@ -140,8 +140,8 @@ void Foam::MeshedSurface<Face>::write { FatalErrorInFunction << "Unknown file extension " << ext << nl << nl - << "Valid types are :" << endl - << (supported | writeTypes()) + << "Valid types:" << nl + << flatOutput((delegate | writeTypes()).sortedToc()) << nl << exit(FatalError); } } diff --git a/src/surfMesh/MeshedSurface/MeshedSurfaceNew.C b/src/surfMesh/MeshedSurface/MeshedSurfaceNew.C index 41da2d6a1a55fdba1d3839fc32039b345b098003..a8280451ee8c6e95c383f74bc9128b0dec957fb0 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurfaceNew.C +++ b/src/surfMesh/MeshedSurface/MeshedSurfaceNew.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,6 +25,7 @@ License #include "MeshedSurface.H" #include "UnsortedMeshedSurface.H" +#include "ListOps.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -42,25 +43,25 @@ Foam::MeshedSurface<Face>::New(const fileName& name, const word& ext) if (cstrIter == fileExtensionConstructorTablePtr_->end()) { - // no direct reader, delegate if possible - wordHashSet supported = FriendType::readTypes(); - if (supported.found(ext)) + // No direct reader, delegate to friend if possible + const wordHashSet& delegate = FriendType::readTypes(); + + if (delegate.found(ext)) { - // create indirectly + // Create indirectly autoPtr<MeshedSurface<Face>> surf(new MeshedSurface<Face>); surf().transfer(FriendType::New(name, ext)()); return surf; } - - // nothing left to try, issue error - supported += readTypes(); - - FatalErrorInFunction - << "Unknown file extension " << ext << nl << nl - << "Valid types are :" << nl - << supported - << exit(FatalError); + else + { + FatalErrorInFunction + << "Unknown file extension " << ext << nl << nl + << "Valid types:" << nl + << flatOutput((delegate | readTypes()).sortedToc()) << nl + << exit(FatalError); + } } return autoPtr<MeshedSurface<Face>>(cstrIter()(name)); diff --git a/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.C b/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.C index d7c92fa620ff84ce14d8b1fd4b5eacf56f8c81c3..168155a59716e9fc1e00ec7da637a4fb62384b15 100644 --- a/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.C +++ b/src/surfMesh/MeshedSurfaceProxy/MeshedSurfaceProxy.C @@ -3,7 +3,7 @@ \\ / 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. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,9 +26,9 @@ License #include "MeshedSurfaceProxy.H" #include "Time.H" +#include "ListOps.H" #include "surfMesh.H" #include "OFstream.H" -#include "ListOps.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -65,7 +65,7 @@ void Foam::MeshedSurfaceProxy<Face>::write InfoInFunction << "Writing to " << name << endl; } - word ext = name.ext(); + const word ext = name.ext(); typename writefileExtensionMemberFunctionTable::iterator mfIter = writefileExtensionMemberFunctionTablePtr_->find(ext); @@ -74,8 +74,8 @@ void Foam::MeshedSurfaceProxy<Face>::write { FatalErrorInFunction << "Unknown file extension " << ext << nl << nl - << "Valid types are :" << endl - << writeTypes() + << "Valid types:" << nl + << flatOutput(writeTypes().sortedToc()) << nl << exit(FatalError); } @@ -91,7 +91,7 @@ void Foam::MeshedSurfaceProxy<Face>::write ) const { // the surface name to be used - word name(surfName.size() ? surfName : surfaceRegistry::defaultName); + const word name(surfName.size() ? surfName : surfaceRegistry::defaultName); if (debug) { diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C index e3975c6b8b1be8cbb20b5d36af6413a1591b53ce..42a7d1d9fe1ecc8e4d36466c10f430d536cf7862 100644 --- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C +++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurface.C @@ -3,7 +3,7 @@ \\ / 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. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,7 @@ License #include "IFstream.H" #include "OFstream.H" #include "Time.H" +#include "ListOps.H" #include "polyBoundaryMesh.H" #include "polyMesh.H" @@ -117,10 +118,10 @@ void Foam::UnsortedMeshedSurface<Face>::write if (mfIter == writefileExtensionMemberFunctionTablePtr_->end()) { - // no direct writer, delegate to proxy if possible - wordHashSet supported = ProxyType::writeTypes(); + // No direct writer, delegate to proxy if possible + const wordHashSet& delegate = ProxyType::writeTypes(); - if (supported.found(ext)) + if (delegate.found(ext)) { MeshedSurfaceProxy<Face>(surf).write(name); } @@ -128,8 +129,8 @@ void Foam::UnsortedMeshedSurface<Face>::write { FatalErrorInFunction << "Unknown file extension " << ext << nl << nl - << "Valid types are :" << endl - << (supported | writeTypes()) + << "Valid types:" << nl + << flatOutput((delegate | writeTypes()).sortedToc()) << nl << exit(FatalError); } } diff --git a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceNew.C b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceNew.C index e61df5c6fc06cbd1f3598e78049488109263d4d0..f6f1431a8353b3eb01814acf26034b6bae87eeb1 100644 --- a/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceNew.C +++ b/src/surfMesh/UnsortedMeshedSurface/UnsortedMeshedSurfaceNew.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "UnsortedMeshedSurface.H" +#include "ListOps.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -41,11 +42,12 @@ Foam::UnsortedMeshedSurface<Face>::New(const fileName& name, const word& ext) if (cstrIter == fileExtensionConstructorTablePtr_->end()) { - // no direct reader, use the parent if possible - wordHashSet supported = ParentType::readTypes(); - if (supported.found(ext)) + // No direct reader, delegate to parent if possible + const wordHashSet& delegate = ParentType::readTypes(); + + if (delegate.found(ext)) { - // create indirectly + // Create indirectly autoPtr<UnsortedMeshedSurface<Face>> surf ( new UnsortedMeshedSurface<Face> @@ -54,15 +56,14 @@ Foam::UnsortedMeshedSurface<Face>::New(const fileName& name, const word& ext) return surf; } - - // nothing left but to issue an error - supported += readTypes(); - - FatalErrorInFunction - << "Unknown file extension " << ext << nl << nl - << "Valid types are:" << nl - << supported - << exit(FatalError); + else + { + FatalErrorInFunction + << "Unknown file extension " << ext << nl << nl + << "Valid types:" << nl + << flatOutput((delegate | readTypes()).sortedToc()) << nl + << exit(FatalError); + } } return autoPtr<UnsortedMeshedSurface<Face>>(cstrIter()(name)); diff --git a/src/surfMesh/surfaceFormats/surfaceFormatsCore.C b/src/surfMesh/surfaceFormats/surfaceFormatsCore.C index c098eaf1b9114eb7df187633c0f77ca130010dc5..cff6e37d141821e0f07c6e1a7c18d106ce34e265 100644 --- a/src/surfMesh/surfaceFormats/surfaceFormatsCore.C +++ b/src/surfMesh/surfaceFormats/surfaceFormatsCore.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,9 +26,9 @@ License #include "surfaceFormatsCore.H" #include "Time.H" +#include "ListOps.H" #include "IFstream.H" #include "OFstream.H" -#include "SortableList.H" #include "surfMesh.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -167,18 +167,9 @@ bool Foam::fileFormats::surfaceFormatsCore::checkSupport } else if (verbose) { - wordList toc = available.toc(); - SortableList<word> known(toc.xfer()); - Info<<"Unknown file extension for " << functionName << " : " << ext << nl - <<"Valid types: ("; - // compact output: - forAll(known, i) - { - Info<<" " << known[i]; - } - Info<<" )" << endl; + << "Valid types: " << flatOutput(available.sortedToc()) << endl; } return false; diff --git a/src/surfMesh/surfaceFormats/surfaceFormatsCore.H b/src/surfMesh/surfaceFormats/surfaceFormatsCore.H index 73ccc8eff3b14de66634ba17fdd28a2c035a79ba..fe35c5b4b053d8d1bc00449b6a9dfd7fe7a6e8af 100644 --- a/src/surfMesh/surfaceFormats/surfaceFormatsCore.H +++ b/src/surfMesh/surfaceFormats/surfaceFormatsCore.H @@ -62,8 +62,8 @@ class surfaceFormatsCore { protected: - //- Return a list with a single entry, - // the size corresponds to that of the container + //- Return a surfZone list with a single entry, the size of which + // corresponds to that of the container template<class Container> static List<surfZone> oneZone ( @@ -89,6 +89,7 @@ public: // Static Member Functions + //- Helper function when checking if a file extension is supported. static bool checkSupport ( const wordHashSet& available,