41#include <boost/mpi/collectives/gather.hpp>
51#include <unordered_map>
56static int coord(std::string
const &s) {
63 throw std::invalid_argument(
"Invalid Cartesian coordinate: '" + s +
"'");
88 auto const error_msg = std::string(
"Parameter 'node_grid'");
101 throw std::invalid_argument(error_msg +
reason.str());
113 []() { return ::communicator.node_grid; }},
118 if (
context()->is_head_node()) {
119 throw std::domain_error(
"Parameter 'skin' must be >= 0");
136 auto const hd = get_hybrid_decomposition();
137 auto const ns_types =
hd.get_n_square_types();
146 auto const rd = get_regular_decomposition();
147 auto const fcb =
rd.fully_connected_boundary();
150 return Variant{std::unordered_map<std::string, Variant>{
160 auto const hd = get_hybrid_decomposition();
164 [
this]() {
return get_system().nonbonded_ias->maximal_cutoff(); }},
166 [
this]() {
return get_system().bonded_ias->maximal_cutoff(); }},
168 [
this]() {
return get_system().get_interaction_range(); }},
174 if (
name ==
"initialize") {
180 if (
name ==
"resort") {
184 if (
name ==
"get_state") {
188 auto const rd = get_regular_decomposition();
192 auto const hd = get_hybrid_decomposition();
195 mpi_resort_particles(
true);
196 state[
"parts_per_decomposition"] =
197 Variant{std::unordered_map<std::string, Variant>{
198 {
"regular",
hd.count_particles_in_regular()},
199 {
"n_square",
hd.count_particles_in_n_square()}}};
205 if (
name ==
"get_pairs") {
206 std::vector<Variant>
out;
209 system.on_observable_calc();
210 std::vector<std::pair<int, int>>
pair_list;
212 if (std::get_if<std::string>(¶ms.at(
"types"))) {
215 throw std::invalid_argument(
"Unknown argument types='" +
key +
"'");
223 std::ranges::transform(
pair_list, std::back_inserter(
out),
224 [](
auto const &
pair) {
225 return std::vector<int>{
pair.first,
pair.second};
230 if (
name ==
"get_neighbors") {
234 system.on_observable_calc();
245 std::vector<int> neighbors;
254 if (
name ==
"non_bonded_loop_trace") {
256 system.on_observable_calc();
257 std::vector<Variant>
out;
261 std::ranges::transform(
263 return std::vector<Variant>{
pair.id1,
pair.id2,
pair.pos1,
268 if (
name ==
"tune_skin") {
277 if (
name ==
"get_max_range") {
283std::vector<int> CellSystem::mpi_resort_particles(
bool global_flag)
const {
287 auto const size =
static_cast<int>(cell_structure.local_particles().size());
297 m_cell_structure->use_verlet_list =
verlet;
305 std::optional<std::pair<int, int>>
fcb_pair = std::nullopt;
306 if (params.contains(
"fully_connected_boundary")
and
307 not is_none(params.at(
"fully_connected_boundary"))) {
312 coord(std::get<std::string>(
variant.at(
"direction")))}};
316 m_cell_structure->set_regular_decomposition(
338 if (
name ==
"get_node_grid") {
339 return ::communicator.node_grid;
341 if (
name ==
"acquire_lock") {
344 }
else if (
name ==
"release_lock") {
CellStructureType
Cell structure topology.
@ HYBRID
Hybrid decomposition.
@ REGULAR
Regular decomposition.
static int coord(std::string const &s)
static std::string coord_letter(int c)
Vector implementation and trait types for boost qvm interoperability.
Data structures for bonded interactions.
std::optional< std::vector< int > > get_short_range_neighbors(System::System const &system, int const pid, double const distance)
Get ids of particles that are within a certain distance of another particle.
std::vector< PairInfo > non_bonded_loop_trace(System::System const &system, int const rank)
Returns pairs of particle ids, positions and distance as seen by the non-bonded loop.
std::vector< std::pair< int, int > > get_pairs_of_types(System::System const &system, double const distance, std::vector< int > const &types)
Get pairs closer than distance if both their types are in types.
std::vector< std::pair< int, int > > get_pairs(System::System const &system, double const distance)
Get pairs closer than distance from the cells.
This file contains everything related to the global cell structure / cell system.
void add_parameters(std::vector< AutoParameter > &¶ms)
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
auto & get_cell_structure() const
void configure(Particles::ParticleHandle &)
void do_construct(VariantMap const ¶ms) override
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
virtual boost::mpi::communicator const & get_comm() const =0
VariantMap get_parameters() const
Get current parameters.
Context * context() const
Responsible context.
std::string_view name() const
auto const & get_system() const
std::weak_ptr<::System::System > m_system
Communicator communicator
This file contains the asynchronous MPI communication.
constexpr bool is_none(Variant const &v)
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
T get_value_or(VariantMap const &vals, std::string const &name, T const &default_)
Get a value from a VariantMap by name, or return a default value if it does not exist.
constexpr const None none
None-"literal".
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
T product(Vector< T, N > const &v)
Various procedures concerning interactions between particles.
void clear_particle_node()
Invalidate particle_node.
Particles creation and deletion.
bool locked_for_checkpointing
Utils::Vector3i node_grid
void set_node_grid(Utils::Vector3i const &value)
Set new Cartesian topology.
static constexpr const ReadOnly read_only
Recursive variant implementation.