Skip to content

Commit e1c079c

Browse files
committed
Merge pull request #187 from torbjoernk/feature/boris-log-init
examples: boris: refactor logging initialization
2 parents daffbf9 + b8adbdb commit e1c079c

File tree

6 files changed

+53
-45
lines changed

6 files changed

+53
-45
lines changed

examples/boris/bindings/wrapper_simple_physics_solver_impl.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ namespace pfasst
111111
ParticleCloudComponent<scalar>
112112
WrapperSimplePhysicsSolver<scalar, time>::external_e_field_evaluate(const particle_cloud_type& particles, const time t)
113113
{
114-
CVLOG(6, "Solver") << "evaluating external E-Field at t=" << t;
114+
CVLOG(6, "SolverBinding") << "evaluating external E-Field at t=" << t;
115115
size_t num_particles = particles->size();
116116
assert(DIM == particles->dim());
117117

@@ -138,7 +138,7 @@ namespace pfasst
138138
ParticleCloudComponent<scalar>
139139
WrapperSimplePhysicsSolver<scalar, time>::e_field_evaluate(const particle_cloud_type& particles, const time t)
140140
{
141-
CVLOG(6, "Solver") << "evaluating complete E-Field at t=" << t;
141+
CVLOG(6, "SolverBinding") << "evaluating complete E-Field at t=" << t;
142142
size_t num_particles = particles->size();
143143
assert(DIM == particles->dim());
144144

@@ -165,7 +165,7 @@ namespace pfasst
165165
ParticleCloudComponent<scalar>
166166
WrapperSimplePhysicsSolver<scalar, time>::b_field_evaluate(const particle_cloud_type& particles, const time t)
167167
{
168-
CVLOG(6, "Solver") << "evaluating B-Field at t=" << t;
168+
CVLOG(6, "SolverBinding") << "evaluating B-Field at t=" << t;
169169
size_t num_particles = particles->size();
170170
assert(DIM == particles->dim());
171171

@@ -204,7 +204,7 @@ namespace pfasst
204204
ParticleCloudComponent<scalar>
205205
WrapperSimplePhysicsSolver<scalar, time>::force_evaluate(const particle_cloud_type& particles, const time t)
206206
{
207-
CVLOG(6, "Solver") << "compute total force at t=" << t;
207+
CVLOG(6, "SolverBinding") << "compute total force at t=" << t;
208208
auto e_force = this->e_field_evaluate(particles, t);
209209
auto b_force = this->b_field_evaluate(particles, t);
210210
return e_force + b_force;
@@ -214,7 +214,7 @@ namespace pfasst
214214
scalar
215215
WrapperSimplePhysicsSolver<scalar, time>::energy(const particle_cloud_type& particles, const time t)
216216
{
217-
CVLOG(6, "Solver") << "computing system's total energy at t=" << t;
217+
CVLOG(6, "SolverBinding") << "computing system's total energy at t=" << t;
218218
size_t num_particles = particles->size();
219219
assert(DIM == particles->dim());
220220

examples/boris/boris_mlsdc.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ namespace pfasst
8888
#ifndef PFASST_UNIT_TESTING
8989
int main(int argc, char** argv)
9090
{
91-
pfasst::init(argc, argv, pfasst::examples::boris::init_opts<double>);
92-
pfasst::init(argc, argv);
93-
pfasst::log::add_custom_logger("Boris");
94-
pfasst::log::add_custom_logger("BorisTransfer");
95-
pfasst::log::add_custom_logger("Solver");
91+
pfasst::init(argc, argv,
92+
pfasst::examples::boris::init_opts<>,
93+
pfasst::examples::boris::init_logs<>);
9694

9795
const size_t nsteps = pfasst::config::get_value<size_t>("num_steps", 1);
9896
const double dt = pfasst::config::get_value<double>("delta_step", 0.015625);
@@ -102,13 +100,13 @@ int main(int argc, char** argv)
102100
const double abs_res_tol = pfasst::config::get_value<double>("abs_res_tol", 0.0);
103101
const double rel_res_tol = pfasst::config::get_value<double>("rel_res_tol", 0.0);
104102

105-
LOG(INFO) << "nsteps=" << nsteps << ", "
106-
<< "dt=" << dt << ", "
107-
<< "nnodes=" << nnodes << ", "
108-
<< "nparticles=" << nparticles << ", "
109-
<< "niter=" << niters << ", "
110-
<< "abs res=" << abs_res_tol << ", "
111-
<< "rel res=" << rel_res_tol;
103+
CLOG(INFO, "Boris") << "nsteps=" << nsteps << ", "
104+
<< "dt=" << dt << ", "
105+
<< "nnodes=" << nnodes << ", "
106+
<< "nparticles=" << nparticles << ", "
107+
<< "niter=" << niters << ", "
108+
<< "abs res=" << abs_res_tol << ", "
109+
<< "rel res=" << rel_res_tol;
112110

113111
pfasst::examples::boris::run_boris_sdc<double>(nsteps, dt, nnodes, nparticles, niters, abs_res_tol, rel_res_tol);
114112
}

examples/boris/boris_pfasst.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ namespace pfasst
9393
int main(int argc, char** argv)
9494
{
9595
MPI_Init(&argc, &argv);
96-
pfasst::init(argc, argv, pfasst::examples::boris::init_opts<double>);
97-
pfasst::log::add_custom_logger("Boris");
98-
pfasst::log::add_custom_logger("BorisTransfer");
99-
pfasst::log::add_custom_logger("Solver");
96+
pfasst::init(argc, argv,
97+
pfasst::examples::boris::init_opts<>,
98+
pfasst::examples::boris::init_logs<>);
10099

101100
const size_t nsteps = pfasst::config::get_value<size_t>("num_steps", 1);
102101
const double dt = pfasst::config::get_value<double>("delta_step", 0.015625);
@@ -106,13 +105,13 @@ int main(int argc, char** argv)
106105
const double abs_res_tol = pfasst::config::get_value<double>("abs_res_tol", 0.0);
107106
const double rel_res_tol = pfasst::config::get_value<double>("rel_res_tol", 0.0);
108107

109-
LOG(INFO) << "nsteps=" << nsteps << ", "
110-
<< "dt=" << dt << ", "
111-
<< "nnodes=" << nnodes << ", "
112-
<< "nparticles=" << nparticles << ", "
113-
<< "niter=" << niters << ", "
114-
<< "abs res=" << abs_res_tol << ", "
115-
<< "rel res=" << rel_res_tol;
108+
CLOG(INFO, "Boris") << "nsteps=" << nsteps << ", "
109+
<< "dt=" << dt << ", "
110+
<< "nnodes=" << nnodes << ", "
111+
<< "nparticles=" << nparticles << ", "
112+
<< "niter=" << niters << ", "
113+
<< "abs res=" << abs_res_tol << ", "
114+
<< "rel res=" << rel_res_tol;
116115

117116
pfasst::examples::boris::run_boris_pfasst<double>(nsteps, dt, nnodes, nparticles, niters, abs_res_tol, rel_res_tol);
118117
MPI_Finalize();

examples/boris/boris_sdc.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ namespace pfasst
6767
#ifndef PFASST_UNIT_TESTING
6868
int main(int argc, char** argv)
6969
{
70-
pfasst::init(argc, argv, pfasst::examples::boris::init_opts<double>);
71-
pfasst::log::add_custom_logger("Boris");
72-
pfasst::log::add_custom_logger("Solver");
70+
pfasst::init(argc, argv,
71+
pfasst::examples::boris::init_opts<>,
72+
pfasst::examples::boris::init_logs<>);
7373

7474
const size_t nsteps = pfasst::config::get_value<size_t>("num_steps", 1);
7575
const double dt = pfasst::config::get_value<double>("delta_step", 0.015625);
@@ -79,13 +79,13 @@ int main(int argc, char** argv)
7979
const double abs_res_tol = pfasst::config::get_value<double>("abs_res_tol", 0.0);
8080
const double rel_res_tol = pfasst::config::get_value<double>("rel_res_tol", 0.0);
8181

82-
LOG(INFO) << "nsteps=" << nsteps << ", "
83-
<< "dt=" << dt << ", "
84-
<< "nnodes=" << nnodes << ", "
85-
<< "nparticles=" << nparticles << ", "
86-
<< "niter=" << niters << ", "
87-
<< "abs res=" << abs_res_tol << ", "
88-
<< "rel res=" << rel_res_tol;
82+
CLOG(INFO, "Boris") << "nsteps=" << nsteps << ", "
83+
<< "dt=" << dt << ", "
84+
<< "nnodes=" << nnodes << ", "
85+
<< "nparticles=" << nparticles << ", "
86+
<< "niter=" << niters << ", "
87+
<< "abs res=" << abs_res_tol << ", "
88+
<< "rel res=" << rel_res_tol;
8989

9090
pfasst::examples::boris::run_boris_sdc<double>(nsteps, dt, nnodes, nparticles, niters, abs_res_tol, rel_res_tol);
9191
}

examples/boris/boris_sweeper.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,12 @@ namespace pfasst
9191
using error_map = map<error_index, ErrorTuple<scalar>>;
9292

9393

94-
template<typename scalar>
94+
template<typename precision = pfasst::time_precision>
9595
static void init_opts();
9696

97+
template<typename precision = pfasst::time_precision>
98+
static void init_logs();
99+
97100

98101
class LogIndent
99102
{

examples/boris/boris_sweeper_impl.hpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,28 @@ namespace pfasst
4848
{
4949
namespace boris
5050
{
51-
template<typename scalar>
52-
void ParticleError<scalar>::log(el::base::type::ostream_t& os) const
51+
template<typename precision>
52+
void ParticleError<precision>::log(el::base::type::ostream_t& os) const
5353
{
5454
os << "pos: [" << x << " " << y << " " << z << "]\tvel: [" << y << " " << v << " " << w << "]";
5555
}
5656

5757

58-
template<typename scalar>
58+
template<typename precision>
5959
static void init_opts()
6060
{
6161
pfasst::config::options::add_option<size_t>("Boris-SDC", "num_particles", "number of particles in the cloud");
62-
pfasst::config::options::add_option<scalar>("Boris-SDC", "epsilon", "Boris' epsilon");
63-
pfasst::config::options::add_option<scalar>("Boris-SDC", "omega_e", "E-field constant");
64-
pfasst::config::options::add_option<scalar>("Boris-SDC", "omega_b", "B-field constant");
62+
pfasst::config::options::add_option<precision>("Boris-SDC", "epsilon", "Boris' epsilon");
63+
pfasst::config::options::add_option<precision>("Boris-SDC", "omega_e", "E-field constant");
64+
pfasst::config::options::add_option<precision>("Boris-SDC", "omega_b", "B-field constant");
65+
}
66+
67+
template<typename precision>
68+
static void init_logs()
69+
{
70+
pfasst::log::add_custom_logger("Boris");
71+
pfasst::log::add_custom_logger("SolverBinding");
72+
pfasst::log::add_custom_logger("Solver");
6573
}
6674

6775

0 commit comments

Comments
 (0)