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 DIPOLES
47 template <typename T>
48 result_type operator()(std::shared_ptr<T> const &) const {
49 return {};
50 }
51
52#ifdef DP3M
53 result_type operator()(std::shared_ptr<DipolarP3M> const &ptr) const {
54 auto const &actor = *ptr;
55 return kernel_type{[&actor](Particle const &p1, Particle const &p2,
56 Utils::Vector3d const &d, double dist,
57 double dist2) {
58 return actor.pair_force(p1, p2, d, dist2, dist);
59 }};
60 }
61#endif // DP3M
62
64 operator()(std::shared_ptr<DipolarLayerCorrection> const &ptr) const {
65 return std::visit(*this, ptr->base_solver);
66 }
67#endif // DIPOLES
68};
69
71
73 using result_type = std::optional<kernel_type>;
74
75#ifdef DIPOLES
76 template <typename T>
77 result_type operator()(std::shared_ptr<T> const &) const {
78 return {};
79 }
80
81#ifdef DP3M
82 result_type operator()(std::shared_ptr<DipolarP3M> const &ptr) const {
83 auto const &actor = *ptr;
84 return kernel_type{[&actor](Particle const &p1, Particle const &p2,
85 Utils::Vector3d const &d, double dist,
86 double dist2) {
87 return actor.pair_energy(p1, p2, d, dist2, dist);
88 }};
89 }
90#endif // DP3M
91
93 operator()(std::shared_ptr<DipolarLayerCorrection> const &ptr) const {
94 return std::visit(*this, ptr->base_solver);
95 }
96#endif // DIPOLES
97};
98
99inline std::optional<Solver::ShortRangeForceKernel>
101#ifdef DIPOLES
102 if (auto &solver = impl->solver; solver.has_value()) {
103 auto const visitor = Dipoles::ShortRangeForceKernel();
104 return std::visit(visitor, *solver);
105 }
106#endif // DIPOLES
107 return std::nullopt;
108}
109
110inline std::optional<Solver::ShortRangeEnergyKernel>
112#ifdef DIPOLES
113 if (auto &solver = impl->solver; solver.has_value()) {
114 auto const visitor = Dipoles::ShortRangeEnergyKernel();
115 return std::visit(visitor, *solver);
116 }
117#endif // DIPOLES
118 return std::nullopt;
119}
120
121} // namespace Dipoles
Vector implementation and trait types for boost qvm interoperability.
This file contains the defaults for ESPResSo.
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::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::function< ParticleForce(Particle const &, Particle const &, Utils::Vector3d const &, double, double)> ShortRangeForceKernel
std::optional< ShortRangeEnergyKernel > pair_energy_kernel() const
Struct holding all information for one particle.
Definition Particle.hpp:393