Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tarun-mitruka committed Apr 3, 2024
1 parent 2d7cca7 commit c9b7ffb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/iks005_newtonRaphson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include <ikarus/assembler/simpleassemblers.hh>
#include <ikarus/solver/nonlinearsolver/newtonraphson.hh>
#include <ikarus/solver/nonlinearsolver/solverstate.hh>
#include <ikarus/utils/init.hh>
#include <ikarus/utils/nonlinearoperator.hh>
#include <ikarus/utils/observer/nonlinearsolverlogger.hh>
#include <ikarus/utils/observer/observable.hh>

auto f(double& x) { return 0.5 * x * x + x - 2; }
auto df(double& x) { return x + 1; }
Expand Down Expand Up @@ -46,11 +46,10 @@ void newtonRaphsonVeryBasicExample() {
std::cout << "expected solution: " << xExpected << "\n";
}

class OurFirstObserver
: public Ikarus::IObserver<Ikarus::IObservable<Ikarus::NonLinearSolverMessages, Ikarus::NonLinearSolverState>>
class OurFirstObserver : public Ikarus::IObserver<Ikarus::NonLinearSolverObservable>
{
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";
}
Expand Down
3 changes: 2 additions & 1 deletion src/iks006_nonlinear2DSolid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -250,4 +250,5 @@ int main(int argc, char** argv) {
resultWriter.addVertexData(vonMisesFunction);

resultWriter.write("iks006_nonlinear2DSolid_Result");
return controlState.success;
}
6 changes: 4 additions & 2 deletions src/iks007_vonMisesTruss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <ikarus/utils/observer/controlvtkwriter.hh>
#include <ikarus/utils/observer/genericobserver.hh>
#include <ikarus/utils/observer/nonlinearsolverlogger.hh>
#include <ikarus/utils/observer/observable.hh>
#include <ikarus/utils/pythonautodiffdefinitions.hh>

using namespace Ikarus;
Expand Down Expand Up @@ -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<Ikarus::GenericObserver<Ikarus::ControlMessages, Ikarus::ControlState>>(
auto lvkObserver = std::make_shared<Ikarus::GenericObserver<Ikarus::ControlObservable>>(
Ikarus::ControlMessages::SOLUTION_CHANGED, [&](int step) {
lambdaAndDisp(0, step) = lambda;
lambdaAndDisp(1, step) = d[2];
Expand All @@ -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;
Expand Down Expand Up @@ -241,4 +242,5 @@ int main(int argc, char** argv) {
// f->draw();
// using namespace std::chrono_literals;
// std::this_thread::sleep_for(5s);
return controlState.success;
}

0 comments on commit c9b7ffb

Please sign in to comment.