ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/LBProfileObservable.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef SCRIPT_INTERFACE_OBSERVABLES_LBPROFILEOBSERVABLE_HPP
23#define SCRIPT_INTERFACE_OBSERVABLES_LBPROFILEOBSERVABLE_HPP
24
26
27#include "Observable.hpp"
29
30#include <boost/range/algorithm.hpp>
31
32#include <cstddef>
33#include <iterator>
34#include <memory>
35#include <string>
36#include <type_traits>
37#include <vector>
38
39namespace ScriptInterface {
40namespace Observables {
41
42template <typename CoreLBObs>
44 : public AutoParameters<LBProfileObservable<CoreLBObs>, Observable> {
46
47public:
48 static_assert(
49 std::is_base_of_v<::Observables::LBProfileObservable, CoreLBObs>);
50 using Base::Base;
52 this->add_parameters(
53 {{"n_x_bins", AutoParameter::read_only,
54 [this]() {
55 return static_cast<int>(profile_observable()->n_bins()[0]);
56 }},
57 {"n_y_bins", AutoParameter::read_only,
58 [this]() {
59 return static_cast<int>(profile_observable()->n_bins()[1]);
60 }},
61 {"n_z_bins", AutoParameter::read_only,
62 [this]() {
63 return static_cast<int>(profile_observable()->n_bins()[2]);
64 }},
66 [this]() { return profile_observable()->limits()[0].first; }},
68 [this]() { return profile_observable()->limits()[1].first; }},
70 [this]() { return profile_observable()->limits()[2].first; }},
72 [this]() { return profile_observable()->limits()[0].second; }},
74 [this]() { return profile_observable()->limits()[1].second; }},
76 [this]() { return profile_observable()->limits()[2].second; }},
77 {"sampling_delta_x", AutoParameter::read_only,
78 [this]() { return profile_observable()->sampling_delta[0]; }},
79 {"sampling_delta_y", AutoParameter::read_only,
80 [this]() { return profile_observable()->sampling_delta[1]; }},
81 {"sampling_delta_z", AutoParameter::read_only,
82 [this]() { return profile_observable()->sampling_delta[2]; }},
83 {"sampling_offset_x", AutoParameter::read_only,
84 [this]() { return profile_observable()->sampling_offset[0]; }},
85 {"sampling_offset_y", AutoParameter::read_only,
86 [this]() { return profile_observable()->sampling_offset[1]; }},
87 {"sampling_offset_z", AutoParameter::read_only,
88 [this]() { return profile_observable()->sampling_offset[2]; }},
89 {"allow_empty_bins", AutoParameter::read_only,
90 [this]() { return profile_observable()->allow_empty_bins; }}});
91 }
92
93 void do_construct(VariantMap const &params) override {
95 m_observable =
96 make_shared_from_args<CoreLBObs, double, double, double, double,
97 double, double, int, int, int, double, double,
98 double, double, double, double, bool>(
99 params, "sampling_delta_x", "sampling_delta_y",
100 "sampling_delta_z", "sampling_offset_x", "sampling_offset_y",
101 "sampling_offset_z", "n_x_bins", "n_y_bins", "n_z_bins", "min_x",
102 "max_x", "min_y", "max_y", "min_z", "max_z", "allow_empty_bins");
103 });
104 }
105
106 Variant do_call_method(std::string const &method,
107 VariantMap const &parameters) override {
108 if (method == "edges") {
109 std::vector<Variant> variant_edges;
110 boost::copy(profile_observable()->edges(),
111 std::back_inserter(variant_edges));
112 return variant_edges;
113 }
114 return Base::do_call_method(method, parameters);
115 }
116
117 std::shared_ptr<::Observables::Observable> observable() const override {
118 return m_observable;
119 }
120
121 virtual std::shared_ptr<::Observables::LBProfileObservable>
123 return m_observable;
124 }
125
126private:
127 std::shared_ptr<CoreLBObs> m_observable;
128};
129
130} /* namespace Observables */
131} /* namespace ScriptInterface */
132
133#endif
Bind parameters in the script interface.
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
Context * context() const
Responsible context.
virtual std::shared_ptr<::Observables::LBProfileObservable > profile_observable() const
Variant do_call_method(std::string const &method, VariantMap const &parameters) override
std::shared_ptr<::Observables::Observable > observable() const override
Base class for script interfaces to core observables classes.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:82
std::shared_ptr< T > make_shared_from_args(VariantMap const &vals, ArgNames &&...args)
Make a new std::shared_ptr<T> with arguments extracted from a VariantMap.
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.
static constexpr const ReadOnly read_only