Skip to content

Commit bc7f126

Browse files
author
Daniel Ruprecht
committed
more documentation for scalar example; added mathjax directives at multiple points
1 parent d9257db commit bc7f126

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

examples/scalar/scalar_sdc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Solves Dahlquist's test equation with single level SDC
55
*
6-
* y' = lambda y = a y + i b y, y(0) = 1.0
6+
* \\( u' = \\lambda*u \\quad\\text{ , } u(0) = u_0 \\)
77
*
88
* with complex lambda, treating the real part implicitly and the imaginary part
99
* explicitly.
@@ -25,7 +25,7 @@ double run_scalar_sdc(const size_t nsteps, const double dt, const size_t nnodes,
2525
pfasst::SDC<> sdc;
2626

2727
/*
28-
* For test equation, set initial value to 1+i0
28+
* For test equation, set initial value to \\( 1+0i )\\
2929
*/
3030
const complex<double> y0 = complex<double>(1.0, 0.0);
3131

examples/scalar/scalar_sweeper.hpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ template<typename time = pfasst::time_precision>
1414
/**
1515
* Sweeper for scalar test equation
1616
*
17-
* u' = lambda*u, u(0) = u0
17+
* \\( u' = \\lambda*u \\quad\\text{ , } u(0) = u_0 \\)
1818
*
19-
* with complex lambda using an IMEX scheme. Derived from the generic imex_sweeper
19+
* with complex lambda using an IMEX scheme. Derived from the generic imex_sweeper.
2020
*
21-
* ScalarSweeper is derived from the generic IMEXSweeper
2221
*/
2322
class ScalarSweeper
2423
: public pfasst::encap::IMEXSweeper<time>
@@ -31,7 +30,7 @@ class ScalarSweeper
3130
typedef pfasst::encap::VectorEncapsulation<complex<double>> complex_vector_type;
3231

3332
//! Parameter lambda and initial value u0
34-
complex<double> lambda, u0;
33+
const complex<double> lambda, u0;
3534

3635
//! The complex unit i = sqrt(-1)
3736
const complex<double> i_complex = complex<double>(0, 1);
@@ -46,10 +45,10 @@ class ScalarSweeper
4645

4746
/**
4847
* Generic constructor; initialize all function call counters with zero.
49-
* lambda = coefficient in test equation
50-
* u0 = initial value at t=0
48+
* @param[in] lambda coefficient in test equation
49+
* @param[in] u0initial value at \\( t=0 \\)
5150
*/
52-
ScalarSweeper(complex<double> lambda, complex<double> u0)
51+
ScalarSweeper(const complex<double> lambda, const complex<double> u0)
5352
: lambda(lambda)
5453
, u0(u0)
5554
, n_f_expl_eval(0)
@@ -70,7 +69,8 @@ class ScalarSweeper
7069
}
7170

7271
/**
73-
* Compute error and print it to cout
72+
* Compute error between last state and exact solution at time tand print it to cout
73+
* @param[in] Time t
7474
*/
7575
void echo_error(time t)
7676
{
@@ -115,7 +115,10 @@ class ScalarSweeper
115115
}
116116

117117
/**
118-
* Computes the exact solution u0*exp(lambda*t) at a given time t.
118+
* Computes the exact solution \\( u_0 \\exp \\left( \\lambda*t \\right) \\)
119+
* at a given time t.
120+
* @param[in] ???
121+
* @param[in] Time t
119122
*/
120123
void exact(complex_vector_type& q, time t)
121124
{
@@ -129,7 +132,8 @@ class ScalarSweeper
129132
}
130133

131134
/**
132-
* Evaluate the explicit part of the right hand side: Multiply with imag(lambda)
135+
* Evaluate the explicit part of the right hand side: Multiply with
136+
* \\( \\text{imag}(\\lambda) \\)
133137
*/
134138
void f_expl_eval(shared_ptr<encap_type> f_encap,
135139
shared_ptr<encap_type> q_encap, time t) override
@@ -145,7 +149,8 @@ class ScalarSweeper
145149
}
146150

147151
/**
148-
* Evaluate the implicit part of the right hand side: Multiply with real(lambda)
152+
* Evaluate the implicit part of the right hand side: Multiply with
153+
* \\( \\text{real}(\\lambda) \\)
149154
*/
150155
void f_impl_eval(shared_ptr<encap_type> f_encap,
151156
shared_ptr<encap_type> q_encap, time t) override
@@ -161,7 +166,9 @@ class ScalarSweeper
161166
}
162167

163168
/**
164-
* For given b, solve (Id - dt*real(lambda))*u = b for u
169+
* For given \\( b \\), solve
170+
* \\( \\left( \\mathbb{I}_d - \\Delta t \\text{real}(\\lambda) \\right) u = b \\)
171+
* for \\( u \\) and set f_encap to \\( \\text{real}(\\lambda) u \\)
165172
*/
166173
void impl_solve(shared_ptr<encap_type> f_encap,
167174
shared_ptr<encap_type> q_encap, time t, time dt,

0 commit comments

Comments
 (0)