ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/accumulators/AccumulatorBase.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-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#pragma once
21
22#include <cassert>
23#include <cstddef>
24#include <stdexcept>
25#include <string>
26#include <vector>
27
28// Forward declarations
29namespace boost::mpi {
30class communicator;
31}
32namespace System {
33class System;
34}
35
36namespace Accumulators {
37
39public:
42 if (delta_N < 1) {
43 throw std::runtime_error("delta_N must be >= 1");
44 }
45 }
46 virtual ~AccumulatorBase() = default;
47
48 int &delta_N() { return m_delta_N; }
50 return reinterpret_cast<void const *>(system) == m_system;
51 }
53 assert(m_system == nullptr);
54 m_system = reinterpret_cast<void const *>(system);
55 }
56
57 virtual void update(boost::mpi::communicator const &comm) = 0;
58 /** Dimensions needed to reshape the flat array returned by the accumulator */
59 virtual std::vector<std::size_t> shape() const = 0;
60 /** Serialization of private members. */
61 virtual std::string get_internal_state() const = 0;
62 virtual void set_internal_state(std::string const &) = 0;
63
64protected:
65 void const *m_system; ///< for bookkeeping purposes
66private:
67 /// Number of time steps between automatic updates.
68 int m_delta_N;
69};
70} // namespace Accumulators
void override_system_handle(::System::System const *system)
virtual void set_internal_state(std::string const &)=0
virtual ~AccumulatorBase()=default
bool has_same_system_handle(::System::System const *system) const
virtual std::vector< std::size_t > shape() const =0
Dimensions needed to reshape the flat array returned by the accumulator.
virtual void update(boost::mpi::communicator const &comm)=0
AccumulatorBase(::System::System const *system, int delta_N)
virtual std::string get_internal_state() const =0
Serialization of private members.
void const * m_system
for bookkeeping purposes
Main system class.
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Communicator communicator