| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2010 - 2024 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
|
| 16 |
#ifndef dealii_dof_output_operator_h |
| 17 |
#define dealii_dof_output_operator_h |
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/algorithms/any_data.h> |
| 22 |
#include <deal.II/algorithms/operator.h> |
| 23 |
|
| 24 |
#include <deal.II/base/event.h> |
| 25 |
|
| 26 |
#include <deal.II/dofs/dof_handler.h> |
| 27 |
|
| 28 |
#include <deal.II/numerics/data_out.h> |
| 29 |
|
| 30 |
#include <fstream> |
| 31 |
|
| 32 |
DEAL_II_NAMESPACE_OPEN |
| 33 |
|
| 34 |
#ifndef DOXYGEN |
| 35 |
class ParameterHandler; |
| 36 |
#endif |
| 37 |
|
| 38 |
namespace Algorithms |
| 39 |
{ |
| 40 |
/** |
| 41 |
* An output operator writing a separate file in each step and writing the |
| 42 |
* vectors as finite element functions with respect to a given DoFHandler. |
| 43 |
*/ |
| 44 |
template <typename VectorType, int dim, int spacedim = dim> |
| 45 |
class DoFOutputOperator : public OutputOperator<VectorType> |
| 46 |
{ |
| 47 |
public: |
| 48 |
/* |
| 49 |
* Constructor. The <tt>filename</tt> is the common base name of |
| 50 |
* all files and the argument <tt>digits</tt> should be the number |
| 51 |
* of digits of the highest number in the sequence. File names by |
| 52 |
* default have the form "outputNNN" with NNN the number set by the |
| 53 |
* last step command. Numbers with less digits are filled with |
| 54 |
* zeros from the left. |
| 55 |
*/ |
| 56 |
DoFOutputOperator(const std::string &filename_base = "output", |
| 57 |
const unsigned int digits = 3); |
| 58 |
|
| 59 |
void |
| 60 |
parse_parameters(ParameterHandler ¶m); |
| 61 |
void |
| 62 |
initialize(const DoFHandler<dim, spacedim> &dof_handler); |
| 63 |
|
| 64 |
virtual OutputOperator<VectorType> & |
| 65 |
operator<<(const AnyData &vectors) override; |
| 66 |
|
| 67 |
private: |
| 68 |
ObserverPointer<const DoFHandler<dim, spacedim>, |
| 69 |
DoFOutputOperator<VectorType, dim, spacedim>> |
| 70 |
dof; |
| 71 |
|
| 72 |
const std::string filename_base; |
| 73 |
const unsigned int digits; |
| 74 |
|
| 75 |
DataOut<dim> out; |
| 76 |
}; |
| 77 |
|
| 78 |
template <typename VectorType, int dim, int spacedim> |
| 79 |
inline void |
| 80 |
DoFOutputOperator<VectorType, dim, spacedim>::initialize( |
| 81 |
const DoFHandler<dim, spacedim> &dof_handler) |
| 82 |
{ |
| 83 |
dof = &dof_handler; |
| 84 |
} |
| 85 |
} // namespace Algorithms |
| 86 |
|
| 87 |
|
| 88 |
DEAL_II_NAMESPACE_CLOSE |
| 89 |
|
| 90 |
#endif |