ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/accumulators/ContactTimes.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2025 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 "
AccumulatorBase.hpp
"
23
#include "
script_interface/observables/Observable.hpp
"
24
25
#include "
core/accumulators/ContactTimes.hpp
"
26
#include "
core/system/System.hpp
"
27
28
#include <memory>
29
#include <string>
30
#include <utility>
31
#include <vector>
32
33
namespace
ScriptInterface
{
34
namespace
Accumulators
{
35
36
class
ContactTimes
:
public
AccumulatorBase
{
37
using
CoreCorr
=
::Accumulators::ContactTimes
;
38
39
public
:
40
ContactTimes
() {
41
add_parameters
({
42
{
"obs"
, std::as_const(m_obs)},
43
{
"contact_threshold"
, m_accumulator, &CoreCorr::get_contact_threshold},
44
});
45
}
46
47
void
do_construct
(
VariantMap
const
&
params
)
override
{
48
set_from_args
(m_obs,
params
,
"obs"
);
49
50
ObjectHandle::context
()->
parallel_try_catch
([&]() {
51
m_accumulator = std::make_shared<CoreCorr>(
52
get_core_system_pointer
(
params
),
53
get_value_or<int>
(
params
,
"delta_N"
, 1),
54
get_value<double>
(
params
,
"contact_threshold"
), m_obs->observable());
55
});
56
}
57
58
Variant
do_call_method
(std::string
const
&
method
,
59
VariantMap
const
&
parameters
)
override
{
60
if
(
method
==
"update"
) {
61
ObjectHandle::context
()->
parallel_try_catch
(
62
[&]() { m_accumulator->update(
context
()->get_comm()); });
63
return
{};
64
}
65
if
(
method
==
"contact_times"
) {
66
return
m_accumulator->contact_times();
67
}
68
if
(
method
==
"clear"
) {
69
m_accumulator->clear();
70
}
71
72
return
AccumulatorBase::do_call_method
(
method
,
parameters
);
73
}
74
75
std::shared_ptr<::Accumulators::AccumulatorBase>
accumulator
()
override
{
76
return
m_accumulator;
77
}
78
79
std::shared_ptr<const ::Accumulators::AccumulatorBase>
80
accumulator
()
const override
{
81
return
std::static_pointer_cast<::Accumulators::AccumulatorBase>(
82
m_accumulator);
83
}
84
85
private
:
86
/* The actual accumulator */
87
std::shared_ptr<CoreCorr> m_accumulator;
88
std::shared_ptr<Observables::Observable> m_obs;
89
};
90
91
}
// namespace Accumulators
92
}
// namespace ScriptInterface
Accumulators::ContactTimes
Record the time distances are below a threshold.
Definition
core/accumulators/ContactTimes.hpp:43
ScriptInterface::Accumulators::AccumulatorBase
Definition
script_interface/accumulators/AccumulatorBase.hpp:36
ScriptInterface::Accumulators::AccumulatorBase::get_core_system_pointer
auto get_core_system_pointer(VariantMap const ¶ms) const
Definition
script_interface/accumulators/AccumulatorBase.hpp:63
ScriptInterface::Accumulators::AccumulatorBase::do_call_method
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Definition
script_interface/accumulators/AccumulatorBase.hpp:45
ScriptInterface::Accumulators::ContactTimes
Definition
script_interface/accumulators/ContactTimes.hpp:36
ScriptInterface::Accumulators::ContactTimes::accumulator
std::shared_ptr< const ::Accumulators::AccumulatorBase > accumulator() const override
Definition
script_interface/accumulators/ContactTimes.hpp:80
ScriptInterface::Accumulators::ContactTimes::ContactTimes
ContactTimes()
Definition
script_interface/accumulators/ContactTimes.hpp:40
ScriptInterface::Accumulators::ContactTimes::accumulator
std::shared_ptr<::Accumulators::AccumulatorBase > accumulator() override
Definition
script_interface/accumulators/ContactTimes.hpp:75
ScriptInterface::Accumulators::ContactTimes::do_construct
void do_construct(VariantMap const ¶ms) override
Definition
script_interface/accumulators/ContactTimes.hpp:47
ScriptInterface::Accumulators::ContactTimes::do_call_method
Variant do_call_method(std::string const &method, VariantMap const ¶meters) override
Definition
script_interface/accumulators/ContactTimes.hpp:58
ScriptInterface::AutoParameters< AccumulatorBase >::add_parameters
void add_parameters(std::vector< AutoParameter > &¶ms)
Definition
AutoParameters.hpp:123
ScriptInterface::Context::parallel_try_catch
virtual void parallel_try_catch(std::function< void()> const &cb) const =0
ScriptInterface::ObjectHandle::context
Context * context() const
Responsible context.
Definition
ObjectHandle.hpp:57
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
ContactTimes.hpp
System.hpp
Accumulators
Definition
core/accumulators/AccumulatorBase.hpp:35
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::VariantMap
std::unordered_map< std::string, Variant > VariantMap
Definition
Variant.hpp:133
ScriptInterface::set_from_args
void set_from_args(T &dst, VariantMap const &vals, const char *name)
Definition
get_value.hpp:440
AccumulatorBase.hpp
Observable.hpp
params
static SteepestDescentParameters params
Currently active steepest descent instance.
Definition
steepest_descent.cpp:44
ScriptInterface::impl::recursive_variant
Recursive variant implementation.
Definition
Variant.hpp:84
src
script_interface
accumulators
ContactTimes.hpp
Generated on Mon Dec 8 2025 02:32:29 for ESPResSo by
1.9.8