| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2000 - 2023 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 |
#ifndef dealii_data_out_rotation_h |
| 16 |
#define dealii_data_out_rotation_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/numerics/data_out_dof_data.h> |
| 22 |
|
| 23 |
#include <string> |
| 24 |
#include <vector> |
| 25 |
|
| 26 |
DEAL_II_NAMESPACE_OPEN |
| 27 |
|
| 28 |
|
| 29 |
namespace internal |
| 30 |
{ |
| 31 |
namespace DataOutRotationImplementation |
| 32 |
{ |
| 33 |
/** |
| 34 |
* A derived class for use in the DataOutFaces class. This is a class for |
| 35 |
* the AdditionalData kind of data structure discussed in the |
| 36 |
* documentation of the WorkStream class. |
| 37 |
*/ |
| 38 |
template <int dim, int spacedim> |
| 39 |
struct ParallelData |
| 40 |
: public internal::DataOutImplementation::ParallelDataBase<dim, spacedim> |
| 41 |
{ |
| 42 |
ParallelData(const unsigned int n_datasets, |
| 43 |
const unsigned int n_subdivisions, |
| 44 |
const unsigned int n_patches_per_circle, |
| 45 |
const std::vector<unsigned int> &n_postprocessor_outputs, |
| 46 |
const Mapping<dim, spacedim> &mapping, |
| 47 |
const std::vector< |
| 48 |
std::shared_ptr<dealii::hp::FECollection<dim, spacedim>>> |
| 49 |
&finite_elements, |
| 50 |
const UpdateFlags update_flags); |
| 51 |
|
| 52 |
const unsigned int n_patches_per_circle; |
| 53 |
|
| 54 |
std::vector<Point<spacedim>> patch_evaluation_points; |
| 55 |
}; |
| 56 |
} // namespace DataOutRotationImplementation |
| 57 |
} // namespace internal |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
/** |
| 62 |
* This class generates output in the full domain of computations that were |
| 63 |
* done using rotational symmetry of domain and solution. In particular, if a |
| 64 |
* computation of a three dimensional problem with rotational symmetry around |
| 65 |
* the @p z-axis (i.e. in the @p r-z-plane) was done, then this class can be |
| 66 |
* used to generate the output in the original @p x-y-z space. In order to do |
| 67 |
* so, it generates from each cell in the computational mesh a cell in the |
| 68 |
* space with dimension one greater than that of the DoFHandler object. The |
| 69 |
* resulting output will then consist of hexahedra forming an object that has |
| 70 |
* rotational symmetry around the z-axis. As most graphical programs can not |
| 71 |
* represent ring-like structures, the angular (rotation) variable is |
| 72 |
* discretized into a finite number of intervals as well; the number of these |
| 73 |
* intervals must be given to the @p build_patches function. It is noted, |
| 74 |
* however, that while this function generates nice pictures of the whole |
| 75 |
* domain, it often produces <em>very</em> large output files. |
| 76 |
* |
| 77 |
* |
| 78 |
* <h3>Interface</h3> |
| 79 |
* |
| 80 |
* The interface of this class is copied from the DataOut class. Furthermore, |
| 81 |
* they share the common parent class DataOut_DoFData(). See the reference of |
| 82 |
* these two classes for a discussion of the interface and how to extend it by |
| 83 |
* deriving further classes from this class. |
| 84 |
* |
| 85 |
* |
| 86 |
* <h3>Details for 1d computations</h3> |
| 87 |
* |
| 88 |
* The one coordinate in the triangulation used by the DoFHandler object |
| 89 |
* passed to this class is taken as the radial variable, and the output will |
| 90 |
* then be either a circle or a ring domain. It is in the user's |
| 91 |
* responsibility to assure that the radial coordinate only attains |
| 92 |
* non-negative values. |
| 93 |
* |
| 94 |
* |
| 95 |
* <h3>Details for 2d computations</h3> |
| 96 |
* |
| 97 |
* We consider the computation (represented by the DoFHandler object that is |
| 98 |
* attached to this class) to have happened in the @p r-z-plane, where @p r is |
| 99 |
* the radial variable and @p z denotes the axis of revolution around which |
| 100 |
* the solution is symmetric. The output is in @p x-y-z space, where the |
| 101 |
* radial dependence is transformed to the @p x-y plane. At present, it is not |
| 102 |
* possible to exchange the meaning of the first and second variable of the |
| 103 |
* plane in which the simulation was made, i.e. generate output from a |
| 104 |
* simulation where the first variable denoted the symmetry axis, and the |
| 105 |
* second denoted the radial variable. You have to take that into account when |
| 106 |
* first programming your application. |
| 107 |
* |
| 108 |
* It is in the responsibility of the user to make sure that the radial |
| 109 |
* variable attains only non-negative values. |
| 110 |
* |
| 111 |
* @ingroup output |
| 112 |
*/ |
| 113 |
template <int dim, int spacedim = dim> |
| 114 |
class DataOutRotation |
| 115 |
: public DataOut_DoFData<dim, dim + 1, spacedim, spacedim + 1> |
| 116 |
{ |
| 117 |
static_assert(dim == spacedim, "Not implemented for dim != spacedim."); |
| 118 |
|
| 119 |
public: |
| 120 |
/** |
| 121 |
* Dimension parameters for the patches. |
| 122 |
*/ |
| 123 |
static constexpr int patch_dim = dim + 1; |
| 124 |
static constexpr int patch_spacedim = spacedim + 1; |
| 125 |
|
| 126 |
/** |
| 127 |
* Typedef to the iterator type of the dof handler class under |
| 128 |
* consideration. |
| 129 |
*/ |
| 130 |
using cell_iterator = |
| 131 |
typename DataOut_DoFData<dim, patch_dim, spacedim, patch_spacedim>:: |
| 132 |
cell_iterator; |
| 133 |
|
| 134 |
/** |
| 135 |
* This is the central function of this class since it builds the list of |
| 136 |
* patches to be written by the low-level functions of the base class. A |
| 137 |
* patch is, in essence, some intermediate representation of the data on |
| 138 |
* each cell of a triangulation and DoFHandler object that can then be used |
| 139 |
* to write files in some format that is readable by visualization programs. |
| 140 |
* |
| 141 |
* You can find an overview of the use of this function in the general |
| 142 |
* documentation of this class. An example is also provided in the |
| 143 |
* documentation of this class's base class DataOut_DoFData. |
| 144 |
* |
| 145 |
* @param n_patches_per_circle Denotes into how many intervals the angular |
| 146 |
* (rotation) variable is to be subdivided. |
| 147 |
* |
| 148 |
* @param n_subdivisions See DataOut::build_patches() for an extensive |
| 149 |
* description of this parameter. |
| 150 |
*/ |
| 151 |
virtual void |
| 152 |
build_patches(const unsigned int n_patches_per_circle, |
| 153 |
const unsigned int n_subdivisions = 0); |
| 154 |
|
| 155 |
/** |
| 156 |
* Return the first cell which we want output for. The default |
| 157 |
* implementation returns the first |
| 158 |
* @ref GlossActive "active cell", |
| 159 |
* but you might want to return other cells in a derived class. |
| 160 |
*/ |
| 161 |
virtual cell_iterator |
| 162 |
first_cell(); |
| 163 |
|
| 164 |
/** |
| 165 |
* Return the next cell after @p cell which we want output for. If there are |
| 166 |
* no more cells, <tt>dofs->end()</tt> shall be returned. |
| 167 |
* |
| 168 |
* The default implementation returns the next active cell, but you might |
| 169 |
* want to return other cells in a derived class. Note that the default |
| 170 |
* implementation assumes that the given @p cell is active, which is |
| 171 |
* guaranteed as long as @p first_cell is also used from the default |
| 172 |
* implementation. Overloading only one of the two functions might not be a |
| 173 |
* good idea. |
| 174 |
*/ |
| 175 |
virtual cell_iterator |
| 176 |
next_cell(const cell_iterator &cell); |
| 177 |
|
| 178 |
/** |
| 179 |
* Exception |
| 180 |
*/ |
| 181 |
DeclException1(ExcRadialVariableHasNegativeValues, |
| 182 |
double, |
| 183 |
<< "You are attempting to use this class on a triangulation " |
| 184 |
"in which some vertices have a negative radial coordinate " |
| 185 |
"value of " |
| 186 |
<< arg1 |
| 187 |
<< ". If you rotate such a triangulation around an " |
| 188 |
"axis, you will get (dim+1)-dimensional meshes " |
| 189 |
"that are not likely what you hoped to see."); |
| 190 |
|
| 191 |
private: |
| 192 |
/** |
| 193 |
* Build all of the patches that correspond to the cell given in the first |
| 194 |
* argument. Use the second argument as scratch space for parallel |
| 195 |
* invocation in WorkStream, and put the results into the last argument. |
| 196 |
*/ |
| 197 |
void |
| 198 |
build_one_patch( |
| 199 |
const cell_iterator *cell, |
| 200 |
internal::DataOutRotationImplementation::ParallelData<dim, spacedim> &data, |
| 201 |
std::vector<DataOutBase::Patch<patch_dim, patch_spacedim>> &my_patches); |
| 202 |
}; |
| 203 |
|
| 204 |
|
| 205 |
DEAL_II_NAMESPACE_CLOSE |
| 206 |
|
| 207 |
#endif |