ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
electrostatics/Actor.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 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#pragma once
21
22#include "config/config.hpp"
23
24#ifdef ELECTROSTATICS
25
31
32#include <memory>
33#include <string>
34
35namespace ScriptInterface {
36namespace Coulomb {
37
38/**
39 * @brief Common interface for electrostatic actors.
40 * Several methods are defined in initialize.cpp since they
41 * depend on symbols only available in @ref coulomb.hpp, which cannot be
42 * included in this header file for separation of concerns reasons.
43 */
44template <class SIClass, class CoreClass>
45class Actor : public AutoParameters<Actor<SIClass, CoreClass>, System::Leaf> {
46protected:
47 using SIActorClass = SIClass;
48 using CoreActorClass = CoreClass;
55 std::shared_ptr<CoreActorClass> m_actor;
56
58 m_actor->bind_system(m_system.lock());
59 }
60
61public:
62 Actor();
63
64 Variant do_call_method(std::string const &name,
65 VariantMap const &params) override;
66
67 std::shared_ptr<CoreActorClass> actor() { return m_actor; }
68 std::shared_ptr<CoreActorClass const> actor() const { return m_actor; }
69
70protected:
72 auto const key_chk = std::string("check_neutrality");
73 auto const key_tol = std::string("charge_neutrality_tolerance");
74 if (params.count(key_tol)) {
75 do_set_parameter(key_tol, params.at(key_tol));
76 }
77 do_set_parameter(key_chk, params.at(key_chk));
78 }
79};
80
81} // namespace Coulomb
82} // namespace ScriptInterface
83
84#endif // ELECTROSTATICS
ScriptInterface::Context decorates ScriptInterface::ObjectHandle objects with a context: a creation p...
Bind parameters in the script interface.
void do_set_parameter(const std::string &name, const Variant &value) final
Common interface for electrostatic actors.
void on_bind_system(::System::System &) override
std::shared_ptr< CoreActorClass > m_actor
std::shared_ptr< CoreActorClass > actor()
Actor< SIClass, CoreClass > ObjectClass
Variant do_call_method(std::string const &name, VariantMap const &params) override
std::shared_ptr< CoreActorClass const > actor() const
void set_charge_neutrality_tolerance(VariantMap const &params)
boost::string_ref name() const
Context * context() const
Responsible context.
Script interface wrapper for a component of the system class.
std::weak_ptr<::System::System > m_system
Main system class.
This file contains the defaults for ESPResSo.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:82
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
Definition Variant.hpp:80
static SteepestDescentParameters params
Currently active steepest descent instance.