From 47ee7ff4ae0cdb0bafbd1538ff386524ab0ccc3b Mon Sep 17 00:00:00 2001
From: Timon Habenicht <t.habenicht@tu-bs.de>
Date: Thu, 22 Nov 2018 21:34:48 +0100
Subject: [PATCH] adds Test Time

---
 .../LogFileTimeInformation.cpp                |  6 ++--
 .../Utilities/TestSimulation/TestSimulation.h | 10 +++---
 .../TestSimulation/TestSimulationImp.cpp      | 31 ++++++++++++++-----
 .../TestSimulation/TestSimulationImp.h        | 12 ++++---
 .../VirtualFluidSimulationImp.cpp             |  4 +--
 targets/tests/NumericalTests/config.txt       |  2 +-
 targets/tests/NumericalTests/main.cpp         |  5 +++
 7 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp
index 74a6ffcf0..fd4331d3e 100644
--- a/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp
+++ b/targets/tests/NumericalTests/Utilities/LogFileInformation/LogFileTimeInformation/LogFileTimeInformation.cpp
@@ -2,6 +2,8 @@
 
 #include "Utilities\TestSimulation\TestSimulation.h"
 
+#include <iomanip>
+
 std::shared_ptr<LogFileTimeInformation> LogFileTimeInformation::getNewInstance(std::vector<std::shared_ptr<TestSimulation>> testSimulation, bool fileWriting)
 {
 	return std::shared_ptr<LogFileTimeInformation>(new LogFileTimeInformation(testSimulation, fileWriting));
@@ -12,10 +14,10 @@ std::string LogFileTimeInformation::getOutput()
 	makeCenterHead("Simulation Time Information");
 	oss << "FileWriting: " << std::boolalpha << fileWriting <<std::endl;
 	oss << std::endl;
-	oss << "TestName \t \t \t" << " L\t\t" << "Time for Test" << std::endl;
+	oss << std::left << std::setfill(' ') << std::setw(11) << "" << "TestName \t \t \t" << " L\t\t" << "Time for Test" << std::endl;
 	oss << std::endl;
 	for (int i = 0; i < testSimulation.size(); i++)
-		oss << testSimulation.at(i)->getSimulationRunTimeOutput();
+		oss << testSimulation.at(i)->getRunTimeOutput();
 	oss << std::endl;
 	return oss.str();
 }
diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h
index 9c8353a2a..ffbf2d909 100644
--- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h
+++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulation.h
@@ -20,13 +20,15 @@ public:
 	
 	virtual std::shared_ptr< SimulationResults> getSimulationResults() = 0;
 	virtual bool getSimulationRun() = 0;
-	virtual std::string getSimulationRunTimeOutput() = 0;
+	virtual std::string getRunTimeOutput() = 0;
 	virtual void registerSimulationObserver(std::shared_ptr< SimulationObserver> simObserver) = 0;
 	
-	
 	virtual void makeSimulationHeadOutput() = 0;
-	virtual void setStartTime() = 0;
-	virtual void setEndTime() = 0;
+	virtual void setSimulationStartTime() = 0;
+	virtual void setSimulationEndTimeAndNotifyObserver() = 0;
+
+	virtual void setTestStartTime() = 0;
+	virtual void setTestEndTime() = 0;
 
 private:
 
diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp
index 7efa4735b..2fa45ed11 100644
--- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp
+++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.cpp
@@ -13,7 +13,6 @@
 #include <sstream>
 #include <iomanip>
 
-
 std::shared_ptr<TestSimulation> TestSimulationImp::getNewInsance(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput)
 {
 	return std::shared_ptr< TestSimulation>(new TestSimulationImp(simID, simPara, simInfo, colorOutput));
@@ -52,7 +51,12 @@ void TestSimulationImp::notifyObserver()
 
 double TestSimulationImp::calcSimTime()
 {
-	return difftime(endTime, startTime);
+	return difftime(simulationEndTime, simulationStartTime);
+}
+
+double TestSimulationImp::calcTestTime()
+{
+	return difftime(testEndTime, testStartTime);
 }
 
 void TestSimulationImp::makeSimulationHeadOutput()
@@ -60,22 +64,33 @@ void TestSimulationImp::makeSimulationHeadOutput()
 	colorOutput->makeSimulationHeadOutput(simInfo);
 }
 
-void TestSimulationImp::setStartTime()
+void TestSimulationImp::setSimulationStartTime()
 {
-	startTime = time(NULL);
+	simulationStartTime = time(NULL);
 }
 
-void TestSimulationImp::setEndTime()
+void TestSimulationImp::setSimulationEndTimeAndNotifyObserver()
 {
-	endTime = time(NULL);
+	simulationEndTime = time(NULL);
 	simualtionRun = true;
 	notifyObserver();
 }
 
-std::string TestSimulationImp::getSimulationRunTimeOutput()
+void TestSimulationImp::setTestStartTime()
+{
+	testStartTime = time(NULL);
+}
+
+void TestSimulationImp::setTestEndTime()
+{
+	testEndTime = time(NULL);
+}
+
+std::string TestSimulationImp::getRunTimeOutput()
 {
 	std::ostringstream oss;
-	oss << std::left << std::setfill(' ') << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcSimTime() << " sec" << std::endl;
+	oss << std::left << std::setfill(' ') << std::setw(11) << "Simulation" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcSimTime() << " sec" << std::endl;
+	oss << std::left << std::setfill(' ') << std::setw(11) << "Test" << std::setw(17) << simInfo->getSimulationName() << "\t" << std::right << std::setw(3) << simPara->getLx() << "\t\t" << std::setw(9) << calcTestTime() << " sec" << std::endl;
 	return oss.str();
 }
 
diff --git a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h
index c891de582..5a63d60a4 100644
--- a/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h
+++ b/targets/tests/NumericalTests/Utilities/TestSimulation/TestSimulationImp.h
@@ -23,14 +23,17 @@ public:
 	std::shared_ptr< SimulationResults> getSimulationResults();
 
 	void makeSimulationHeadOutput();
-	void setStartTime();
-	void setEndTime();
-	std::string getSimulationRunTimeOutput();
+	void setSimulationStartTime();
+	void setSimulationEndTimeAndNotifyObserver();
+	void setTestStartTime();
+	void setTestEndTime();
+	std::string getRunTimeOutput();
 
 private:
 	TestSimulationImp(int simID, std::shared_ptr< SimulationParameter> simPara, std::shared_ptr< SimulationInfo> simInfo, std::shared_ptr< ColorConsoleOutput> colorOutput);
 	void notifyObserver();
 	double calcSimTime();
+	double calcTestTime();
 
 	std::shared_ptr< SimulationParameter> simPara;
 	std::shared_ptr< SimulationInfo> simInfo;
@@ -40,7 +43,8 @@ private:
 	std::vector< std::shared_ptr< SimulationObserver>> simObserver;
 
 	bool simualtionRun;
-	time_t startTime, endTime;
+	time_t simulationStartTime, simulationEndTime;
+	time_t testStartTime, testEndTime;
 	int simID;
 };
 #endif
\ No newline at end of file
diff --git a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp
index a1ded1209..f5018283d 100644
--- a/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp
+++ b/targets/tests/NumericalTests/Utilities/VirtualFluidSimulation/VirtualFluidSimulationImp.cpp
@@ -14,14 +14,14 @@
 void VirtualFluidSimulationImp::run()
 {
 	testSim->makeSimulationHeadOutput();
-	testSim->setStartTime();
+	testSim->setSimulationStartTime();
 
 	Simulation sim;
 	sim.init(para, grid, dataWriter);
 	sim.run();
 	sim.free();
 
-	testSim->setEndTime();
+	testSim->setSimulationEndTimeAndNotifyObserver();
 }
 
 std::shared_ptr<VirtualFluidSimulationImp> VirtualFluidSimulationImp::getNewInstance()
diff --git a/targets/tests/NumericalTests/config.txt b/targets/tests/NumericalTests/config.txt
index 4edca80a3..ea0aef7e1 100644
--- a/targets/tests/NumericalTests/config.txt
+++ b/targets/tests/NumericalTests/config.txt
@@ -57,7 +57,7 @@ L2NormTest_SW=true
 #			Simulation To Perform				 #
 ##################################################
 TaylorGreenVortex32=true
-TaylorGreenVortex64=true
+TaylorGreenVortex64=false
 TaylorGreenVortex128=false
 TaylorGreenVortex256=false
 TaylorGreenVortex512=false
diff --git a/targets/tests/NumericalTests/main.cpp b/targets/tests/NumericalTests/main.cpp
index 8c0697cab..77ef04a17 100644
--- a/targets/tests/NumericalTests/main.cpp
+++ b/targets/tests/NumericalTests/main.cpp
@@ -5,6 +5,7 @@
 #include "Utilities\LogFileQueue\LogFileQueue.h"
 #include "Utilities\NumericalTestFactory\NumericalTestFactoryImp.h"
 #include "Utilities\TestQueue\TestQueue.h"
+#include "Utilities\TestSimulation\TestSimulation.h"
 #include "Utilities\VirtualFluidSimulation\VirtualFluidSimulation.h"
 #include "Utilities\VirtualFluidSimulationFactory\VirtualFluidSimulationFactoryImp.h"
 
@@ -23,8 +24,12 @@ static void startNumericalTests(const std::string &configFile)
 
 	for (int i = 0; i < vfSimulations.size(); i++)
 	{
+		if (i > 0)
+			testSim.at(i)->setTestEndTime();
 		vfSimulations.at(i)->run();
+		testSim.at(i)->setTestStartTime();
 	}
+	testSim.at(testSim.size()-1)->setTestEndTime();
 
 	testQueue->makeFinalOutput();
 	logFileQueue->writeLogFiles();
-- 
GitLab