11/* *
2+ * \file vdp_sdc.cpp
23 * Run SDC for the van der Pol oscillator.
3- *
44 */
5-
65#include < pfasst.hpp>
76#include < pfasst/config.hpp>
87#include < pfasst/logging.hpp>
1110
1211#include " vdp_sweeper.hpp"
1312
14- double run_vdp_sdc (const size_t nsteps, const double dt, const size_t nnodes,
15- const size_t niters, const double nu, const double x0,
16- const double y0, const pfasst::quadrature::QuadratureType nodetype)
13+ namespace pfasst
1714{
18- pfasst::SDC<> sdc;
15+ namespace examples
16+ {
17+ namespace vdp
18+ {
19+ double run_vdp_sdc (const size_t nsteps, const double dt, const size_t nnodes,
20+ const size_t niters, const double nu, const double x0,
21+ const double y0, const quadrature::QuadratureType nodetype)
22+ {
23+ SDC<> sdc;
1924
20- auto quad = pfasst:: quadrature::quadrature_factory (nnodes, nodetype);
25+ auto quad = quadrature::quadrature_factory (nnodes, nodetype);
2126
22- // van der Pol oscillator (as first order system) has two components
23- auto factory = make_shared<pfasst:: encap::VectorFactory<double >>(2 );
24- // input is parameter nu and initial values for position and velocity
25- auto sweeper = make_shared<VdpSweeper<>>(nu, x0, y0);
27+ // van der Pol oscillator (as first order system) has two components
28+ auto factory = make_shared<encap::VectorFactory<double >>(2 );
29+ // input is parameter nu and initial values for position and velocity
30+ auto sweeper = make_shared<VdpSweeper<>>(nu, x0, y0);
2631
27- sweeper->set_quadrature (quad);
28- sweeper->set_factory (factory);
32+ sweeper->set_quadrature (quad);
33+ sweeper->set_factory (factory);
2934
30- sdc.add_level (sweeper);
35+ sdc.add_level (sweeper);
3136
32- // Final time Tend = dt*nsteps
33- sdc.set_duration (0.0 , dt*nsteps, dt, niters);
34- sdc.setup ();
37+ // Final time Tend = dt*nsteps
38+ sdc.set_duration (0.0 , dt*nsteps, dt, niters);
39+ sdc.setup ();
3540
36- auto q0 = sweeper->get_start_state ();
37- sweeper->exact (q0, 0.0 );
41+ auto q0 = sweeper->get_start_state ();
42+ sweeper->exact (q0, 0.0 );
3843
39- sdc.run ();
44+ sdc.run ();
45+
46+ return sweeper->get_errors ();
47+ }
48+ } // ::pfasst::examples::vdp
49+ } // ::pfasst::examples
50+ } // ::pfasst
4051
41- return sweeper->get_errors ();
42- }
4352
4453#ifndef PFASST_UNIT_TESTING
4554/* *
@@ -59,6 +68,6 @@ int main(int argc, char** argv)
5968 pfasst::init (argc, argv);
6069 LOG (INFO) << " Used timestep:" << dt;
6170
62- run_vdp_sdc (nsteps, dt, nnodes, niters, nu, x0, y0, nodetype);
71+ pfasst::examples::vdp:: run_vdp_sdc (nsteps, dt, nnodes, niters, nu, x0, y0, nodetype);
6372}
6473#endif
0 commit comments