Skip to content
Snippets Groups Projects
Commit b95ece0b authored by Abhinav Singh's avatar Abhinav Singh
Browse files

Adding default and more constructor

parent 3ecc7f89
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ BOOST_AUTO_TEST_SUITE(odeInt_BASE_tests)
BOOST_AUTO_TEST_CASE(odeint_base_test_gpu)
{
size_t edgeSemiSize = 40;
size_t edgeSemiSize = 512;
const size_t sz[2] = {edgeSemiSize,edgeSemiSize };
Box<2, double> box({ 0, 0 }, { 1.0, 1.0 });
size_t bc[2] = { NON_PERIODIC, NON_PERIODIC };
......@@ -56,8 +56,8 @@ BOOST_AUTO_TEST_CASE(odeint_base_test_gpu)
mem_id k1 = key.get(1);
double yp0 = k1 * spacing[1];
Particles.getLastPos()[1] = yp0;
Particles.getLastProp<0>() = xp0*yp0*exp(0);
Particles.getLastProp<1>() = xp0*yp0*exp(0.4);
Particles.getLastProp<0>() = xp0*yp0*exp(-5);
Particles.getLastProp<1>() = xp0*yp0*exp(5);
++it;
}
......@@ -73,51 +73,30 @@ BOOST_AUTO_TEST_CASE(odeint_base_test_gpu)
x0.data.get<0>().getVector().deviceToHost<0>();
// The rhs of x' = f(x)
double t=0,tf=0.4;
const double dt=0.1;
double t0=-5,tf=5;
const double dt=0.01;
//This doesnt work Why?
//size_t steps=boost::numeric::odeint::integrate(Exponential,x0,0.0,tf,dt);
size_t steps=boost::numeric::odeint::integrate_const( boost::numeric::odeint::runge_kutta4< state_type, double, state_type, double, boost::numeric::odeint::vector_space_algebra_ofp_gpu,boost::numeric::odeint::ofp_operations>(),ExponentialGPU,x0,0.0,tf,dt);
timer tt;
tt.start();
size_t steps=boost::numeric::odeint::integrate_const( boost::numeric::odeint::runge_kutta4< state_type, double, state_type, double, boost::numeric::odeint::vector_space_algebra_ofp_gpu,boost::numeric::odeint::ofp_operations>(),ExponentialGPU,x0,t0,tf,dt);
tt.stop();
OdeSol=x0.data.get<0>();
Particles.deviceToHostProp<0,1,2>();
auto it2 = Particles.getDomainIterator();
double worst = 0.0;
while (it2.isNext()) {
auto p = it2.get();
std::cout<<"A:"<<Particles.getProp<1>(p)<<std::endl;
std::cout<<"B:"<<Particles.getProp<2>(p)<<std::endl;
if (fabs(Particles.getProp<1>(p) - Particles.getProp<2>(p)) > worst) {
worst = fabs(Particles.getProp<1>(p) - Particles.getProp<2>(p));
}
++it2;
}
//std::cout<<worst<<std::endl;
BOOST_REQUIRE(worst < 1e-6);
x0.data.get<0>()=Init;
boost::numeric::odeint::runge_kutta4< state_type, double, state_type, double, boost::numeric::odeint::vector_space_algebra_ofp ,boost::numeric::odeint::ofp_operations> rk4;
while (t<tf)
{
rk4.do_step(ExponentialGPU,x0,t,dt);
OdeSol=x0.data.get<0>();
t+=dt;
}
OdeSol=x0.data.get<0>();
auto it3 = Particles.getDomainIterator();
double worst2 = 0.0;
while (it3.isNext()) {
auto p = it3.get();
if (fabs(Particles.getProp<1>(p) - Particles.getProp<2>(p)) > worst2) {
worst2 = fabs(Particles.getProp<1>(p) - Particles.getProp<2>(p));
}
++it3;
}
//std::cout<<worst2<<std::endl;
std::cout<<"WCT:"<<tt.getwct()<<std::endl;
std::cout<<"CPU:"<<tt.getcputime()<<std::endl;
std::cout<<worst<<std::endl;
BOOST_REQUIRE(worst < 1e-6);
BOOST_REQUIRE_EQUAL(worst,worst2);
}
BOOST_AUTO_TEST_SUITE_END()
......@@ -1266,6 +1266,12 @@ public:
vector_dist_expression_impl()
{}
template<unsigned int prp2, typename vector2>
vector_dist_expression_impl(const vector_dist_expression<prp2,vector2> & v_exp)
{
this->operator=(v_exp);
};
template<typename exp1, typename exp2, unsigned int op>
vector_dist_expression_impl(const vector_dist_expression_op<exp1,exp2,op> & v_exp)
{
......@@ -1445,7 +1451,24 @@ class vector_dist_expression<0,openfpm::vector<aggregate<T>,memory, layout_base>
{
typedef openfpm::vector<aggregate<T>,memory, layout_base> vector;
typedef vector_dist_expression_impl<vector> base;
public:
vector_dist_expression()
{
}
template<unsigned int prp2, typename vector2>
vector_dist_expression(const vector_dist_expression<prp2,vector2> & v_exp)
:base(v_exp)
{
}
template<typename exp1, typename exp2, unsigned int op>
vector_dist_expression(const vector_dist_expression_op<exp1,exp2,op> & v_exp)
: base(v_exp)
{
}
template<unsigned int prp2, typename vector2> vector & operator=(const vector_dist_expression<prp2,vector2> & v_exp)
{
return base::operator=(v_exp);
......@@ -1469,6 +1492,22 @@ class vector_dist_expression<0,openfpm::vector_gpu<aggregate<T>>> : public vecto
typedef openfpm::vector_gpu<aggregate<T>> vector;
typedef vector_dist_expression_impl<vector> base;
public:
vector_dist_expression()
{
}
template<unsigned int prp2, typename vector2>
vector_dist_expression(const vector_dist_expression<prp2,vector2> & v_exp)
:base(v_exp)
{
}
template<typename exp1, typename exp2, unsigned int op>
vector_dist_expression(const vector_dist_expression_op<exp1,exp2,op> & v_exp)
: base(v_exp)
{
}
template<unsigned int prp2, typename vector2> vector & operator=(const vector_dist_expression<prp2,vector2> & v_exp)
{
return base::operator=(v_exp);
......
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