Skip to content
Snippets Groups Projects
Commit 56e78d71 authored by Timon Habenicht's avatar Timon Habenicht
Browse files

adds Tests and MathematicaAssistant to NumericalTestPostProcessing

parent 91938193
No related branches found
No related tags found
No related merge requests found
Showing
with 544 additions and 87 deletions
#include "L2NormMathematicaAssistant.h"
#include "Tests/L2Norm/LogFileData/L2NormLogFileData.h"
#include "Utilities/LogFileData/LogFileData.h"
#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h"
#include <sstream>
std::shared_ptr<L2NormMathematicaAssistant> L2NormMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory)
{
return std::shared_ptr<L2NormMathematicaAssistant>(new L2NormMathematicaAssistant(functionFactory));
}
void L2NormMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
{
std::shared_ptr<SortedDataL2Norm> mySortedData = sortLogFileData(logFileData);
makeL2NormDiffMathematicaOutput(aMathmaticaFile, mySortedData);
makeL2NormBasicTimeStepMathematicaOutput(aMathmaticaFile, mySortedData);
makeL2NormDivergentTimeStepMathematicaOutput(aMathmaticaFile, mySortedData);
}
L2NormMathematicaAssistant::L2NormMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : MathematicaAssistantImp(functionFactory)
{
}
bool L2NormMathematicaAssistant::checkTestParameter(std::shared_ptr<L2NormLogFileData> logFileData1, std::shared_ptr<L2NormLogFileData> logFileData2)
{
if (logFileData1->getDataToCalc() != logFileData2->getDataToCalc())
return false;
if (logFileData1->getNormalizeData() != logFileData2->getNormalizeData())
return false;
if (logFileData1->getBasicTimeStep() != logFileData2->getBasicTimeStep())
return false;
if (logFileData1->getDivergentTimeStep() != logFileData2->getDivergentTimeStep())
return false;
return true;
}
std::shared_ptr<SortedDataL2Norm> L2NormMathematicaAssistant::sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData)
{
std::vector<std::vector<std::shared_ptr<L2NormLogFileData> > > testLogFileData;
std::vector<std::vector<std::string> > basicListNames;
for (int i = 0; i < logFileData->getLogFileData(0)->getL2NormLogFileData().size(); i++) {
std::vector<std::shared_ptr<L2NormLogFileData> > aTestLogFileDataGroup;
aTestLogFileDataGroup.push_back(logFileData->getLogFileData(0)->getL2NormLogFileData().at(i));
std::vector<std::string> aListNameGroup;
aListNameGroup.push_back(logFileData->getLogFileData(0)->getSimulationSigniture());
basicListNames.push_back(aListNameGroup);
}
for (int i = 0; i < logFileData->getGroupSize(); i++) {
for (int j = 0; j < logFileData->getLogFileData(i)->getL2NormLogFileData().size(); j++) {
std::string dataToCalc = logFileData->getLogFileData(i)->getL2NormLogFileData().at(j)->getDataToCalc();
bool added = false;
for (int k = 0; k < testLogFileData.size(); k++) {
if (checkTestParameter(logFileData->getLogFileData(i)->getL2NormLogFileData().at(j), testLogFileData.at(k).at(0))) {
testLogFileData.at(k).push_back(logFileData->getLogFileData(i)->getL2NormLogFileData().at(j));
basicListNames.at(k).push_back(logFileData->getLogFileData(i)->getSimulationSigniture());
added = true;
}
}
if (!added) {
std::vector<std::shared_ptr<L2NormLogFileData> > aTestLogFileDataGroup;
aTestLogFileDataGroup.push_back(logFileData->getLogFileData(i)->getL2NormLogFileData().at(j));
testLogFileData.push_back(aTestLogFileDataGroup);
std::vector<std::string> aListNameGroup;
aListNameGroup.push_back(logFileData->getLogFileData(i)->getSimulationSigniture());
basicListNames.push_back(aListNameGroup);
}
}
}
std::shared_ptr<SortedDataL2Norm> mySortedData = std::shared_ptr<SortedDataL2Norm>(new SortedDataL2Norm);
mySortedData->basicListNames = basicListNames;
mySortedData->testLogFileData = testLogFileData;
return mySortedData;
}
void L2NormMathematicaAssistant::makeL2NormDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
std::vector<std::vector<double> > gridLengths;
std::vector<std::vector<double> > l2NormDiff;
std::vector<std::string> aBasicListNamesList;
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
l2NormDiff.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormDiff());
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
}
std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, "L2NormDiff", sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), sortedData->testLogFileData.at(i).at(0)->getNormalizeData());
addSecondOrderOfAccuracyRef(gridLengths, l2NormDiff, finalListNames);
addFourthOrderOfAccuracyRef(gridLengths, l2NormDiff, finalListNames);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, l2NormDiff, "L[dx]", "L2NormDiff[-]");
}
}
void L2NormMathematicaAssistant::makeL2NormAllTimeStepsMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
std::vector<std::vector<double> > gridLengths;
std::vector<std::vector<double> > l2Norm;
std::vector<std::string> aBasicListNamesList;
std::vector<std::string> basicTimeSteps;
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
l2Norm.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormForBasicTimeStep());
l2Norm.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormForDivergentTimeStep());
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
std::ostringstream aBasicTimeStep;
aBasicTimeStep << "TimeStep" << sortedData->testLogFileData.at(i).at(j)->getBasicTimeStep();
basicTimeSteps.push_back(aBasicTimeStep.str());
std::ostringstream aDivTimeStep;
aDivTimeStep << "TimeStep" << sortedData->testLogFileData.at(i).at(j)->getDivergentTimeStep();
basicTimeSteps.push_back(aDivTimeStep.str());
}
std::vector<std::string> finalListNamesBasic = finalizeListNames(aBasicListNamesList, "L2NormAllTimeSteps", sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), sortedData->testLogFileData.at(i).at(0)->getNormalizeData(), basicTimeSteps);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNamesBasic, gridLengths, l2Norm, "L[dx]", "L2Norm[-]");
}
}
void L2NormMathematicaAssistant::makeL2NormBasicTimeStepMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
std::vector<std::vector<double> > gridLengths;
std::vector<std::vector<double> > l2NormBasic;
std::vector<std::string> aBasicListNamesList;
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
l2NormBasic.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormForBasicTimeStep());
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
}
std::ostringstream basicTimeStep;
basicTimeStep << "TimeStep" << sortedData->testLogFileData.at(i).at(0)->getBasicTimeStep();
std::vector<std::string> finalListNamesBasic = finalizeListNames(aBasicListNamesList, "L2Norm", sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), sortedData->testLogFileData.at(i).at(0)->getNormalizeData(), basicTimeStep.str());
addSecondOrderOfAccuracyRef(gridLengths, l2NormBasic, finalListNamesBasic);
addFourthOrderOfAccuracyRef(gridLengths, l2NormBasic, finalListNamesBasic);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNamesBasic, gridLengths, l2NormBasic, "L[dx]", "L2Norm[-]");
}
}
void L2NormMathematicaAssistant::makeL2NormDivergentTimeStepMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
std::vector<std::vector<double> > gridLengths;
std::vector<std::vector<double> > l2NormDivergent;
std::vector<std::string> aBasicListNamesList;
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
l2NormDivergent.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormForDivergentTimeStep());
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
}
std::ostringstream divTimeStep;
divTimeStep << "TimeStep" << sortedData->testLogFileData.at(i).at(0)->getDivergentTimeStep();
std::vector<std::string> finalListNamesDiv = finalizeListNames(aBasicListNamesList, "L2Norm", sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), sortedData->testLogFileData.at(i).at(0)->getNormalizeData(), divTimeStep.str());
addSecondOrderOfAccuracyRef(gridLengths, l2NormDivergent, finalListNamesDiv);
addFourthOrderOfAccuracyRef(gridLengths, l2NormDivergent, finalListNamesDiv);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNamesDiv, gridLengths, l2NormDivergent, "L[dx]", "L2Norm[-]");
}
}
L2NormMathematicaAssistant::L2NormMathematicaAssistant()
{
}
#ifndef L2NORM_MATHEMATICA_ASSISTANT_H
#define L2NORM_MATHEMATICA_ASSISTANT_H
#include "Utilities/MathematicaAssistant/MathematicaAssistantImp.h"
class MathematicaFunctionFactory;
class L2NormLogFileData;
struct SortedDataL2Norm {
std::vector<std::vector<std::shared_ptr<L2NormLogFileData> > > testLogFileData;
std::vector<std::vector<std::string> > basicListNames;
};
class L2NormMathematicaAssistant : public MathematicaAssistantImp
{
public:
static std::shared_ptr<L2NormMathematicaAssistant> getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory);
void makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile);
private:
L2NormMathematicaAssistant();
L2NormMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory);
bool checkTestParameter(std::shared_ptr<L2NormLogFileData> logFileData1, std::shared_ptr<L2NormLogFileData> logFileData2);
std::shared_ptr<SortedDataL2Norm> sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData);
void makeL2NormDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData);
void makeL2NormAllTimeStepsMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData);
void makeL2NormBasicTimeStepMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData);
void makeL2NormDivergentTimeStepMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2Norm> sortedData);
};
#endif
\ No newline at end of file
......@@ -9,6 +9,7 @@ class L2NormBetweenKernelsLogFileData
public:
virtual std::vector<double> getBasicGridLengths() = 0;
virtual std::string getBasicKernel() = 0;
virtual std::string getDivergentKernel() = 0;
virtual std::string getDataToCalculate() = 0;
virtual int getTimeStep() = 0;
virtual std::vector<double> getL2NormForBasicKernel() = 0;
......
......@@ -15,6 +15,11 @@ std::string L2NormBetweenKernelsLogFileDataImp::getBasicKernel()
return basicKernel;
}
std::string L2NormBetweenKernelsLogFileDataImp::getDivergentKernel()
{
return divergentKernel;
}
std::string L2NormBetweenKernelsLogFileDataImp::getDataToCalculate()
{
return dataToCalc;
......@@ -55,6 +60,11 @@ void L2NormBetweenKernelsLogFileDataImp::setBasicKernel(std::string basicKernel)
this->basicKernel = basicKernel;
}
void L2NormBetweenKernelsLogFileDataImp::setDivergentKernel(std::string divergentKernel)
{
this->divergentKernel = divergentKernel;
}
void L2NormBetweenKernelsLogFileDataImp::setDataToCalculate(std::string dataToCalc)
{
this->dataToCalc = dataToCalc;
......
......@@ -12,6 +12,7 @@ public:
std::vector<double> getBasicGridLengths();
std::string getBasicKernel();
std::string getDivergentKernel();
std::string getDataToCalculate();
int getTimeStep();
std::vector<double> getL2NormForBasicKernel();
......@@ -21,6 +22,7 @@ public:
void setBasicGridLengths(std::vector<double> basicGridLengths);
void setBasicKernel(std::string basicKernel);
void setDivergentKernel(std::string divergentKernel);
void setDataToCalculate(std::string dataToCalc);
void setTimeStep(int timeStep);
void setL2NormForBasicKernel(std::vector<double> l2Norm);
......@@ -35,6 +37,7 @@ private:
std::vector<double> basicGridLengths;
std::string basicKernel;
std::string divergentKernel;
std::string dataToCalc;
int timeStep;
std::vector<double> l2NormForBasicKernel;
......
#include "L2NormBetweenKernelsMathematicaAssistant.h"
#include "Tests/L2NormBetweenKernels/LogFileData/L2NormBetweenKernelsLogFileData.h"
#include "Utilities/LogFileData/LogFileData.h"
#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h"
#include <sstream>
std::shared_ptr<L2NormBetweenKernelsMathematicaAssistant> L2NormBetweenKernelsMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory)
{
return std::shared_ptr<L2NormBetweenKernelsMathematicaAssistant>(new L2NormBetweenKernelsMathematicaAssistant(functionFactory));
}
void L2NormBetweenKernelsMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile)
{
std::shared_ptr<SortedDataL2NormBetweenKernels> mySortedData = sortLogFileData(logFileData);
makeL2NormMathematicaOutput(aMathmaticaFile, mySortedData);
makeL2NormBetweenKernelsMathematicaOutput(aMathmaticaFile, mySortedData);
}
L2NormBetweenKernelsMathematicaAssistant::L2NormBetweenKernelsMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : MathematicaAssistantImp(functionFactory)
{
}
bool L2NormBetweenKernelsMathematicaAssistant::checkTestParameter(std::shared_ptr<L2NormBetweenKernelsLogFileData> logFileData1, std::shared_ptr<L2NormBetweenKernelsLogFileData> logFileData2)
{
if (logFileData1->getBasicKernel() != logFileData2->getBasicKernel())
return false;
if (logFileData1->getNormalizeData() != logFileData2->getNormalizeData())
return false;
if (logFileData1->getTimeStep() != logFileData2->getTimeStep())
return false;
if (logFileData1->getDataToCalculate() != logFileData2->getDataToCalculate())
return false;
return true;
}
std::shared_ptr<SortedDataL2NormBetweenKernels> L2NormBetweenKernelsMathematicaAssistant::sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData)
{
std::vector<std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > > testLogFileData;
std::vector<std::vector<std::string> > basicListNames;
for (int i = 0; i < logFileData->getLogFileData(0)->getL2NormBetweenKernelsLogFileData().size(); i++) {
std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > aTestLogFileDataGroup;
aTestLogFileDataGroup.push_back(logFileData->getLogFileData(0)->getL2NormBetweenKernelsLogFileData().at(i));
std::vector<std::string> aListNameGroup;
aListNameGroup.push_back(logFileData->getLogFileData(0)->getSimulationSigniture());
basicListNames.push_back(aListNameGroup);
}
for (int i = 0; i < logFileData->getGroupSize(); i++) {
for (int j = 0; j < logFileData->getLogFileData(i)->getL2NormBetweenKernelsLogFileData().size(); j++) {
std::string dataToCalc = logFileData->getLogFileData(i)->getL2NormBetweenKernelsLogFileData().at(j)->getDataToCalculate();
bool added = false;
for (int k = 0; k < testLogFileData.size(); k++) {
if (checkTestParameter(logFileData->getLogFileData(i)->getL2NormBetweenKernelsLogFileData().at(j), testLogFileData.at(k).at(0))) {
testLogFileData.at(k).push_back(logFileData->getLogFileData(i)->getL2NormBetweenKernelsLogFileData().at(j));
basicListNames.at(k).push_back(logFileData->getLogFileData(i)->getSimulationSigniture());
added = true;
}
}
if (!added) {
std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > aTestLogFileDataGroup;
aTestLogFileDataGroup.push_back(logFileData->getLogFileData(i)->getL2NormBetweenKernelsLogFileData().at(j));
testLogFileData.push_back(aTestLogFileDataGroup);
std::vector<std::string> aListNameGroup;
aListNameGroup.push_back(logFileData->getLogFileData(i)->getSimulationSigniture());
basicListNames.push_back(aListNameGroup);
}
}
}
std::shared_ptr<SortedDataL2NormBetweenKernels> mySortedData = std::shared_ptr<SortedDataL2NormBetweenKernels>(new SortedDataL2NormBetweenKernels);
mySortedData->basicListNames = basicListNames;
mySortedData->testLogFileData = testLogFileData;
return mySortedData;
}
void L2NormBetweenKernelsMathematicaAssistant::makeL2NormMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2NormBetweenKernels> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
std::vector<std::vector<double> > gridLengths;
std::vector<std::vector<double> > l2Norm;
std::vector<std::string> aListNamesList;
std::vector<std::string> timeSteps;
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
l2Norm.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormForBasicKernel());
l2Norm.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormForDivergentKernel());
aListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
std::string divergentKernel = sortedData->basicListNames.at(i).at(j);
int sizeOfString = sortedData->testLogFileData.at(i).at(j)->getDivergentKernel().size();
divergentKernel.erase(divergentKernel.begin(), divergentKernel.begin() + sizeOfString);
divergentKernel = sortedData->testLogFileData.at(i).at(j)->getBasicKernel() + divergentKernel;
aListNamesList.push_back(divergentKernel);
std::ostringstream timeStep;
timeStep << "TimeStep" << sortedData->testLogFileData.at(i).at(j)->getTimeStep();
timeSteps.push_back(timeStep.str());
timeSteps.push_back(timeStep.str());
}
std::vector<std::string> finalListNames = finalizeListNames(aListNamesList, "L2Norm", sortedData->testLogFileData.at(i).at(0)->getDataToCalculate(), sortedData->testLogFileData.at(i).at(0)->getNormalizeData(), timeSteps);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, l2Norm, "L[dx]", "L2Norm[-]");
}
}
void L2NormBetweenKernelsMathematicaAssistant::makeL2NormBetweenKernelsMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2NormBetweenKernels> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
std::vector<std::vector<double> > gridLengths;
std::vector<std::vector<double> > l2NormBK;
std::vector<std::string> aListNamesList;
std::vector<std::string> timeSteps;
std::vector<std::string> basicKernel;
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
gridLengths.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicGridLengths());
l2NormBK.push_back(sortedData->testLogFileData.at(i).at(j)->getL2NormBetweenKernels());
aListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
basicKernel.push_back(sortedData->testLogFileData.at(i).at(j)->getBasicKernel());
std::ostringstream timeStep;
timeStep << "TimeStep" << sortedData->testLogFileData.at(i).at(j)->getTimeStep();
timeSteps.push_back(timeStep.str());
}
std::vector<std::string> finalListNames = finalizeListNames(aListNamesList, "L2NormBetweenKernels", sortedData->testLogFileData.at(i).at(0)->getDataToCalculate(), sortedData->testLogFileData.at(i).at(0)->getNormalizeData(), timeSteps, basicKernel);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, l2NormBK, "L[dx]", "L2Norm[-]");
}
}
L2NormBetweenKernelsMathematicaAssistant::L2NormBetweenKernelsMathematicaAssistant()
{
}
#ifndef L2NORM_BK_MATHEMATICA_ASSISTANT_H
#define L2NORM_BK_MATHEMATICA_ASSISTANT_H
#include "Utilities/MathematicaAssistant/MathematicaAssistantImp.h"
class MathematicaFunctionFactory;
class L2NormBetweenKernelsLogFileData;
struct SortedDataL2NormBetweenKernels {
std::vector<std::vector<std::shared_ptr<L2NormBetweenKernelsLogFileData> > > testLogFileData;
std::vector<std::vector<std::string> > basicListNames;
};
class L2NormBetweenKernelsMathematicaAssistant : public MathematicaAssistantImp
{
public:
static std::shared_ptr<L2NormBetweenKernelsMathematicaAssistant> getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory);
void makeMathematicaOutput(std::shared_ptr<LogFileDataGroup> logFileData, std::shared_ptr<MathematicaFile> aMathmaticaFile);
private:
L2NormBetweenKernelsMathematicaAssistant();
L2NormBetweenKernelsMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory);
bool checkTestParameter(std::shared_ptr<L2NormBetweenKernelsLogFileData> logFileData1, std::shared_ptr<L2NormBetweenKernelsLogFileData> logFileData2);
std::shared_ptr<SortedDataL2NormBetweenKernels> sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData);
void makeL2NormMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2NormBetweenKernels> sortedData);
void makeL2NormBetweenKernelsMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataL2NormBetweenKernels> sortedData);
};
#endif
\ No newline at end of file
......@@ -19,7 +19,7 @@ void NyMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataGr
makeNyDiffMathematicaOutput(aMathmaticaFile, mySortedData);
}
NyMathematicaAssistant::NyMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : functionFactory(functionFactory)
NyMathematicaAssistant::NyMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : MathematicaAssistantImp(functionFactory)
{
}
......@@ -74,34 +74,6 @@ std::shared_ptr<SortedDataNy> NyMathematicaAssistant::sortLogFileData(std::share
return mySortedData;
}
void NyMathematicaAssistant::addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes)
{
std::vector<std::vector<std::shared_ptr<DataPoint> > > dataPointGroup;
for (int i = 0; i < xAxesData.size(); i++) {
std::vector<std::shared_ptr<DataPoint> > dataPoints;
for (int j = 0; j < xAxesData.at(i).size(); j++)
dataPoints.push_back(DataPoint::getNewInstance(xAxesData.at(i).at(j), yAxesData.at(i).at(j)));
dataPointGroup.push_back(dataPoints);
}
std::vector<std::shared_ptr<MathematicaPointList> > pointList;
for (int i = 0; i < dataPointGroup.size(); i++) {
std::shared_ptr<MathematicaPointList> aPointList = functionFactory->makeMathematicaPointList(aMathmaticaFile, listNames.at(i), dataPointGroup.at(i));
pointList.push_back(aPointList);
}
std::shared_ptr<MathematicaListPlot> listLogLogPlot = functionFactory->makeMathematicaListPlot(aMathmaticaFile, pointList, "ListLogLogPlot", labelXAxes, labelYAxes);
}
std::vector<std::string> NyMathematicaAssistant::finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName)
{
std::vector<std::string> finalListNames;
for (int i = 0; i < basicListNames.size(); i++)
finalListNames.push_back(testName + basicListNames.at(i) + dataToCalc);
return finalListNames;
}
void NyMathematicaAssistant::makeNyDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataNy> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
......@@ -113,8 +85,25 @@ void NyMathematicaAssistant::makeNyDiffMathematicaOutput(std::shared_ptr<Mathema
nyDiff.push_back(sortedData->testLogFileData.at(i).at(j)->getNyDiff());
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
}
std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), "NyDiff");
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, nyDiff, "L[dx]", "Err Ny");
std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, "NyDiff", sortedData->testLogFileData.at(i).at(0)->getDataToCalc());
addSecondOrderOfAccuracyRef(gridLengths, nyDiff, finalListNames);
addFourthOrderOfAccuracyRef(gridLengths, nyDiff, finalListNames);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, nyDiff, "L[dx]", "Err Ny[-]");
}
}
void NyMathematicaAssistant::makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataNy> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
std::vector<std::vector<double>> ooA = sortedData->testLogFileData.at(i).at(j)->getOrderOfAccuracy();
std::string basicListName = sortedData->basicListNames.at(i).at(j);
std::string dataToCalc = sortedData->testLogFileData.at(i).at(j)->getDataToCalc();
std::string finalListName = finalizeListName(basicListName, "NyDiffOrderOfAccuracy", dataToCalc);
addListOfListsToMathematicaFile(aMathmaticaFile, finalListName, ooA);
}
}
}
......
......@@ -25,10 +25,9 @@ private:
bool checkTestParameter(std::shared_ptr<NyLogFileData> logFileData1, std::shared_ptr<NyLogFileData> logFileData2);
std::shared_ptr<SortedDataNy> sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData);
void addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes);
std::vector<std::string> finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName);
void makeNyDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataNy> sortedData);
void makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataNy> sortedData);
std::shared_ptr<MathematicaFunctionFactory> functionFactory;
};
#endif
\ No newline at end of file
#include "PhiMathematicaAssistant.h"
#include "Tests/PhiTest/LogFileData/PhiLogFileData.h"
#include "Utilities/DataPoint/DataPoint.h"
#include "Utilities/LogFileData/LogFileData.h"
#include "Utilities/LogFileData/LogFileDataGroup/LogFileDataGroup.h"
#include "Utilities/MathematicaFunctionFactory/MathematicaFunctionFactory.h"
std::shared_ptr<PhiMathematicaAssistant> PhiMathematicaAssistant::getNewInstance(std::shared_ptr<MathematicaFunctionFactory> functionFactory)
{
......@@ -17,9 +15,11 @@ void PhiMathematicaAssistant::makeMathematicaOutput(std::shared_ptr<LogFileDataG
std::shared_ptr<SortedDataPhi> mySortedData = sortLogFileData(logFileData);
makePhiDiffMathematicaOutput(aMathmaticaFile, mySortedData);
makeOrderOfAccuracyMathematicaOutput(aMathmaticaFile, mySortedData);
}
PhiMathematicaAssistant::PhiMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : functionFactory(functionFactory)
PhiMathematicaAssistant::PhiMathematicaAssistant(std::shared_ptr<MathematicaFunctionFactory> functionFactory) : MathematicaAssistantImp(functionFactory)
{
}
......@@ -74,39 +74,6 @@ std::shared_ptr<SortedDataPhi> PhiMathematicaAssistant::sortLogFileData(std::sha
return mySortedData;
}
void PhiMathematicaAssistant::addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes)
{
std::vector<std::vector<std::shared_ptr<DataPoint> > > dataPointGroup;
for (int i = 0; i < xAxesData.size(); i++) {
std::vector<std::shared_ptr<DataPoint> > dataPoints;
for (int j = 0; j < xAxesData.at(i).size(); j++)
dataPoints.push_back(DataPoint::getNewInstance(xAxesData.at(i).at(j), yAxesData.at(i).at(j)));
dataPointGroup.push_back(dataPoints);
}
std::vector<std::shared_ptr<MathematicaPointList> > pointList;
for (int i = 0; i < dataPointGroup.size(); i++) {
std::shared_ptr<MathematicaPointList> aPointList = functionFactory->makeMathematicaPointList(aMathmaticaFile, listNames.at(i), dataPointGroup.at(i));
pointList.push_back(aPointList);
}
std::shared_ptr<MathematicaListPlot> listLogLogPlot = functionFactory->makeMathematicaListPlot(aMathmaticaFile, pointList, "ListLogLogPlot", labelXAxes, labelYAxes);
}
void PhiMathematicaAssistant::addListOfListsToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::string listNames, std::vector<std::vector<double>> listOfLists)
{
functionFactory->makeMathematicaListOfLists(aMathmaticaFile, listNames, listOfLists);
}
std::vector<std::string> PhiMathematicaAssistant::finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName)
{
std::vector<std::string> finalListNames;
for (int i = 0; i < basicListNames.size(); i++)
finalListNames.push_back(testName + basicListNames.at(i) + dataToCalc);
return finalListNames;
}
void PhiMathematicaAssistant::makePhiDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
......@@ -118,15 +85,24 @@ void PhiMathematicaAssistant::makePhiDiffMathematicaOutput(std::shared_ptr<Mathe
phiDiff.push_back(sortedData->testLogFileData.at(i).at(j)->getPhiDiff());
aBasicListNamesList.push_back(sortedData->basicListNames.at(i).at(j));
}
std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, sortedData->testLogFileData.at(i).at(0)->getDataToCalc(), "PhiDiff");
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, phiDiff, "L[dx]", "Err Phi");
std::vector<std::string> finalListNames = finalizeListNames(aBasicListNamesList, "PhiDiff", sortedData->testLogFileData.at(i).at(0)->getDataToCalc());
addSecondOrderOfAccuracyRef(gridLengths, phiDiff, finalListNames);
addFourthOrderOfAccuracyRef(gridLengths, phiDiff, finalListNames);
addListLogLogPlotToMathematicaFile(aMathmaticaFile, finalListNames, gridLengths, phiDiff, "L[dx]", "Err Phi[-]");
}
}
void PhiMathematicaAssistant::makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData)
{
for (int i = 0; i < sortedData->testLogFileData.size(); i++) {
for (int j = 0; j < sortedData->testLogFileData.at(i).size(); j++) {
std::vector<std::vector<double>> ooA = sortedData->testLogFileData.at(i).at(j)->getOrderOfAccuracy();
std::string basicListName = sortedData->basicListNames.at(i).at(j);
std::string dataToCalc = sortedData->testLogFileData.at(i).at(j)->getDataToCalc();
std::string finalListName = finalizeListName(basicListName, "PhiDiffOrderOfAccuracy", dataToCalc);
addListOfListsToMathematicaFile(aMathmaticaFile, finalListName, ooA);
}
}
}
......
......@@ -25,12 +25,10 @@ private:
bool checkTestParameter(std::shared_ptr<PhiLogFileData> logFileData1, std::shared_ptr<PhiLogFileData> logFileData2);
std::shared_ptr<SortedDataPhi> sortLogFileData(std::shared_ptr<LogFileDataGroup> logFileData);
void addListLogLogPlotToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::vector<std::string> listNames, std::vector<std::vector<double> > xAxesData, std::vector<std::vector<double> > yAxesData, std::string labelXAxes, std::string labelYAxes);
void addListOfListsToMathematicaFile(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::string listNames, std::vector<std::vector<double> > listOfLists);
std::vector<std::string> finalizeListNames(std::vector<std::string> basicListNames, std::string dataToCalc, std::string testName);
void makePhiDiffMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData);
void makeOrderOfAccuracyMathematicaOutput(std::shared_ptr<MathematicaFile> aMathmaticaFile, std::shared_ptr<SortedDataPhi> sortedData);
std::shared_ptr<MathematicaFunctionFactory> functionFactory;
};
#endif
\ No newline at end of file
......@@ -6,13 +6,15 @@
#include <memory>
#include <vector>
enum DataCombination{ EqualSimulationsForDifferentKernels , EqualKernelSimulationsForDifferentViscosities};
class LogFileData;
class LogFileDataGroup;
class LogFileDataAssistant
{
public:
virtual std::vector<std::shared_ptr<LogFileDataGroup> > findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation) = 0;
virtual std::vector<std::shared_ptr<LogFileDataGroup> > findEqualKernelSimulationsForDifferentViscosities(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation) = 0;
virtual std::vector<std::shared_ptr<LogFileDataGroup> > findDataCombination(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation, DataCombination combination) = 0;
};
#endif
\ No newline at end of file
......@@ -96,6 +96,25 @@ std::shared_ptr<LogFileDataAssistant> LogFileDataAssistantImp::getNewInstance()
return std::shared_ptr<LogFileDataAssistant>(new LogFileDataAssistantImp());
}
std::vector<std::shared_ptr<LogFileDataGroup>> LogFileDataAssistantImp::findDataCombination(std::vector<std::shared_ptr<LogFileData>> allLogFileData, BasicSimulation simulation, DataCombination combination)
{
std::vector<std::shared_ptr<LogFileDataGroup>> myLogFileDataGroup;
switch (combination)
{
case EqualSimulationsForDifferentKernels:
myLogFileDataGroup = findEqualSimulationsForDifferentKernels(allLogFileData, simulation);
break;
case EqualKernelSimulationsForDifferentViscosities:
myLogFileDataGroup = findEqualKernelSimulationsForDifferentViscosities(allLogFileData, simulation);
break;
default:
break;
}
return myLogFileDataGroup;
}
std::vector<std::shared_ptr<LogFileDataGroup>> LogFileDataAssistantImp::findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData>> allLogFileData, BasicSimulation simulation)
{
std::shared_ptr<LogFileDataAssistantStrategy> strategy = assistentStrategyFactory->makeLogFileDataAssistantStrategy(simulation);
......
......@@ -11,13 +11,17 @@ class LogFileDataAssistantImp : public LogFileDataAssistant
public:
static std::shared_ptr<LogFileDataAssistant> getNewInstance();
std::vector<std::shared_ptr<LogFileDataGroup> > findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation);
std::vector<std::shared_ptr<LogFileDataGroup> > findEqualKernelSimulationsForDifferentViscosities(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation);
std::vector<std::shared_ptr<LogFileDataGroup> > findDataCombination(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation, DataCombination combination);
protected:
LogFileDataAssistantImp();
std::vector<std::shared_ptr<LogFileDataGroup> > findEqualSimulationsForDifferentKernels(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation);
std::vector<std::shared_ptr<LogFileDataGroup> > findEqualKernelSimulationsForDifferentViscosities(std::vector<std::shared_ptr<LogFileData> > allLogFileData, BasicSimulation simulation);
std::vector<std::shared_ptr<LogFileData> > getSimulationGroupLogFileData(std::string simName, std::vector<std::shared_ptr<LogFileData> > allLogFileData);
std::vector<std::vector<std::shared_ptr<LogFileData> > > sortLogFileDataAfterKernels(std::vector<std::shared_ptr<LogFileData> > logFileData);
......
......@@ -52,6 +52,8 @@ std::shared_ptr<LogFileData> LogFileReader::readLogFileToLogFileData(std::string
logFileData->setSimName(StringUtil::toString(input->getValue("SimulationName")));
std::ostringstream simSigniture;
if (logFileData->getSimName() == "ShearWave") {
std::vector<double> shearWaveLx = StringUtil::toDoubleVector(input->getValue("Lx"));
......@@ -143,7 +145,7 @@ std::shared_ptr<LogFileData> LogFileReader::readLogFileToLogFileData(std::string
simTime.push_back(StringUtil::toInt(simTimeString));
resultsCheckTime.push_back(StringUtil::toDouble(resultCheckTimeString));
testTime.push_back(StringUtil::toDouble(testTimeString));
analyticalVTKWritingTimeString.push_back(StringUtil::toInt(analyticalVTKWritingTimeString));
analyticalVTKWritingTime.push_back(StringUtil::toInt(analyticalVTKWritingTimeString));
}
logFileData->setVTKFileWriting(StringUtil::toBool(input->getValue("VTKFileWriting")));
......@@ -185,7 +187,6 @@ std::shared_ptr<LogFileData> LogFileReader::readLogFileToLogFileData(std::string
phiDiff.push_back(StringUtil::toDouble(input->getValue(phiDiffString.str())));
}
for (int k = j + 1; k < logFileData->getBasicGridLengths().size(); k++) {
std::vector<double> aOrderOfAccuracyGroup;
std::ostringstream phiDiffOOA, phiDiffBasicOOA;
......@@ -346,14 +347,16 @@ std::shared_ptr<LogFileData> LogFileReader::readLogFileToLogFileData(std::string
std::vector<std::string> normalizeData = StringUtil::toStringVector(input->getValue("NormalizeWith_L2Norm_BK"));
std::vector<std::string> failL2Norm = StringUtil::toStringVector(input->getValue("FailTests_L2Norm_BK"));
std::vector<double> l2NormBasicKernel;
std::vector<double> l2NormDivergentKernel;
std::vector<double> l2NormBetweenKernels;
for (int i = 0; i < dataToCalc.size(); i++) {
for (int j = 0; j < timeSteps.size(); j++) {
for (int k = 0; k < normalizeData.size(); k++) {
std::vector<double> l2NormBasicKernel;
std::vector<double> l2NormDivergentKernel;
std::vector<double> l2NormBetweenKernels;
std::shared_ptr<L2NormBetweenKernelsLogFileDataImp> aL2NormLogFileData = L2NormBetweenKernelsLogFileDataImp::getNewInstance();
aL2NormLogFileData->setBasicKernel(StringUtil::toString(input->getValue("BasicKernel_L2Norm_BK")));
aL2NormLogFileData->setDivergentKernel(logFileData->getKernel());
aL2NormLogFileData->setDataToCalculate(dataToCalc.at(i));
aL2NormLogFileData->setTimeStep(timeSteps.at(j));
aL2NormLogFileData->setNormalizeData(normalizeData.at(k));
......
......@@ -4,6 +4,8 @@
#include <memory>
#include <vector>
enum Assistant{Phi, Ny, L2Norm, L2NormBetweenKernels, Time };
class LogFileDataGroup;
class MathematicaFile;
......
#ifndef MATHEMATICA_ASSISTANT_FACTORY_H
#define MATHEMATICA_ASSISTANT_FACTORY_H
#include "../MathematicaAssistant.h"
#include <memory>
#include <vector>
class MathematicaFunctionFactory;
class MathematicaAssistantFactory
{
public:
virtual std::vector<std::shared_ptr<MathematicaAssistant> > makeMathematicaAssistants(std::vector<Assistant> types, std::shared_ptr<MathematicaFunctionFactory> functionFactory) = 0;
};
#endif
\ No newline at end of file
#include "MathematicaAssistantFactoryImp.h"
#include "Tests/PhiTest/MathematicaAssistant/PhiMathematicaAssistant.h"
#include "Tests/NyTest/MathematicaAssistant/NyMathematicaAssistant.h"
#include "Tests/L2Norm/MathematicaAssistant/L2NormMathematicaAssistant.h"
#include "Tests/L2NormBetweenKernels/MathematicaAssistant/L2NormBetweenKernelsMathematicaAssistant.h"
#include "Utilities/MathematicaAssistant/TimeAssistant/TimeMathematicaAssistant.h"
std::shared_ptr<MathematicaAssistantFactory> MathematicaAssistantFactoryImp::getNewInstance()
{
return std::shared_ptr<MathematicaAssistantFactory>(new MathematicaAssistantFactoryImp());
}
std::vector<std::shared_ptr<MathematicaAssistant>> MathematicaAssistantFactoryImp::makeMathematicaAssistants(std::vector<Assistant> types, std::shared_ptr<MathematicaFunctionFactory> functionFactory)
{
std::vector<std::shared_ptr<MathematicaAssistant>> myAssistants;
for(int i = 0; i < types.size(); i++){
switch (types.at(i))
{
case Phi:
myAssistants.push_back(PhiMathematicaAssistant::getNewInstance(functionFactory));
break;
case Ny:
myAssistants.push_back(NyMathematicaAssistant::getNewInstance(functionFactory));
break;
case L2Norm:
myAssistants.push_back(L2NormMathematicaAssistant::getNewInstance(functionFactory));
break;
case L2NormBetweenKernels:
myAssistants.push_back(L2NormBetweenKernelsMathematicaAssistant::getNewInstance(functionFactory));
break;
case Time:
myAssistants.push_back(TimeMathematicaAssistant::getNewInstance(functionFactory));
break;
default:
break;
}
}
return myAssistants;
}
MathematicaAssistantFactoryImp::MathematicaAssistantFactoryImp()
{
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment