Skip to content

Commit

Permalink
Rename DomainDecomposition->RegularDecomposition.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkreissl committed Feb 4, 2022
1 parent 9531cf1 commit d162319
Show file tree
Hide file tree
Showing 18 changed files with 103 additions and 103 deletions.
16 changes: 8 additions & 8 deletions doc/sphinx/system_setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ Details about the cell system can be obtained by :meth:`espressomd.system.System
* ``type`` The current type of the cell system.
* ``verlet_reuse`` Average number of integration steps the Verlet list is re-used.

.. _Domain decomposition:
.. _Regular decomposition:

Domain decomposition
~~~~~~~~~~~~~~~~~~~~
Regular decomposition
~~~~~~~~~~~~~~~~~~~~~

Invoking :py:meth:`~espressomd.cellsystem.CellSystem.set_domain_decomposition`
selects the domain decomposition cell scheme, using Verlet lists
Invoking :py:meth:`~espressomd.cellsystem.CellSystem.set_regular_decomposition`
selects the regular decomposition cell scheme, using Verlet lists
for the calculation of the interactions. If you specify ``use_verlet_lists=False``, only the
domain decomposition is used, but not the Verlet lists. ::
regular decomposition is used, but not the Verlet lists. ::

system = espressomd.System(box_l=[1, 1, 1])

system.cell_system.set_domain_decomposition(use_verlet_lists=True)
system.cell_system.set_regular_decomposition(use_verlet_lists=True)

The domain decomposition cellsystem is the default system and suits most
The regular decomposition cellsystem is the default system and suits most
applications with short ranged interactions. The particles are divided
up spatially into small compartments, the cells, such that the cell size
is larger than the maximal interaction range. In this case interactions
Expand Down
6 changes: 3 additions & 3 deletions doc/sphinx/under_the_hood.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ how they are distributed onto the processor nodes and how they are
organized on each of them. Moreover a cell system also defines
procedures to efficiently calculate the force, energy and pressure for
the short ranged interactions, since these can be heavily optimized
depending on the cell system. For example, the domain decomposition
depending on the cell system. For example, the regular decomposition
cellsystem allows an order N interactions evaluation.

Technically, a cell is organized as a dynamically growing array, not as
Expand All @@ -41,7 +41,7 @@ without direct knowledge of the currently used cell system. Only the
force, energy and pressure loops are implemented separately for each
cell model as explained above.

The domain decomposition or link cell algorithm is implemented such
The regular decomposition or link cell algorithm is implemented such
that the cells equal the cells, i.e. each cell is a separate particle
list. For an example let us assume that the simulation box has size
:math:`20\times 20\times 20` and that we assign 2 processors to the
Expand Down Expand Up @@ -108,7 +108,7 @@ memory organization of |es|, the particles are accessed in a virtually
linear order. Because the force calculation goes through the cells in a
linear fashion, all accesses to a single cell occur close in time, for
the force calculation of the cell itself as well as for its neighbors.
Using the domain decomposition cell scheme, two cell layers have to be
Using the regular decomposition cell scheme, two cell layers have to be
kept in the processor cache. For 10000 particles and a typical cell grid
size of 20, these two cell layers consume roughly 200 KBytes, which
nearly fits into the L2 cache. Therefore every cell has to be read from
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/constant_pH/constant_pH.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
"After the initial relaxation we set the electrostatic interactions between the particles if it has been enabled via the `USE_ELECTROSTATICS` flag. For electrostatics can use either the Debye-Hückel `DH` algorithm or the `P3M` algorithm. The `DH` algorithm is based on the Debye-Hückel approximation, the assumptions of which are not satisfied in our simulated system. However, it runs much faster than the `P3M` algorithm, and the approximate result closely resembles the correct one. Therefore, the `DH` algorithm should not be used in production simulations. By using the `DH` algorithm in this tutorial, we sacrifice the accuracy for speed.\n",
"To obtain an accurate result, we can use the `P3M` algorithm using `accuracy` of $10^{-3}$ as an acceptable tradeoff between accuracy and performance. For production runs it might be necessary to use a lower value of `accuracy`, depending on the simulated system.\n",
"\n",
"By default, ESPResSo uses the domain decomposition cell system to speed up the calculation of short-range interactions. However, for a system with small number of particles and without electrostatics, it runs faster with `n_square` cell system. See the [user guide](https://espressomd.github.io/doc/system_setup.html#n-squared) for additional details on the cell systems."
"By default, ESPResSo uses the regular decomposition cell system to speed up the calculation of short-range interactions. However, for a system with small number of particles and without electrostatics, it runs faster with `n_square` cell system. See the [user guide](https://espressomd.github.io/doc/system_setup.html#n-squared) for additional details on the cell systems."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(EspressoCore_SRC
rotate_system.cpp
rotation.cpp
Observable_stat.cpp
RegularDecomposition.cpp
RuntimeErrorCollector.cpp
RuntimeError.cpp
RuntimeErrorStream.cpp
Expand All @@ -41,8 +42,7 @@ set(EspressoCore_SRC
CellStructure.cpp
PartCfg.cpp
AtomDecomposition.cpp
EspressoSystemStandAlone.cpp
DomainDecomposition.cpp)
EspressoSystemStandAlone.cpp)

if(CUDA)
set(EspressoCuda_SRC
Expand Down
8 changes: 4 additions & 4 deletions src/core/CellStructure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "CellStructure.hpp"

#include "AtomDecomposition.hpp"
#include "DomainDecomposition.hpp"
#include "RegularDecomposition.hpp"

#include <utils/contains.hpp>

Expand Down Expand Up @@ -246,10 +246,10 @@ void CellStructure::set_atom_decomposition(boost::mpi::communicator const &comm,
m_type = CELL_STRUCTURE_NSQUARE;
}

void CellStructure::set_domain_decomposition(
void CellStructure::set_regular_decomposition(
boost::mpi::communicator const &comm, double range, BoxGeometry const &box,
LocalBox<double> const &local_geo) {
set_particle_decomposition(
std::make_unique<DomainDecomposition>(comm, range, box, local_geo));
m_type = CELL_STRUCTURE_DOMDEC;
std::make_unique<RegularDecomposition>(comm, range, box, local_geo));
m_type = CELL_STRUCTURE_REGULAR;
}
12 changes: 6 additions & 6 deletions src/core/CellStructure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

/** Cell Structure */
enum CellStructureType : int {
/** cell structure domain decomposition */
CELL_STRUCTURE_DOMDEC = 1,
/** cell structure regular decomposition */
CELL_STRUCTURE_REGULAR = 1,
/** cell structure n square */
CELL_STRUCTURE_NSQUARE = 2
};
Expand Down Expand Up @@ -503,16 +503,16 @@ struct CellStructure {
BoxGeometry const &box);

/**
* @brief Set the particle decomposition to DomainDecomposition.
* @brief Set the particle decomposition to RegularDecomposition.
*
* @param comm Cartesian communicator to use.
* @param range Interaction range.
* @param box Box Geometry
* @param local_geo Geometry of the local box.
*/
void set_domain_decomposition(boost::mpi::communicator const &comm,
double range, BoxGeometry const &box,
LocalBox<double> const &local_geo);
void set_regular_decomposition(boost::mpi::communicator const &comm,
double range, BoxGeometry const &box,
LocalBox<double> const &local_geo);

public:
template <class BondKernel> void bond_loop(BondKernel const &bond_kernel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "DomainDecomposition.hpp"
#include "RegularDecomposition.hpp"

#include "RuntimeErrorStream.hpp"
#include "errorhandling.hpp"
Expand All @@ -45,7 +45,7 @@
/** Returns pointer to the cell which corresponds to the position if the
* position is in the nodes spatial domain otherwise a nullptr pointer.
*/
Cell *DomainDecomposition::position_to_cell(const Utils::Vector3d &pos) {
Cell *RegularDecomposition::position_to_cell(const Utils::Vector3d &pos) {
Utils::Vector3i cpos;

for (int i = 0; i < 3; i++) {
Expand Down Expand Up @@ -76,7 +76,7 @@ Cell *DomainDecomposition::position_to_cell(const Utils::Vector3d &pos) {
return &(cells.at(ind));
}

void DomainDecomposition::move_if_local(
void RegularDecomposition::move_if_local(
ParticleList &src, ParticleList &rest,
std::vector<ParticleChange> &modified_cells) {
for (auto &part : src) {
Expand All @@ -93,10 +93,10 @@ void DomainDecomposition::move_if_local(
src.clear();
}

void DomainDecomposition::move_left_or_right(ParticleList &src,
ParticleList &left,
ParticleList &right,
int dir) const {
void RegularDecomposition::move_left_or_right(ParticleList &src,
ParticleList &left,
ParticleList &right,
int dir) const {
for (auto it = src.begin(); it != src.end();) {
if ((m_box.get_mi_coord(it->r.p[dir], m_local_box.my_left()[dir], dir) <
0.0) and
Expand All @@ -115,7 +115,7 @@ void DomainDecomposition::move_left_or_right(ParticleList &src,
}
}

void DomainDecomposition::exchange_neighbors(
void RegularDecomposition::exchange_neighbors(
ParticleList &pl, std::vector<ParticleChange> &modified_cells) {
auto const node_neighbors = Utils::Mpi::cart_neighbors<3>(m_comm);
static ParticleList send_buf_l, send_buf_r, recv_buf_l, recv_buf_r;
Expand Down Expand Up @@ -168,8 +168,8 @@ void fold_and_reset(Particle &p, BoxGeometry const &box_geo) {
}
} // namespace

void DomainDecomposition::resort(bool global,
std::vector<ParticleChange> &diff) {
void RegularDecomposition::resort(bool global,
std::vector<ParticleChange> &diff) {
ParticleList displaced_parts;

for (auto &c : local_cells()) {
Expand Down Expand Up @@ -234,7 +234,7 @@ void DomainDecomposition::resort(bool global,
}
}

void DomainDecomposition::mark_cells() {
void RegularDecomposition::mark_cells() {
m_local_cells.clear();
m_ghost_cells.clear();

Expand All @@ -250,9 +250,9 @@ void DomainDecomposition::mark_cells() {
}
}

void DomainDecomposition::fill_comm_cell_lists(ParticleList **part_lists,
const Utils::Vector3i &lc,
const Utils::Vector3i &hc) {
void RegularDecomposition::fill_comm_cell_lists(ParticleList **part_lists,
const Utils::Vector3i &lc,
const Utils::Vector3i &hc) {
for (int o = lc[0]; o <= hc[0]; o++)
for (int n = lc[1]; n <= hc[1]; n++)
for (int m = lc[2]; m <= hc[2]; m++) {
Expand All @@ -261,16 +261,16 @@ void DomainDecomposition::fill_comm_cell_lists(ParticleList **part_lists,
*part_lists++ = &(cells.at(i).particles());
}
}
Utils::Vector3d DomainDecomposition::max_cutoff() const {
Utils::Vector3d RegularDecomposition::max_cutoff() const {
auto dir_max_range = [this](int i) {
return std::min(0.5 * m_box.length()[i], m_local_box.length()[i]);
};

return {dir_max_range(0), dir_max_range(1), dir_max_range(2)};
}

Utils::Vector3d DomainDecomposition::max_range() const { return cell_size; }
int DomainDecomposition::calc_processor_min_num_cells() const {
Utils::Vector3d RegularDecomposition::max_range() const { return cell_size; }
int RegularDecomposition::calc_processor_min_num_cells() const {
/* the minimal number of cells can be lower if there are at least two nodes
serving a direction,
since this also ensures that the cell size is at most half the box
Expand All @@ -282,7 +282,7 @@ int DomainDecomposition::calc_processor_min_num_cells() const {
});
}

void DomainDecomposition::create_cell_grid(double range) {
void RegularDecomposition::create_cell_grid(double range) {
auto const cart_info = Utils::Mpi::cart_get<3>(m_comm);

int n_local_cells;
Expand All @@ -300,7 +300,7 @@ void DomainDecomposition::create_cell_grid(double range) {
/* Calculate initial cell grid */
auto const &local_box_l = m_local_box.length();
auto const volume = Utils::product(local_box_l);
auto const scale = std::cbrt(DomainDecomposition::max_num_cells / volume);
auto const scale = std::cbrt(RegularDecomposition::max_num_cells / volume);

for (int i = 0; i < 3; i++) {
/* this is at least 1 */
Expand Down Expand Up @@ -328,7 +328,7 @@ void DomainDecomposition::create_cell_grid(double range) {
n_local_cells = Utils::product(cell_grid);

/* done */
if (n_local_cells <= DomainDecomposition::max_num_cells)
if (n_local_cells <= RegularDecomposition::max_num_cells)
break;

/* find coordinate with the smallest cell range */
Expand All @@ -355,7 +355,7 @@ void DomainDecomposition::create_cell_grid(double range) {
}
}

if (n_local_cells > DomainDecomposition::max_num_cells) {
if (n_local_cells > RegularDecomposition::max_num_cells) {
runtimeErrorMsg() << "no suitable cell grid found";
}

Expand All @@ -378,7 +378,7 @@ void DomainDecomposition::create_cell_grid(double range) {
m_ghost_cells.resize(new_cells - n_local_cells);
}

void DomainDecomposition::init_cell_interactions() {
void RegularDecomposition::init_cell_interactions() {
/* loop all local cells */
for (int o = 1; o < cell_grid[2] + 1; o++)
for (int n = 1; n < cell_grid[1] + 1; n++)
Expand Down Expand Up @@ -457,7 +457,7 @@ Utils::Vector3d shift(BoxGeometry const &box, LocalBox<double> const &local_box,
}
} // namespace

GhostCommunicator DomainDecomposition::prepare_comm() {
GhostCommunicator RegularDecomposition::prepare_comm() {
int dir, lr, i, cnt, n_comm_cells[3];
Utils::Vector3i lc{}, hc{}, done{};

Expand Down Expand Up @@ -560,12 +560,12 @@ GhostCommunicator DomainDecomposition::prepare_comm() {
return ghost_comm;
}

DomainDecomposition::DomainDecomposition(boost::mpi::communicator comm,
double range,
const BoxGeometry &box_geo,
const LocalBox<double> &local_geo)
RegularDecomposition::RegularDecomposition(boost::mpi::communicator comm,
double range,
const BoxGeometry &box_geo,
const LocalBox<double> &local_geo)
: m_comm(std::move(comm)), m_box(box_geo), m_local_box(local_geo) {
/* set up new domain decomposition cell structure */
/* set up new regular decomposition cell structure */
create_cell_grid(range);

/* setup cell neighbors */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ESPRESSO_DOMAIN_DECOMPOSITION_HPP
#define ESPRESSO_DOMAIN_DECOMPOSITION_HPP
#ifndef ESPRESSO_REGULAR_DECOMPOSITION_HPP
#define ESPRESSO_REGULAR_DECOMPOSITION_HPP

#include "ParticleDecomposition.hpp"

Expand All @@ -40,13 +40,13 @@
#include <vector>

/** @brief Structure containing the information about the cell grid used for
* domain decomposition.
* regular decomposition.
*
* The domain of a node is split into a 3D cell grid with dimension
* cell_grid. Together with one ghost cell
* layer on each side the overall dimension of the ghost cell grid is
* ghost_cell_grid. The domain
* decomposition enables one the use of the linked cell algorithm
* ghost_cell_grid. The regular
* decomposition enables the use of the linked cell algorithm
* which is in turn used for setting up the Verlet list for the
* system. You can see a 2D graphical representation of the linked
* cell grid below.
Expand All @@ -65,7 +65,7 @@
* some ghost-ghost cell interaction as well, which we do not need!
*
*/
struct DomainDecomposition : public ParticleDecomposition {
struct RegularDecomposition : public ParticleDecomposition {
/** Grid dimensions per node. */
Utils::Vector3i cell_grid = {};
/** Cell size. */
Expand All @@ -74,7 +74,7 @@ struct DomainDecomposition : public ParticleDecomposition {
Utils::Vector3i cell_offset = {};
/** linked cell grid with ghost frame. */
Utils::Vector3i ghost_cell_grid = {};
/** inverse cell size = \see DomainDecomposition::cell_size ^ -1. */
/** inverse cell size = \see RegularDecomposition::cell_size ^ -1. */
Utils::Vector3d inv_cell_size = {};

boost::mpi::communicator m_comm;
Expand All @@ -87,9 +87,9 @@ struct DomainDecomposition : public ParticleDecomposition {
GhostCommunicator m_collect_ghost_force_comm;

public:
DomainDecomposition(boost::mpi::communicator comm, double range,
const BoxGeometry &box_geo,
const LocalBox<double> &local_geo);
RegularDecomposition(boost::mpi::communicator comm, double range,
const BoxGeometry &box_geo,
const LocalBox<double> &local_geo);

GhostCommunicator const &exchange_ghosts_comm() const override {
return m_exchange_ghosts_comm;
Expand Down Expand Up @@ -118,7 +118,7 @@ struct DomainDecomposition : public ParticleDecomposition {
}

private:
/** Fill @c m_local_cells list and @c m_ghost_cells list for use with domain
/** Fill @c m_local_cells list and @c m_ghost_cells list for use with regular
* decomposition.
*/
void mark_cells();
Expand Down Expand Up @@ -196,14 +196,14 @@ struct DomainDecomposition : public ParticleDecomposition {
*/
void create_cell_grid(double range);

/** Init cell interactions for cell system domain decomposition.
/** Init cell interactions for cell system regular decomposition.
* Initializes the interacting neighbor cell list of a cell.
* This list of interacting neighbor cells is used by the Verlet
* algorithm.
*/
void init_cell_interactions();

/** Create communicators for cell structure domain decomposition (see \ref
/** Create communicators for cell structure regular decomposition (see \ref
* GhostCommunicator).
*/
GhostCommunicator prepare_comm();
Expand Down
Loading

0 comments on commit d162319

Please sign in to comment.