diff --git a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C index e973bc1bd8fc90039bb43542cf5b3a7dce8000b3..94759bfe330b655d4846c9910f1d0a5773cc3ade 100644 --- a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C +++ b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.C @@ -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) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,11 +31,41 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +namespace Foam +{ // Signal number to catch -int Foam::sigStopAtWriteNow::signal_ +int sigStopAtWriteNow::signal_ ( debug::optimisationSwitch("stopAtWriteNowSignal", -1) ); +// Register re-reader +class addstopAtWriteNowSignalToOpt +: + public ::Foam::simpleRegIOobject +{ +public: + addstopAtWriteNowSignalToOpt(const char* name) + : + ::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name) + {} + virtual ~addstopAtWriteNowSignalToOpt() + {} + virtual void readData(Foam::Istream& is) + { + sigStopAtWriteNow::signal_ = readLabel(is); + sigStopAtWriteNow::set(true); + } + virtual void writeData(Foam::Ostream& os) const + { + os << sigStopAtWriteNow::signal_; + } +}; +addstopAtWriteNowSignalToOpt addstopAtWriteNowSignalToOpt_ +( + "stopAtWriteNowSignal" +); +} + static Foam::Time const* runTimePtr_ = NULL; @@ -80,6 +110,36 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow const bool verbose, const Time& runTime ) +{ + // Store runTime + runTimePtr_ = &runTime; + + set(verbose); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sigStopAtWriteNow::~sigStopAtWriteNow() +{ + // Reset old handling + if (signal_ > 0) + { + if (sigaction(signal_, &oldAction_, NULL) < 0) + { + FatalErrorIn + ( + "Foam::sigStopAtWriteNow::~sigStopAtWriteNow()" + ) << "Cannot reset " << signal_ << " trapping" + << abort(FatalError); + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::sigStopAtWriteNow::set(const bool verbose) { if (signal_ > 0) { @@ -98,9 +158,6 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow } - // Store runTime - runTimePtr_ = &runTime; - struct sigaction newAction; newAction.sa_handler = sigHandler; newAction.sa_flags = SA_NODEFER; @@ -125,27 +182,6 @@ Foam::sigStopAtWriteNow::sigStopAtWriteNow } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::sigStopAtWriteNow::~sigStopAtWriteNow() -{ - // Reset old handling - if (signal_ > 0) - { - if (sigaction(signal_, &oldAction_, NULL) < 0) - { - FatalErrorIn - ( - "Foam::sigStopAtWriteNow::~sigStopAtWriteNow()" - ) << "Cannot reset " << signal_ << " trapping" - << abort(FatalError); - } - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - bool Foam::sigStopAtWriteNow::active() const { return signal_ > 0; diff --git a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.H b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.H index 4c07248eb21be8c29325914f1dcbc99bb72c86d0..d7d9d113b08b5d13de705193f7249a1efbbeddb0 100644 --- a/src/OSspecific/POSIX/signals/sigStopAtWriteNow.H +++ b/src/OSspecific/POSIX/signals/sigStopAtWriteNow.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) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,6 +68,9 @@ class sigStopAtWriteNow public: + //- wip. Have setter have access to signal_ + friend class addstopAtWriteNowSignalToOpt; + // Constructors //- Construct null @@ -83,6 +86,9 @@ public: // Member functions + //- (re)set signal catcher + static void set(const bool verbose); + //- Is active? bool active() const; }; diff --git a/src/OSspecific/POSIX/signals/sigWriteNow.C b/src/OSspecific/POSIX/signals/sigWriteNow.C index 6ad98a6190d88bac2a87ad29edf3416da049d917..29381368a2d8ab168f32591d6d59890908c284e5 100644 --- a/src/OSspecific/POSIX/signals/sigWriteNow.C +++ b/src/OSspecific/POSIX/signals/sigWriteNow.C @@ -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) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,11 +31,39 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +namespace Foam +{ // Signal number to catch -int Foam::sigWriteNow::signal_ +int sigWriteNow::signal_ ( debug::optimisationSwitch("writeNowSignal", -1) ); +// Register re-reader +class addwriteNowSignalToOpt +: + public ::Foam::simpleRegIOobject +{ +public: + addwriteNowSignalToOpt(const char* name) + : + ::Foam::simpleRegIOobject(Foam::debug::addOptimisationObject, name) + {} + virtual ~addwriteNowSignalToOpt() + {} + virtual void readData(Foam::Istream& is) + { + sigWriteNow::signal_ = readLabel(is); + sigWriteNow::set(true); + } + virtual void writeData(Foam::Ostream& os) const + { + os << sigWriteNow::signal_; + } +}; +addwriteNowSignalToOpt addwriteNowSignalToOpt_("writeNowSignal"); + +} + static Foam::Time* runTimePtr_ = NULL; @@ -64,31 +92,10 @@ Foam::sigWriteNow::sigWriteNow() Foam::sigWriteNow::sigWriteNow(const bool verbose, Time& runTime) { - if (signal_ >= 0) - { - // Store runTime - runTimePtr_ = &runTime; + // Store runTime + runTimePtr_ = &runTime; - struct sigaction newAction; - newAction.sa_handler = sigHandler; - newAction.sa_flags = SA_NODEFER; - sigemptyset(&newAction.sa_mask); - if (sigaction(signal_, &newAction, &oldAction_) < 0) - { - FatalErrorIn - ( - "Foam::sigWriteNow::sigWriteNow(const bool, const Time&)" - ) << "Cannot set " << signal_ << " trapping" - << abort(FatalError); - } - - if (verbose) - { - Info<< "sigWriteNow :" - << " Enabling writing upon signal " << signal_ - << endl; - } - } + set(verbose); } @@ -113,6 +120,33 @@ Foam::sigWriteNow::~sigWriteNow() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::sigWriteNow::set(const bool verbose) +{ + if (signal_ >= 0) + { + struct sigaction newAction; + newAction.sa_handler = sigHandler; + newAction.sa_flags = SA_NODEFER; + sigemptyset(&newAction.sa_mask); + if (sigaction(signal_, &newAction, &oldAction_) < 0) + { + FatalErrorIn + ( + "Foam::sigWriteNow::sigWriteNow(const bool, const Time&)" + ) << "Cannot set " << signal_ << " trapping" + << abort(FatalError); + } + + if (verbose) + { + Info<< "sigWriteNow :" + << " Enabling writing upon signal " << signal_ + << endl; + } + } +} + + bool Foam::sigWriteNow::active() const { return signal_ > 0; diff --git a/src/OSspecific/POSIX/signals/sigWriteNow.H b/src/OSspecific/POSIX/signals/sigWriteNow.H index 477bae825f4b2a48ffd06d3b9203b7af57f40896..f89933721f20509d3b9e5365cd4d79b45aad56cc 100644 --- a/src/OSspecific/POSIX/signals/sigWriteNow.H +++ b/src/OSspecific/POSIX/signals/sigWriteNow.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) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,6 +69,9 @@ public: friend class sigStopAtWriteNow; + //- wip. Have setter have access to signal_ + friend class addwriteNowSignalToOpt; + // Constructors //- Construct null @@ -84,6 +87,9 @@ public: // Member functions + //- (re)set signal catcher + static void set(const bool verbose); + //- Is active? bool active() const; diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index ed699c286e925a4974c5f4f132cc66fe04051f27..fc6ac5d723eb46811781aa23c3ace56726644563 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -40,6 +40,9 @@ void Foam::Time::readDict() // Check for local switches and settings + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Debug switches if (controlDict_.found("DebugSwitches")) { simpleObjectRegistry& objects = debug::debugObjects(); @@ -50,8 +53,8 @@ void Foam::Time::readDict() simpleObjectRegistry::iterator fnd = objects.find(name); if (fnd != objects.end()) { - Info<< controlDict_.name() << " : overriding debug switch " - << name << " to " << fnd() << endl; + Info<< controlDict_.name() << " : overriding debug switch : " + << iter() << endl; if (iter().isDict()) { @@ -67,6 +70,8 @@ void Foam::Time::readDict() } } } + + // Dimension sets if (controlDict_.found("DimensionSets")) { dictionary dict(Foam::dimensionSystems()); @@ -84,6 +89,8 @@ void Foam::Time::readDict() fnd()->readData(is); } } + + // Optimisation Switches if (controlDict_.found("OptimisationSwitches")) { simpleObjectRegistry& objects = debug::optimisationObjects(); @@ -98,8 +105,7 @@ void Foam::Time::readDict() if (fnd != objects.end()) { Info<< controlDict_.name() - << " : overriding optimisation switch " - << name << " to " << fnd() << endl; + << " : overriding optimisation switch : " << iter() << endl; if (iter().isDict()) { diff --git a/src/OpenFOAM/db/typeInfo/debugName.H b/src/OpenFOAM/db/typeInfo/debugName.H index b169e26e22490787967392aba62a8c78b05829ad..2277945ed4dcb2eb9eca8e984d03c064846806e7 100644 --- a/src/OpenFOAM/db/typeInfo/debugName.H +++ b/src/OpenFOAM/db/typeInfo/debugName.H @@ -89,6 +89,7 @@ Description }; \ add##Tag##ToInfo add##Tag##ToInfo_(Name) + //- Register optimisation switch (if int), lookup as \a Name #define registerOptSwitchWithName(Switch,Tag,Name) \ class add##Tag##ToOpt \ diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.H index 94895c53fd7baabfde5fb31f3c692bb83163b34d..1eb9f40e77705bfc987720190b696721a831d0d0 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/refinementHistory.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) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -174,8 +174,6 @@ public: private: - TypeName("refinementHistory"); - // Private data //- Storage for splitCells @@ -230,6 +228,10 @@ private: public: + // Declare name of the class and its debug switch + TypeName("refinementHistory"); + + // Constructors //- Construct (read) given an IOobject