Skip to content

Commit b7ffc09

Browse files
committed
Merge pull request #145 from torbjoernk/feature/boris-logging-improve
Improving logging for Boris SDC
2 parents 2d1f433 + 01cd1ab commit b7ffc09

File tree

7 files changed

+148
-125
lines changed

7 files changed

+148
-125
lines changed

examples/boris/bindings/simple_physics_solver.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ namespace simple_physics_solver
7575
// cout << "SimplePhysicsSolver::evaluate_internal_e_field(t=" << t << ")" << endl;
7676
double r = double(0.0),
7777
r3 = double(0.0),
78-
dist = double(0.0);
78+
dist2 = double(0.0);
79+
double* dist = new double[DIM];
7980

8081
// computing forces on particle i
8182
for (size_t i = 0; i < num_particles; ++i) {
@@ -92,18 +93,19 @@ namespace simple_physics_solver
9293
// cout << " skipping" << endl;
9394
continue;
9495
}
95-
dist = double(0.0);
96+
dist2 = double(0.0);
9697
for (size_t d = 0; d < DIM; ++d) {
97-
dist += (positions[i * DIM + d] - positions[j * DIM + d]) * (positions[i * DIM + d] - positions[j * DIM + d]);
98+
dist[d] = positions[i * DIM + d] - positions[j * DIM + d];
99+
dist2 += dist[d] * dist[d];
98100
}
99101
// cout << " dist = " << dist << endl;
100-
r = sqrt(dist * dist + config->sigma2);
102+
r = sqrt(dist2 + config->sigma2);
101103
// cout << " r = " << r << " (= sqrt(dist^2+" << config->sigma2 << ")" << endl;
102-
phis[i] += charges[j] / r;
104+
// phis[i] += charges[j] / r;
103105

104106
r3 = r * r * r;
105107
for (size_t d = 0; d < DIM; ++d) {
106-
exyz[i * DIM + d] += positions[j * DIM + d] / r3 * charges[j];
108+
exyz[i * DIM + d] += dist[d] / r3 * charges[j];
107109
// cout << " exyz[" << i * DIM + d << "] += " << positions[j * DIM + d] << " / " << r3 << " * " << charges[j] << "(q) => " << exyz[i * DIM + d] << endl;
108110
}
109111
}
@@ -113,6 +115,7 @@ namespace simple_physics_solver
113115
// cout << endl
114116
// << " phi_i = " << phis[i] << endl;
115117
}
118+
delete[] dist;
116119
// cout << "DONE SimplePhysicsSolver::evaluate_internal_e_field(t=" << t << ")" << endl;
117120
}
118121

examples/boris/bindings/wrapper_simple_physics_solver_impl.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,10 @@ namespace pfasst
115115
ParticleCloudComponent<scalar>
116116
WrapperSimplePhysicsSolver<scalar, time>::e_field_evaluate(const particle_cloud_type& particles, const time t)
117117
{
118-
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << "time=" << t;
118+
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << " time=" << t;
119119
size_t num_particles = particles->size();
120120
assert(DIM == particles->dim());
121121

122-
// VLOG(3) << LOG_INDENT << "positions:" << particles->positions();
123-
124122
scalar* packed_positions = new scalar[num_particles * DIM];
125123
scalar* packed_masses = new scalar[num_particles];
126124
scalar* packed_charges = new scalar[num_particles];
@@ -145,7 +143,7 @@ namespace pfasst
145143
ParticleCloudComponent<scalar>
146144
WrapperSimplePhysicsSolver<scalar, time>::b_field_evaluate(const particle_cloud_type& particles, const time t)
147145
{
148-
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << "time=" << t;
146+
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << " time=" << t;
149147
size_t num_particles = particles->size();
150148
assert(DIM == particles->dim());
151149

@@ -173,7 +171,7 @@ namespace pfasst
173171
ParticleCloudComponent<scalar>
174172
WrapperSimplePhysicsSolver<scalar, time>::b_field_vecs(const particle_cloud_type& particles, const time t)
175173
{
176-
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << "time=" << t;
174+
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << " time=" << t;
177175
auto b_vecs = cloud_component_factory<scalar>(particles->size(), particles->dim());
178176
for (size_t p = 0; p < particles->size(); ++p) {
179177
b_vecs[p] = this->get_b_field_vector() / particles->charges()[p] / particles->masses()[p];
@@ -186,7 +184,7 @@ namespace pfasst
186184
ParticleCloudComponent<scalar>
187185
WrapperSimplePhysicsSolver<scalar, time>::force_evaluate(const particle_cloud_type& particles, const time t)
188186
{
189-
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << "time=" << t;
187+
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << " time=" << t;
190188
auto e_force = this->e_field_evaluate(particles, t);
191189
auto b_force = this->b_field_evaluate(particles, t);
192190
VLOG_FUNC_END("WrapperSimplePhysicsSolver");
@@ -197,7 +195,7 @@ namespace pfasst
197195
scalar
198196
WrapperSimplePhysicsSolver<scalar, time>::energy(const particle_cloud_type& particles, const time t)
199197
{
200-
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << "time=" << t;
198+
VLOG_FUNC_START("WrapperSimplePhysicsSolver") << " time=" << t;
201199
size_t num_particles = particles->size();
202200
assert(DIM == particles->dim());
203201

@@ -212,7 +210,6 @@ namespace pfasst
212210

213211
auto energy = solver::compute_energy(packed_positions, packed_velocities, packed_charges, packed_masses,
214212
num_particles, t, this->config.get());
215-
VLOG(2) << LOG_INDENT << "energy =" << energy;
216213
delete[] packed_velocities;
217214
delete[] packed_positions;
218215
delete[] packed_masses;

0 commit comments

Comments
 (0)