Multi Resolution Molecular Dynamics 0.4.0
Multi Resolution Molecular Dynamics
Loading...
Searching...
No Matches
MultiResPeriodicGhostExchange.hpp
Go to the documentation of this file.
1// Copyright 2024 Sebastian Eibl
2// Copyright 2026 Julian Friedrich Hille
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include "data/Atoms.hpp"
18#include "data/Molecules.hpp"
19#include "data/Subdomain.hpp"
20#include "datatypes.hpp"
21#include "util/Kokkos_grow.hpp"
22
23namespace mrmd
24{
25namespace communication
26{
27namespace impl
28{
29struct DoubleCounter
30{
31 idx_t atoms = 0;
32 idx_t molecules = 0;
33
34 DoubleCounter() = default;
35 KOKKOS_INLINE_FUNCTION
36 DoubleCounter(idx_t newAtoms, idx_t newMolecules) : atoms(newAtoms), molecules(newMolecules) {}
37 DoubleCounter(const DoubleCounter& rhs) = default;
38
39 KOKKOS_INLINE_FUNCTION
40 void operator=(const DoubleCounter& rhs)
41 {
42 atoms = rhs.atoms;
43 molecules = rhs.molecules;
44 }
45
46 KOKKOS_INLINE_FUNCTION
47 DoubleCounter& operator+=(const DoubleCounter& rhs)
48 {
49 atoms += rhs.atoms;
50 molecules += rhs.molecules;
51 return *this;
52 }
53};
54
55KOKKOS_INLINE_FUNCTION
56DoubleCounter operator+(const DoubleCounter& lhs, const DoubleCounter& rhs)
57{
58 return DoubleCounter(lhs.atoms + rhs.atoms, lhs.molecules + rhs.molecules);
59}
64class MultiResPeriodicGhostExchange
65{
66private:
67 struct Info
68 {
69 enum
70 {
71 POSITIVE_MOLECULE_IDX = 0,
72 POSITIVE_NUM_ATOMS = 1,
73 NEGATIVE_MOLECULE_IDX = 2,
74 NEGATIVE_NUM_ATOMS = 3
75 };
76 };
80 Kokkos::View<idx_t* [4]> communicationInfo_;
81
82 struct Item
83 {
84 enum
85 {
86 POSITIVE_MOLECULES = 0,
87 POSITIVE_ATOMS = 1,
88 NEGATIVE_MOLECULES = 2,
89 NEGATIVE_ATOMS = 3
90 };
91 };
93 Kokkos::View<idx_t[4]> numberOfCommunicationItems_;
94
96 IndexView atomsCorrespondingRealAtom_;
97
99 IndexView moleculesCorrespondingRealMolecule_;
100
101public:
102 IndexView createGhostAtoms(data::Molecules& molecules,
103 data::Atoms& atoms,
104 const data::Subdomain& subdomain,
105 const AXIS& axis);
106
107 IndexView createGhostAtomsXYZ(data::Molecules& molecules,
108 data::Atoms& atoms,
109 const data::Subdomain& subdomain);
110
111 void resetCorrespondingRealAtoms(data::Atoms& atoms);
112 void resetCorrespondingRealMolecules(data::Molecules& molecules);
113
114 explicit MultiResPeriodicGhostExchange(const idx_t& initialSize = 0);
115};
116} // namespace impl
117} // namespace communication
118} // namespace mrmd
Everything related to ghost particles and periodic boundary conditions.
DeviceMolecules Molecules
Definition Molecules.hpp:176
DeviceAtoms Atoms
Definition Atoms.hpp:177
Top-level namespace of MRMD.
Kokkos::View< idx_t * > IndexView
Definition datatypes.hpp:153
int64_t idx_t
Definition datatypes.hpp:91
AXIS
Definition datatypes.hpp:141