ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
EKIndexedReactionSlice.hpp
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#pragma once
21
22#include <config/config.hpp>
23
24#ifdef ESPRESSO_WALBERLA
25
26#include "EKReaction.hpp"
27#include "EKSpeciesSlice.hpp"
28#include "LatticeSlice.hpp"
29
31
34
35#include <utils/Vector.hpp>
36
37#include <cassert>
38#include <memory>
39#include <string>
40#include <unordered_map>
41#include <vector>
42
44
45/**
46 * @brief Adapter that exposes @c EKReactionBaseIndexed with the
47 * interface expected by @c LatticeSlice::gather_3d / scatter_3d.
48 *
49 * @c LatticeSlice requires the lattice model to provide
50 * @c get_lattice() returning a @c LatticeWalberla const &, but
51 * @c EKReactionBase::get_lattice() returns a @c shared_ptr.
52 * This adapter bridges that mismatch.
53 */
75
76class EKIndexedReactionSlice : public LatticeSlice<EKFieldSerializer> {
77 std::shared_ptr<::walberla::EKReactionBaseIndexed> m_reaction_impl;
78 std::shared_ptr<EKIndexedReaction> m_reaction_sip;
79 std::unordered_map<std::string, std::vector<int>> m_shape_val;
80
81public:
82 void do_construct(VariantMap const &params) override {
83 m_reaction_sip =
85 m_reaction_impl = m_reaction_sip->get_impl();
86 assert(m_reaction_impl);
87 m_shape = get_value<std::vector<int>>(params, "shape");
89 get_value<Utils::Vector3i>(params, "slice_lower_corner");
91 get_value<Utils::Vector3i>(params, "slice_upper_corner");
92 m_shape_val["is_boundary"] = std::vector<int>(1, 1);
93 }
94
95 Variant do_call_method(std::string const &name,
96 VariantMap const &params) override;
97
98 ::LatticeWalberla const &get_lattice() const override {
99 return *m_reaction_impl->get_lattice();
100 }
101};
102
103} // namespace ScriptInterface::walberla
104
105#endif // ESPRESSO_WALBERLA
Vector implementation and trait types for boost qvm interoperability.
Class that runs and controls the BlockForest in waLBerla.
std::string_view name() const
::LatticeWalberla const & get_lattice() const override
void do_construct(VariantMap const &params) override
Variant do_call_method(std::string const &name, VariantMap const &params) override
virtual void set_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner, std::vector< int > const &is_boundary)=0
virtual void ghost_communication()=0
virtual std::vector< int > get_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const =0
auto get_lattice() const noexcept
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)
::LatticeWalberla const & get_lattice() const noexcept
std::vector< int > get_slice_is_boundary(Utils::Vector3i const &lower_corner, Utils::Vector3i const &upper_corner) const