Message.h (getdp-3.4.0-source.tgz) | : | Message.h (getdp-3.5.0-source.tgz) | ||
---|---|---|---|---|
// GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege | // GetDP - Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege | |||
// | // | |||
// See the LICENSE.txt file for license information. Please report all | // See the LICENSE.txt file for license information. Please report all | |||
// issues on https://gitlab.onelab.info/getdp/getdp/issues. | // issues on https://gitlab.onelab.info/getdp/getdp/issues. | |||
#ifndef MESSAGE_H | #ifndef MESSAGE_H | |||
#define MESSAGE_H | #define MESSAGE_H | |||
#include <map> | #include <map> | |||
#include <string> | #include <string> | |||
#include <vector> | #include <vector> | |||
#include <stdarg.h> | #include <stdarg.h> | |||
class GmshClient; | class GmshClient; | |||
struct Constant; | struct Constant; | |||
struct Expression; | struct Expression; | |||
struct Group; | struct Group; | |||
namespace onelab{ class client; } | namespace onelab { | |||
class client; | ||||
} | ||||
// a class to manage messages | // a class to manage messages | |||
class Message { | class Message { | |||
private: | private: | |||
// current cpu number and total number of cpus | // current cpu number and total number of cpus | |||
static int _commRank, _commSize, _isCommWorld; | static int _commRank, _commSize, _isCommWorld; | |||
// error count | // error count | |||
static int _warningCount, _errorCount; | static int _warningCount, _errorCount; | |||
// last PETSc error code | // last PETSc error code | |||
static int _lastPETScError; | static int _lastPETScError; | |||
// behavior on error (0: none, 1: exit, 2: throw exception) | // behavior on error (0: none, 1: exit, 2: throw exception) | |||
static int _exitOnError; | static int _exitOnError; | |||
// are we inside an adaptive time loop? | // are we inside an adaptive time loop? | |||
static bool _operatingInTimeLoopAdaptive; | static bool _operatingInTimeLoopAdaptive; | |||
skipping to change at line 49 | skipping to change at line 51 | |||
// report cpu time for each info message? | // report cpu time for each info message? | |||
static bool _infoCpu; | static bool _infoCpu; | |||
// starting time (gettimeofday at startup) | // starting time (gettimeofday at startup) | |||
static double _startTime; | static double _startTime; | |||
// timers | // timers | |||
static std::map<std::string, double> _timers; | static std::map<std::string, double> _timers; | |||
// communication with Gmsh | // communication with Gmsh | |||
static GmshClient *_client; | static GmshClient *_client; | |||
// communication with onelab server | // communication with onelab server | |||
static onelab::client *_onelabClient; | static onelab::client *_onelabClient; | |||
public: | ||||
public: | ||||
Message() {} | Message() {} | |||
static void Initialize(int argc, char **argv); | static void Initialize(int argc, char **argv); | |||
static void Finalize(); | static void Finalize(); | |||
static void Exit(int level); | static void Exit(int level); | |||
static int GetCommRank(){ return _commRank; } | static int GetCommRank() { return _commRank; } | |||
static int GetCommSize(){ return _commSize; } | static int GetCommSize() { return _commSize; } | |||
static void SetCommRank(int val){ _commRank = val; } | static void SetCommRank(int val) { _commRank = val; } | |||
static void SetCommSize(int val){ _commSize = val; } | static void SetCommSize(int val) { _commSize = val; } | |||
static void Barrier(); | static void Barrier(); | |||
static int GetIsCommWorld(){return _isCommWorld; } | static int GetIsCommWorld() { return _isCommWorld; } | |||
static void SetIsCommWorld(int val){ _isCommWorld = val; } | static void SetIsCommWorld(int val) { _isCommWorld = val; } | |||
static int GetNumThreads(); | static int GetNumThreads(); | |||
static void SetNumThreads(int num); | static void SetNumThreads(int num); | |||
static int GetMaxThreads(); | static int GetMaxThreads(); | |||
static int GetThreadNum(); | static int GetThreadNum(); | |||
static void SetVerbosity(int val){ _verbosity = val; } | static void SetVerbosity(int val) { _verbosity = val; } | |||
static int GetVerbosity(){ return _verbosity; } | static int GetVerbosity() { return _verbosity; } | |||
static void Fatal(const char *fmt, ...); | static void Fatal(const char *fmt, ...); | |||
static void Error(const char *fmt, ...); | static void Error(const char *fmt, ...); | |||
static void ResetErrorCounter(){ _errorCount = 0; } | static void ResetErrorCounter() { _errorCount = 0; } | |||
static int GetErrorCount(){ return _errorCount; } | static int GetErrorCount() { return _errorCount; } | |||
static void SetExitOnError(int val){ _exitOnError = val; } | static void SetExitOnError(int val) { _exitOnError = val; } | |||
static void SetOperatingInTimeLoopAdaptive(bool val){ _operatingInTimeLoopAdap | static void SetOperatingInTimeLoopAdaptive(bool val) | |||
tive = val; } | { | |||
static bool GetOperatingInTimeLoopAdaptive(){ return _operatingInTimeLoopAdapt | _operatingInTimeLoopAdaptive = val; | |||
ive; } | } | |||
static bool GetOperatingInTimeLoopAdaptive() | ||||
{ | ||||
return _operatingInTimeLoopAdaptive; | ||||
} | ||||
static void Warning(const char *fmt, ...); | static void Warning(const char *fmt, ...); | |||
static void Info(const char *fmt, ...); | static void Info(const char *fmt, ...); | |||
static void Info(int level, const char *fmt, ...); | static void Info(int level, const char *fmt, ...); | |||
static void Direct(const char *fmt, ...); | static void Direct(const char *fmt, ...); | |||
static void Direct(int level, const char *fmt, ...); | static void Direct(int level, const char *fmt, ...); | |||
static void Check(const char *fmt, ...); | static void Check(const char *fmt, ...); | |||
static void Debug(const char *fmt, ...); | static void Debug(const char *fmt, ...); | |||
static double GetWallClockTime(); | static double GetWallClockTime(); | |||
static void Cpu(const char *fmt, ...); | static void Cpu(const char *fmt, ...); | |||
static void Cpu(int level, bool printDate, bool printWallTime, bool printCpu, | static void Cpu(int level, bool printDate, bool printWallTime, bool printCpu, | |||
bool printMem, bool printTraffic, const char *fmt, ...); | bool printMem, bool printTraffic, const char *fmt, ...); | |||
static void ProgressMeter(int n, int N, const char *fmt, ...); | static void ProgressMeter(int n, int N, const char *fmt, ...); | |||
static void ProgressMeter(int n, int N){ ProgressMeter(n, N, ""); } | static void ProgressMeter(int n, int N) { ProgressMeter(n, N, ""); } | |||
static void SetProgressMeterStep(int step){ _progressMeterStep = step; } | static void SetProgressMeterStep(int step) { _progressMeterStep = step; } | |||
static int GetProgressMeterStep(){ return _progressMeterStep; } | static int GetProgressMeterStep() { return _progressMeterStep; } | |||
static void ResetProgressMeter(){ if(!_commRank) _progressMeterCurrent = 0; } | static void ResetProgressMeter() | |||
static void SetInfoCpu(bool val){ _infoCpu = val; } | { | |||
if(!_commRank) _progressMeterCurrent = 0; | ||||
} | ||||
static void SetInfoCpu(bool val) { _infoCpu = val; } | ||||
static void PrintErrorCounter(const char *title); | static void PrintErrorCounter(const char *title); | |||
static void SetLastPETScError(int ierr){ _lastPETScError = ierr; } | static void SetLastPETScError(int ierr) { _lastPETScError = ierr; } | |||
static int GetLastPETScError(){ return _lastPETScError; } | static int GetLastPETScError() { return _lastPETScError; } | |||
static double &Timer(std::string str){ return _timers[str]; } | static double &Timer(std::string str) { return _timers[str]; } | |||
static void PrintTimers(); | static void PrintTimers(); | |||
static void InitializeSocket(std::string sockname); | static void InitializeSocket(std::string sockname); | |||
static void FinalizeSocket(); | static void FinalizeSocket(); | |||
static bool UseSocket(){ return _client ? true : false; } | static bool UseSocket() { return _client ? true : false; } | |||
static void SendMergeFileRequest(const std::string &filename); | static void SendMergeFileRequest(const std::string &filename); | |||
static void SendOptionOnSocket(int num, std::string option); | static void SendOptionOnSocket(int num, std::string option); | |||
static void TestSocket(); | static void TestSocket(); | |||
static void InitializeOnelab(std::string name, std::string sockname); | static void InitializeOnelab(std::string name, std::string sockname); | |||
static void FinalizeOnelab(); | static void FinalizeOnelab(); | |||
static bool UseOnelab(){ return _onelabClient ? true : false; } | static bool UseOnelab() { return _onelabClient ? true : false; } | |||
static std::string GetOnelabClientName(); | static std::string GetOnelabClientName(); | |||
static void SetOnelabNumber(std::string name, double val); | static void SetOnelabNumber(std::string name, double val); | |||
static void SetOnelabString(std::string name, std::string val); | static void SetOnelabString(std::string name, std::string val); | |||
static double GetOnelabNumber(std::string name, double defaultValue=0., | static double GetOnelabNumber(std::string name, double defaultValue = 0., | |||
bool errorIfMissing=false); | bool errorIfMissing = false); | |||
static std::string GetOnelabString(std::string name, const std::string &defaul | static std::string GetOnelabString(std::string name, | |||
tValue="", | const std::string &defaultValue = "", | |||
bool errorIfMissing=false); | bool errorIfMissing = false); | |||
static void GetOnelabNumbers(std::string name, std::vector<double> &value, | static void GetOnelabNumbers(std::string name, std::vector<double> &value, | |||
bool errorIfMissing); | bool errorIfMissing); | |||
static std::string GetOnelabAction(); | static std::string GetOnelabAction(); | |||
static void AddOnelabNumberChoice(std::string name, const std::vector<double> | static void AddOnelabNumberChoice(std::string name, | |||
&value, | const std::vector<double> &value, | |||
const char *color=0, const char *units=0, | const char *color = 0, | |||
const char *label=0, bool visible=true, | const char *units = 0, | |||
bool closed=false); | const char *label = 0, bool visible = true, | |||
bool closed = false); | ||||
static void AddOnelabStringChoice(std::string name, std::string kind, | static void AddOnelabStringChoice(std::string name, std::string kind, | |||
std::string value, bool updateValue=true, | std::string value, bool updateValue = true, | |||
bool readOnly=false); | bool readOnly = false); | |||
typedef std::map<std::string, std::vector<double> > fmap; | typedef std::map<std::string, std::vector<double> > fmap; | |||
typedef std::map<std::string, std::vector<std::string> > cmap; | typedef std::map<std::string, std::vector<std::string> > cmap; | |||
static void ExchangeOnelabParameter(Constant *c, fmap &fopt, cmap &copt); | static void ExchangeOnelabParameter(Constant *c, fmap &fopt, cmap &copt); | |||
static void UndefineOnelabParameter(const std::string &name); | static void UndefineOnelabParameter(const std::string &name); | |||
}; | }; | |||
#endif | #endif | |||
End of changes. 15 change blocks. | ||||
41 lines changed or deleted | 52 lines changed or added |