Skip to content

Commit

Permalink
Remove particle_data.cpp
Browse files Browse the repository at this point in the history
Rewrite the EspressoSystemStandAlone class and all particle property
setters, getters and events without MpiCallbacks. Run unit tests in
parallel.
  • Loading branch information
jngrad committed Feb 10, 2023
1 parent 801857d commit 4fbbcb1
Show file tree
Hide file tree
Showing 32 changed files with 399 additions and 778 deletions.
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ add_library(
integrate.cpp
npt.cpp
partCfg_global.cpp
particle_data.cpp
particle_node.cpp
polymer.cpp
pressure.cpp
Expand Down
36 changes: 4 additions & 32 deletions src/core/EspressoSystemStandAlone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "config/config.hpp"

#include "EspressoSystemStandAlone.hpp"
#include "MpiCallbacks.hpp"
#include "communication.hpp"
#include "event.hpp"
#include "grid.hpp"
Expand All @@ -47,48 +46,21 @@ EspressoSystemStandAlone::EspressoSystemStandAlone(int argc, char **argv) {
#ifdef VIRTUAL_SITES
set_virtual_sites(std::make_shared<VirtualSitesOff>());
#endif

// initialize the MpiCallbacks loop (blocking on worker nodes)
mpi_loop();
}

static void mpi_set_box_length_local(Utils::Vector3d const &value) {
set_box_length(value);
}

static void mpi_set_node_grid_local(Utils::Vector3i const &value) {
set_node_grid(value);
}

static void mpi_set_time_step_local(double const &value) {
set_time_step(value);
}

REGISTER_CALLBACK(mpi_set_box_length_local)
REGISTER_CALLBACK(mpi_set_node_grid_local)
REGISTER_CALLBACK(mpi_set_time_step_local)

void EspressoSystemStandAlone::set_box_l(Utils::Vector3d const &box_l) const {
if (!head_node)
return;
mpi_call_all(mpi_set_box_length_local, box_l);
set_box_length(box_l);
}

void EspressoSystemStandAlone::set_node_grid(
Utils::Vector3i const &node_grid) const {
if (!head_node)
return;
mpi_call_all(mpi_set_node_grid_local, node_grid);
::set_node_grid(node_grid);
}

void EspressoSystemStandAlone::set_time_step(double time_step) const {
if (!head_node)
return;
mpi_call_all(mpi_set_time_step_local, time_step);
::set_time_step(time_step);
}

void EspressoSystemStandAlone::set_skin(double new_skin) const {
if (!head_node)
return;
mpi_call_all(mpi_set_skin_local, new_skin);
mpi_set_skin_local(new_skin);
}
1 change: 0 additions & 1 deletion src/core/bond_breakage/bond_breakage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "communication.hpp"
#include "errorhandling.hpp"
#include "event.hpp"
#include "particle_data.hpp"

#include <utils/mpi/gather_buffer.hpp>

Expand Down
10 changes: 5 additions & 5 deletions src/core/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,33 +193,33 @@ void Collision_parameters::initialize() {
throw std::domain_error("Collision detection particle type for virtual "
"sites needs to be >=0");
}
make_particle_type_exist_local(collision_params.vs_particle_type);
make_particle_type_exist(collision_params.vs_particle_type);
}

if (collision_params.mode == CollisionModeType::GLUE_TO_SURF) {
if (collision_params.vs_particle_type < 0) {
throw std::domain_error("Collision detection particle type for virtual "
"sites needs to be >=0");
}
make_particle_type_exist_local(collision_params.vs_particle_type);
make_particle_type_exist(collision_params.vs_particle_type);

if (collision_params.part_type_to_be_glued < 0) {
throw std::domain_error("Collision detection particle type to be glued "
"needs to be >=0");
}
make_particle_type_exist_local(collision_params.part_type_to_be_glued);
make_particle_type_exist(collision_params.part_type_to_be_glued);

if (collision_params.part_type_to_attach_vs_to < 0) {
throw std::domain_error("Collision detection particle type to attach "
"the virtual site to needs to be >=0");
}
make_particle_type_exist_local(collision_params.part_type_to_attach_vs_to);
make_particle_type_exist(collision_params.part_type_to_attach_vs_to);

if (collision_params.part_type_after_glueing < 0) {
throw std::domain_error("Collision detection particle type after gluing "
"needs to be >=0");
}
make_particle_type_exist_local(collision_params.part_type_after_glueing);
make_particle_type_exist(collision_params.part_type_after_glueing);
}

on_short_range_ia_change();
Expand Down
2 changes: 1 addition & 1 deletion src/core/constraints/ShapeBasedConstraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ShapeBasedConstraint : public Constraint {

void set_type(const int &type) {
part_rep.type() = type;
make_particle_type_exist_local(type);
make_particle_type_exist(type);
}

Utils::Vector3d total_force() const;
Expand Down
1 change: 0 additions & 1 deletion src/core/electrostatics/scafacos_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "event.hpp"
#include "grid.hpp"
#include "integrate.hpp"
#include "particle_data.hpp"
#include "tuning.hpp"

#include <utils/Span.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/core/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void on_program_start() {
cells_re_init(CellStructureType::CELL_STRUCTURE_REGULAR);

/* make sure interaction 0<->0 always exists */
make_particle_type_exist_local(0);
make_particle_type_exist(0);
}

void on_integration_start(double time_step) {
Expand Down
1 change: 0 additions & 1 deletion src/core/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include "communication.hpp"
#include "event.hpp"
#include "particle_data.hpp"

#include <utils/Vector.hpp>
#include <utils/mpi/cart_comm.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/core/magnetostatics/dlc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "communication.hpp"
#include "errorhandling.hpp"
#include "grid.hpp"
#include "particle_data.hpp"

#include <utils/constants.hpp>
#include <utils/math/sqr.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/core/magnetostatics/scafacos_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "cells.hpp"
#include "communication.hpp"
#include "grid.hpp"
#include "particle_data.hpp"

#include <utils/Span.hpp>
#include <utils/Vector.hpp>
Expand Down
19 changes: 2 additions & 17 deletions src/core/nonbonded_interactions/nonbonded_interaction_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
#include "nonbonded_interactions/nonbonded_interaction_data.hpp"

#include "communication.hpp"
#include "electrostatics/coulomb.hpp"
#include "event.hpp"

Expand All @@ -50,7 +49,7 @@ static double min_global_cut = INACTIVE_CUTOFF;
* general low-level functions
*****************************************/

void mpi_realloc_ia_params_local(int new_size) {
static void realloc_ia_params(int new_size) {
auto const old_size = ::max_seen_particle_type;
if (new_size <= old_size)
return;
Expand All @@ -76,8 +75,6 @@ void mpi_realloc_ia_params_local(int new_size) {
::nonbonded_ia_params = std::move(new_params);
}

REGISTER_CALLBACK(mpi_realloc_ia_params_local)

static double recalc_maximal_cutoff(const IA_parameters &data) {
auto max_cut_current = INACTIVE_CUTOFF;

Expand Down Expand Up @@ -165,19 +162,7 @@ double maximal_cutoff_nonbonded() {
return max_cut_nonbonded;
}

bool is_new_particle_type(int type) {
return (type + 1) > max_seen_particle_type;
}

void make_particle_type_exist(int type) {
if (is_new_particle_type(type))
mpi_call_all(mpi_realloc_ia_params_local, type + 1);
}

void make_particle_type_exist_local(int type) {
if (is_new_particle_type(type))
mpi_realloc_ia_params_local(type + 1);
}
void make_particle_type_exist(int type) { realloc_ia_params(type + 1); }

void set_min_global_cut(double min_global_cut) {
::min_global_cut = min_global_cut;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,12 @@ inline IA_parameters &get_ia_param(int i, int j) {
return *::nonbonded_ia_params[get_ia_param_key(i, j)];
}

void mpi_realloc_ia_params_local(int new_size);

bool is_new_particle_type(int type);
/** Make sure that ia_params is large enough to cover interactions
* for this particle type. The interactions are initialized with values
* such that no physical interaction occurs.
*/
void make_particle_type_exist(int type);

void make_particle_type_exist_local(int type);

/** Check if a non-bonded interaction is defined */
inline bool checkIfInteraction(IA_parameters const &data) {
return data.max_cut != INACTIVE_CUTOFF;
Expand Down
Loading

0 comments on commit 4fbbcb1

Please sign in to comment.