diff --git a/Input/input_sup2.xml b/Input/input_sup2.xml index 5274aa2..a490125 100644 --- a/Input/input_sup2.xml +++ b/Input/input_sup2.xml @@ -23,6 +23,11 @@ + + + + + diff --git a/Input/input_sup5.xml b/Input/input_sup5.xml index 6df0429..fe4c7ae 100644 --- a/Input/input_sup5.xml +++ b/Input/input_sup5.xml @@ -23,6 +23,11 @@ + + + + + diff --git a/Input/input_sup6.xml b/Input/input_sup6.xml index b22c47c..a9bfa7e 100644 --- a/Input/input_sup6.xml +++ b/Input/input_sup6.xml @@ -23,6 +23,11 @@ + + + + + \ No newline at end of file diff --git a/Input/input_sup7.xml b/Input/input_sup7.xml index 80ad46d..d35e506 100644 --- a/Input/input_sup7.xml +++ b/Input/input_sup7.xml @@ -23,6 +23,11 @@ + + + + + \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 201d0ce..c9f6dad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,10 +32,14 @@ int main(int argc, char* argv[]) int MaxIteration = 0; bool PressureGreenFunFlag = false; + double ExpectedPressure = -1.0; + double ExpectedPressureTolerance = -1.0; + MIRCO::SetParameters(E1, E2, LateralLength, nu1, nu2, CompositeYoungs, CompositePoissonsRatio, ShapeFactor, ElasticComplianceCorrection, GridSize, Tolerance, Delta, TopologyFilePath, Resolution, InitialTopologyStdDeviation, inputFileName, RandomTopologyFlag, Hurst, - RandomSeedFlag, RandomGeneratorSeed, WarmStartingFlag, MaxIteration, PressureGreenFunFlag); + RandomSeedFlag, RandomGeneratorSeed, WarmStartingFlag, MaxIteration, PressureGreenFunFlag, + ExpectedPressure, ExpectedPressureTolerance); // Identical Vectors/Matricies, therefore only created one here. int ngrid = int(ceil((LateralLength - (GridSize / 2)) / GridSize)); @@ -67,6 +71,13 @@ int main(int argc, char* argv[]) const auto finish = std::chrono::high_resolution_clock::now(); const double elapsedTime = - std::chrono::duration_cast(finish - start).count(); + std::chrono::duration_cast>(finish - start).count(); std::cout << "Elapsed time is: " + std::to_string(elapsedTime) + "s." << std::endl; + + // Test for correct output if the result_description is given in the input file + if (ExpectedPressure >= 0) + { + TEUCHOS_TEST_FOR_EXCEPTION(std::abs(pressure - ExpectedPressure) > ExpectedPressureTolerance, + std::runtime_error, "The output pressure is incorrect"); + } } diff --git a/src/mirco_setparameters.cpp b/src/mirco_setparameters.cpp index b058923..5ddc8d0 100644 --- a/src/mirco_setparameters.cpp +++ b/src/mirco_setparameters.cpp @@ -15,7 +15,8 @@ void MIRCO::SetParameters(double& E1, double& E2, double& LateralLength, double& double& ElasticComplianceCorrection, double& GridSize, double& Tolerance, double& Delta, std::string& TopologyFilePath, int& Resolution, double& InitialTopologyStdDeviation, const std::string& inputFileName, bool& RandomTopologyFlag, double& Hurst, bool& RandomSeedFlag, - int& RandomGeneratorSeed, bool& WarmStartingFlag, int& MaxIteration, bool& PressureGreenFunFlag) + int& RandomGeneratorSeed, bool& WarmStartingFlag, int& MaxIteration, bool& PressureGreenFunFlag, + double& ExpectedPressure, double& ExpectedPressureTolerance) { Teuchos::RCP parameterList = Teuchos::rcp(new Teuchos::ParameterList()); Teuchos::updateParametersFromXmlFile(inputFileName, parameterList.ptr()); @@ -94,4 +95,11 @@ void MIRCO::SetParameters(double& E1, double& E2, double& LateralLength, double& ElasticComplianceCorrection = LateralLength * CompositeYoungs / ShapeFactor; GridSize = LateralLength / (pow(2, Resolution) + 1); + + if (parameterList->isSublist("result_description")) + { + Teuchos::ParameterList& result_description = parameterList->sublist("result_description"); + ExpectedPressure = result_description.get("ExpectedPressure"); + ExpectedPressureTolerance = result_description.get("ExpectedPressureTolerance"); + } } diff --git a/src/mirco_setparameters.h b/src/mirco_setparameters.h index 65e9823..5d99a08 100644 --- a/src/mirco_setparameters.h +++ b/src/mirco_setparameters.h @@ -38,6 +38,8 @@ namespace MIRCO * @param MaxIteration Maximum number of iterations for the force to converge. * @param PressureGreenFunFlag Flag to use Green function based on uniform pressure instead of * point force + * @param ExpectedPressure Expected pressure output for framework test + * @param ExpectedPressureTolerance Tolerance to compare the output to the expected pressure */ void SetParameters(double& E1, double& E2, double& LateralLength, double& nu1, double& nu2, double& CompositeYoungs, double& CompositePoissonsRatio, double& alpha, @@ -45,7 +47,7 @@ namespace MIRCO std::string& TopologyFilePath, int& Resolution, double& InitialTopologyStdDeviation, const std::string& inputFileName, bool& RandomTopologyFlag, double& Hurst, bool& RandomSeedFlag, int& RandomGeneratorSeed, bool& WarmStartingFlag, int& MaxIteration, - bool& PressureGreenFunFlag); + bool& PressureGreenFunFlag, double& ExpectedPressure, double& ExpectedPressureTolerance); } // namespace MIRCO #endif // SRC_SETPARAMETERS_H_