From a96df512cd4c82bf30d95b5d745ae8272c247afc Mon Sep 17 00:00:00 2001 From: Tarun Mitruka Date: Tue, 2 Apr 2024 22:55:23 +0200 Subject: [PATCH] fixes --- src/iks005_newtonRaphson.cpp | 7 +++---- src/iks006_nonlinear2DSolid.cpp | 3 ++- src/iks007_vonMisesTruss.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/iks005_newtonRaphson.cpp b/src/iks005_newtonRaphson.cpp index 3f88af4..44fa19f 100644 --- a/src/iks005_newtonRaphson.cpp +++ b/src/iks005_newtonRaphson.cpp @@ -5,10 +5,10 @@ #include #include -#include #include #include #include +#include auto f(double& x) { return 0.5 * x * x + x - 2; } auto df(double& x) { return x + 1; } @@ -46,11 +46,10 @@ void newtonRaphsonVeryBasicExample() { std::cout << "expected solution: " << xExpected << "\n"; } -class OurFirstObserver - : public Ikarus::IObserver> +class OurFirstObserver : public Ikarus::IObserver { public: - void updateImpl(Ikarus::NonLinearSolverMessages message, const Ikarus::NonLinearSolverState&) override { + void updateImpl(MessageType message, const StateType&) override { if (message == Ikarus::NonLinearSolverMessages::ITERATION_STARTED) std::cout << "Iteration started.\n"; } diff --git a/src/iks006_nonlinear2DSolid.cpp b/src/iks006_nonlinear2DSolid.cpp index 87fa51c..755c4ec 100644 --- a/src/iks006_nonlinear2DSolid.cpp +++ b/src/iks006_nonlinear2DSolid.cpp @@ -233,7 +233,7 @@ int main(int argc, char** argv) { lc.subscribeAll(vtkWriter); std::cout << "Energy before: " << nonLinOp.value() << std::endl; - lc.run(); + const auto controlState = lc.run(); nonLinOp.update<0>(); std::cout << "Energy after: " << nonLinOp.value() << std::endl; @@ -250,4 +250,5 @@ int main(int argc, char** argv) { resultWriter.addVertexData(vonMisesFunction); resultWriter.write("iks006_nonlinear2DSolid_Result"); + return not(controlState.success); } diff --git a/src/iks007_vonMisesTruss.cpp b/src/iks007_vonMisesTruss.cpp index e81bda7..002a7d7 100644 --- a/src/iks007_vonMisesTruss.cpp +++ b/src/iks007_vonMisesTruss.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include using namespace Ikarus; @@ -193,7 +194,7 @@ int main(int argc, char** argv) { lambdaAndDisp.setZero(Eigen::NoChange, loadSteps + 1); /// Create Observer which executes when control routines messages /// SOLUTION_CHANGED - auto lvkObserver = std::make_shared>( + auto lvkObserver = std::make_shared>( Ikarus::ControlMessages::SOLUTION_CHANGED, [&](int step) { lambdaAndDisp(0, step) = lambda; lambdaAndDisp(1, step) = d[2]; @@ -213,7 +214,7 @@ int main(int argc, char** argv) { lc.subscribeAll({vtkWriter, lvkObserver}); /// Execute! - lc.run(); + const auto controlState = lc.run(); /// Postprocess using namespace matplot; @@ -241,4 +242,5 @@ int main(int argc, char** argv) { // f->draw(); // using namespace std::chrono_literals; // std::this_thread::sleep_for(5s); + return not(controlState.success); }