ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
EKPoissonSolverNode.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2025-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
24
#include "
EKPoissonSolverNode.hpp
"
25
26
#include "
LatticeIndices.hpp
"
27
28
#include <
walberla_bridge/electrokinetics/PoissonSolver.hpp
>
29
30
#include <
utils/Vector.hpp
>
31
#include <
utils/mpi/reduce_optional.hpp
>
32
33
#include <string>
34
35
namespace
ScriptInterface::walberla
{
36
37
Variant
EKPoissonSolverNode::do_call_method
(std::string
const
&name,
38
VariantMap
const
¶ms) {
39
if
(
name
==
"override_index"
) {
40
// this hidden feature is used to iterate an EK slice without
41
// rebuilding an EKPoissonSolverNode for each node in the slice
42
auto
const
index =
get_value<Utils::Vector3i>
(params,
"index"
);
43
if
(
not
is_index_valid
(index, m_grid_size)) {
44
return
1;
45
}
46
m_index = index;
47
return
0;
48
}
49
if
(
name
==
"get_potential"
) {
50
auto
const
result = m_ek_poisson_solver->get_node_potential(m_index);
51
return
Utils::Mpi::reduce_optional
(
context
()->get_comm(), result) /
52
m_conv_potential;
53
}
54
if
(
name
==
"set_potential"
) {
55
auto
const
potential
=
get_value<double>
(params,
"value"
);
56
context
()->
parallel_try_catch
([&]() {
57
m_ek_poisson_solver->set_node_potential(m_index,
58
potential
* m_conv_potential);
59
});
60
return
{};
61
}
62
63
return
{};
64
}
65
66
}
// namespace ScriptInterface::walberla
67
68
#endif
// ESPRESSO_WALBERLA
EKPoissonSolverNode.hpp
LatticeIndices.hpp
PoissonSolver.hpp
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::LatticeIndices::is_index_valid
bool is_index_valid(Utils::Vector3i const &index, Utils::Vector3i const &shape) const
Definition
LatticeIndices.hpp:35
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:57
ScriptInterface::ObjectHandle::name
std::string_view name() const
Definition
ObjectHandle.cpp:117
ScriptInterface::walberla::EKPoissonSolverNode::do_call_method
Variant do_call_method(std::string const &name, VariantMap const ¶ms) override
Definition
EKPoissonSolverNode.cpp:37
config.hpp
ScriptInterface::walberla
Definition
script_interface/walberla/EKContainer.hpp:49
ScriptInterface::get_value
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
Definition
get_value.hpp:398
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:133
Utils::Mpi::reduce_optional
T reduce_optional(boost::mpi::communicator const &comm, std::optional< T > const &result)
Reduce an optional on the head node.
Definition
reduce_optional.hpp:36
reduce_optional.hpp
ScriptInterface::impl::recursive_variant
Recursive variant implementation.
Definition
Variant.hpp:84
EKPoissonOutputVTK::potential
@ potential
src
script_interface
walberla
EKPoissonSolverNode.cpp
Generated on Mon May 25 2026 01:34:53 for ESPResSo by
1.9.8