ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
walberla_bridge/include/walberla_bridge/VTKHandle.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020-2023 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
24
25#include <memory>
26#include <stdexcept>
27#include <string>
28#include <utility>
29
30namespace walberla::vtk {
31// forward declare
32class VTKOutput;
33} // namespace walberla::vtk
34
35/** @brief Handle to a VTK object */
36class VTKHandle {
37 std::unique_ptr<ResourceManager> m_vtk_resources_lock;
38
39public:
40 VTKHandle(std::shared_ptr<walberla::vtk::VTKOutput> sp, int ec, bool en)
42 m_vtk_resources_lock = ::walberla::get_vtk_dependent_resources();
43 }
45 // vtk objects must be cleared *before* the MPI resources can be freed,
46 // because file handles need to be closed on all ranks
47 ptr.reset();
48 m_vtk_resources_lock.reset();
49 }
50
51 std::shared_ptr<walberla::vtk::VTKOutput> ptr;
53 bool enabled;
54};
55
56/** @brief LB statistics to write to VTK files */
57enum class OutputVTK : int {
58 density = 1 << 0,
59 velocity_vector = 1 << 1,
60 pressure_tensor = 1 << 2,
61};
62
63/** @brief EK statistics to write to VTK files */
64enum class EKOutputVTK : int {
65 density = 1 << 0,
66 flux = 1 << 1,
67};
68
69/** @brief EK Poisson solver statistics to write to VTK files */
70enum class EKPoissonOutputVTK : int {
71 potential = 1 << 0,
72};
73
74class vtk_runtime_error : public std::runtime_error {
75public:
76 explicit vtk_runtime_error(std::string const &vtk_uid,
77 std::string const &reason)
78 : std::runtime_error("VTKOutput object '" + vtk_uid + "' " + reason) {}
79};
std::shared_ptr< walberla::vtk::VTKOutput > ptr
VTKHandle(std::shared_ptr< walberla::vtk::VTKOutput > sp, int ec, bool en)
vtk_runtime_error(std::string const &vtk_uid, std::string const &reason)
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
STL namespace.
std::unique_ptr< ResourceManager > get_vtk_dependent_resources()
Get a lock on waLBerla's global resources for VTK.
EKOutputVTK
EK statistics to write to VTK files.
OutputVTK
LB statistics to write to VTK files.
EKPoissonOutputVTK
EK Poisson solver statistics to write to VTK files.