VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
NumericalTestFactoryImp.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
34
42
48
54
60
61#include "Tests/NyTest/NyTest.h"
73
78
86
91
92#include <algorithm>
93
94
95std::shared_ptr<NumericalTestFactoryImp> NumericalTestFactoryImp::getNewInstance(std::shared_ptr<ConfigDataStruct> configFileData)
96{
97 return std::shared_ptr<NumericalTestFactoryImp>(new NumericalTestFactoryImp(configFileData));
98}
99
100NumericalTestFactoryImp::NumericalTestFactoryImp(std::shared_ptr<ConfigDataStruct> configFileData)
101{
103 myTestQueue = TestQueueImp::getNewInstance(colorOutput);
104 myLogFileWriterQueue = LogFileQueueImp::getNewInstance(configFileData->logFilePath);
105 anaResultWriter = AnalyticalResults2DToVTKWriterImp::getInstance(configFileData->writeAnalyticalToVTK);
106 l2NormCalculatorFactory = L2NormCalculatorFactoryImp::getInstance();
107 l2NormTestsBetweenKernels.resize(0);
108 init(configFileData);
109}
110
111std::vector<std::shared_ptr<TestSimulation> > NumericalTestFactoryImp::getTestSimulations()
112{
113 return myTestSimulations;
114}
115
116std::shared_ptr<TestQueue> NumericalTestFactoryImp::getTestQueue()
117{
118 return myTestQueue;
119}
120
121std::shared_ptr<LogFileQueue> NumericalTestFactoryImp::getLogFileQueue()
122{
123 return myLogFileWriterQueue;
124}
125
126void NumericalTestFactoryImp::init(std::shared_ptr<ConfigDataStruct> configFileData)
127{
128 simID = 1;
129 numberOfSimulations = configFileData->numberOfSimulations;
130
131 for (size_t i = 0; i < configFileData->kernelsToTest.size(); i++) {
132 for (size_t j = 0; j < configFileData->viscosity.size(); j++) {
133 for (size_t k = 0; k < configFileData->taylorGreenVortexUxParameter.size(); k++) {
134 std::shared_ptr<SimulationDataStruct> simDataStruct = makeTaylorGreenUxSimulationData(configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUxParameter.at(k), configFileData->taylorGreenVortexUxGridInformation);
135 if (simDataStruct->simGroupRun) {
136 std::shared_ptr<NumericalTestStruct> numericalTestStruct = makeNumericalTestStruct(configFileData, simDataStruct, configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUxParameter.at(k)->basicTimeStepLength);
137 addNumericalTestStruct(numericalTestStruct);
138 }
139 }
140
141 for (size_t k = 0; k < configFileData->taylorGreenVortexUzParameter.size(); k++) {
142 std::shared_ptr<SimulationDataStruct> simDataStruct = makeTaylorGreenUzSimulationData(configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUzParameter.at(k), configFileData->taylorGreenVortexUzGridInformation);
143 if (simDataStruct->simGroupRun) {
144 std::shared_ptr<NumericalTestStruct> numericalTestStruct = makeNumericalTestStruct(configFileData, simDataStruct, configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->taylorGreenVortexUzParameter.at(k)->basicTimeStepLength);
145 addNumericalTestStruct(numericalTestStruct);
146 }
147 }
148
149 for (size_t k = 0; k < configFileData->shearWaveParameter.size(); k++) {
150 std::shared_ptr<SimulationDataStruct> simDataStruct = makeShearWaveSimulationData(configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->shearWaveParameter.at(k), configFileData->shearWaveGridInformation);
151 if (simDataStruct->simGroupRun) {
152 std::shared_ptr<NumericalTestStruct> numericalTestStruct = makeNumericalTestStruct(configFileData, simDataStruct, configFileData->kernelsToTest.at(i), configFileData->viscosity.at(j), configFileData->shearWaveParameter.at(k)->basicTimeStepLength);
153 addNumericalTestStruct(numericalTestStruct);
154 }
155
156 }
157
158 }
159 }
160}
161
162std::shared_ptr<NumericalTestStruct> NumericalTestFactoryImp::makeNumericalTestStruct(std::shared_ptr<ConfigDataStruct> configFileData, std::shared_ptr<SimulationDataStruct> simDataStruct, std::string kernel, double viscosity, int basicTimeStepLength)
163{
164 std::shared_ptr<NumericalTestStruct> numTestStruct = std::shared_ptr<NumericalTestStruct>(new NumericalTestStruct);
165
166 std::vector<std::shared_ptr<TestSimulationImp> > testSim = makeTestSimulations(simDataStruct->testSimData, configFileData->vectorWriterInfo, configFileData->ySliceForCalculation);
167 numTestStruct->testSimulations = testSim;
168 std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo = BasicTestLogFileInformation::getNewInstance();
169 std::vector<std::shared_ptr<TestLogFileInformation> > testLogFileInfo;
170
171 std::shared_ptr<TestStruct> phiTestStruct = makePhiTestsStructs(configFileData->phiTestParameter, testSim, viscosity);
173
174 std::shared_ptr<TestStruct> nyTestStruct = makeNyTestsStructs(configFileData->nyTestParameter, testSim, viscosity);
176
177 std::shared_ptr<TestStruct> l2NormTestSruct = makeL2NormTestsStructs(configFileData->l2NormTestParameter, testSim);
179
180 std::shared_ptr<TestStruct> l2NormTestBetweenKernelStruct = makeL2NormTestsBetweenKernelsStructs(configFileData->l2NormTestBetweenKernelsParameter, testSim, kernel);
182
183 std::vector<std::shared_ptr<SimulationInfo> > simInfo;
184 for (size_t i = 0; i < simDataStruct->testSimData.size(); i++)
185 simInfo.push_back(simDataStruct->testSimData.at(i)->simInformation);
186
187 std::shared_ptr<LogFileWriter> logFileWriter = makeLogFileWriter(testLogFileInfo, simDataStruct->logFileInformation, simInfo, kernel, viscosity, basicTimeStepLength, configFileData->logFilePara, basicTestLogFileInfo);
188 numTestStruct->logFileWriter = logFileWriter;
189
190 return numTestStruct;
191}
192
193void NumericalTestFactoryImp::addNumericalTestStruct(std::shared_ptr<NumericalTestStruct> numericalTestStruct)
194{
195 for (size_t i = 0; i < numericalTestStruct->testSimulations.size(); i++)
196 myTestSimulations.push_back(numericalTestStruct->testSimulations.at(i));
197
198 for (size_t i = 0; i < numericalTestStruct->tests.size(); i++)
199 myTestQueue->addTest(numericalTestStruct->tests.at(i));
200
201 myLogFileWriterQueue->addLogFileWriter(numericalTestStruct->logFileWriter);
202}
203
204std::shared_ptr<SimulationDataStruct> NumericalTestFactoryImp::makeTaylorGreenUxSimulationData(std::string kernel, double viscosity, std::shared_ptr<TaylorGreenVortexUxParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct)
205{
206 std::shared_ptr<SimulationDataStruct> simDataStruct = std::shared_ptr<SimulationDataStruct>(new SimulationDataStruct);
207
208 if (gridInfoStruct.size() > 0) {
209 for (size_t i = 0; i < gridInfoStruct.size(); i++) {
210 std::shared_ptr<TestSimulationDataStruct> aTestSimData = std::shared_ptr<TestSimulationDataStruct>(new TestSimulationDataStruct);
213 aTestSimData->simInformation = SimulationInfoTaylorGreenUx::getNewInstance(simID, kernel, viscosity, simParaStruct, gridInfoStruct.at(i), numberOfSimulations);
214 simID++;
216 simDataStruct->testSimData.push_back(aTestSimData);
217 }
219 simDataStruct->simGroupRun = true;
220 }
221 else {
222 simDataStruct->simGroupRun = false;
223 }
224 return simDataStruct;
225}
226
227std::shared_ptr<SimulationDataStruct> NumericalTestFactoryImp::makeTaylorGreenUzSimulationData(std::string kernel, double viscosity, std::shared_ptr<TaylorGreenVortexUzParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct)
228{
229 std::shared_ptr<SimulationDataStruct> simDataStruct = std::shared_ptr<SimulationDataStruct>(new SimulationDataStruct);
230 if (gridInfoStruct.size() > 0) {
231 for (size_t i = 0; i < gridInfoStruct.size(); i++) {
232 std::shared_ptr<TestSimulationDataStruct> aTestSimData = std::shared_ptr<TestSimulationDataStruct>(new TestSimulationDataStruct);
235 aTestSimData->simInformation = SimulationInfoTaylorGreenUz::getNewInstance(simID, kernel, viscosity, simParaStruct, gridInfoStruct.at(i), numberOfSimulations);
236 simID++;
238 simDataStruct->testSimData.push_back(aTestSimData);
239 }
241 simDataStruct->simGroupRun = true;
242 }
243 else {
244 simDataStruct->simGroupRun = false;
245 }
246 return simDataStruct;
247}
248
249std::shared_ptr<SimulationDataStruct> NumericalTestFactoryImp::makeShearWaveSimulationData(std::string kernel, double viscosity, std::shared_ptr<ShearWaveParameterStruct> simParaStruct, std::vector<std::shared_ptr<GridInformationStruct> > gridInfoStruct)
250{
251 std::shared_ptr<SimulationDataStruct> simDataStruct = std::shared_ptr<SimulationDataStruct>(new SimulationDataStruct);
252 if (gridInfoStruct.size() > 0) {
253 for (size_t i = 0; i < gridInfoStruct.size(); i++) {
254 std::shared_ptr<TestSimulationDataStruct> aTestSimData = std::shared_ptr<TestSimulationDataStruct>(new TestSimulationDataStruct);
257 aTestSimData->simInformation = ShearWaveSimulationInfo::getNewInstance(simID, kernel, viscosity, simParaStruct, gridInfoStruct.at(i), numberOfSimulations);
258 simID++;
260 simDataStruct->testSimData.push_back(aTestSimData);
261 }
263 simDataStruct->simGroupRun = true;
264 }
265 else {
266 simDataStruct->simGroupRun = false;
267 }
268 return simDataStruct;
269}
270
271std::vector<std::shared_ptr<TestSimulationImp> > NumericalTestFactoryImp::makeTestSimulations(std::vector<std::shared_ptr<TestSimulationDataStruct> > testSimDataStruct, std::shared_ptr<VectorWriterInformationStruct> vectorWriterInfo, unsigned int ySliceForCalculation)
272{
273 std::vector<std::shared_ptr<TestSimulationImp> > testSimulations;
274 for (size_t i = 0; i < testSimDataStruct.size(); i++) {
275 std::shared_ptr<TimeImp> time = TimeImp::getNewInstance();
276 testSimDataStruct.at(i)->simInformation->setTimeInfo(time);
277 std::shared_ptr<SimulationResults> simResult = SimulationResults::getNewInstance(testSimDataStruct.at(i)->simParameter);
278 std::shared_ptr<ToVectorWriter> toVectorWriter = Y2dSliceToResults::getNewInstance(vectorWriterInfo, testSimDataStruct.at(i)->simParameter->getTimeStepLength(), simResult, ySliceForCalculation);
279
280
282 auto para = vf::gpu::tests::makeParameter(currentTestSimData->simParameter);
283 currentTestSimData->initialCondition->setParameter(para);
284 auto vfsim = vf::gpu::tests::makeVirtualFluidSimulation(para, currentTestSimData->initialCondition, toVectorWriter);
285
286 auto testSim = std::make_shared<TestSimulationImp>(vfsim, currentTestSimData, simResult, time, toVectorWriter, anaResultWriter, colorOutput);
287 testSim->setParameter(para);
288
289 testSimulations.push_back(testSim);
290 }
291
292 return testSimulations;
293}
294
295std::shared_ptr<TestStruct> NumericalTestFactoryImp::makePhiTestsStructs(std::shared_ptr<PhiTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSimumlations, double viscosity)
296{
297 std::shared_ptr<TestStruct> testStruct = std::shared_ptr<TestStruct>(new TestStruct);
298
299 if (testParameter->basicTestParameter->runTest && testSimumlations.size() > 1) {
300 std::shared_ptr<PhiTestLogFileInformation> testLogFileInfo = PhiTestLogFileInformation::getNewInstance(testParameter);
301
302 std::vector<std::shared_ptr<PhiTestPostProcessingStrategy> > postProcessingStrategies;
303 for (size_t i = 0; i < testSimumlations.size(); i++)
304 postProcessingStrategies.push_back(PhiTestPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, testSimumlations.at(i)->getDataToCalcTests()));
305
306 for (size_t i = 0; i < testSimumlations.at(0)->getDataToCalcTests().size(); i++) {
307 std::vector<std::shared_ptr<PhiTest> > phiTests = makePhiTests(testParameter, testSimumlations, postProcessingStrategies, viscosity, testSimumlations.at(0)->getDataToCalcTests().at(i));
308 testLogFileInfo->addTestGroup(phiTests);
309 for (size_t j = 0; j < phiTests.size(); j++)
310 testStruct->tests.push_back(phiTests.at(j));
311 }
312 testStruct->logFileInfo = testLogFileInfo;
313 testStruct->testName = "PhiTest";
314 }
315
316 return testStruct;
317}
318
319std::vector<std::shared_ptr<PhiTest>> NumericalTestFactoryImp::makePhiTests(std::shared_ptr<PhiTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector<std::shared_ptr<PhiTestPostProcessingStrategy>> phiPostProStrategy, double viscosity, std::string dataToCalculate)
320{
321 std::vector<std::shared_ptr<PhiTest> > phiTests;
322 for (size_t i = 1; i < testSim.size(); i++) {
323 for (size_t j = 0; j < i; j++) {
324 std::shared_ptr<PhiTest> test = PhiTest::getNewInstance(colorOutput, viscosity, testParameter, dataToCalculate);
325 test->addSimulation(testSim.at(j), testSim.at(j)->getSimulationInfo(), phiPostProStrategy.at(j));
326 test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), phiPostProStrategy.at(i));
327
328 testSim.at(j)->registerSimulationObserver(test);
329 testSim.at(i)->registerSimulationObserver(test);
330
331 phiTests.push_back(test);
332 }
333 }
334 return phiTests;
335}
336
337std::shared_ptr<TestStruct> NumericalTestFactoryImp::makeNyTestsStructs(std::shared_ptr<NyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSimumlations, double viscosity)
338{
339 std::shared_ptr<TestStruct> testStruct = std::shared_ptr<TestStruct>(new TestStruct);
340
341 if (testParameter->basicTestParameter->runTest && testSimumlations.size() > 1) {
342 std::shared_ptr<NyTestLogFileInformation> testLogFileInfo = NyTestLogFileInformation::getNewInstance(testParameter);
343
344 std::vector<std::shared_ptr<NyTestPostProcessingStrategy> > postProcessingStrategies;
345 for (size_t i = 0; i < testSimumlations.size(); i++)
346 postProcessingStrategies.push_back(NyTestPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, testSimumlations.at(i)->getDataToCalcTests()));
347
348 for (size_t i = 0; i < testSimumlations.at(0)->getDataToCalcTests().size(); i++) {
349 std::vector<std::shared_ptr<NyTest> > nyTests = makeNyTests(testParameter, testSimumlations, postProcessingStrategies, viscosity, testSimumlations.at(0)->getDataToCalcTests().at(i));
350 testLogFileInfo->addTestGroup(nyTests);
351 for (size_t j = 0; j < nyTests.size(); j++)
352 testStruct->tests.push_back(nyTests.at(j));
353 }
354 testStruct->logFileInfo = testLogFileInfo;
355 testStruct->testName = "NyTest";
356 }
357
358 return testStruct;
359}
360
361std::vector<std::shared_ptr<NyTest>> NumericalTestFactoryImp::makeNyTests(std::shared_ptr<NyTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp>> testSim, std::vector<std::shared_ptr<NyTestPostProcessingStrategy>> nuPostProStrategy, double viscosity, std::string dataToCalculate)
362{
363 std::vector<std::shared_ptr<NyTest> > nyTests;
364 for (size_t i = 1; i < testSim.size(); i++) {
365 for (size_t j = 0; j < i; j++) {
366 std::shared_ptr<NyTest> test = NyTest::getNewInstance(colorOutput, viscosity, testParameter, dataToCalculate);
367 test->addSimulation(testSim.at(j), testSim.at(j)->getSimulationInfo(), nuPostProStrategy.at(j));
368 test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), nuPostProStrategy.at(i));
369
370 testSim.at(j)->registerSimulationObserver(test);
371 testSim.at(i)->registerSimulationObserver(test);
372
373 nyTests.push_back(test);
374 }
375 }
376 return nyTests;
377}
378
379std::shared_ptr<TestStruct> NumericalTestFactoryImp::makeL2NormTestsStructs(std::shared_ptr<L2NormTestParameterStruct> testParameter, std::vector<std::shared_ptr<TestSimulationImp> > testSimumlations)
380{
381 std::shared_ptr<TestStruct> testStruct = std::shared_ptr<TestStruct> (new TestStruct);
382
383 if (testParameter->basicTestParameter->runTest) {
384 std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > postProcessingStrategies;
385 for (size_t i = 0; i < testSimumlations.size(); i++)
386 postProcessingStrategies.push_back(L2NormPostProcessingStrategy::getNewInstance(testSimumlations.at(i)->getSimulationResults(), testSimumlations.at(i)->getAnalyticalResults(), testParameter, l2NormCalculatorFactory, testSimumlations.at(i)->getDataToCalcTests()));
387
388 std::vector<std::shared_ptr<L2NormTest> > tests = makeL2NormTests(testSimumlations, postProcessingStrategies, testParameter);
389 std::shared_ptr<L2NormInformation> testLogFileInfo = L2NormInformation::getNewInstance(tests, testParameter, testSimumlations.at(0)->getDataToCalcTests());
390
391 for(size_t i = 0; i < tests.size(); i++)
392 testStruct->tests.push_back(tests.at(i));
393 testStruct->logFileInfo = testLogFileInfo;
394 testStruct->testName = "L2NormTest";
395 }
396 return testStruct;
397}
398
399std::vector<std::shared_ptr<L2NormTest> > NumericalTestFactoryImp::makeL2NormTests(std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormPostProcessingStrategy> > postProStrategy, std::shared_ptr<L2NormTestParameterStruct> testParameter)
400{
401 std::vector<std::shared_ptr<L2NormTest> > l2Tests;
402 for (size_t k = 0; k < testParameter->normalizeData.size(); k++) {
403 for (size_t i = 0; i < testSim.size(); i++) {
404 for (size_t j = 0; j < testSim.at(i)->getDataToCalcTests().size(); j++) {
405 std::shared_ptr<L2NormTest> test = L2NormTest::getNewInstance(colorOutput, testParameter, testSim.at(i)->getDataToCalcTests().at(j), testParameter->maxDiff.at(k), testParameter->normalizeData.at(k));
406 test->addSimulation(testSim.at(i), testSim.at(i)->getSimulationInfo(), postProStrategy.at(i));
407 testSim.at(i)->registerSimulationObserver(test);
408 l2Tests.push_back(test);
409 }
410 }
411 }
412 return l2Tests;
413}
414
415std::shared_ptr<TestStruct> NumericalTestFactoryImp::makeL2NormTestsBetweenKernelsStructs(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::string kernelName)
416{
417 std::shared_ptr<TestStruct> testStruct = std::shared_ptr<TestStruct>(new TestStruct);
418 testStruct->testName = "L2NormTestBetweenKernel";
419
420 if (testPara->basicTestParameter->runTest) {
421
422 std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies;
423 for (size_t i = 0; i < testSim.size(); i++)
424 postProcessingStrategies.push_back(L2NormBetweenKernelPostProcessingStrategy::getNewInstance(testSim.at(i)->getSimulationResults(), testSim.at(i)->getAnalyticalResults(), testPara, l2NormCalculatorFactory, testSim.at(i)->getDataToCalcTests()));
425
426 if (kernelName == testPara->basicKernel) {
427 std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > tests = makeL2NormTestsBetweenKernels(testPara, testSim, postProcessingStrategies);
428
429 if (l2NormTestsBetweenKernels.size() == 0) {
430 l2NormTestsBetweenKernels = tests;
431 }
432 else {
433 for (size_t i = 0; i < tests.size(); i++)
434 for (size_t j = 0; j < tests.at(i).size(); j++)
435 l2NormTestsBetweenKernels.at(i).push_back(tests.at(i).at(j));
436 }
437
438 }else{
439 std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests = linkL2NormTestsBetweenKernels(testPara, testSim, postProcessingStrategies);
440 for (size_t i = 0; i < tests.size(); i++)
441 testStruct->tests.push_back(tests.at(i));
442 testStruct->logFileInfo = L2NormBetweenKernelsInformation::getNewInstance(tests, testPara, testSim.at(0)->getDataToCalcTests());
443 }
444 }
445 return testStruct;
446}
447
448std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > NumericalTestFactoryImp::makeL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies)
449{
450 std::vector<std::vector<std::shared_ptr<L2NormTestBetweenKernels> > > testsForAllKernels;
451
452 std::vector<std::shared_ptr<L2NormTestBetweenKernels> > testForOneKernel;
453
454 for (size_t l = 0; l < testPara->kernelsToTest.size() - 1; l++) {
455 for (size_t k = 0; k < testSim.size(); k++) {
456 for(size_t j = 0; j < testSim.at(k)->getDataToCalcTests().size(); j++){
457 for (size_t m = 0; m < testPara->normalizeData.size(); m++) {
458 for (size_t i = 0; i < testPara->timeSteps.size(); i++) {
459 std::shared_ptr<L2NormTestBetweenKernels> aTest = L2NormTestBetweenKernels::getNewInstance(colorOutput, testSim.at(k)->getDataToCalcTests().at(j), testPara->timeSteps.at(i), testPara->normalizeData.at(m), l2NormCalculatorFactory);
460 aTest->setBasicSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k));
461 testSim.at(k)->registerSimulationObserver(aTest);
462 testForOneKernel.push_back(aTest);
463 }
464 }
465 }
466 }
468 testForOneKernel.resize(0);
469 }
470
471 return testsForAllKernels;
472}
473
474std::vector<std::shared_ptr<L2NormTestBetweenKernels> > NumericalTestFactoryImp::linkL2NormTestsBetweenKernels(std::shared_ptr<L2NormTestBetweenKernelsParameterStruct> testPara, std::vector<std::shared_ptr<TestSimulationImp> > testSim, std::vector<std::shared_ptr<L2NormBetweenKernelPostProcessingStrategy> > postProcessingStrategies)
475{
476 std::vector<std::shared_ptr<L2NormTestBetweenKernels> > tests;
477
478 if (testSim.size() > 0)
479 if (l2NormTestsBetweenKernels.at(0).size() == 0)
480 l2NormTestsBetweenKernels.erase(l2NormTestsBetweenKernels.begin());
481
482 for (size_t k = 0; k < testSim.size(); k++) {
483 for (size_t j = 0; j < testSim.at(k)->getDataToCalcTests().size(); j++) {
484 for (size_t m = 0; m < testPara->normalizeData.size(); m++) {
485 for (size_t i = 0; i < testPara->timeSteps.size(); i++) {
486 std::shared_ptr<L2NormTestBetweenKernels> aTest = l2NormTestsBetweenKernels.at(0).at(0);
487 l2NormTestsBetweenKernels.at(0).erase(l2NormTestsBetweenKernels.at(0).begin());
488 aTest->setDivergentKernelSimulation(testSim.at(k), testSim.at(k)->getSimulationInfo(), postProcessingStrategies.at(k));
489 testSim.at(k)->registerSimulationObserver(aTest);
490 tests.push_back(aTest);
491 }
492 }
493 }
494 }
495 return tests;
496}
497
498void NumericalTestFactoryImp::initTestStruct(std::shared_ptr<TestStruct> testStruct, std::shared_ptr<NumericalTestStruct> numericalTestStruct, std::vector<std::shared_ptr<TestLogFileInformation> > &testLogFileInfo, std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo)
499{
500 for (size_t i = 0; i < testStruct->tests.size(); i++)
501 numericalTestStruct->tests.push_back(testStruct->tests.at(i));
502 if (testStruct->tests.size() > 0) {
503 testLogFileInfo.push_back(testStruct->logFileInfo);
504 basicTestLogFileInfo->addTest(testStruct->testName, true);
505 }
506 else {
507 basicTestLogFileInfo->addTest(testStruct->testName, false);
508 }
509}
510
511std::shared_ptr<LogFileWriter> NumericalTestFactoryImp::makeLogFileWriter(std::vector<std::shared_ptr<TestLogFileInformation> > testLogFiles, std::shared_ptr<SimulationLogFileInformation> simLogInfo, std::vector<std::shared_ptr<SimulationInfo> > simInfo, std::string kernel, double viscosity, int basicTimeStepLength, std::shared_ptr<LogFileParameterStruct> logFilePara, std::shared_ptr<BasicTestLogFileInformation> basicTestLogFileInfo)
512{
513 std::shared_ptr<LogFileHead> logFileHead = LogFileHead::getNewInstance(logFilePara->devices);
514 std::shared_ptr<BasicSimulationInfo> basicSimInfo = BasicSimulationInfo::getNewInstance(logFilePara->numberOfTimeSteps, viscosity, basicTimeStepLength, kernel);
515
516 std::shared_ptr<LogFileTimeInformation> logFileTimeInfo = LogFileTimeInformation::getNewInstance(simInfo, logFilePara->writeAnalyticalToVTK);
517
518 std::shared_ptr<LogFileWriterImp> logFileWriter = LogFileWriterImp::getNewInstance(logFileHead, basicSimInfo, basicTestLogFileInfo, testLogFiles, logFileTimeInfo, simLogInfo, kernel, viscosity);
519
520 return logFileWriter;
521}
static std::shared_ptr< PhiTestLogFileInformation > getNewInstance(std::shared_ptr< PhiTestParameterStruct > testPara)
static std::shared_ptr< ColorConsoleOutput > getInstance()
static std::shared_ptr< LogFileWriterImp > getNewInstance(std::shared_ptr< LogFileHead > logFileHead, std::shared_ptr< BasicSimulationInfo > basicSimInfo, std::shared_ptr< BasicTestLogFileInformation > basicTestInfo, std::vector< std::shared_ptr< TestLogFileInformation > > testLogFiles, std::shared_ptr< LogFileTimeInformation > logFileTimeInfo, std::shared_ptr< SimulationLogFileInformation > simLogInfo, std::string kernel, double viscosity)
static std::shared_ptr< Y2dSliceToResults > getNewInstance(std::shared_ptr< VectorWriterInformationStruct > vectorWriterInfo, unsigned int timeStepLength, std::shared_ptr< SimulationResults > simResults, unsigned int ySliceForCalculation)
static std::shared_ptr< TimeImp > getNewInstance()
Definition TimeImp.cpp:37
static std::shared_ptr< LogFileInformationTaylorGreenUz > getNewInstance(std::shared_ptr< TaylorGreenVortexUzParameterStruct > simParaStruct, std::vector< std::shared_ptr< GridInformationStruct > > gridInfoStruct)
static std::shared_ptr< PhiTest > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput, double viscosity, std::shared_ptr< PhiTestParameterStruct > testPara, std::string dataToCalculate)
Definition PhiTest.cpp:47
static std::shared_ptr< InitialConditionTaylorGreenUz > getNewInstance(std::shared_ptr< TaylorGreenVortexUzParameterStruct > simParaStruct, std::shared_ptr< GridInformationStruct > gridInfoStruct)
static std::shared_ptr< AnalyticalResults2DToVTKWriterImp > getInstance(bool writeAnalyticalResults)
std::shared_ptr< TestQueue > getTestQueue()
static std::shared_ptr< L2NormBetweenKernelPostProcessingStrategy > getNewInstance(std::shared_ptr< SimulationResults > simResult, std::shared_ptr< AnalyticalResults > analyticalResult, std::shared_ptr< L2NormTestBetweenKernelsParameterStruct > testPara, std::shared_ptr< L2NormCalculatorFactory > factory, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< ShearWaveInformation > getNewInstance(std::shared_ptr< ShearWaveParameterStruct > simParaStruct, std::vector< std::shared_ptr< GridInformationStruct > > gridInfoStruct)
static std::shared_ptr< NumericalTestFactoryImp > getNewInstance(std::shared_ptr< ConfigDataStruct > configFileData)
static std::shared_ptr< L2NormInformation > getNewInstance(std::vector< std::shared_ptr< L2NormTest > > tests, std::shared_ptr< L2NormTestParameterStruct > testParameter, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< InitialConditionShearWave > getNewInstance(std::shared_ptr< ShearWaveParameterStruct > simParaStruct, std::shared_ptr< GridInformationStruct > gridInfoStruct)
static std::shared_ptr< SimulationInfoTaylorGreenUz > getNewInstance(int simID, std::string kernel, double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct > simParaStruct, std::shared_ptr< GridInformationStruct > gridInfoStruct, int numberOfSimulations)
static std::shared_ptr< SimulationParameter > getNewInstance(std::string kernel, double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct > tgvParameterStruct, std::shared_ptr< GridInformationStruct > gridInfo)
static std::shared_ptr< InitialConditionTaylorGreenUx > getNewInstance(std::shared_ptr< TaylorGreenVortexUxParameterStruct > simParaStruct, std::shared_ptr< GridInformationStruct > gridInfoStruct)
static std::shared_ptr< LogFileTimeInformation > getNewInstance(std::vector< std::shared_ptr< SimulationInfo > > simInfo, bool fileWriting)
static std::shared_ptr< SimulationResults > getNewInstance(std::shared_ptr< SimulationParameter > simPara)
static std::shared_ptr< TestQueueImp > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput)
static std::shared_ptr< PhiTestPostProcessingStrategy > getNewInstance(std::shared_ptr< SimulationResults > simResult, std::shared_ptr< AnalyticalResults > analyticalResult, std::shared_ptr< PhiTestParameterStruct > testPara, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< BasicTestLogFileInformation > getNewInstance()
static std::shared_ptr< AnalyticalResults > getNewInstance(double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct > simParaStruct)
static std::shared_ptr< L2NormTest > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput, std::shared_ptr< L2NormTestParameterStruct > testParameter, std::string dataToCalculate, double maxL2NormDiff, std::string normalizeData)
std::shared_ptr< LogFileQueue > getLogFileQueue()
static std::shared_ptr< LogFileHead > getNewInstance(std::vector< int > devices)
static std::shared_ptr< L2NormPostProcessingStrategy > getNewInstance(std::shared_ptr< SimulationResults > simResult, std::shared_ptr< AnalyticalResults > analyticalResult, std::shared_ptr< L2NormTestParameterStruct > testPara, std::shared_ptr< L2NormCalculatorFactory > factory, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< AnalyticalResults > getNewInstance(double viscosity, std::shared_ptr< ShearWaveParameterStruct > simParaStruct)
static std::shared_ptr< BasicSimulationInfo > getNewInstance(int numberOfTimeSteps, double viscosity, int basicTimeStepLength, std::string kernel)
static std::shared_ptr< L2NormCalculatorFactory > getInstance()
static std::shared_ptr< AnalyticalResults > getNewInstance(double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct > simParaStruct)
static std::shared_ptr< L2NormBetweenKernelsInformation > getNewInstance(std::vector< std::shared_ptr< L2NormTestBetweenKernels > > tests, std::shared_ptr< L2NormTestBetweenKernelsParameterStruct > testPara, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< L2NormTestBetweenKernels > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput, std::string dataToCalculate, unsigned int timeStep, std::string normalizeWith, std::shared_ptr< L2NormCalculatorFactory > factory)
static std::shared_ptr< NyTest > getNewInstance(std::shared_ptr< ColorConsoleOutput > colorOutput, double viscosity, std::shared_ptr< NyTestParameterStruct > testPara, std::string dataToCalculate)
Definition NyTest.cpp:45
static std::shared_ptr< ShearWaveSimulationInfo > getNewInstance(int simID, std::string kernel, double viscosity, std::shared_ptr< ShearWaveParameterStruct > simParaStruct, std::shared_ptr< GridInformationStruct > gridInfoStruct, int numberOfSimulations)
static std::shared_ptr< LogFileInformationTaylorGreenUx > getNewInstance(std::shared_ptr< TaylorGreenVortexUxParameterStruct > simParaStruct, std::vector< std::shared_ptr< GridInformationStruct > > gridInfoStruct)
static std::shared_ptr< SimulationParameterTaylorGreenUz > getNewInstance(std::string kernel, double viscosity, std::shared_ptr< TaylorGreenVortexUzParameterStruct > tgvParameterStruct, std::shared_ptr< GridInformationStruct > gridInfo)
static std::shared_ptr< SimulationInfoTaylorGreenUx > getNewInstance(int simID, std::string kernel, double viscosity, std::shared_ptr< TaylorGreenVortexUxParameterStruct > simParaStruct, std::shared_ptr< GridInformationStruct > gridInfoStruct, int numberOfSimulations)
static std::shared_ptr< NyTestPostProcessingStrategy > getNewInstance(std::shared_ptr< SimulationResults > simResult, std::shared_ptr< AnalyticalResults > analyticalResult, std::shared_ptr< NyTestParameterStruct > testPara, std::vector< std::string > dataToCalcTests)
static std::shared_ptr< SimulationParameter > getNewInstance(std::string kernel, double viscosity, std::shared_ptr< ShearWaveParameterStruct > parameterStruct, std::shared_ptr< GridInformationStruct > gridInfo)
static std::shared_ptr< LogFileQueueImp > getNewInstance(std::string basicLogFilePath)
static std::shared_ptr< NyTestLogFileInformation > getNewInstance(std::shared_ptr< NyTestParameterStruct > testPara)
std::vector< std::shared_ptr< TestSimulation > > getTestSimulations()
std::shared_ptr< T > SPtr
const std::function< void()> makeVirtualFluidSimulation(std::shared_ptr< Parameter > para, std::shared_ptr< InitialCondition > condition, std::shared_ptr< DataWriter > dataWriter)
std::shared_ptr< Parameter > makeParameter(std::shared_ptr< SimulationParameter > simPara)