ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
dipoles_inline.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
22#include "config/config.hpp"
23
27
28#include "Particle.hpp"
29
30#include "actor/traits.hpp"
31#include "actor/visitors.hpp"
32
33#include <utils/Vector.hpp>
34
35#include <functional>
36#include <optional>
37#include <variant>
38
39namespace Dipoles {
40
42
44 using result_type = std::optional<kernel_type>;
45
46#ifdef ESPRESSO_DIPOLES
47 template <typename T>
48 result_type operator()(std::shared_ptr<T> const &) const {
49 return {};
50 }
51
52#ifdef ESPRESSO_DP3M
53 result_type operator()(std::shared_ptr<DipolarP3M> const &ptr) const {
54 auto const &actor = *ptr;
55 return kernel_type{[&actor](double d1d2, Utils::Vector3d const &dip1,
56 Utils::Vector3d const &dip2,
57 Utils::Vector3d const &d, double dist,
58 double dist2) {
59 return actor.pair_force(d1d2, dip1, dip2, d, dist, dist2);
60 }};
61 }
62#endif // ESPRESSO_DP3M
63
65 operator()(std::shared_ptr<DipolarLayerCorrection> const &ptr) const {
66 return std::visit(*this, ptr->base_solver);
67 }
68#endif // ESPRESSO_DIPOLES
69};
70
72
74 using result_type = std::optional<kernel_type>;
75
76#ifdef ESPRESSO_DIPOLES
77 template <typename T>
78 result_type operator()(std::shared_ptr<T> const &) const {
79 return {};
80 }
81
82#ifdef ESPRESSO_DP3M
83 result_type operator()(std::shared_ptr<DipolarP3M> const &ptr) const {
84 auto const &actor = *ptr;
85 return kernel_type{[&actor](Particle const &p1, Particle const &p2,
86 Utils::Vector3d const &d, double dist,
87 double dist2) {
88 return actor.pair_energy(p1, p2, d, dist, dist2);
89 }};
90 }
91#endif // ESPRESSO_DP3M
92
94 operator()(std::shared_ptr<DipolarLayerCorrection> const &ptr) const {
95 return std::visit(*this, ptr->base_solver);
96 }
97#endif // ESPRESSO_DIPOLES
98};
99
100inline std::optional<Solver::ShortRangeForceKernel>
102#ifdef ESPRESSO_DIPOLES
103 if (auto &solver = impl->solver; solver.has_value()) {
105 return std::visit(visitor, *solver);
106 }
107#endif // ESPRESSO_DIPOLES
108 return std::nullopt;
109}
110
111inline std::optional<Solver::ShortRangeEnergyKernel>
113#ifdef ESPRESSO_DIPOLES
114 if (auto &solver = impl->solver; solver.has_value()) {
116 return std::visit(visitor, *solver);
117 }
118#endif // ESPRESSO_DIPOLES
119 return std::nullopt;
120}
121
122} // namespace Dipoles
Vector implementation and trait types for boost qvm interoperability.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
P3M algorithm for long-range magnetic dipole-dipole interaction.
result_type operator()(std::shared_ptr< T > const &) const
std::optional< kernel_type > result_type
result_type operator()(std::shared_ptr< DipolarLayerCorrection > const &ptr) const
Solver::ShortRangeEnergyKernel kernel_type
result_type operator()(std::shared_ptr< DipolarP3M > const &ptr) const
result_type operator()(std::shared_ptr< DipolarLayerCorrection > const &ptr) const
std::optional< kernel_type > result_type
result_type operator()(std::shared_ptr< T > const &) const
Solver::ShortRangeForceKernel kernel_type
result_type operator()(std::shared_ptr< DipolarP3M > const &ptr) const
std::function< ParticleForce(double, Utils::Vector3d const &, Utils::Vector3d const &, Utils::Vector3d const &, double, double)> ShortRangeForceKernel
std::optional< ShortRangeForceKernel > pair_force_kernel() const
std::unique_ptr< Implementation > impl
Pointer-to-implementation.
std::function< double(Particle const &, Particle const &, Utils::Vector3d const &, double, double)> ShortRangeEnergyKernel
std::optional< ShortRangeEnergyKernel > pair_energy_kernel() const
Struct holding all information for one particle.
Definition Particle.hpp:450