@@ -22,7 +22,8 @@ namespace pfasst
2222 {
2323 template <typename scalar>
2424 error_map<scalar> run_boris_sdc (const size_t nsteps, const scalar dt, const size_t nnodes,
25- const size_t nparticles, const size_t niters)
25+ const size_t nparticles, const size_t niters,
26+ const double abs_res_tol, const double rel_res_tol)
2627 {
2728 MLSDC<> controller;
2829
@@ -33,20 +34,29 @@ namespace pfasst
3334 make_shared<bindings::WrapperSimplePhysicsSolver<double , double >>();
3435 bindings::setup (dynamic_pointer_cast<bindings::WrapperSimplePhysicsSolver<double , double >>(impl_solver));
3536
36- auto quad1 = quadrature::quadrature_factory<double >(nnodes, quadrature::QuadratureType::GaussLobatto);
37- auto factory1 = make_shared<ParticleCloudFactory<double >>(nparticles, 3 , mass, charge);
38- string data_file1 = " s" + to_string (nsteps) + " _i" + to_string (niters) + " _dt" + to_string (dt) + " _m" + to_string (nnodes) + " _p" + to_string (nparticles) + " _level1.csv" ;
39- auto sweeper1 = make_shared<BorisSweeper<double , double >>(impl_solver, data_file1);
40- auto transfer1 = make_shared<InjectiveTransfer<double , double >>();
37+ // fine level
38+ auto quad1 = quadrature::quadrature_factory<double >(nnodes,
39+ quadrature::QuadratureType::GaussLobatto);
40+ auto factory1 = make_shared<ParticleCloudFactory<double >>(nparticles, 3 , mass, charge);
41+ string data_file1 = " s" + to_string (nsteps) + " _i" + to_string (niters)
42+ + " _dt" + to_string (dt) + " _m" + to_string (nnodes)
43+ + " _p" + to_string (nparticles) + " _level1.csv" ;
44+ auto sweeper1 = make_shared<BorisSweeper<double , double >>(impl_solver, data_file1);
45+ auto transfer1 = make_shared<InjectiveTransfer<double , double >>();
4146 sweeper1->set_quadrature (quad1);
4247 sweeper1->set_factory (factory1);
48+ sweeper1->set_residual_tolerances (abs_res_tol, rel_res_tol);
4349 controller.add_level (sweeper1, transfer1);
4450
45- auto quad2 = quadrature::quadrature_factory<double >(nnodes, quadrature::QuadratureType::GaussLobatto);
46- auto factory2 = make_shared<ParticleCloudFactory<double >>(nparticles, 3 , mass, charge);
47- string data_file2 = " s" + to_string (nsteps) + " _i" + to_string (niters) + " _dt" + to_string (dt) + " _m" + to_string (nnodes) + " _p" + to_string (nparticles) + " _level2.csv" ;
48- auto sweeper2 = make_shared<BorisSweeper<double , double >>(impl_solver, data_file2);
49- auto transfer2 = make_shared<InjectiveTransfer<double , double >>();
51+ // coarse level
52+ auto quad2 = quadrature::quadrature_factory<double >(nnodes,
53+ quadrature::QuadratureType::GaussLobatto);
54+ auto factory2 = make_shared<ParticleCloudFactory<double >>(nparticles, 3 , mass, charge);
55+ string data_file2 = " s" + to_string (nsteps) + " _i" + to_string (niters)
56+ + " _dt" + to_string (dt) + " _m" + to_string (nnodes)
57+ + " _p" + to_string (nparticles) + " _level2.csv" ;
58+ auto sweeper2 = make_shared<BorisSweeper<double , double >>(impl_solver, data_file2);
59+ auto transfer2 = make_shared<InjectiveTransfer<double , double >>();
5060 sweeper2->set_quadrature (quad2);
5161 sweeper2->set_factory (factory2);
5262 controller.add_level (sweeper2, transfer2);
@@ -60,17 +70,13 @@ namespace pfasst
6070 center->vel ()[2 ] = 100 ;
6171
6272 auto fine_sweeper = controller.get_finest <BorisSweeper<double , double >>();
63- shared_ptr<ParticleCloud<double >> q0 = dynamic_pointer_cast<ParticleCloud<double >>(fine_sweeper->get_start_state ());
73+ shared_ptr<ParticleCloud<double >> q0 = \
74+ dynamic_pointer_cast<ParticleCloud<double >>(fine_sweeper->get_start_state ());
6475 q0->distribute_around_center (center);
65- CLOG (INFO, " Boris" ) << " Initial Particle (fine) : " << *(dynamic_pointer_cast<ParticleCloud<double >>(fine_sweeper->get_start_state ()));
76+ CLOG (INFO, " Boris" ) << " Initial Particle (fine) : "
77+ << *(dynamic_pointer_cast<ParticleCloud<double >>(fine_sweeper->get_start_state ()));
6678 fine_sweeper->set_initial_energy ();
6779
68- // auto coarse_sweeper = controller.get_coarsest<BorisSweeper<double, double>>();
69- // shared_ptr<ParticleCloud<double>> q0_coarse = dynamic_pointer_cast<ParticleCloud<double>>(coarse_sweeper->get_start_state());
70- // q0_coarse->copy(q0);
71- // LOG(INFO) << OUT::green << "Initial Particle (coarse): " << *(dynamic_pointer_cast<ParticleCloud<double>>(coarse_sweeper->get_start_state()));
72- // coarse_sweeper->set_initial_energy();
73-
7480 controller.run ();
7581
7682 return fine_sweeper->get_errors ();
@@ -93,7 +99,17 @@ int main(int argc, char** argv)
9399 const size_t nnodes = pfasst::config::get_value<size_t >(" num_nodes" , 5 );
94100 const size_t nparticles = pfasst::config::get_value<size_t >(" num_particles" , 1 );
95101 const size_t niters = pfasst::config::get_value<size_t >(" num_iter" , 2 );
96-
97- pfasst::examples::boris::run_boris_sdc<double >(nsteps, dt, nnodes, nparticles, niters);
102+ const double abs_res_tol = pfasst::config::get_value<double >(" abs_res_tol" , 0.0 );
103+ const double rel_res_tol = pfasst::config::get_value<double >(" rel_res_tol" , 0.0 );
104+
105+ LOG (INFO) << " nsteps=" << nsteps << " , "
106+ << " dt=" << dt << " , "
107+ << " nnodes=" << nnodes << " , "
108+ << " nparticles=" << nparticles << " , "
109+ << " niter=" << niters << " , "
110+ << " abs res=" << abs_res_tol << " , "
111+ << " rel res=" << rel_res_tol;
112+
113+ pfasst::examples::boris::run_boris_sdc<double >(nsteps, dt, nnodes, nparticles, niters, abs_res_tol, rel_res_tol);
98114}
99115#endif
0 commit comments