ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
DipolarP3M.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 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
24
#ifdef DP3M
25
26
#include "
Actor.hpp
"
27
28
#include "
core/magnetostatics/dp3m.hpp
"
29
#include "
core/magnetostatics/dp3m.impl.hpp
"
30
#include "
core/p3m/FFTBackendLegacy.hpp
"
31
#include "
core/p3m/FFTBuffersLegacy.hpp
"
32
33
#include "
script_interface/get_value.hpp
"
34
35
#include <memory>
36
#include <stdexcept>
37
#include <string>
38
#include <utility>
39
40
#ifdef FFTW3_H
41
#error "The FFTW3 library shouldn't be visible in this translation unit"
42
#endif
43
44
namespace
ScriptInterface
{
45
namespace
Dipoles
{
46
47
template
<Arch Architecture>
48
class
DipolarP3M
:
public
Actor
<DipolarP3M<Architecture>, ::DipolarP3M> {
49
int
m_tune_timings;
50
bool
m_tune;
51
bool
m_tune_verbose;
52
53
public
:
54
using
Base
=
Actor<DipolarP3M<Architecture>
,
::DipolarP3M
>;
55
using
Base::actor
;
56
using
Base::add_parameters
;
57
using
Base::context
;
58
59
protected
:
60
using
Base::m_actor
;
61
62
public
:
63
DipolarP3M
() {
64
add_parameters
({
65
{
"single_precision"
,
AutoParameter::read_only
,
66
[
this
]() {
return
not
actor
()->is_double_precision(); }},
67
{
"alpha_L"
,
AutoParameter::read_only
,
68
[
this
]() {
return
actor
()->dp3m_params.alpha_L; }},
69
{
"r_cut_iL"
,
AutoParameter::read_only
,
70
[
this
]() {
return
actor
()->dp3m_params.r_cut_iL; }},
71
{
"mesh"
,
AutoParameter::read_only
,
72
[
this
]() {
return
actor
()->dp3m_params.mesh; }},
73
{
"mesh_off"
,
AutoParameter::read_only
,
74
[
this
]() {
return
actor
()->dp3m_params.mesh_off; }},
75
{
"cao"
,
AutoParameter::read_only
,
76
[
this
]() {
return
actor
()->dp3m_params.cao; }},
77
{
"accuracy"
,
AutoParameter::read_only
,
78
[
this
]() {
return
actor
()->dp3m_params.accuracy; }},
79
{
"epsilon"
,
AutoParameter::read_only
,
80
[
this
]() {
return
actor
()->dp3m_params.epsilon; }},
81
{
"a"
,
AutoParameter::read_only
,
82
[
this
]() {
return
actor
()->dp3m_params.a; }},
83
{
"alpha"
,
AutoParameter::read_only
,
84
[
this
]() {
return
actor
()->dp3m_params.alpha; }},
85
{
"r_cut"
,
AutoParameter::read_only
,
86
[
this
]() {
return
actor
()->dp3m_params.r_cut; }},
87
{
"is_tuned"
,
AutoParameter::read_only
,
88
[
this
]() {
return
actor
()->is_tuned(); }},
89
{
"verbose"
,
AutoParameter::read_only
,
90
[
this
]() {
return
m_tune_verbose; }},
91
{
"timings"
,
AutoParameter::read_only
,
92
[
this
]() {
return
m_tune_timings; }},
93
{
"tune"
,
AutoParameter::read_only
, [
this
]() {
return
m_tune; }},
94
});
95
}
96
97
void
do_construct
(
VariantMap
const
&
params
)
override
{
98
m_tune =
get_value<bool>
(
params
,
"tune"
);
99
m_tune_timings =
get_value<int>
(
params
,
"timings"
);
100
m_tune_verbose =
get_value<bool>
(
params
,
"verbose"
);
101
auto
const
single_precision
=
get_value<bool>
(
params
,
"single_precision"
);
102
static_assert
(
Architecture
==
Arch::CPU
,
"GPU not implemented"
);
103
context
()->
parallel_try_catch
([&]() {
104
auto
p3m =
P3MParameters
{!
get_value_or<bool>
(
params
,
"is_tuned"
, !m_tune),
105
get_value<double>
(
params
,
"epsilon"
),
106
get_value<double>
(
params
,
"r_cut"
),
107
get_value<Utils::Vector3i>
(
params
,
"mesh"
),
108
get_value<Utils::Vector3d>
(
params
,
"mesh_off"
),
109
get_value<int>
(
params
,
"cao"
),
110
get_value<double>
(
params
,
"alpha"
),
111
get_value<double>
(
params
,
"accuracy"
)};
112
make_handle(
single_precision
, std::move(p3m),
113
get_value<double>
(
params
,
"prefactor"
), m_tune_timings,
114
m_tune_verbose);
115
});
116
}
117
118
private
:
119
template
<
typename
FloatType,
class
...
Args
>
120
void
make_handle_impl(
Args
&&...
args
) {
121
m_actor
=
new_dp3m_handle
<FloatType,
Architecture
,
FFTBackendLegacy
,
122
FFTBuffersLegacy
>(std::forward<Args>(
args
)...);
123
}
124
template
<
class
...
Args
>
125
void
make_handle(
bool
single_precision
,
Args
&&...
args
) {
126
if
(
single_precision
) {
127
make_handle_impl<
float
,
Args
...>(std::forward<Args>(
args
)...);
128
}
else
{
129
make_handle_impl<
double
,
Args
...>(std::forward<Args>(
args
)...);
130
}
131
}
132
};
133
134
}
// namespace Dipoles
135
}
// namespace ScriptInterface
136
137
#endif
// DP3M
FFTBackendLegacy.hpp
FFTBuffersLegacy.hpp
FFTBackendLegacy
Historic FFT backend based on FFTW3.
Definition
FFTBackendLegacy.hpp:45
FFTBuffersLegacy
Buffers for FFTBackendLegacy.
Definition
FFTBuffersLegacy.hpp:39
ScriptInterface::AutoParameters::add_parameters
void add_parameters(std::vector< AutoParameter > &¶ms)
Definition
AutoParameters.hpp:115
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::Dipoles::Actor
Common interface for magnetostatic actors.
Definition
magnetostatics/Actor.hpp:45
ScriptInterface::Dipoles::Actor< DipolarP3M< Architecture >, ::DipolarP3M >::actor
std::shared_ptr< CoreActorClass > actor()
Definition
magnetostatics/Actor.hpp:71
ScriptInterface::Dipoles::Actor< DipolarP3M< Architecture >, ::DipolarP3M >::m_actor
std::shared_ptr< CoreActorClass > m_actor
Definition
magnetostatics/Actor.hpp:54
ScriptInterface::Dipoles::DipolarP3M
Definition
DipolarP3M.hpp:48
ScriptInterface::Dipoles::DipolarP3M::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
DipolarP3M.hpp:97
ScriptInterface::Dipoles::DipolarP3M::DipolarP3M
DipolarP3M()
Definition
DipolarP3M.hpp:63
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:58
config.hpp
This file contains the defaults for ESPResSo.
dp3m.hpp
P3M algorithm for long-range magnetic dipole-dipole interaction.
dp3m.impl.hpp
new_dp3m_handle
std::shared_ptr< DipolarP3M > new_dp3m_handle(P3MParameters &&p3m, Args &&...args)
Definition
dp3m.impl.hpp:147
get_value.hpp
Actor.hpp
Dipoles
Definition
magnetostatics/actor.hpp:30
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::get_value
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
Definition
get_value.hpp:400
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:69
Arch::CPU
@ CPU
params
static SteepestDescentParameters params
Currently active steepest descent instance.
Definition
steepest_descent.cpp:44
DipolarP3M
Dipolar P3M solver.
Definition
dp3m.hpp:59
P3MParameters
Structure to hold P3M parameters and some dependent variables.
Definition
p3m/common.hpp:59
ScriptInterface::AutoParameter::read_only
static constexpr const ReadOnly read_only
Definition
AutoParameter.hpp:42
src
script_interface
magnetostatics
DipolarP3M.hpp
Generated on Fri Nov 22 2024 02:13:55 for ESPResSo by
1.9.8