ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
EKPoissonSolverSlice.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 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 <config/config.hpp>
21
22#ifdef ESPRESSO_WALBERLA
23
25
26#include "LatticeIndices.hpp"
27#include "LatticeSlice.impl.hpp"
28
30
31#include <utils/Vector.hpp>
33
34#include <stdexcept>
35#include <string>
36#include <type_traits>
37#include <vector>
38
40
42 VariantMap const &params) {
43 if (name == "get_slice_size") {
45 }
46 if (name == "get_slice_ranges") {
47 return {std::vector<Variant>{m_slice_lower_corner, m_slice_upper_corner}};
48 }
49 if (name == "get_ek_solver_sip") {
50 return {m_ek_solver_sip};
51 }
52 if (name == "get_value_shape") {
53 auto const name = get_value<std::string>(params, "name");
54 if (not m_shape_val.contains(name)) {
56 throw std::invalid_argument("Unknown Poisson solver property '" + name +
57 "'");
58 });
59 }
60 return m_shape_val.at(name);
61 }
62
63 // slice getter/setter callback
64 auto const call = [this, params](auto method_ptr,
65 std::vector<int> const &data_dims,
66 double units = 1.) -> Variant {
67 auto &obj = *m_ek_poisson_solver;
68 if constexpr (std::is_invocable_v<decltype(method_ptr), LatticeModel *,
69 Utils::Vector3i const &,
70 Utils::Vector3i const &>) {
72 } else {
74 return {};
75 }
76 };
77
78 if (name == "get_potential") {
79 return call(&LatticeModel::get_slice_potential, {1});
80 }
81
82 return {};
83}
84
85} // namespace ScriptInterface::walberla
86
87#endif // ESPRESSO_WALBERLA
Vector implementation and trait types for boost qvm interoperability.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
std::string_view name() const
Variant do_call_method(std::string const &name, VariantMap const &params) override
Variant gather_3d(std::vector< int > const &data_dims, LatticeModel const &lattice_model, std::vector< T >(LatticeModel::*getter)(Utils::Vector3i const &, Utils::Vector3i const &) const, double units_conversion=1.) const
void scatter_3d(Variant const &grid_values, std::vector< int > const &data_dims, LatticeModel &lattice_model, void(LatticeModel::*setter)(Utils::Vector3i const &, Utils::Vector3i const &, std::vector< T > const &), double units_conversion=1.)
virtual std::vector< double > get_slice_potential(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const =0
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:133
static SteepestDescentParameters params
Currently active steepest descent instance.
Recursive variant implementation.
Definition Variant.hpp:84