ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
SanityChecksLB.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 "BoxGeometry.hpp"
23#include "lb/Solver.hpp"
24
25#include <utils/Vector.hpp>
26
27#include <cstddef>
28
29namespace Observables {
30
31/** @brief Bookkeeping of the box gometry and LB object memory address. */
34 double m_agrid = 0.;
35 std::size_t m_lb_obj_tag = 0ul;
36
37 std::size_t get_lb_obj_tag(LB::Solver const &solver) const {
38 std::size_t lb_obj_tag{0u};
39 solver.connect([&lb_obj_tag](auto const &lb_obj) {
40 lb_obj_tag = reinterpret_cast<std::size_t>(&lb_obj);
41 });
42 return lb_obj_tag;
43 }
44
45public:
46 SanityChecksLB() = default;
47 SanityChecksLB(BoxGeometry const &box_geo, LB::Solver const &solver) {
48 m_box_l = box_geo.length();
49 m_agrid = solver.get_agrid();
50 m_lb_obj_tag = get_lb_obj_tag(solver);
51 }
52
53 bool mismatch(BoxGeometry const &box_geo, LB::Solver const &solver) const {
54 if (m_lb_obj_tag == 0u) {
55 return true;
56 }
57 auto const same_lb_obj = get_lb_obj_tag(solver) == m_lb_obj_tag;
58 auto const same_box_l = m_box_l == box_geo.length();
59 auto const same_agrid = m_agrid == solver.get_agrid();
61 }
62};
63
64} // namespace Observables
Vector implementation and trait types for boost qvm interoperability.
Utils::Vector3d const & length() const
Box length.
Bookkeeping of the box gometry and LB object memory address.
bool mismatch(BoxGeometry const &box_geo, LB::Solver const &solver) const
SanityChecksLB(BoxGeometry const &box_geo, LB::Solver const &solver)
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
Definition Vector.hpp:132
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
void connect(Connector &&connector) const
Connector to the implementation internal state.
Definition lb/Solver.hpp:63
double get_agrid() const
Get the LB grid spacing.