ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Scafacos.cpp
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#include "scafacos/Scafacos.hpp"
21
22#include "utils.hpp"
23
24#include <string>
25#include <utility>
26#include <vector>
27
28namespace Scafacos {
29
30std::vector<std::string> Scafacos::available_methods() {
31 std::vector<std::string> methods;
32
33#ifdef FCS_ENABLE_DIRECT
34 methods.emplace_back("direct");
35#endif
36#ifdef FCS_ENABLE_EWALD
37 methods.emplace_back("ewald");
38#endif
39#ifdef FCS_ENABLE_FMM
40 methods.emplace_back("fmm");
41#endif
42#ifdef FCS_ENABLE_MEMD
43 methods.emplace_back("memd");
44#endif
45#ifdef FCS_ENABLE_MMM1D
46 methods.emplace_back("mmm1d");
47#endif
48#ifdef FCS_ENABLE_MMM2D
49 methods.emplace_back("mmm2d");
50#endif
51#ifdef FCS_ENABLE_P2NFFT
52 methods.emplace_back("p2nfft");
53#endif
54#ifdef FCS_ENABLE_P3M
55 methods.emplace_back("p3m");
56#endif
57#ifdef FCS_ENABLE_PEPC
58 methods.emplace_back("pepc");
59#endif
60#ifdef FCS_ENABLE_PP3MG
61 methods.emplace_back("pp3mg");
62#endif
63#ifdef FCS_ENABLE_VMG
64 methods.emplace_back("vmg");
65#endif
66#ifdef FCS_ENABLE_WOLF
67 methods.emplace_back("wolf");
68#endif
69
70 return methods;
71}
72
73Scafacos::Scafacos(MPI_Comm comm, std::string method, std::string parameters)
74 : m_method_name{std::move(method)}, m_parameters{std::move(parameters)} {
75
76 handle_error(fcs_init(&m_handle, m_method_name.c_str(), comm));
77
78 fcs_set_resort(m_handle, 0);
79
80 handle_error(fcs_parser(m_handle, m_parameters.c_str(), 0));
81}
82
83Scafacos::~Scafacos() { fcs_destroy(m_handle); }
84
85void Scafacos::set_runtime_parameters(double const *box_l,
86 int const *periodicity,
87 int total_particles,
88 int near_field_flag) {
89 // define rectangular box
90 double boxa[3] = {box_l[0], 0., 0.};
91 double boxb[3] = {0., box_l[1], 0.};
92 double boxc[3] = {0., 0., box_l[2]};
93 double off[3] = {0., 0., 0.};
94 handle_error(fcs_set_common(m_handle, near_field_flag, boxa, boxb, boxc, off,
95 periodicity, total_particles));
96}
97
98} // namespace Scafacos
#define handle_error(stmt)
Abstraction of a method from the ScaFaCoS library.
Definition Scafacos.hpp:34
void set_runtime_parameters(double const *box_l, int const *periodicity, int total_particles, int near_field_flag)
Set box geometry, number of particles and calculation type.
Definition Scafacos.cpp:85
static std::vector< std::string > available_methods()
Get a list of methods supported by the library.
Definition Scafacos.cpp:30