ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
LocalBox.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
23
24#include <utils/Array.hpp>
25#include <utils/Vector.hpp>
26
27class LocalBox {
28 Utils::Vector3d m_local_box_l = {1., 1., 1.};
29 Utils::Vector3d m_lower_corner = {0., 0., 0.};
30 Utils::Vector3d m_upper_corner = {1., 1., 1.};
31 Utils::Array<int, 6> m_boundaries = {};
32 CellStructureType m_cell_structure_type;
33
34public:
35 LocalBox() = default;
36 LocalBox(Utils::Vector3d const &lower_corner,
37 Utils::Vector3d const &local_box_length,
38 Utils::Array<int, 6> const &boundaries,
40 : m_local_box_l(local_box_length), m_lower_corner(lower_corner),
41 m_upper_corner(lower_corner + local_box_length),
42 m_boundaries(boundaries), m_cell_structure_type(cell_structure_type) {}
43
44 /** Left (bottom, front) corner of this nodes local box. */
45 auto const &my_left() const { return m_lower_corner; }
46 /** Right (top, back) corner of this nodes local box. */
47 auto const &my_right() const { return m_upper_corner; }
48 /** Dimensions of the box a single node is responsible for. */
49 auto const &length() const { return m_local_box_l; }
50 /** @brief Boundary information for the local box.
51 *
52 * This returns for each of the faces of the local box if
53 * it is a boundary of the simulation box. The format is
54 * as follows:
55 * (x low, x high, y low, y high, z low, z high).
56 *
57 * @return Array with boundary information.
58 */
59 auto const &boundary() const { return m_boundaries; }
60
61 /** Return cell structure type. */
62 auto const &cell_structure_type() const { return m_cell_structure_type; }
63
64 /** Set cell structure type. */
68
70 Utils::Vector3i const &node_index,
71 Utils::Vector3i const &node_grid) {
72
73 auto const local_length = Utils::hadamard_division(box_l, node_grid);
74 auto const my_left = Utils::hadamard_product(node_index, local_length);
75
76 decltype(LocalBox::m_boundaries) boundaries;
77 for (unsigned int dir = 0u; dir < 3u; dir++) {
78 /* left boundary ? */
79 boundaries[2u * dir] = (node_index[dir] == 0);
80 /* right boundary ? */
81 boundaries[2u * dir + 1u] = -(node_index[dir] + 1 == node_grid[dir]);
82 }
83
84 return {my_left, local_length, boundaries, CellStructureType::REGULAR};
85 }
86};
Array implementation with CUDA support.
CellStructureType
Cell structure topology.
@ REGULAR
Regular decomposition.
Vector implementation and trait types for boost qvm interoperability.
auto const & my_right() const
Right (top, back) corner of this nodes local box.
Definition LocalBox.hpp:47
void set_cell_structure_type(CellStructureType cell_structure_type)
Set cell structure type.
Definition LocalBox.hpp:65
auto const & boundary() const
Boundary information for the local box.
Definition LocalBox.hpp:59
auto const & cell_structure_type() const
Return cell structure type.
Definition LocalBox.hpp:62
LocalBox(Utils::Vector3d const &lower_corner, Utils::Vector3d const &local_box_length, Utils::Array< int, 6 > const &boundaries, CellStructureType const cell_structure_type)
Definition LocalBox.hpp:36
LocalBox()=default
auto const & my_left() const
Left (bottom, front) corner of this nodes local box.
Definition LocalBox.hpp:45
auto const & length() const
Dimensions of the box a single node is responsible for.
Definition LocalBox.hpp:49
static LocalBox make_regular_decomposition(Utils::Vector3d const &box_l, Utils::Vector3i const &node_index, Utils::Vector3i const &node_grid)
Definition LocalBox.hpp:69
auto hadamard_division(Vector< T, N > const &a, Vector< U, N > const &b)
Definition Vector.hpp:422
auto hadamard_product(Vector< T, N > const &a, Vector< U, N > const &b)
Definition Vector.hpp:379