Skip to content

Commit

Permalink
core: Extract P3M tuning code
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed May 7, 2022
1 parent 9ea50b2 commit 860563c
Show file tree
Hide file tree
Showing 23 changed files with 830 additions and 974 deletions.
12 changes: 3 additions & 9 deletions src/core/actor/visit_try_catch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,21 @@

/** @brief Run a kernel on a variant and queue errors. */
template <typename Visitor, typename Variant>
bool visit_active_actor_try_catch(Visitor &&visitor, Variant &actor) {
bool failed = false;
void visit_active_actor_try_catch(Visitor &&visitor, Variant &actor) {
try {
boost::apply_visitor(visitor, actor);
} catch (std::runtime_error const &err) {
runtimeErrorMsg() << err.what();
failed = true;
}
return failed;
}

/** @brief Run a kernel on a variant and queue errors. */
template <typename Visitor, typename Variant>
bool visit_active_actor_try_catch(Visitor &&visitor,
void visit_active_actor_try_catch(Visitor &&visitor,
boost::optional<Variant> &actor) {
bool failed = false;
if (actor) {
failed =
visit_active_actor_try_catch(std::forward<Visitor>(visitor), *actor);
visit_active_actor_try_catch(std::forward<Visitor>(visitor), *actor);
}
return failed;
}

#endif
12 changes: 5 additions & 7 deletions src/core/electrostatics/coulomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ boost::optional<ElectrostaticsExtension> electrostatics_extension;

namespace Coulomb {

bool sanity_checks() {
return visit_active_actor_try_catch(
[](auto &actor) {
actor->sanity_checks();
actor->sanity_checks_charge_neutrality();
},
electrostatics_actor);
void sanity_checks() {
if (electrostatics_actor) {
boost::apply_visitor([](auto &actor) { actor->sanity_checks(); },
*electrostatics_actor);
}
}

void on_coulomb_change() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/electrostatics/coulomb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void check_charge_neutrality(double relative_tolerance);

Utils::Vector9d calc_pressure_long_range(ParticleRange const &particles);

bool sanity_checks();
void sanity_checks();
double cutoff(Utils::Vector3d const &box_l);

void on_observable_calc();
Expand Down
2 changes: 1 addition & 1 deletion src/core/electrostatics/debye_hueckel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct DebyeHueckel : public Coulomb::Actor<DebyeHueckel> {
this->r_cut = r_cut;
}

void on_activation() const { sanity_checks_charge_neutrality(); }
void on_activation() const { sanity_checks(); }
void on_boxl_change() const {}
void on_node_grid_change() const {}
void on_periodicity_change() const {}
Expand Down
Loading

0 comments on commit 860563c

Please sign in to comment.