Files
solver/OndselSolver/BasicIntegrator.cpp
aiksiongkoh 3d6a23a678 Cmake gtest (#72)
* Check rackpin and gear for zero radii

* rebase zero-radii-check (#69)

* contributing

* Update push-freecad.yml

updated actions/checkout to v4

* dragging log for debugging

* fix calcdxNorm crash

* setDebug and remove MBDyn*

* Update cmakelists.txt

* fix includes for gcc-14

gcc-14 is more disciplined about not including <algorithm> transitively.

* fix runDragStep

* backhoe files (#65)

* Mark unused variables to silence compiler warnings. (#64)

* Backhoe issues (#67)

* backhoe issues

* runDragStep edit

* backhoe issues

* runDragStep edit

* Reduce large drag step progressively until convergence.

* Switch to using built-in M_PI, even on MSVC (#68)

---------

Co-authored-by: Brad Collette <bradcollette@pop-os.localdomain>
Co-authored-by: mosfet80 <realeandrea@yahoo.it>
Co-authored-by: PaddleStroke <pierrelouis.boyer@gmail.com>
Co-authored-by: Jed Brown <jed@jedbrown.org>
Co-authored-by: sliptonic <shopinthewoods@gmail.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>

* in progress

* Gtest added

---------

Co-authored-by: Brad Collette <bradcollette@pop-os.localdomain>
Co-authored-by: mosfet80 <realeandrea@yahoo.it>
Co-authored-by: PaddleStroke <pierrelouis.boyer@gmail.com>
Co-authored-by: Jed Brown <jed@jedbrown.org>
Co-authored-by: sliptonic <shopinthewoods@gmail.com>
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2024-07-30 14:45:59 -06:00

164 lines
3.1 KiB
C++

/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include "BasicIntegrator.h"
#include "CREATE.h"
#include "StableBackwardDifference.h"
#include "IntegratorInterface.h"
using namespace MbD;
void BasicIntegrator::initializeLocally()
{
_continue = true;
}
void BasicIntegrator::iStep(size_t integer)
{
istep = integer;
opBDF->setiStep(integer);
}
void BasicIntegrator::postFirstStep()
{
t = tnew;
system->postFirstStep();
}
void BasicIntegrator::postRun()
{
}
void BasicIntegrator::postStep()
{
t = tnew;
system->postStep();
}
void BasicIntegrator::initializeGlobally()
{
//"Get info from system and prepare for start of simulation."
//"Integrator asks system for info. Not system setting integrator."
this->sett(system->tstart);
this->direction = system->direction;
this->orderMax = system->orderMax();
}
void BasicIntegrator::setSystem(Solver* sys)
{
system = static_cast<IntegratorInterface*>(sys);
}
void BasicIntegrator::calcOperatorMatrix()
{
opBDF->calcOperatorMatrix();
}
void BasicIntegrator::incrementTime()
{
tpast->insert(tpast->begin(), t);
if (tpast->size() > (orderMax + 1)) { tpast->pop_back(); }
auto istepNew = istep + 1;
this->iStep(istepNew);
this->setorder(orderNew);
h = hnew;
this->settnew(t + (direction * h));
this->calcOperatorMatrix();
system->incrementTime(tnew);
}
void BasicIntegrator::incrementTry()
{
assert(false);
}
void BasicIntegrator::initialize()
{
Solver::initialize();
//statistics = IdentityDictionary new.
tpast = std::make_shared<std::vector<double>>();
opBDF = CREATE<StableBackwardDifference>::With();
opBDF->timeNodes = tpast;
}
void BasicIntegrator::logString(const std::string& str)
{
system->logString(str);
}
void BasicIntegrator::run()
{
this->preRun();
this->initializeLocally();
this->initializeGlobally();
this->firstStep();
this->subsequentSteps();
this->finalize();
this->reportStats();
this->postRun();
}
void BasicIntegrator::selectOrder()
{
//"Increase order consecutively with step."
if (iTry == 1) orderNew = std::min(istep + 1, orderMax);
}
void BasicIntegrator::preFirstStep()
{
system->preFirstStep();
}
void BasicIntegrator::preRun()
{
}
void BasicIntegrator::preStep()
{
system->preStep();
}
void BasicIntegrator::reportStats()
{
}
void BasicIntegrator::setorder(size_t o)
{
order = o;
opBDF->setorder(o);
}
void BasicIntegrator::settnew(double t)
{
tnew = t;
this->settime(t);
}
void BasicIntegrator::sett(double tt)
{
t = tt;
opBDF->settime(tt);
}
void BasicIntegrator::settime(double tt)
{
opBDF->settime(tt);
}
double BasicIntegrator::tprevious()
{
return tpast->at(0);
}
void BasicIntegrator::subsequentSteps()
{
while (_continue) { this->nextStep(); }
}