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-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 <cassert>
23#include <cstddef>
24#include <string>
25#include <vector>
26
27// Forward declarations
28namespace boost::mpi {
29class communicator;
30}
31namespace System {
32class System;
33}
34
35namespace Accumulators {
36
38public:
40 : m_system(reinterpret_cast<void const *>(system)), m_delta_N(delta_N) {}
41 virtual ~AccumulatorBase() = default;
42
43 int &delta_N() { return m_delta_N; }
44 bool has_same_system_handle(::System::System const *system) const {
45 return reinterpret_cast<void const *>(system) == m_system;
46 }
48 assert(m_system == nullptr);
49 m_system = reinterpret_cast<void const *>(system);
50 }
51
52 virtual void update(boost::mpi::communicator const &comm) = 0;
53 /** Dimensions needed to reshape the flat array returned by the accumulator */
54 virtual std::vector<std::size_t> shape() const = 0;
55 /** Serialization of private members. */
56 virtual std::string get_internal_state() const = 0;
57 virtual void set_internal_state(std::string const &) = 0;
58
59protected:
60 void const *m_system; ///< for bookkeeping purposes
61private:
62 /// Number of time steps between automatic updates.
63 int m_delta_N;
64};
65} // 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.
Communicator communicator