1- /*
2- * Sweeper for scalar test equation
3- *
4- * u' = lambda*u, u(0) = u0
5- *
6- * with complex lambda using an IMEX scheme. Derived from the generic imex_sweeper
7- *
8- */
9-
101#ifndef _EXAMPLES__SCALAR__SCALAR_SWEEPER_HPP_
112#define _EXAMPLES__SCALAR__SCALAR_SWEEPER_HPP_
123
@@ -20,7 +11,13 @@ using namespace std;
2011
2112template <typename time = pfasst::time_precision>
2213
23- /*
14+ /* *
15+ * Sweeper for scalar test equation
16+ *
17+ * u' = lambda*u, u(0) = u0
18+ *
19+ * with complex lambda using an IMEX scheme. Derived from the generic imex_sweeper
20+ *
2421 * ScalarSweeper is derived from the generic IMEXSweeper
2522 */
2623class ScalarSweeper
@@ -30,35 +27,27 @@ class ScalarSweeper
3027 private:
3128 typedef pfasst::encap::Encapsulation<time> encap_type;
3229
33- /*
34- * Define a type for a complex PFASST vector encapsulation.
35- */
30+ // ! Define a type for a complex PFASST vector encapsulation.
3631 typedef pfasst::encap::VectorEncapsulation<complex <double >> complex_vector_type;
3732
38- /*
39- * Parameter lambda and initial value u0
40- */
33+ // ! Parameter lambda and initial value u0
4134 complex <double > lambda, u0;
4235
43- /*
44- * The complex unit i = sqrt(-1)
45- */
36+ // ! The complex unit i = sqrt(-1)
4637 const complex <double > i_complex = complex <double >(0 , 1 );
4738
48- /*
49- * Error at the final time. For the scalar example, an analytical solution is known.
50- */
39+ // ! Error at the final time. For the scalar example, an analytical solution is known.
5140 double error;
5241
53- /*
54- * Counters for how often f_expl_eval, f_impl_eval and impl_solve are called.
55- */
42+ // ! Counters for how often f_expl_eval, f_impl_eval and impl_solve are called.
5643 size_t n_f_expl_eval, n_f_impl_eval, n_impl_solve;
5744
5845 public:
5946
60- /*
47+ /* *
6148 * Generic constructor; initialize all function call counters with zero.
49+ * lambda = coefficient in test equation
50+ * u0 = initial value at t=0
6251 */
6352 ScalarSweeper (complex <double > lambda, complex <double > u0)
6453 : lambda(lambda)
@@ -69,7 +58,7 @@ class ScalarSweeper
6958 , error(0.0 )
7059 {}
7160
72- /*
61+ /* *
7362 * Upon destruction, report final error and number of function calls
7463 */
7564 virtual ~ScalarSweeper ()
@@ -80,7 +69,7 @@ class ScalarSweeper
8069 cout << " Number of implicit solves: " << this ->n_impl_solve << endl;
8170 }
8271
83- /*
72+ /* *
8473 * Compute error and print it to cout
8574 */
8675 void echo_error (time t)
@@ -95,15 +84,15 @@ class ScalarSweeper
9584 this ->error = max_err;
9685 }
9786
98- /*
87+ /* *
9988 * Returns error, but does not update it!
10089 */
10190 double get_errors ()
10291 {
10392 return this ->error ;
10493 }
10594
106- /*
95+ /* *
10796 * Prediction step and update of error. Uses predictor as provided by IMEXSweeper.
10897 */
10998 void predict (bool initial) override
@@ -114,7 +103,7 @@ class ScalarSweeper
114103 this ->echo_error (t + dt);
115104 }
116105
117- /*
106+ /* *
118107 * Perform a sweep and update error. Uses sweep as provided by IMEXSweeper.
119108 */
120109 void sweep () override
@@ -125,7 +114,7 @@ class ScalarSweeper
125114 this ->echo_error (t + dt);
126115 }
127116
128- /*
117+ /* *
129118 * Computes the exact solution u0*exp(lambda*t) at a given time t.
130119 */
131120 void exact (complex_vector_type& q, time t)
@@ -139,7 +128,7 @@ class ScalarSweeper
139128 this ->exact (q, t);
140129 }
141130
142- /*
131+ /* *
143132 * Evaluate the explicit part of the right hand side: Multiply with imag(lambda)
144133 */
145134 void f_expl_eval (shared_ptr<encap_type> f_encap,
@@ -155,7 +144,7 @@ class ScalarSweeper
155144 this ->n_f_expl_eval ++;
156145 }
157146
158- /*
147+ /* *
159148 * Evaluate the implicit part of the right hand side: Multiply with real(lambda)
160149 */
161150 void f_impl_eval (shared_ptr<encap_type> f_encap,
@@ -171,7 +160,7 @@ class ScalarSweeper
171160 this ->n_f_impl_eval ++;
172161 }
173162
174- /*
163+ /* *
175164 * For given b, solve (Id - dt*real(lambda))*u = b for u
176165 */
177166 void impl_solve (shared_ptr<encap_type> f_encap,
0 commit comments