ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
EKIndexedReactionSlice.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 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 "LatticeSlice.impl.hpp"
27
28#include <stdexcept>
29#include <string>
30#include <type_traits>
31#include <vector>
32
34
36 VariantMap const &params) {
37 if (name == "get_slice_size") {
39 }
40 if (name == "get_slice_ranges") {
41 return {std::vector<Variant>{m_slice_lower_corner, m_slice_upper_corner}};
42 }
43 if (name == "get_reaction_sip") {
44 return {m_reaction_sip};
45 }
46 if (name == "get_value_shape") {
47 auto const attr = get_value<std::string>(params, "name");
48 if (not m_shape_val.contains(attr)) {
50 std::string const class_prop{"EK indexed reaction property"};
51 throw std::runtime_error("Unknown " + class_prop + " '" + attr + "'");
52 });
53 }
54 return m_shape_val.at(attr);
55 }
56
57 auto adapter = EKReactionSliceAdapter{m_reaction_impl.get()};
58
59 auto const call = [this, &adapter,
60 &params](auto method_ptr,
61 std::vector<int> const &data_dims) -> Variant {
62 if constexpr (std::is_invocable_v<
64 Utils::Vector3i const &, Utils::Vector3i const &>) {
66 } else {
67 scatter_3d(params.at("values"), data_dims, adapter, method_ptr);
68 return {};
69 }
70 };
71
72 if (name == "get_is_boundary") {
74 }
75 if (name == "set_is_boundary") {
77 }
78
79 return {};
80}
81
82} // namespace ScriptInterface::walberla
83
84#endif // ESPRESSO_WALBERLA
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.)
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:133
Recursive variant implementation.
Definition Variant.hpp:84
Adapter that exposes EKReactionBaseIndexed with the interface expected by LatticeSlice::gather_3d / s...
void set_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< int > const &values)
std::vector< int > get_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const