Skip to content
Snippets Groups Projects
Commit 2b38f7ae authored by wenqing's avatar wenqing
Browse files

[Timer] Allow to add extra times in time stepper

parent 272caa62
No related branches found
No related tags found
No related merge requests found
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
#include <functional> #include <functional>
#include <limits> #include <limits>
#include <vector> #include <vector>
#include <logog/include/logog.hpp>
#include "EvolutionaryPIDcontroller.h" #include "BaseLib/makeVectorUnique.h"
#include <logog/include/logog.hpp> #include "EvolutionaryPIDcontroller.h"
namespace NumLib namespace NumLib
{ {
...@@ -156,4 +157,18 @@ double EvolutionaryPIDcontroller::checkSpecificTimeReached(const double h_new) ...@@ -156,4 +157,18 @@ double EvolutionaryPIDcontroller::checkSpecificTimeReached(const double h_new)
return h_new; return h_new;
} }
void EvolutionaryPIDcontroller::addSpecificTimes(
std::vector<double> const& extra_specific_times)
{
_specific_times.insert(_specific_times.end(), extra_specific_times.begin(),
extra_specific_times.end());
// Sort again in the descending order.
std::sort(
_specific_times.begin(), _specific_times.end(), std::greater<double>());
// Remove possible duplicated elements.
BaseLib::makeVectorUnique(_specific_times);
}
} // end of namespace NumLib } // end of namespace NumLib
...@@ -91,6 +91,10 @@ public: ...@@ -91,6 +91,10 @@ public:
/// Get a flag to indicate that this algorithm need to compute /// Get a flag to indicate that this algorithm need to compute
/// solution error. /// solution error.
bool isSolutionErrorComputationNeeded() override { return true; } bool isSolutionErrorComputationNeeded() override { return true; }
/// Add specific times
void addSpecificTimes(
std::vector<double> const& extra_specific_times) override;
private: private:
const double _kP = 0.075; ///< Parameter. \see EvolutionaryPIDcontroller const double _kP = 0.075; ///< Parameter. \see EvolutionaryPIDcontroller
const double _kI = 0.175; ///< Parameter. \see EvolutionaryPIDcontroller const double _kI = 0.175; ///< Parameter. \see EvolutionaryPIDcontroller
......
...@@ -85,6 +85,12 @@ public: ...@@ -85,6 +85,12 @@ public:
/// Get a flag to indicate whether this algorithm needs to compute /// Get a flag to indicate whether this algorithm needs to compute
/// solution error. The default return value is false. /// solution error. The default return value is false.
virtual bool isSolutionErrorComputationNeeded() { return false; } virtual bool isSolutionErrorComputationNeeded() { return false; }
/// Add specific times
virtual void addSpecificTimes(std::vector<double> const& /*specific_times*/)
{
}
protected: protected:
/// initial time /// initial time
const double _t_initial; const double _t_initial;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment