Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
output_struct.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_output_struct_h
5#define lethe_output_struct_h
6
7#include <deal.II/base/table_handler.h>
8
9#include <deal.II/numerics/data_postprocessor.h>
10
11using namespace dealii;
12
13/**
14 * @brief Struct containing information about the solution output.
15 * It is used to pass the information required upon calling
16 * add_data_vector() for the DataOut instance without losing track of its
17 * attributes such as name and data component interpretation. This version of
18 * the struct uses Postprocessors.
19 */
20template <int dim, typename VectorType>
22{
23 /**
24 * @brief Constructor for when data is in data_postprocessor.
25 *
26 * @param[in] dof_handler DoFHandler containing solution.
27 * @param[in] solution Solution field.
28 * @param[in] data_postprocessor Data postprocessor.
29 *
30 */
32 const DoFHandler<dim> &dof_handler,
33 const VectorType &solution,
34 const std::shared_ptr<DataPostprocessor<dim>> &data_postprocessor)
38 {}
39 const DoFHandler<dim> &dof_handler;
41 const std::shared_ptr<DataPostprocessor<dim>> data_postprocessor;
42};
43
44/**
45 * @brief Struct containing information about the solution output.
46 * It is used to pass all the information required upon calling
47 * add_data_vector() for the DataOut instance without losing track of its
48 * attributes such as name and data component interpretation. This version of
49 * the struct uses the DoF handler, the present solution field, and the data
50 * component interpretation vector.
51 */
52template <int dim, typename VectorType>
54{
55 /**
56 * @brief Constructor for when data is not related to a data_postprocessor.
57 *
58 * @param[in] dof_handler DoFHandler containing solution.
59 * @param[in] solution Solution field.
60 * @param[in] solution_names Vector with strings containing solution name.
61 * @param[in] data_component_interpretation Vector with data component
62 * interpretation of the solution.
63 */
65 const DoFHandler<dim> &dof_handler,
66 const VectorType &solution,
67 const std::vector<std::string> &solution_names,
68 const std::vector<DataComponentInterpretation::DataComponentInterpretation>
74 {}
75 const DoFHandler<dim> &dof_handler;
77 const std::vector<std::string> solution_names;
78 const std::vector<DataComponentInterpretation::DataComponentInterpretation>
80};
81
82/**
83 * @brief Struct containing information about the solution output.
84 * It is used to pass all the information required upon calling
85 * add_data_vector() for the DataOut instance without losing track of its
86 * attributes such as name and data component interpretation. This version of
87 * the struct uses a cell-based field parsed as a Vector and the solution name.
88 */
90{
91 /**
92 * @brief Constructor for when data is not related to a data_postprocessor.
93 *
94 * @param[in] solution Solution Vector<float>, which is stored as a copy.
95 * @param[in] solution_name String containing solution name.
96 */
97 OutputStructCellVector(const Vector<float> &solution,
98 const std::string &solution_name)
101 {}
102 const Vector<float> solution;
103 const std::string solution_name;
104};
105
106/**
107 * @brief Variant handler of the three output structs
108 * (OutputStructPostprocessor, OutputStructSolution and OutputStructCellVector).
109 * This is used to allow the output of both postprocessors with their respective
110 * DoF handlers, and the straightforward cell data struct in a single vector of
111 * OutputStruct.
112 */
113template <int dim, typename VectorType>
114using OutputStruct = std::variant<OutputStructPostprocessor<dim, VectorType>,
117
118/**
119 * @brief Struct containing information about the table handlers to be
120 * written/read. It is used to pass a vector of references to TableHandler
121 * objects that should be serialized/deserialized at the writing/reading of a
122 * checkpoint by the solver used, and a vector of references to strings
123 * containing the names of the corresponding files.
124 */
126{
127 /**
128 * @brief Constructor
129 *
130 * @param[in] table A reference to a TableHandler object that needs to be
131 * serialized/ deserialized.
132 * @param[in] table_filename A string with the corresponding file name.
133 */
135 const std::string &table_filename)
136 : table(table)
138 {}
139 /// Reference to the TableHandler object to be serialized/deserialized
140 TableHandler &table;
141 /// Name of the file associated with the TableHandler for input/output
142 const std::string table_filename;
143};
144#endif
std::variant< OutputStructPostprocessor< dim, VectorType >, OutputStructSolution< dim, VectorType >, OutputStructCellVector > OutputStruct
Variant handler of the three output structs (OutputStructPostprocessor, OutputStructSolution and Outp...
Struct containing information about the solution output. It is used to pass all the information requi...
const Vector< float > solution
OutputStructCellVector(const Vector< float > &solution, const std::string &solution_name)
Constructor for when data is not related to a data_postprocessor.
const std::string solution_name
const VectorType & solution
OutputStructPostprocessor(const DoFHandler< dim > &dof_handler, const VectorType &solution, const std::shared_ptr< DataPostprocessor< dim > > &data_postprocessor)
Constructor for when data is in data_postprocessor.
const std::shared_ptr< DataPostprocessor< dim > > data_postprocessor
const DoFHandler< dim > & dof_handler
Struct containing information about the solution output. It is used to pass all the information requi...
const DoFHandler< dim > & dof_handler
const std::vector< std::string > solution_names
OutputStructSolution(const DoFHandler< dim > &dof_handler, const VectorType &solution, const std::vector< std::string > &solution_names, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation)
Constructor for when data is not related to a data_postprocessor.
const VectorType & solution
const std::vector< DataComponentInterpretation::DataComponentInterpretation > data_component_interpretation
const std::string table_filename
Name of the file associated with the TableHandler for input/output.
OutputStructTableHandler(TableHandler &table, const std::string &table_filename)
Constructor.
TableHandler & table
Reference to the TableHandler object to be serialized/deserialized.
GlobalVectorType VectorType