From 830f7494c865f0421c8200f6c2948cd40a10cc31 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 8 Nov 2011 11:49:14 +0100 Subject: [PATCH] console output cleanup: use verbose level ('-v') for old verbose style --- FDTD/engine.cpp | 2 +- FDTD/engine_multithread.cpp | 9 ++++++--- FDTD/operator_cylinder.cpp | 6 ++++-- FDTD/operator_mpi.cpp | 2 +- FDTD/operator_multithread.cpp | 3 ++- FDTD/operator_sse_compressed.cpp | 3 ++- openems.cpp | 28 ++++++++++++++++++++-------- tools/global.cpp | 9 ++++++++- tools/useful.cpp | 7 +++++++ tools/useful.h | 3 +++ 10 files changed, 54 insertions(+), 18 deletions(-) diff --git a/FDTD/engine.cpp b/FDTD/engine.cpp index f8c8141..8a3aae6 100644 --- a/FDTD/engine.cpp +++ b/FDTD/engine.cpp @@ -87,7 +87,7 @@ void Engine::SortExtensionByPriority() stable_sort(m_Eng_exts.begin(),m_Eng_exts.end(), CompareExtensions); reverse(m_Eng_exts.begin(),m_Eng_exts.end()); - if (g_settings.GetVerboseLevel()>0) + if (g_settings.GetVerboseLevel()>1) { cout << "--- Engine::SortExtensionByPriority() ---" << endl; for (size_t n=0; n m_Stop_Lines; m_Op_MT->CalcStartStopLines( m_numThreads, m_Start_Lines, m_Stop_Lines ); - cout << "Multithreaded engine using " << m_numThreads << " threads. Utilization: ("; + if (g_settings.GetVerboseLevel()>0) + cout << "Multithreaded engine using " << m_numThreads << " threads. Utilization: ("; m_IterateBarrier = new boost::barrier(m_numThreads); // numThread workers m_startBarrier = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller @@ -117,10 +118,12 @@ void Engine_Multithread::Init() { // last thread stop_h = stop-1; - cout << stop-start+1 << ")" << endl; + if (g_settings.GetVerboseLevel()>0) + cout << stop-start+1 << ")" << endl; } else - cout << stop-start+1 << ";"; + if (g_settings.GetVerboseLevel()>0) + cout << stop-start+1 << ";"; // NS_Engine_Multithread::DBG().cout() << "###DEBUG## Thread " << n << ": start=" << start << " stop=" << stop << " stop_h=" << stop_h << std::endl; boost::thread *t = new boost::thread( NS_Engine_Multithread::thread(this,start,stop,stop_h,n) ); m_thread_group.add_thread( t ); diff --git a/FDTD/operator_cylinder.cpp b/FDTD/operator_cylinder.cpp index 81638d9..1539fb3 100644 --- a/FDTD/operator_cylinder.cpp +++ b/FDTD/operator_cylinder.cpp @@ -193,7 +193,8 @@ bool Operator_Cylinder::SetupCSXGrid(CSRectGrid* grid) double minmaxA = fabs(alphaLines[alphaNum-1]-alphaLines[0]); if (fabs(minmaxA-2*PI) < OPERATOR_CYLINDER_CLOSED_ALPHA_THRESHOLD) { - cout << "Operator_Cylinder::SetupCSXGrid: Alpha is a full 2*PI => closed Cylinder..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Operator_Cylinder::SetupCSXGrid: Alpha is a full 2*PI => closed Cylinder..." << endl; CC_closedAlpha = true; grid->SetLine(1,alphaNum-1,2*PI+alphaLines[0]); grid->AddDiscLine(1,2*PI+alphaLines[1]); @@ -218,7 +219,8 @@ bool Operator_Cylinder::SetupCSXGrid(CSRectGrid* grid) } else if (grid->GetLine(0,0)==0.0) { - cout << "Operator_Cylinder::SetupCSXGrid: r=0 included..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Operator_Cylinder::SetupCSXGrid: r=0 included..." << endl; CC_R0_included = CC_closedAlpha; //needed for correct ec-calculation, deactivate if closed cylinder is false... --> E_r = 0 anyways } diff --git a/FDTD/operator_mpi.cpp b/FDTD/operator_mpi.cpp index bdb4f4a..1e70421 100644 --- a/FDTD/operator_mpi.cpp +++ b/FDTD/operator_mpi.cpp @@ -129,7 +129,7 @@ void Operator_MPI::Init() m_Processor_Name = new char[MPI_MAX_PROCESSOR_NAME]; MPI::Get_processor_name(m_Processor_Name,namelen); - if (m_MPI_Enabled) + if ((m_MPI_Enabled) && (g_settings.GetVerboseLevel()>0)) cerr << "Operator_MPI::Init(): Running on " << m_Processor_Name << endl; } diff --git a/FDTD/operator_multithread.cpp b/FDTD/operator_multithread.cpp index 11f7d7a..8768d07 100644 --- a/FDTD/operator_multithread.cpp +++ b/FDTD/operator_multithread.cpp @@ -113,7 +113,8 @@ int Operator_Multithread::CalcECOperator( DebugFlags debugFlags ) vector m_Stop_Lines; CalcStartStopLines( m_numThreads, m_Start_Lines, m_Stop_Lines ); - cout << "Multithreaded operator using " << m_numThreads << " threads." << std::endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Multithreaded operator using " << m_numThreads << " threads." << std::endl; m_thread_group.join_all(); delete m_CalcEC_Start; diff --git a/FDTD/operator_sse_compressed.cpp b/FDTD/operator_sse_compressed.cpp index 4c818ff..a04eea9 100644 --- a/FDTD/operator_sse_compressed.cpp +++ b/FDTD/operator_sse_compressed.cpp @@ -156,7 +156,8 @@ bool Operator_SSE_Compressed::CompareOperators(unsigned int pos1[3], unsigned in bool Operator_SSE_Compressed::CompressOperator() { - cout << "Compressing the FDTD operator... this may take a while..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Compressing the FDTD operator... this may take a while..." << endl; map lookUpMap; diff --git a/openems.cpp b/openems.cpp index d84800c..6a6bd89 100644 --- a/openems.cpp +++ b/openems.cpp @@ -18,6 +18,7 @@ #include "openems.h" #include #include "tools/array_ops.h" +#include "tools/useful.h" #include "FDTD/operator_cylinder.h" #include "FDTD/operator_cylindermultigrid.h" #include "FDTD/engine_multithread.h" @@ -294,7 +295,8 @@ Engine_Interface_FDTD* openEMS::NewEngineInterface() bool openEMS::SetupProcessing() { //*************** setup processing ************// - cout << "Setting up processing..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Setting up processing..." << endl; unsigned int Nyquist = FDTD_Op->Exc->GetNyquistNum(); PA = new ProcessingArray(Nyquist); @@ -527,7 +529,8 @@ int openEMS::SetupFDTD(const char* file) if (file==NULL) return -1; Reset(); - cout << "Read openEMS xml file: " << file << " ..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Read openEMS xml file: " << file << " ..." << endl; timeval startTime; gettimeofday(&startTime,NULL); @@ -540,7 +543,8 @@ int openEMS::SetupFDTD(const char* file) exit(-1); } - cout << "Read openEMS Settings..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Read openEMS Settings..." << endl; TiXmlElement* openEMSxml = doc.FirstChildElement("openEMS"); if (openEMSxml==NULL) { @@ -588,7 +592,8 @@ int openEMS::SetupFDTD(const char* file) exit(-3); } - cout << "Read Geometry..." << endl; + if (g_settings.GetVerboseLevel()>0) + cout << "Read Geometry..." << endl; m_CSX = new ContinuousStructure(); string EC(m_CSX->ReadFromXML(openEMSxml)); if (EC.empty()==false) @@ -597,7 +602,7 @@ int openEMS::SetupFDTD(const char* file) // return(-2); } - if (g_settings.GetVerboseLevel()>0) + if (g_settings.GetVerboseLevel()>1) m_CSX->ShowPropertyStatus(cerr); if (CylinderCoords) @@ -659,10 +664,17 @@ int openEMS::SetupFDTD(const char* file) timeval OpDoneTime; gettimeofday(&OpDoneTime,NULL); - FDTD_Op->ShowStat(); - FDTD_Op->ShowExtStat(); + if (g_settings.GetVerboseLevel()>0) + { + FDTD_Op->ShowStat(); + FDTD_Op->ShowExtStat(); + cout << "Creation time for operator: " << CalcDiffTime(OpDoneTime,startTime) << " s" << endl; + } + cout << "FDTD timestep is: " <GetTimestep() << " s; Nyquist rate: " << FDTD_Op->Exc->GetNyquistNum() << " timesteps @" << CalcNyquistFrequency(FDTD_Op->Exc->GetNyquistNum(),FDTD_Op->GetTimestep()) << " Hz" << endl; + cout << "Excitation signal length is: " << FDTD_Op->Exc->Length << " timesteps (" << FDTD_Op->Exc->Length*FDTD_Op->GetTimestep() << "s)" << endl; - cout << "Creation time for operator: " << CalcDiffTime(OpDoneTime,startTime) << " s" << endl; + if (FDTD_Op->Exc->GetNyquistNum()>1000) + cerr << "openEMS::SetupFDTD: Warning, the timestep seems to be very small --> long simulation. Check your mesh!?" << endl; if (m_no_simulation) { diff --git a/tools/global.cpp b/tools/global.cpp index 855a920..cd1cd36 100644 --- a/tools/global.cpp +++ b/tools/global.cpp @@ -34,7 +34,8 @@ Global::Global() void Global::ShowArguments(ostream& ostr, string front) { ostr << front << "--showProbeDiscretization\tShow probe discretization information" << endl; - ostr << front << "--nativeFieldDumps\tDump all fields using the native field components" << endl; + ostr << front << "--nativeFieldDumps\t\tDump all fields using the native field components" << endl; + ostr << front << "-v(v)\t\t\t\tSet debug level to 1(2)" << endl; } //! \brief This function initializes the object @@ -61,5 +62,11 @@ bool Global::parseCommandLineArgument( const char *argv ) m_VerboseLevel = 1; return true; } + else if (strcmp(argv,"-vv")==0) + { + cout << "openEMS - verbose level 2" << endl; + m_VerboseLevel = 2; + return true; + } return false; } diff --git a/tools/useful.cpp b/tools/useful.cpp index cfac0e4..6ddd589 100644 --- a/tools/useful.cpp +++ b/tools/useful.cpp @@ -32,6 +32,13 @@ unsigned int CalcNyquistNum(double fmax, double dT) return floor(T0/2/dT); } +double CalcNyquistFrequency(unsigned int nyquist, double dT) +{ + if (nyquist==0) return 0; + if (dT==0) return 0; + return floor(1/(double)nyquist/2/dT); +} + std::vector AssignJobs2Threads(unsigned int jobs, unsigned int nrThreads, bool RemoveEmpty) { std::vector jpt; //jobs per thread diff --git a/tools/useful.h b/tools/useful.h index c6160cf..c81bd96 100644 --- a/tools/useful.h +++ b/tools/useful.h @@ -23,6 +23,9 @@ //! Calc the nyquist number of timesteps for a given frequency and timestep unsigned int CalcNyquistNum(double fmax, double dT); +//! Calc the highest frequency allowed for a given nyquist number of timesteps and timestep +double CalcNyquistFrequency(unsigned int nyquist, double dT); + //! Calculate an optimal job distribution to a given number of threads. Will return a vector with the jobs for each thread. std::vector AssignJobs2Threads(unsigned int jobs, unsigned int nrThreads, bool RemoveEmpty=false);