ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/observables/Observable.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_OBSERVABLE_HPP
23
#define SCRIPT_INTERFACE_OBSERVABLES_OBSERVABLE_HPP
24
25
#include "
script_interface/ScriptInterface.hpp
"
26
27
#include "
core/observables/Observable.hpp
"
28
29
#include <memory>
30
#include <stdexcept>
31
#include <string>
32
#include <vector>
33
34
namespace
ScriptInterface
{
35
namespace
Observables
{
36
37
/** Base class for script interfaces to core observables classes */
38
class
Observable
:
public
ObjectHandle
{
39
public
:
40
virtual
std::shared_ptr<::Observables::Observable>
observable
()
const
= 0;
41
Variant
do_call_method
(std::string
const
&
method
,
42
VariantMap
const
&)
override
{
43
if
(
method
==
"calculate"
) {
44
std::vector<double>
out
{};
45
context
()->
parallel_try_catch
([
this
, &
out
]() {
46
out
=
observable
()->operator()(
context
()->
get_comm
());
47
});
48
return
out
;
49
}
50
if
(
method
==
"shape"
) {
51
auto
const
shape =
observable
()->shape();
52
return
std::vector<int>{shape.begin(), shape.end()};
53
}
54
return
{};
55
}
56
};
57
}
/* namespace Observables */
58
}
/* namespace ScriptInterface */
59
60
#endif
ScriptInterface.hpp
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::Context::get_comm
virtual boost::mpi::communicator const & get_comm() const =0
ScriptInterface::ObjectHandle
Base class for interface handles.
Definition
ObjectHandle.hpp:37
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:57
ScriptInterface::Observables::Observable
Base class for script interfaces to core observables classes.
Definition
script_interface/observables/Observable.hpp:38
ScriptInterface::Observables::Observable::do_call_method
Variant do_call_method(std::string const &method, VariantMap const &) override
Definition
script_interface/observables/Observable.hpp:41
ScriptInterface::Observables::Observable::observable
virtual std::shared_ptr<::Observables::Observable > observable() const =0
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
Observable.hpp
Observables
Definition
BondAngles.hpp:37
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:133
ScriptInterface::impl::recursive_variant
Recursive variant implementation.
Definition
Variant.hpp:84
src
script_interface
observables
Observable.hpp
Generated on Mon Dec 8 2025 02:32:30 for ESPResSo by
1.9.8