Skip to content

Commit b27bfb6

Browse files
committed
Merge pull request #204 from torbjoernk/feature/advec-logging
changed logging output from IMEX sweeper
2 parents d6ea835 + abdaa0e commit b27bfb6

File tree

6 files changed

+27
-14
lines changed

6 files changed

+27
-14
lines changed

examples/advection_diffusion/advection_diffusion_sweeper.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ namespace pfasst
167167
auto n = this->get_controller()->get_step();
168168
auto k = this->get_controller()->get_iteration();
169169

170-
CLOG(INFO, "Advec") << "err: " << n << " " << k << " " << max << " (" << qend.size() << "," << predict << ")";
171170
this->errors.insert(vtype(ktype(n, k), max));
172171
}
173172

@@ -188,7 +187,10 @@ namespace pfasst
188187

189188
auto n = this->get_controller()->get_step();
190189
auto k = this->get_controller()->get_iteration();
191-
CLOG(INFO, "Advec") << "res: " << n << " " << k << " " << rmax << " (" << residuals.size() << ")";
190+
191+
auto err = this->errors[ktype(n, k)];
192+
193+
CLOG(INFO, "Advec") << boost::format(this->FORMAT_STR) % (n+1) % k % this->get_nodes().size() % as_vector<double, time>(this->state[0]).size() % rmax % err;
192194

193195
this->residuals[ktype(n, k)] = rmax;
194196
}

examples/boris/boris_sweeper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ namespace pfasst
172172

173173
ofstream data_stream;
174174

175-
string FORMAT_STR;
176175
boost::format log_fmt;
177176
string DATA_STREAM_FORMAT_STR;
178177
boost::format data_stream_fmt;

include/pfasst/encap/encap_sweeper.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ namespace pfasst
9999
time rel_residual_tol;
100100
//! @}
101101

102+
string FORMAT_STR;
103+
102104
public:
103105
EncapSweeper();
104106

include/pfasst/logging.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ namespace pfasst
191191
*
192192
* @ingroup Internals
193193
*/
194-
inline string format_mpi_rank(const size_t width = 4, const char fill = ' ')
194+
inline string format_mpi_rank(const char fill = ' ')
195195
{
196196
ostringstream frmter;
197-
frmter << std::setw(width) << std::setfill(fill) << pfasst::config::get_rank();
197+
frmter << std::setw(4) << std::setfill(fill) << pfasst::config::get_rank();
198198
return frmter.str();
199199
}
200200

src/pfasst/controller/mlsdc_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace pfasst
2020
void MLSDC<time>::perform_sweeps(size_t level)
2121
{
2222
auto sweeper = this->get_level(level);
23-
CLOG(INFO, "Controller") << "on level " << level + 1 << "/" << this->nlevels();
23+
CVLOG(1, "Controller") << "on level " << level + 1 << "/" << this->nlevels();
2424
for (size_t s = 0; s < this->nsweeps[level]; s++) {
2525
if (predict) {
2626
sweeper->predict(initial & predict);

src/pfasst/encap/imex_sweeper_impl.hpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "pfasst/encap/imex_sweeper.hpp"
22

3+
#include <algorithm>
34
#include <cassert>
45
using namespace std;
56

@@ -39,6 +40,15 @@ namespace pfasst
3940
if (! this->quadrature->left_is_node()) {
4041
this->fs_expl_start = this->get_factory()->create(pfasst::encap::function);
4142
}
43+
44+
size_t nsteps = this->get_controller()->get_end_time() / this->get_controller()->get_time_step();
45+
size_t digit_step = (this->get_controller()->get_time_step() > 0) ?
46+
to_string(nsteps + 1).length() : 3;
47+
size_t digit_iter = (this->get_controller()->get_max_iterations() > 0) ?
48+
to_string(this->get_controller()->get_max_iterations() - 1).length() : 3;
49+
this->FORMAT_STR = "step: %|" + to_string(digit_step) + "| iter: %|" + to_string(digit_iter) + "|"
50+
+ " n1: %|2| n2: %|3|"
51+
+ " residual: %10.4e" + " err: %10.4e";
4252
}
4353

4454
template<typename time>
@@ -165,8 +175,8 @@ namespace pfasst
165175
{
166176
time dt = this->get_controller()->get_time_step();
167177
time t = this->get_controller()->get_time();
168-
CLOG(INFO, "Sweeper") << "predicting step " << this->get_controller()->get_step() + 1
169-
<< " (t=" << t << ", dt=" << dt << ")";
178+
CVLOG(1, "Sweeper") << "predicting step " << this->get_controller()->get_step() + 1
179+
<< " (t=" << t << ", dt=" << dt << ")";
170180

171181
if (initial) {
172182
this->state[0]->copy(this->start_state);
@@ -195,8 +205,8 @@ namespace pfasst
195205
UNUSED(initial);
196206
time dt = this->get_controller()->get_time_step();
197207
time t = this->get_controller()->get_time();
198-
CLOG(INFO, "Sweeper") << "predicting step " << this->get_controller()->get_step() + 1
199-
<< " (t=" << t << ", dt=" << dt << ")";
208+
CVLOG(1, "Sweeper") << "predicting step " << this->get_controller()->get_step() + 1
209+
<< " (t=" << t << ", dt=" << dt << ")";
200210
time ds;
201211

202212
shared_ptr<Encapsulation<time>> rhs = this->get_factory()->create(pfasst::encap::solution);
@@ -228,8 +238,8 @@ namespace pfasst
228238
auto const nodes = this->quadrature->get_nodes();
229239
auto const dt = this->get_controller()->get_time_step();
230240
auto const s_mat = this->quadrature->get_s_mat().block(1, 0, nodes.size()-1, nodes.size());
231-
CLOG(INFO, "Sweeper") << "sweeping on step " << this->get_controller()->get_step() + 1
232-
<< " in iteration " << this->get_controller()->get_iteration() << " (dt=" << dt << ")";
241+
CVLOG(1, "Sweeper") << "sweeping on step " << this->get_controller()->get_step() + 1
242+
<< " in iteration " << this->get_controller()->get_iteration() << " (dt=" << dt << ")";
233243
time ds;
234244

235245
this->s_integrals[0]->mat_apply(this->s_integrals, dt, s_mat, this->fs_expl, true);
@@ -266,8 +276,8 @@ namespace pfasst
266276
auto const nodes = this->quadrature->get_nodes();
267277
auto const dt = this->get_controller()->get_time_step();
268278
auto const s_mat = this->quadrature->get_s_mat();
269-
CLOG(INFO, "Sweeper") << "sweeping on step " << this->get_controller()->get_step() + 1
270-
<< " in iteration " << this->get_controller()->get_iteration() << " (dt=" << dt << ")";
279+
CVLOG(1, "Sweeper") << "sweeping on step " << this->get_controller()->get_step() + 1
280+
<< " in iteration " << this->get_controller()->get_iteration() << " (dt=" << dt << ")";
271281
time ds;
272282

273283
this->s_integrals[0]->mat_apply(this->s_integrals, dt, s_mat, this->fs_expl, true);

0 commit comments

Comments
 (0)