From 7ac55ac74ac2433416e00e966d9eb70f5d67d9c4 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 3 Jul 2017 13:24:08 +0200 Subject: [PATCH 01/20] ENH: consolidate arch and version strings (issue #513) - make some IOobject writing routines non-templated. - relocate more IOobject methods into the IOobjectI.H (generally cleanup the main header). --- .../graphics/ensightFoamReader/libuserd.C | 1 + src/OpenFOAM/db/IOobject/IOobject.C | 14 +- src/OpenFOAM/db/IOobject/IOobject.H | 286 ++++++++---------- src/OpenFOAM/db/IOobject/IOobjectI.H | 192 +++++++----- src/OpenFOAM/db/IOobject/IOobjectTemplates.C | 5 +- .../db/IOobject/IOobjectWriteHeader.C | 104 +++++-- src/OpenFOAM/global/argList/argList.C | 30 +- src/OpenFOAM/global/foamVersion.H | 14 +- src/OpenFOAM/global/global.Cver | 20 ++ 9 files changed, 369 insertions(+), 297 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C b/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C index 88bf926c42..4df3379e3c 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C @@ -45,6 +45,7 @@ Description #include "fvMesh.H" #include "cellModeller.H" #include "globalFoam.H" +#include "foamVersion.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index 5953185baa..f61465bcb3 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -351,6 +351,12 @@ const Foam::Time& Foam::IOobject::time() const } +const Foam::fileName& Foam::IOobject::rootPath() const +{ + return time().rootPath(); +} + + const Foam::fileName& Foam::IOobject::caseName() const { return time().caseName(); @@ -387,12 +393,6 @@ Foam::word Foam::IOobject::member() const } -const Foam::fileName& Foam::IOobject::rootPath() const -{ - return time().rootPath(); -} - - Foam::fileName Foam::IOobject::path() const { if (instance().isAbsolute()) @@ -617,6 +617,8 @@ void Foam::IOobject::setBad(const string& s) } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + void Foam::IOobject::operator=(const IOobject& io) { name_ = io.name_; diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index b08b3bb661..a0502fb1df 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -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. @@ -191,6 +191,12 @@ public: TypeName("IOobject"); + // Static data members + + //- Type of file modification checking + static fileCheckTypes fileModificationChecking; + + // Static Member Functions //- Split path into instance, local, name components @@ -202,11 +208,9 @@ public: word& name ); - template - static inline word groupName(Name name, const word& group); - - //- Type of file modification checking - static fileCheckTypes fileModificationChecking; + //- Create dot-delimited name.group + template + static inline word groupName(StringType name, const word& group); // Constructors @@ -280,214 +284,162 @@ public: // Member Functions - // General access + // General access - //- Return time - const Time& time() const; + //- Return the local objectRegistry + const objectRegistry& db() const; - //- Return the local objectRegistry - const objectRegistry& db() const; + //- Return time + const Time& time() const; - //- Return name - const word& name() const - { - return name_; - } + //- Return name + inline const word& name() const; - //- Return name of the class name read from header - const word& headerClassName() const - { - return headerClassName_; - } + //- Return name of the class name read from header + inline const word& headerClassName() const; - //- Return non-constant access to the optional note - string& note() - { - return note_; - } + //- Return the optional note + inline const string& note() const; - //- Return the optional note - const string& note() const - { - return note_; - } + //- Return non-constant access to the optional note + inline string& note(); - //- Rename - virtual void rename(const word& newName) - { - name_ = newName; - } + //- Rename + virtual void rename(const word& newName) + { + name_ = newName; + } - //- Register object created from this IOobject with registry if true - bool& registerObject() - { - return registerObject_; - } + //- Register object created from this IOobject with registry if true + inline bool registerObject() const; - //- Register object created from this IOobject with registry if true - bool registerObject() const - { - return registerObject_; - } + //- Register object created from this IOobject with registry if true + inline bool& registerObject(); - //- Is object same for all processors - bool& globalObject() - { - return globalObject_; - } + //- Is object same for all processors + inline bool globalObject() const; - //- Is object same for all processors - bool globalObject() const - { - return globalObject_; - } + //- Is object same for all processors + inline bool& globalObject(); - // Read/write options + // Read/write options - readOption readOpt() const - { - return rOpt_; - } + //- The read option + inline readOption readOpt() const; - readOption& readOpt() - { - return rOpt_; - } + //- Non-constant access to the read option + inline readOption& readOpt(); - writeOption writeOpt() const - { - return wOpt_; - } + //- The write option + inline writeOption writeOpt() const; - writeOption& writeOpt() - { - return wOpt_; - } + //- Non-constant access to the write option + inline writeOption& writeOpt(); - // Path components + // Path components - //- Return group (extension part of name) - word group() const; + //- Return group (extension part of name) + word group() const; - //- Return member (name without the extension) - word member() const; + //- Return member (name without the extension) + word member() const; - const fileName& rootPath() const; + const fileName& rootPath() const; - const fileName& caseName() const; + const fileName& caseName() const; - const fileName& instance() const - { - return instance_; - } + inline const fileName& instance() const; - fileName& instance() - { - return instance_; - } + inline fileName& instance(); - const fileName& local() const - { - return local_; - } + inline const fileName& local() const; - //- Return complete path - fileName path() const; + //- Return complete path + fileName path() const; - //- Return complete path with alternative instance and local - fileName path - ( - const word& instance, - const fileName& local = fileName::null - ) const; + //- Return complete path with alternative instance and local + fileName path + ( + const word& instance, + const fileName& local = fileName::null + ) const; - //- Return complete path + object name - fileName objectPath() const - { - return path()/name(); - } + //- Return complete path + object name + inline fileName objectPath() const; - //- Helper for filePath that searches locally. - // When search is false, simply use the current instance, - // otherwise search previous instances. - fileName localFilePath(const bool search=true) const; + //- Helper for filePath that searches locally. + // When search is false, simply use the current instance, + // otherwise search previous instances. + fileName localFilePath(const bool search=true) const; - //- Helper for filePath that searches up if in parallel - // When search is false, simply use the current instance, - // otherwise search previous instances. - fileName globalFilePath(const bool search=true) const; + //- Helper for filePath that searches up if in parallel + // When search is false, simply use the current instance, + // otherwise search previous instances. + fileName globalFilePath(const bool search=true) const; - // Reading + // Reading - //- Read header - bool readHeader(Istream&); + //- Read header + bool readHeader(Istream& is); - //- Read header (uses typeFilePath to find file) and check its info. - // Optionally checks headerClassName against the type-name. - // When search is false, simply use the current instance, - // otherwise search previous instances. - template - bool typeHeaderOk - ( - const bool checkType = true, - const bool search = true - ); + //- Read header (uses typeFilePath to find file) and check its info. + // Optionally checks headerClassName against the type-name. + // When search is false, simply use the current instance, + // otherwise search previous instances. + template + bool typeHeaderOk + ( + const bool checkType = true, + const bool search = true + ); - //- Helper: warn that type does not support re-reading - template - void warnNoRereading() const; - - // Writing - - //- Write the standard OpenFOAM file/dictionary banner - // Optionally without -*- C++ -*- editor hint (eg, for logs) - template - static inline Stream& writeBanner(Stream& os, bool noHint=false); - - //- Write the standard file section divider - template - static inline Stream& writeDivider(Stream& os); - - //- Write the standard end file divider - template - static inline Stream& writeEndDivider(Stream& os); - - //- Write header - bool writeHeader(Ostream&) const; - - //- Write header. Allow override of type - bool writeHeader(Ostream&, const word& objectType) const; + //- Helper: warn that type does not support re-reading + template + void warnNoRereading() const; - // Error Handling + // Writing - bool good() const - { - return objState_ == GOOD; - } + //- Write the standard OpenFOAM file/dictionary banner + // Optionally without -*- C++ -*- editor hint (eg, for logs) + static Ostream& writeBanner(Ostream& os, bool noHint=false); - bool bad() const - { - return objState_ == BAD; - } + //- Write the standard file section divider + static Ostream& writeDivider(Ostream& os); + + //- Write the standard end file divider + static Ostream& writeEndDivider(Ostream& os); + + //- Write header + bool writeHeader(Ostream& os) const; + + //- Write header. Allow override of type + bool writeHeader(Ostream& os, const word& objectType) const; - // Info + // Error Handling - //- Return info proxy. - // Used to print token information to a stream - InfoProxy info() const - { - return *this; - } + inline bool good() const; + + inline bool bad() const; + + + // Info + + //- Return info proxy. + // Used to print token information to a stream + InfoProxy info() const + { + return *this; + } // Member operators - void operator=(const IOobject&); + void operator=(const IOobject& io); }; diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index be0a0760a2..adce4e7fdc 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,95 +23,137 @@ License \*---------------------------------------------------------------------------*/ -#include "foamVersion.H" +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -inline Foam::word Foam::IOobject::groupName(Name name, const word& group) +template +inline Foam::word Foam::IOobject::groupName(StringType name, const word& group) { - if (group != word::null) - { - return name + ('.' + group); - } - else + if (group.empty()) { return name; } -} - - -template -inline Stream& Foam::IOobject::writeBanner(Stream& os, bool noHint) -{ - static bool spacesSet(false); - static char spaces[40]; - - if (!spacesSet) - { - memset(spaces, ' ', 40); - - size_t len = strlen(Foam::FOAMversion); - if (len < 38) - { - spaces[38 - len] = '\0'; - } - else - { - spaces[0] = '\0'; - } - spacesSet = true; - } - - if (noHint) - { - os << - "/*--------------------------------------" - "-------------------------------------*\\\n"; - } else { - os << - "/*--------------------------------*- C++ " - "-*----------------------------------*\\\n"; + return name + ('.' + group); } - - os << - "| ========= |" - " |\n" - "| \\\\ / F ield |" - " OpenFOAM: The Open Source CFD Toolbox |\n" - "| \\\\ / O peration |" - " Version: " << FOAMversion << spaces << "|\n" - "| \\\\ / A nd |" - " Web: www.OpenFOAM.com |\n" - "| \\\\/ M anipulation |" - " |\n" - "\\*-----------------------------------------" - "----------------------------------*/\n"; - - return os; } -template -inline Stream& Foam::IOobject::writeDivider(Stream& os) -{ - os << - "// * * * * * * * * * * * * * * * * * " - "* * * * * * * * * * * * * * * * * * * * //\n"; +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - return os; +// General access + +inline const Foam::word& Foam::IOobject::name() const +{ + return name_; } -template -inline Stream& Foam::IOobject::writeEndDivider(Stream& os) -{ - os << "\n\n" - "// *****************************************" - "******************************** //\n"; - return os; +inline const Foam::word& Foam::IOobject::headerClassName() const +{ + return headerClassName_; +} + + +inline const Foam::string& Foam::IOobject::note() const +{ + return note_; +} + + +inline Foam::string& Foam::IOobject::note() +{ + return note_; +} + + +inline bool Foam::IOobject::registerObject() const +{ + return registerObject_; +} + + +inline bool& Foam::IOobject::registerObject() +{ + return registerObject_; +} + + +inline bool Foam::IOobject::globalObject() const +{ + return globalObject_; +} + + +inline bool& Foam::IOobject::globalObject() +{ + return globalObject_; +} + + +// Read/write options + +inline Foam::IOobject::readOption Foam::IOobject::readOpt() const +{ + return rOpt_; +} + + +inline Foam::IOobject::readOption& Foam::IOobject::readOpt() +{ + return rOpt_; +} + + +inline Foam::IOobject::writeOption Foam::IOobject::writeOpt() const +{ + return wOpt_; +} + + +inline Foam::IOobject::writeOption& Foam::IOobject::writeOpt() +{ + return wOpt_; +} + + +// Path components + +inline const Foam::fileName& Foam::IOobject::instance() const +{ + return instance_; +} + + +inline Foam::fileName& Foam::IOobject::instance() +{ + return instance_; +} + + +inline const Foam::fileName& Foam::IOobject::local() const +{ + return local_; +} + + +inline Foam::fileName Foam::IOobject::objectPath() const +{ + return path()/name(); +} + + +// Error Handling + +inline bool Foam::IOobject::good() const +{ + return objState_ == GOOD; +} + + +inline bool Foam::IOobject::bad() const +{ + return objState_ == BAD; } diff --git a/src/OpenFOAM/db/IOobject/IOobjectTemplates.C b/src/OpenFOAM/db/IOobject/IOobjectTemplates.C index f93384bf8c..58757394db 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectTemplates.C +++ b/src/OpenFOAM/db/IOobject/IOobjectTemplates.C @@ -116,9 +116,8 @@ void Foam::IOobject::warnNoRereading() const { WarningInFunction << Type::typeName << ' ' << name() - << " constructed with IOobject::MUST_READ_IF_MODIFIED" - " but " << Type::typeName - << " does not support automatic rereading." + << " constructed with IOobject::MUST_READ_IF_MODIFIED but " + << Type::typeName << " does not support automatic rereading." << endl; } } diff --git a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C index 51d6f7d853..4e01787843 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.C +++ b/src/OpenFOAM/db/IOobject/IOobjectWriteHeader.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,29 +29,91 @@ Description #include "IOobject.H" #include "objectRegistry.H" -#include "endian.H" -#include "label.H" -#include "scalar.H" +#include "foamVersion.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// file-scope -// Hint about machine endian, OpenFOAM label and scalar sizes -static const std::string archHint = -( -#ifdef WM_LITTLE_ENDIAN - "LSB" -#elif defined (WM_BIG_ENDIAN) - "MSB" -#else - "???" -#endif - ";label=" + std::to_string(8*sizeof(Foam::label)) - + ";scalar=" + std::to_string(8*sizeof(Foam::scalar)) -); +// A banner corresponding to this: +// +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: VERSION | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +Foam::Ostream& Foam::IOobject::writeBanner(Ostream& os, bool noHint) +{ + // The version padded with spaces to fit after "Version: " + // - initialized with zero-length string to detect if it has been populated + static char paddedVersion[39] = ""; + + if (!*paddedVersion) + { + // Populate: like strncpy but without trailing '\0' + const char *p = Foam::FOAMversion; + + memset(paddedVersion, ' ', 38); + for (int i = 0; *p && i < 38; ++i) + { + paddedVersion[i] = *p++; + } + paddedVersion[38] = '\0'; + } + + os << + "/*--------------------------------"; + + if (noHint) + { + // Without syntax hint + os << "---------"; + } + else + { + // With syntax hint + os << "*- C++ -*"; + } + + os << + "----------------------------------*\\\n" + "| ========= |" + " |\n" + "| \\\\ / F ield |" + " OpenFOAM: The Open Source CFD Toolbox |\n" + "| \\\\ / O peration |" + " Version: " << paddedVersion << "|\n" + "| \\\\ / A nd |" + " Web: www.OpenFOAM.com |\n" + "| \\\\/ M anipulation |" + " |\n" + "\\*-----------------------------------------" + "----------------------------------*/\n"; + + return os; +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +Foam::Ostream& Foam::IOobject::writeDivider(Ostream& os) +{ + os << + "// * * * * * * * * * * * * * * * * * " + "* * * * * * * * * * * * * * * * * * * * //\n"; + + return os; +} + + +Foam::Ostream& Foam::IOobject::writeEndDivider(Ostream& os) +{ + os << "\n\n" + "// *****************************************" + "******************************** //\n"; + + return os; +} + bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const { @@ -72,7 +134,7 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const if (os.format() == IOstream::BINARY) { - os << " arch " << archHint << ";\n"; + os << " arch " << Foam::FOAMbuildArch << ";\n"; } if (!note().empty()) diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index e111b33067..42d497c770 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -37,7 +37,7 @@ License #include "sigInt.H" #include "sigQuit.H" #include "sigSegv.H" -#include "endian.H" +#include "foamVersion.H" #include @@ -54,22 +54,6 @@ Foam::string::size_type Foam::argList::usageMin = 20; Foam::string::size_type Foam::argList::usageMax = 80; Foam::word Foam::argList::postProcessOptionName("postProcess"); -// file-scope -// Hint about machine endian, OpenFOAM label and scalar sizes -static const std::string archHint = -( -#ifdef WM_LITTLE_ENDIAN - "LSB" -#elif defined (WM_BIG_ENDIAN) - "MSB" -#else - "???" -#endif - ";label=" + std::to_string(8*sizeof(Foam::label)) - + ";scalar=" + std::to_string(8*sizeof(Foam::scalar)) -); - - Foam::argList::initValidTables::initValidTables() { argList::addOption @@ -639,7 +623,7 @@ void Foam::argList::parse { IOobject::writeBanner(Info, true) << "Build : " << Foam::FOAMbuild << nl - << "Arch : " << archHint << nl + << "Arch : " << Foam::FOAMbuildArch << nl << "Exec : " << argListStr_.c_str() << nl << "Date : " << dateString.c_str() << nl << "Time : " << timeString.c_str() << nl @@ -650,7 +634,7 @@ void Foam::argList::parse jobInfo.add("startDate", dateString); jobInfo.add("startTime", timeString); jobInfo.add("userName", userName()); - jobInfo.add("foamVersion", word(FOAMversion)); + jobInfo.add("foamVersion", word(Foam::FOAMversion)); jobInfo.add("code", executable_); jobInfo.add("argList", argListStr_); jobInfo.add("currentDir", cwd()); @@ -660,10 +644,10 @@ void Foam::argList::parse // Add build information - only use the first word { std::string build(Foam::FOAMbuild); - std::string::size_type found = build.find(' '); - if (found != std::string::npos) + std::string::size_type space = build.find(' '); + if (space != std::string::npos) { - build.resize(found); + build.resize(space); } jobInfo.add("foamBuild", build); } @@ -1247,7 +1231,7 @@ void Foam::argList::printUsage() const <<"Using: OpenFOAM-" << Foam::FOAMversion << " (see www.OpenFOAM.com)" << nl << "Build: " << Foam::FOAMbuild << nl - << "Arch: " << archHint << nl + << "Arch: " << Foam::FOAMbuildArch << nl << endl; } diff --git a/src/OpenFOAM/global/foamVersion.H b/src/OpenFOAM/global/foamVersion.H index bd3386e786..3b5d9fcb46 100644 --- a/src/OpenFOAM/global/foamVersion.H +++ b/src/OpenFOAM/global/foamVersion.H @@ -32,13 +32,20 @@ Global Foam::FOAMversion Description - OpenFOAM version number static string. + OpenFOAM version number as a static string. Global Foam::FOAMbuild Description - OpenFOAM version number static string with build information + OpenFOAM build information as a static string + +Global + Foam::FOAMbuildArch + +Description + OpenFOAM build architecture information (endian, label/scalar sizes) + as a static string SourceFiles global.Cver @@ -48,6 +55,8 @@ SourceFiles #ifndef foamVersion_H #define foamVersion_H +#include + // The directory name for user-resources (located in the HOME directory) #define WM_USER_RESOURCE_DIRNAME ".OpenFOAM" @@ -57,6 +66,7 @@ namespace Foam { extern const char* const FOAMversion; extern const char* const FOAMbuild; + extern const std::string FOAMbuildArch; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/global.Cver b/src/OpenFOAM/global/global.Cver index a868495556..0c9f3fdf31 100644 --- a/src/OpenFOAM/global/global.Cver +++ b/src/OpenFOAM/global/global.Cver @@ -33,10 +33,30 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "foamVersion.H" +#include "endian.H" +#include "label.H" +#include "scalar.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const char* const Foam::FOAMversion = "VERSION_STRING"; const char* const Foam::FOAMbuild = "BUILD_STRING"; +// Information about machine endian, label and scalar sizes +const std::string Foam::FOAMbuildArch = +( +#ifdef WM_LITTLE_ENDIAN + "LSB" +#elif defined (WM_BIG_ENDIAN) + "MSB" +#else + "???" +#endif + ";label=" + std::to_string(8*sizeof(Foam::label)) + + ";scalar=" + std::to_string(8*sizeof(Foam::scalar)) +); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Setup an error handler for the global new operator From 1d56e9f13686dfaa525366e050522d18bbd7b499 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 3 Jul 2017 13:33:53 +0200 Subject: [PATCH 02/20] STYLE: use auto with vtkSmartPointer --- .../fieldVisualisationBase.C | 26 +++++++------------ .../functionObjectCloud.C | 6 ++--- .../functionObjectLine.C | 6 ++--- .../functionObjectSurface.C | 9 +++---- .../runTimePostProcessing/geometrySurface.C | 17 +++++------- .../graphics/runTimePostProcessing/pathline.C | 3 +-- .../runTimePostProcessing.C | 5 ++-- .../graphics/runTimePostProcessing/scene.C | 15 +++++------ .../graphics/runTimePostProcessing/surface.C | 6 ++--- .../graphics/runTimePostProcessing/text.C | 2 +- 10 files changed, 34 insertions(+), 61 deletions(-) diff --git a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C index 1bd8614b68..3645ddbb0c 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C +++ b/src/functionObjects/graphics/runTimePostProcessing/fieldVisualisationBase.C @@ -100,8 +100,7 @@ void Foam::functionObjects::fieldVisualisationBase::setColourMap lut->SetNumberOfColors(nColours); - vtkSmartPointer ctf = - vtkSmartPointer::New(); + auto ctf = vtkSmartPointer::New(); switch (colourMap_) { @@ -163,8 +162,7 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar return; } - vtkSmartPointer sbar = - vtkSmartPointer::New(); + auto sbar = vtkSmartPointer::New(); sbar->SetLookupTable(lut); sbar->SetNumberOfLabels(scalarBar_.numberOfLabels_); @@ -174,8 +172,7 @@ void Foam::functionObjects::fieldVisualisationBase::addScalarBar // - Default scalar bar title text is scales by the scalar bar box // dimensions so if the title is a long string, the text is shrunk to fit // Instead, suppress title and set the title using a vtkTextActor - vtkSmartPointer titleActor = - vtkSmartPointer::New(); + auto titleActor = vtkSmartPointer::New(); sbar->SetTitle(" "); titleActor->SetInput(scalarBar_.title_.c_str()); titleActor->GetTextProperty()->SetFontFamilyToArial(); @@ -282,8 +279,7 @@ void Foam::functionObjects::fieldVisualisationBase::setField case cbField: { // Create look-up table for colours - vtkSmartPointer lut = - vtkSmartPointer::New(); + auto lut = vtkSmartPointer::New(); setColourMap(lut); lut->SetVectorMode(vtkScalarsToColors::MAGNITUDE); @@ -337,9 +333,8 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs vtkRenderer* renderer ) const { - vtkSmartPointer glyph = vtkSmartPointer::New(); - vtkSmartPointer glyphMapper = - vtkSmartPointer::New(); + auto glyph = vtkSmartPointer::New(); + auto glyphMapper = vtkSmartPointer::New(); glyphMapper->SetInputConnection(glyph->GetOutputPort()); glyph->SetInputData(data); @@ -358,8 +353,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs else if (data->GetCellData()->HasArray(scaleFieldNameChar) == 1) { // Need to convert cell data to point data - vtkSmartPointer cellToPoint = - vtkSmartPointer::New(); + auto cellToPoint = vtkSmartPointer::New(); cellToPoint->SetInputData(data); cellToPoint->Update(); vtkDataSet* pds = cellToPoint->GetOutput(); @@ -380,8 +374,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs if (nComponents == 1) { - vtkSmartPointer sphere = - vtkSmartPointer::New(); + auto sphere = vtkSmartPointer::New(); sphere->SetCenter(0, 0, 0); sphere->SetRadius(0.5); @@ -428,8 +421,7 @@ void Foam::functionObjects::fieldVisualisationBase::addGlyphs } else if (nComponents == 3) { - vtkSmartPointer arrow = - vtkSmartPointer::New(); + auto arrow = vtkSmartPointer::New(); arrow->SetTipResolution(10); arrow->SetTipRadius(0.1); arrow->SetTipLength(0.35); diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C index 357997df25..f4fe22be99 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectCloud.C @@ -120,13 +120,11 @@ addGeometryToScene if (fName.ext() == "vtk") { - vtkSmartPointer points = - vtkSmartPointer::New(); + auto points = vtkSmartPointer::New(); points->SetFileName(fName.c_str()); points->Update(); - vtkSmartPointer mapper = - vtkSmartPointer::New(); + auto mapper = vtkSmartPointer::New(); actor_->SetMapper(mapper); diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C index b1a9093f63..2d7fc46940 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectLine.C @@ -101,13 +101,11 @@ addGeometryToScene if (fName.ext() == "vtk") { - vtkSmartPointer lines = - vtkSmartPointer::New(); + auto lines = vtkSmartPointer::New(); lines->SetFileName(fName.c_str()); lines->Update(); - vtkSmartPointer mapper = - vtkSmartPointer::New(); + auto mapper = vtkSmartPointer::New(); setField(position, fieldName_, mapper, renderer, lines->GetOutput()); actor_->SetMapper(mapper); diff --git a/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C b/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C index 343985afa2..22b9c7570e 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C +++ b/src/functionObjects/graphics/runTimePostProcessing/functionObjectSurface.C @@ -101,8 +101,7 @@ addGeometryToScene if (representation_ == rtGlyph) { - vtkSmartPointer surf = - vtkSmartPointer::New(); + auto surf = vtkSmartPointer::New(); surf->SetFileName(fName.c_str()); surf->Update(); @@ -121,15 +120,13 @@ addGeometryToScene { if (fName.ext() == "vtk") { - vtkSmartPointer surf = - vtkSmartPointer::New(); + auto surf = vtkSmartPointer::New(); surf->SetFileName(fName.c_str()); surf->Update(); addFeatureEdges(renderer, surf->GetOutput()); - vtkSmartPointer mapper = - vtkSmartPointer::New(); + auto mapper = vtkSmartPointer::New(); mapper->SetInputConnection(surf->GetOutputPort()); setField(position, fieldName_, mapper, renderer, surf->GetOutput()); diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C b/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C index 19be822aa7..7c68893222 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C +++ b/src/functionObjects/graphics/runTimePostProcessing/geometrySurface.C @@ -79,11 +79,9 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene const Field& surfPoints = surf.points(); const Field& surfFaceNormals = surf.faceNormals(); - vtkSmartPointer points = vtkSmartPointer::New(); - vtkSmartPointer triangles = - vtkSmartPointer::New(); - vtkSmartPointer faceNormals = - vtkSmartPointer::New(); + auto points = vtkSmartPointer::New(); + auto triangles = vtkSmartPointer::New(); + auto faceNormals = vtkSmartPointer::New(); faceNormals->SetNumberOfComponents(3); @@ -97,8 +95,7 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene { const Foam::face& f = surf[i]; - vtkSmartPointer triangle = - vtkSmartPointer::New(); + auto triangle = vtkSmartPointer::New(); triangle->GetPointIds()->SetId(0, f[0]); triangle->GetPointIds()->SetId(1, f[1]); triangle->GetPointIds()->SetId(2, f[2]); @@ -114,14 +111,12 @@ void Foam::functionObjects::runTimePostPro::geometrySurface::addGeometryToScene surf.clearOut(); - vtkSmartPointer polyData = - vtkSmartPointer::New(); + auto polyData = vtkSmartPointer::New(); polyData->SetPoints(points); polyData->SetPolys(triangles); polyData->GetCellData()->SetNormals(faceNormals); - vtkSmartPointer mapper = - vtkSmartPointer::New(); + auto mapper = vtkSmartPointer::New(); mapper->ScalarVisibilityOff(); mapper->SetInputData(polyData); diff --git a/src/functionObjects/graphics/runTimePostProcessing/pathline.C b/src/functionObjects/graphics/runTimePostProcessing/pathline.C index aedd860827..36c1aa9a01 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/pathline.C +++ b/src/functionObjects/graphics/runTimePostProcessing/pathline.C @@ -104,8 +104,7 @@ void Foam::functionObjects::runTimePostPro::pathline::addLines } case rtTube: { - vtkSmartPointer tubes = - vtkSmartPointer::New(); + auto tubes = vtkSmartPointer::New(); tubes->SetInputData(data); tubes->SetRadius(tubeRadius_); tubes->SetNumberOfSides(20); diff --git a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C index fe97eba4b3..1a2e917101 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C +++ b/src/functionObjects/graphics/runTimePostProcessing/runTimePostProcessing.C @@ -150,8 +150,7 @@ bool Foam::functionObjects::runTimePostProcessing::write() sigFpe::unset(false); // Initialise render window - vtkSmartPointer renderWindow = - vtkSmartPointer::New(); + auto renderWindow = vtkSmartPointer::New(); renderWindow->OffScreenRenderingOn(); renderWindow->SetSize(output_.width_, output_.height_); renderWindow->SetAAFrames(10); @@ -159,7 +158,7 @@ bool Foam::functionObjects::runTimePostProcessing::write() renderWindow->SetMultiSamples(0); // renderWindow->PolygonSmoothingOn(); - vtkSmartPointer renderer = vtkSmartPointer::New(); + auto renderer = vtkSmartPointer::New(); scene_.initialise(renderer, output_.name_); renderWindow->AddRenderer(renderer); diff --git a/src/functionObjects/graphics/runTimePostProcessing/scene.C b/src/functionObjects/graphics/runTimePostProcessing/scene.C index cd74326a16..d984e9f03b 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/scene.C +++ b/src/functionObjects/graphics/runTimePostProcessing/scene.C @@ -186,20 +186,19 @@ void Foam::functionObjects::runTimePostPro::scene::initialise renderer->SetOcclusionRatio(0); // Set the camera - vtkSmartPointer camera = vtkSmartPointer::New(); + auto camera = vtkSmartPointer::New(); camera->SetParallelProjection(parallelProjection_); renderer->SetActiveCamera(camera); // Add the lights - vtkSmartPointer lightKit = vtkSmartPointer::New(); + auto lightKit = vtkSmartPointer::New(); lightKit->AddLightsToRenderer(renderer); if (!clipBox_.empty()) { const point& min = clipBox_.min(); const point& max = clipBox_.max(); - vtkSmartPointer clipBox = - vtkSmartPointer::New(); + auto clipBox = vtkSmartPointer::New(); clipBox->SetXLength(max.x() - min.x()); clipBox->SetYLength(max.y() - min.y()); clipBox->SetZLength(max.z() - min.z()); @@ -209,8 +208,7 @@ void Foam::functionObjects::runTimePostPro::scene::initialise min.y() + 0.5*(max.y() - min.y()), min.z() + 0.5*(max.z() - min.z()) ); - vtkSmartPointer clipMapper = - vtkSmartPointer::New(); + auto clipMapper = vtkSmartPointer::New(); clipMapper->SetInputConnection(clipBox->GetOutputPort()); clipBoxActor_ = vtkSmartPointer::New(); @@ -401,8 +399,7 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage renderWindow->Render(); // Set up off-screen rendering - vtkSmartPointer windowToImageFilter = - vtkSmartPointer::New(); + auto windowToImageFilter = vtkSmartPointer::New(); windowToImageFilter->SetInput(renderWindow); @@ -414,7 +411,7 @@ void Foam::functionObjects::runTimePostPro::scene::saveImage windowToImageFilter->Update(); // Save the image - vtkSmartPointer writer = vtkSmartPointer::New(); + auto writer = vtkSmartPointer::New(); fileName fName(prefix/outputName_ + '.' + frameIndexStr() + ".png"); writer->SetFileName(fName.c_str()); writer->SetInputConnection(windowToImageFilter->GetOutputPort()); diff --git a/src/functionObjects/graphics/runTimePostProcessing/surface.C b/src/functionObjects/graphics/runTimePostProcessing/surface.C index 5c0383c4ab..222760c456 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/surface.C +++ b/src/functionObjects/graphics/runTimePostProcessing/surface.C @@ -120,8 +120,7 @@ void Foam::functionObjects::runTimePostPro::surface::addFeatureEdges return; } - vtkSmartPointer featureEdges = - vtkSmartPointer::New(); + auto featureEdges = vtkSmartPointer::New(); featureEdges->SetInputData(data); featureEdges->BoundaryEdgesOn(); featureEdges->FeatureEdgesOn(); @@ -131,8 +130,7 @@ void Foam::functionObjects::runTimePostPro::surface::addFeatureEdges featureEdges->ColoringOff(); featureEdges->Update(); - vtkSmartPointer mapper = - vtkSmartPointer::New(); + auto mapper = vtkSmartPointer::New(); mapper->SetInputConnection(featureEdges->GetOutputPort()); mapper->ScalarVisibilityOff(); diff --git a/src/functionObjects/graphics/runTimePostProcessing/text.C b/src/functionObjects/graphics/runTimePostProcessing/text.C index fc395f5717..f83d31118f 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/text.C +++ b/src/functionObjects/graphics/runTimePostProcessing/text.C @@ -81,7 +81,7 @@ void Foam::functionObjects::runTimePostPro::text::addGeometryToScene return; } - vtkSmartPointer actor = vtkSmartPointer::New(); + auto actor = vtkSmartPointer::New(); // Concatenate string with timeStamp if true string textAndTime = string_; From aefb7395840a672fe1b48210ea21e7378fc74619 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 3 Jul 2017 12:15:41 +0200 Subject: [PATCH 03/20] STYLE: fix permissions on files, remove unused files --- .../multiphaseSystem/multiphaseSystem.H | 4 --- .../multiphaseSystem/multiphaseSystemI.H | 28 ------------------- .../preProcessing/setAlphaField/Make/files | 0 .../preProcessing/setAlphaField/Make/options | 0 .../constant/panelRegion/radiationProperties | 0 .../panelRegion/thermophysicalProperties | 0 .../compartmentFire/system/blockMeshDict.m4 | 0 .../system/panelRegion/decomposeParDict | 0 .../system/panelRegion/fvSchemes | 0 .../system/panelRegion/fvSolution | 0 .../rhoPimpleFoam/laminar/sineWaveDamping/0/p | 0 .../sphereDrop/0.orig/pointDisplacement | 0 12 files changed, 32 deletions(-) delete mode 100644 applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystemI.H mode change 100755 => 100644 applications/utilities/preProcessing/setAlphaField/Make/files mode change 100755 => 100644 applications/utilities/preProcessing/setAlphaField/Make/options mode change 100755 => 100644 tutorials/combustion/fireFoam/LES/compartmentFire/constant/panelRegion/radiationProperties mode change 100755 => 100644 tutorials/combustion/fireFoam/LES/compartmentFire/constant/panelRegion/thermophysicalProperties mode change 100755 => 100644 tutorials/combustion/fireFoam/LES/compartmentFire/system/blockMeshDict.m4 mode change 100755 => 100644 tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/decomposeParDict mode change 100755 => 100644 tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/fvSchemes mode change 100755 => 100644 tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/fvSolution mode change 100755 => 100644 tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/p mode change 100755 => 100644 tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/0.orig/pointDisplacement diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H index dca55bf873..57a5afcb41 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H +++ b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.H @@ -207,10 +207,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "multiphaseSystemI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystemI.H b/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystemI.H deleted file mode 100644 index b4ea367451..0000000000 --- a/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystemI.H +++ /dev/null @@ -1,28 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation - \\/ 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 3 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, see . - -\*---------------------------------------------------------------------------*/ - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -// ************************************************************************* // diff --git a/applications/utilities/preProcessing/setAlphaField/Make/files b/applications/utilities/preProcessing/setAlphaField/Make/files old mode 100755 new mode 100644 diff --git a/applications/utilities/preProcessing/setAlphaField/Make/options b/applications/utilities/preProcessing/setAlphaField/Make/options old mode 100755 new mode 100644 diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/constant/panelRegion/radiationProperties b/tutorials/combustion/fireFoam/LES/compartmentFire/constant/panelRegion/radiationProperties old mode 100755 new mode 100644 diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/constant/panelRegion/thermophysicalProperties b/tutorials/combustion/fireFoam/LES/compartmentFire/constant/panelRegion/thermophysicalProperties old mode 100755 new mode 100644 diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/system/blockMeshDict.m4 b/tutorials/combustion/fireFoam/LES/compartmentFire/system/blockMeshDict.m4 old mode 100755 new mode 100644 diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/decomposeParDict b/tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/decomposeParDict old mode 100755 new mode 100644 diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/fvSchemes b/tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/fvSchemes old mode 100755 new mode 100644 diff --git a/tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/fvSolution b/tutorials/combustion/fireFoam/LES/compartmentFire/system/panelRegion/fvSolution old mode 100755 new mode 100644 diff --git a/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/p b/tutorials/compressible/rhoPimpleFoam/laminar/sineWaveDamping/0/p old mode 100755 new mode 100644 diff --git a/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/0.orig/pointDisplacement b/tutorials/multiphase/compressibleInterDyMFoam/laminar/sphereDrop/0.orig/pointDisplacement old mode 100755 new mode 100644 From efc21270eaf7047f40e5b840aa8b942be5c097b6 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 5 Jul 2017 09:15:52 +0200 Subject: [PATCH 04/20] STYLE: regExp with explicit constructor - use separate constructor for ignore-case option (cf. wordRe treatment) - constructors/destructor now inline. --- src/OSspecific/POSIX/regExp.C | 32 ------------- src/OSspecific/POSIX/regExp.H | 28 ++++++----- src/OSspecific/POSIX/regExpI.H | 48 +++++++++++++++++++ .../starcd/STARCDsurfaceFormatCore.C | 12 ++--- 4 files changed, 70 insertions(+), 50 deletions(-) diff --git a/src/OSspecific/POSIX/regExp.C b/src/OSspecific/POSIX/regExp.C index 95e70ece9d..0f9cd7cb21 100644 --- a/src/OSspecific/POSIX/regExp.C +++ b/src/OSspecific/POSIX/regExp.C @@ -77,38 +77,6 @@ bool Foam::regExp::matchGrouping } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::regExp::regExp() -: - preg_(nullptr) -{} - - -Foam::regExp::regExp(const char* pattern, bool ignoreCase) -: - preg_(nullptr) -{ - set(pattern, ignoreCase); -} - - -Foam::regExp::regExp(const std::string& pattern, bool ignoreCase) -: - preg_(nullptr) -{ - set(pattern.c_str(), ignoreCase); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::regExp::~regExp() -{ - clear(); -} - - // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // bool Foam::regExp::set(const char* pattern, bool ignoreCase) diff --git a/src/OSspecific/POSIX/regExp.H b/src/OSspecific/POSIX/regExp.H index 640f6a819e..1f82552d07 100644 --- a/src/OSspecific/POSIX/regExp.H +++ b/src/OSspecific/POSIX/regExp.H @@ -77,7 +77,7 @@ class regExp //- Return true if it matches and sets the sub-groups matched. bool matchGrouping ( - const std::string&, + const std::string& text, List& groups ) const; @@ -99,17 +99,23 @@ public: // Constructors //- Construct null - regExp(); + inline regExp(); + + //- Construct from character array + inline explicit regExp(const char* pattern); + + //- Construct from string + inline explicit regExp(const std::string& pattern); //- Construct from character array, optionally ignore case - regExp(const char* pattern, bool ignoreCase=false); + inline regExp(const char* pattern, bool ignoreCase); //- Construct from string, optionally ignore case - regExp(const std::string& pattern, bool ignoreCase=false); + inline regExp(const std::string& pattern, bool ignoreCase); //- Destructor - ~regExp(); + inline ~regExp(); // Member functions @@ -143,20 +149,20 @@ public: // Matching/Searching - //- Find position within string. - // \Return The index where it begins or string::npos if not found + //- Find position within the text. + // \return The index where it begins or string::npos if not found std::string::size_type find(const std::string& text) const; - //- Return true if it matches the entire string + //- True if the regex matches the entire text. // The begin-of-line (^) and end-of-line ($) anchors are implicit bool match(const std::string& text) const; - //- Return true if it matches and sets the sub-groups matched + //- True if the regex matches the text, set the sub-groups matched. // The begin-of-line (^) and end-of-line ($) anchors are implicit bool match(const std::string& text, List& groups) const; - //- Return true if the regex was found within string - bool search(const std::string& text) const; + //- Return true if the regex was found within the text + inline bool search(const std::string& text) const; // Member Operators diff --git a/src/OSspecific/POSIX/regExpI.H b/src/OSspecific/POSIX/regExpI.H index e33564e611..7302e02410 100644 --- a/src/OSspecific/POSIX/regExpI.H +++ b/src/OSspecific/POSIX/regExpI.H @@ -38,6 +38,54 @@ inline bool Foam::regExp::meta(const char c) } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::regExp::regExp() +: + preg_(nullptr) +{} + + +inline Foam::regExp::regExp(const char* pattern) +: + preg_(nullptr) +{ + set(pattern, false); +} + + +inline Foam::regExp::regExp(const std::string& pattern) +: + preg_(nullptr) +{ + set(pattern, false); +} + + +inline Foam::regExp::regExp(const char* pattern, bool ignoreCase) +: + preg_(nullptr) +{ + set(pattern, ignoreCase); +} + + +inline Foam::regExp::regExp(const std::string& pattern, bool ignoreCase) +: + preg_(nullptr) +{ + set(pattern, ignoreCase); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +inline Foam::regExp::~regExp() +{ + clear(); +} + + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // inline bool Foam::regExp::empty() const diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C index b926f96802..71b3751c8c 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormatCore.C @@ -26,7 +26,7 @@ License #include "STARCDsurfaceFormatCore.H" #include "clock.H" #include "regExp.H" -#include "IStringStream.H" +#include "IFstream.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -47,7 +47,7 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable return lookup; } - regExp ctnameRE + const regExp ctnameRE ( " *CTNA[^ ]*" // keyword - min 4 chars "[[:space:]]+" // space delimited @@ -64,13 +64,11 @@ Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable if (ctnameRE.match(line, groups)) { const label tableId = atoi(groups[0].c_str()); + const word tableName = word::validated(groups[1]); - // strip bad chars - string::stripInvalid(groups[1]); - - if (!groups[1].empty()) + if (!tableName.empty()) { - lookup.insert(tableId, groups[1]); + lookup.insert(tableId, tableName); } } } From 1bcb454f6daa8b92144791a02cee98faa79a6244 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 5 Jul 2017 10:46:50 +0200 Subject: [PATCH 05/20] STYLE: hash constructors with power-of-two - use 1024 instead of 1000 since it will be changed internally to 1024 anyhow. --- applications/test/PackedList2/Test-PackedList2.C | 2 +- .../utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C | 4 ++-- .../surface/surfaceMeshTriangulate/surfaceMeshTriangulate.C | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/test/PackedList2/Test-PackedList2.C b/applications/test/PackedList2/Test-PackedList2.C index 26981b484f..ce9b15ed51 100644 --- a/applications/test/PackedList2/Test-PackedList2.C +++ b/applications/test/PackedList2/Test-PackedList2.C @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) std::vector stlVector(n, true); labelHashSet emptyHash; - labelHashSet fullHash(1000); + labelHashSet fullHash(1024); for (label i = 0; i < n; i++) { fullHash.insert(i); diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 3e91747415..28d5d4dfc6 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -393,7 +393,7 @@ void extractSurface // Collect sizes. Hash on names to handle local-only patches (e.g. // processor patches) - HashTable