Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F120238982
mtest.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 2, 21:17
Size
1 KB
Mime Type
text/x-c++
Expires
Fri, Jul 4, 21:17 (2 d)
Engine
blob
Format
Raw Data
Handle
27160016
Attached To
R9411 tisue modeling
mtest.cpp
View Options
#define WITH_OBSERVER_MICHA
#include <iostream>
#include <boost/range/algorithm.hpp>
#include <boost/numeric/odeint.hpp>
using namespace std;
using namespace boost::numeric::odeint;
typedef double state_type;
class KeepLast{
protected:
state_type last;
double time;
public:
KeepLast(){}
KeepLast(state_type x):last(x){}
void operator()(const state_type& x, double t){last=x;time=t;};
// void resize(uint n){last.resize(n);}
state_type& getState(){return last;}
double getTime(){return time;}
void setTime(double t){time=t;}
};
// void KeepLast::operator()(const state_type& x, double t){
// for(uint i=0;i<x.size();i++){
// last[i] =x[i];
// }
// time=t;
// }
typedef runge_kutta_cash_karp54< state_type > error_stepper_type;
//typedef runge_kutta_cash_dopri5< state_type > error_stepper_type;
class Myode{
public:
void operator()(const state_type& x, state_type& dxdt, const double t){dxdt=-1-x;}
static bool done(const state_type &x){cout<<x<<endl;return x<=0.0;}
};
int main(int argc, char* argv[]){
Myode ode;
KeepLast obs;
state_type x=20.0;
auto stepper = make_controlled< error_stepper_type >( 1.0e-10 , 1.0e-6 );
// auto stepper = make_dense_output( 1.0e-6 , 1.0e-5 , runge_kutta_dopri5< state_type >());
auto iter= boost::find_if(make_adaptive_range(stepper,ode,x,0.0 , 20.0 , 0.01,obs),
Myode::done);
cout<<"integration stopped at "<<x<<" "<<obs.getState()<<" "<<obs.getTime()<<endl;
return 1;
}
Event Timeline
Log In to Comment