Reference documentation for deal.II version GIT 0582167846 2023-09-24 21:20:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
data_postprocessor.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2007 - 2023 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
17 
19 
20 
21 
23 {
24  template <int spacedim>
26  : face_number(numbers::invalid_unsigned_int)
27  {}
28 
29 
30 
31  template <int spacedim>
32  unsigned int
34  {
35  Assert(
36  face_number != numbers::invalid_unsigned_int,
37  ExcMessage(
38  "This function can only be called if set_cell_and_face() has "
39  "previously been called. Typically, this would be by using DataOutFaces "
40  "or a related class."));
41  return face_number;
42  }
43 } // namespace DataPostprocessorInputs
44 
45 // -------------------------- DataPostprocessor ---------------------------
46 
47 template <int dim>
48 void
51  std::vector<Vector<double>> &) const
52 {
54 }
55 
56 
57 
58 template <int dim>
59 void
62  std::vector<Vector<double>> &) const
63 {
65 }
66 
67 
68 
69 template <int dim>
70 std::vector<DataComponentInterpretation::DataComponentInterpretation>
72 {
73  // default implementation assumes that all
74  // components are independent scalars
75  return std::vector<DataComponentInterpretation::DataComponentInterpretation>(
77 }
78 
79 
80 // -------------------- DataPostprocessorScalar -------------------------
81 
82 template <int dim>
84  const std::string &name,
85  const UpdateFlags update_flags)
86  : name(name)
87  , update_flags(update_flags)
88 {}
89 
90 
91 
92 template <int dim>
93 std::vector<std::string>
95 {
96  return std::vector<std::string>(1, name);
97 }
98 
99 
100 
101 template <int dim>
102 std::vector<DataComponentInterpretation::DataComponentInterpretation>
104 {
105  return std::vector<DataComponentInterpretation::DataComponentInterpretation>(
107 }
108 
109 
110 template <int dim>
113 {
114  return update_flags;
115 }
116 
117 
118 
119 // ------------------------- DataPostprocessorVector ------------------------
120 
121 template <int dim>
123  const std::string &name,
124  const UpdateFlags update_flags)
125  : name(name)
126  , update_flags(update_flags)
127 {}
128 
129 
130 
131 template <int dim>
132 std::vector<std::string>
134 {
135  return std::vector<std::string>(dim, name);
136 }
137 
138 
139 
140 template <int dim>
141 std::vector<DataComponentInterpretation::DataComponentInterpretation>
143 {
144  return std::vector<DataComponentInterpretation::DataComponentInterpretation>(
146 }
147 
148 
149 template <int dim>
152 {
153  return update_flags;
154 }
155 
156 
157 
158 // ------------------------- DataPostprocessorTensor ------------------------
159 
160 template <int dim>
162  const std::string &name,
163  const UpdateFlags update_flags)
164  : name(name)
165  , update_flags(update_flags)
166 {}
167 
168 
169 
170 template <int dim>
171 std::vector<std::string>
173 {
174  return std::vector<std::string>(dim * dim, name);
175 }
176 
177 
178 
179 template <int dim>
180 std::vector<DataComponentInterpretation::DataComponentInterpretation>
182 {
183  return std::vector<DataComponentInterpretation::DataComponentInterpretation>(
185 }
186 
187 
188 template <int dim>
191 {
192  return update_flags;
193 }
194 
195 
196 
197 namespace DataPostprocessors
198 {
199  template <int dim>
201  : DataPostprocessorScalar<dim>("boundary_id", update_default)
202  {}
203 
204 
205  template <int dim>
206  void
209  std::vector<Vector<double>> &computed_quantities) const
210  {
211  AssertDimension(computed_quantities.size(), inputs.solution_values.size());
212 
213  const typename DoFHandler<dim>::active_cell_iterator cell =
214  inputs.template get_cell<dim>();
215  const unsigned int face = inputs.get_face_number();
216 
217  for (auto &output : computed_quantities)
218  {
219  AssertDimension(output.size(), 1);
220 
221  // By default, DataOutFaces is only run on faces at the boundary of the
222  // domain. But one can instruct it to also run on internal faces, and in
223  // that case we cannot ask for the boundary id. Rather, we output -1, as
224  // described in the documentation.
225  if (cell->at_boundary(face))
226  output(0) = cell->face(face)->boundary_id();
227  else
228  output(0) = -1;
229  }
230  }
231 } // namespace DataPostprocessors
232 
233 
234 
235 // explicit instantiation
236 #include "data_postprocessor.inst"
237 
238 
DataPostprocessorScalar(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< std::string > get_names() const override
virtual UpdateFlags get_needed_update_flags() const override
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
DataPostprocessorTensor(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< std::string > get_names() const override
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
virtual UpdateFlags get_needed_update_flags() const override
virtual std::vector< std::string > get_names() const override
virtual UpdateFlags get_needed_update_flags() const override
DataPostprocessorVector(const std::string &name, const UpdateFlags update_flags)
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const override
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
virtual void evaluate_vector_field(const DataPostprocessorInputs::Vector< dim > &input_data, std::vector< Vector< double >> &computed_quantities) const
virtual std::vector< DataComponentInterpretation::DataComponentInterpretation > get_data_component_interpretation() const
virtual void evaluate_scalar_field(const DataPostprocessorInputs::Scalar< dim > &inputs, std::vector< Vector< double >> &computed_quantities) const override
Definition: vector.h:110
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:477
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
static ::ExceptionBase & ExcPureFunctionCalled()
#define Assert(cond, exc)
Definition: exceptions.h:1616
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1789
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Definition: exceptions.h:1705
typename ActiveSelector::active_cell_iterator active_cell_iterator
Definition: dof_handler.h:441
UpdateFlags
@ update_default
No update.
static const unsigned int invalid_unsigned_int
Definition: types.h:213
std::vector< double > solution_values