diff --git a/applications/test/NamedEnum/Make/files b/applications/test/NamedEnum/Make/files index 755b72ba5e..a1a7086041 100644 --- a/applications/test/NamedEnum/Make/files +++ b/applications/test/NamedEnum/Make/files @@ -1,3 +1,3 @@ -Test-namedEnum.C +Test-NamedEnum.C EXE = $(FOAM_USER_APPBIN)/Test-NamedEnum diff --git a/applications/test/NamedEnum/Test-namedEnum.C b/applications/test/NamedEnum/Test-NamedEnum.C similarity index 52% rename from applications/test/NamedEnum/Test-namedEnum.C rename to applications/test/NamedEnum/Test-NamedEnum.C index 22f3596932..63386ed79e 100644 --- a/applications/test/NamedEnum/Test-namedEnum.C +++ b/applications/test/NamedEnum/Test-NamedEnum.C @@ -34,26 +34,28 @@ class namedEnumTest { public: - enum options + enum option { a, b, - c + c, + d }; - static const Foam::NamedEnum namedEnum; + static const Foam::NamedEnum namedEnum; }; template<> -const char* Foam::NamedEnum::names[] = +const char* Foam::NamedEnum::names[] = { "a", "b", - "c" + "c", + "d" }; -const Foam::NamedEnum namedEnumTest::namedEnum; +const Foam::NamedEnum namedEnumTest::namedEnum; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,11 +63,47 @@ const Foam::NamedEnum namedEnumTest::namedEnum; int main(int argc, char *argv[]) { - Info<< namedEnumTest::namedEnum["a"] << endl; - Info<< namedEnumTest::namedEnum[namedEnumTest::a] << endl; + const List options + = namedEnumTest::namedEnum.enums(); - namedEnumTest::options hmm(namedEnumTest::namedEnum.read(Sin)); - Info<< namedEnumTest::namedEnum[hmm] << endl; + Info<< "enums: " << options << nl; + + Info<< "loop over enums (as list):" << nl; + forAll(options, i) + { + const namedEnumTest::option& opt = options[i]; + + Info<< "option[" << opt + << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; + } + +#if __cplusplus > 201100L + // C++11 + Info<< "loop over enums (C++11 for range):" << nl; + for (auto const& opt : options) + { + Info<< "option[" << opt + << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; + } +#else + Info<< "loop over enums (via iterator):" << nl; + forAllConstIter(List, options, iter) + { + const namedEnumTest::option& opt = *iter; + + Info<< "option[" << opt + << "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl; + } +#endif + + Info<< nl + << namedEnumTest::namedEnum["a"] << nl + << namedEnumTest::namedEnum[namedEnumTest::a] << nl; + + Info<< "--- test read construction ---" << endl; + + namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin)); + Info<< namedEnumTest::namedEnum[dummy] << endl; Info<< "End\n" << endl; diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index bbe1c8c7c2..e1aca6c42d 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -30,6 +30,26 @@ Group Description Checks geometric and topological quality of a surface. +Usage + - surfaceCheck surfaceFile [OPTION] + + \param -checkSelfIntersection \n + Check for self-intersection. + + \param -splitNonManifold \n + Split surface along non-manifold edges. + + \param -verbose \n + Extra verbosity. + + \param -blockMesh \n + Write vertices/blocks for tight-fitting 1 cell blockMeshDict. + + \param -outputThreshold \ \n + Specifies upper limit for the number of files written. This is useful to + prevent surfaces with lots of disconnected parts to write lots of files. + Default is 10. A special case is 0 which prevents writing any files. + \*---------------------------------------------------------------------------*/ #include "triangle.H" @@ -356,6 +376,8 @@ int main(int argc, char *argv[]) const bool checkSelfIntersect = args.optionFound("checkSelfIntersection"); const bool verbose = args.optionFound("verbose"); const bool splitNonManifold = args.optionFound("splitNonManifold"); + label outputThreshold = 10; + args.optionReadIfPresent("outputThreshold", outputThreshold); Info<< "Reading surface from " << surfFileName << " ..." << nl << endl; @@ -465,10 +487,14 @@ int main(int argc, char *argv[]) Info<< "Surface has " << illegalFaces.size() << " illegal triangles." << endl; - OFstream str("illegalFaces"); - Info<< "Dumping conflicting face labels to " << str.name() << endl - << "Paste this into the input for surfaceSubset" << endl; - str << illegalFaces; + if (outputThreshold > 0) + { + OFstream str("illegalFaces"); + Info<< "Dumping conflicting face labels to " << str.name() + << endl + << "Paste this into the input for surfaceSubset" << endl; + str << illegalFaces; + } } else { @@ -543,6 +569,7 @@ int main(int argc, char *argv[]) } // Dump for subsetting + if (outputThreshold > 0) { DynamicList