Skip to content

Commit 735f307

Browse files
committed
config: Add two stage config/log init to pfasst::init.
Signed-off-by: Matthew Emmett <[email protected]>
1 parent 5fe8699 commit 735f307

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

examples/advection_diffusion/advection_diffusion_sweeper.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ namespace pfasst
4848
: public encap::IMEXSweeper<time>
4949
{
5050
public:
51-
static void init()
51+
static void init_opts()
5252
{
5353
config::add_option<size_t>("Adv/Diff Sweeper", "spatial_dofs", "Number of spatial degrees of freedom");
5454
}
5555

56+
static void init_logs()
57+
{
58+
pfasst::log::add_custom_logger("Advec");
59+
}
60+
5661
private:
5762
//! @{
5863
FFT fft;
@@ -88,7 +93,7 @@ namespace pfasst
8893

8994
virtual ~AdvectionDiffusionSweeper()
9095
{
91-
CLOG(INFO, "User") << "number of f1 evals: " << this->nf1evals;
96+
CLOG(INFO, "Advec") << "number of f1 evals: " << this->nf1evals;
9297
}
9398
//! @}
9499

@@ -131,7 +136,7 @@ namespace pfasst
131136
auto n = this->get_controller()->get_step();
132137
auto k = this->get_controller()->get_iteration();
133138

134-
CLOG(INFO, "User") << "err: " << n << " " << k << " " << max << " (" << qend.size() << "," << predict << ")";
139+
CLOG(INFO, "Advec") << "err: " << n << " " << k << " " << max << " (" << qend.size() << "," << predict << ")";
135140
this->errors.insert(vtype(ktype(n, k), max));
136141
}
137142

@@ -152,7 +157,7 @@ namespace pfasst
152157

153158
auto n = this->get_controller()->get_step();
154159
auto k = this->get_controller()->get_iteration();
155-
CLOG(INFO, "User") << "res: " << n << " " << k << " " << rmax << " (" << residuals.size() << ")";
160+
CLOG(INFO, "Advec") << "res: " << n << " " << k << " " << rmax << " (" << residuals.size() << ")";
156161

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

examples/advection_diffusion/vanilla_sdc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ namespace pfasst
6262
#ifndef PFASST_UNIT_TESTING
6363
int main(int argc, char** argv)
6464
{
65-
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init();
66-
pfasst::init(argc, argv);
65+
pfasst::init(argc, argv,
66+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_opts,
67+
pfasst::examples::advection_diffusion::AdvectionDiffusionSweeper<>::init_logs);
6768
pfasst::examples::advection_diffusion::run_vanilla_sdc(0.0);
6869
}
6970
#endif

include/pfasst.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99

1010
namespace pfasst
1111
{
12-
inline static void init(int argc, char** argv)
12+
inline static void init(int argc, char** argv, std::function<void()> opts, std::function<void()> logs)
1313
{
14+
if (opts) {
15+
opts();
16+
}
1417
config::init();
1518
log::start_log(argc, argv);
19+
if (logs) {
20+
logs();
21+
}
1622
config::read_commandline(argc, argv);
1723
}
1824
} // ::pfasst

0 commit comments

Comments
 (0)