39#ifdef DEAL_II_WITH_ZLIB
43#ifdef DEAL_II_WITH_HDF5
47#include <boost/iostreams/copy.hpp>
48#include <boost/iostreams/device/back_inserter.hpp>
49#include <boost/iostreams/filtering_stream.hpp>
50#ifdef DEAL_II_WITH_ZLIB
51# include <boost/iostreams/filter/zlib.hpp>
66 <<
"Unexpected input: expected line\n <" << arg1
67 <<
">\nbut got\n <" << arg2 <<
">");
69# ifdef DEAL_II_WITH_ZLIB
70 constexpr bool deal_ii_with_zlib =
true;
72 constexpr bool deal_ii_with_zlib =
false;
76# ifdef DEAL_II_WITH_ZLIB
87 return Z_NO_COMPRESSION;
91 return Z_BEST_COMPRESSION;
93 return Z_DEFAULT_COMPRESSION;
96 return Z_NO_COMPRESSION;
100# ifdef DEAL_II_WITH_MPI
111 return boost::iostreams::zlib::no_compression;
113 return boost::iostreams::zlib::best_speed;
115 return boost::iostreams::zlib::best_compression;
117 return boost::iostreams::zlib::default_compression;
120 return boost::iostreams::zlib::no_compression;
130 template <
typename T>
132 compress_array(
const std::vector<T> &
data,
135# ifdef DEAL_II_WITH_ZLIB
136 if (
data.size() != 0)
138 const std::size_t uncompressed_size = (
data.size() *
sizeof(T));
146 std::numeric_limits<std::uint32_t>::max(),
150 auto compressed_data_length = compressBound(uncompressed_size);
152 std::numeric_limits<std::uint32_t>::max(),
155 std::vector<unsigned char> compressed_data(compressed_data_length);
157 int err = compress2(&compressed_data[0],
158 &compressed_data_length,
159 reinterpret_cast<const Bytef *
>(
data.data()),
161 get_zlib_compression_level(compression_level));
166 compressed_data.resize(compressed_data_length);
169 const std::uint32_t compression_header[4] = {
171 static_cast<std::uint32_t
>(uncompressed_size),
172 static_cast<std::uint32_t
>(
174 static_cast<std::uint32_t
>(
175 compressed_data_length)};
177 const auto *
const header_start =
178 reinterpret_cast<const unsigned char *
>(&compression_header[0]);
181 {header_start, header_start + 4 *
sizeof(std::uint32_t)}) +
188 (void)compression_level;
190 ExcMessage(
"This function can only be called if cmake found "
191 "a working libz installation."));
206 template <
typename T>
208 vtu_stringize_array(
const std::vector<T> &
data,
212 if (deal_ii_with_zlib &&
216 return compress_array(
data, compression_level);
220 std::ostringstream stream;
221 stream.precision(precision);
222 for (
const T &el :
data)
237 struct ParallelIntermediateHeader
240 std::uint64_t version;
241 std::uint64_t compression;
242 std::uint64_t dimension;
243 std::uint64_t space_dimension;
244 std::uint64_t n_ranks;
245 std::uint64_t n_patches;
295 SvgCell::operator<(
const SvgCell &e)
const
298 return depth >
e.depth;
336 EpsCell2d::operator<(
const EpsCell2d &e)
const
339 return depth >
e.depth;
355 template <
int dim,
int spacedim,
typename Number =
double>
356 std::unique_ptr<Table<2, Number>>
357 create_global_data_table(
const std::vector<Patch<dim, spacedim>> &patches)
361 return std::make_unique<Table<2, Number>>();
370 const unsigned int n_data_sets = patches[0].points_are_available ?
371 (patches[0].data.n_rows() - spacedim) :
372 patches[0].
data.n_rows();
373 const unsigned int n_data_points =
374 std::accumulate(patches.begin(),
377 [](
const unsigned int count,
379 return count + patch.data.n_cols();
382 std::unique_ptr<Table<2, Number>> global_data_table =
383 std::make_unique<Table<2, Number>>(n_data_sets, n_data_points);
386 unsigned int next_value = 0;
387 for (
const auto &patch : patches)
389 const unsigned int n_subdivisions = patch.n_subdivisions;
390 (void)n_subdivisions;
392 Assert((patch.data.n_rows() == n_data_sets &&
393 !patch.points_are_available) ||
394 (patch.data.n_rows() == n_data_sets + spacedim &&
395 patch.points_are_available),
397 (n_data_sets + spacedim) :
399 patch.
data.n_rows()));
400 Assert(patch.reference_cell != ReferenceCells::get_hypercube<dim>() ||
401 (n_data_sets == 0) ||
402 (patch.data.n_cols() ==
403 Utilities::fixed_power<dim>(n_subdivisions + 1)),
405 n_subdivisions + 1));
407 for (
unsigned int i = 0; i < patch.data.n_cols(); ++i, ++next_value)
408 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
409 (*global_data_table)[data_set][next_value] =
410 patch.data(data_set, i);
414 return global_data_table;
424 , node_dim(
numbers::invalid_unsigned_int)
432 , node_dim(
numbers::invalid_unsigned_int)
445 for (
unsigned int d = 0; d < dim; ++d)
449 unsigned int internal_ind;
460 internal_ind = it->second;
470 const unsigned int pt_index)
488 for (
unsigned int d = 0; d <
node_dim; ++d)
489 node_data[
node_dim * existing_point.second + d] =
490 existing_point.first[d];
498 std::vector<unsigned int> &cell_data)
const
504 cell_data[filtered_cell.first] =
505 filtered_cell.second + local_node_offset;
574 const unsigned int start,
575 const std::array<unsigned int, dim> &offsets)
579 const unsigned int base_entry =
592 const unsigned int d1 = offsets[0];
601 const unsigned int d1 = offsets[0];
602 const unsigned int d2 = offsets[1];
613 const unsigned int d1 = offsets[0];
614 const unsigned int d2 = offsets[1];
615 const unsigned int d3 = offsets[2];
637 const unsigned int start,
638 const unsigned int n_points,
643 const unsigned int base_entry = index * n_points;
645 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
647 for (
unsigned int i = 0; i < n_points; ++i)
658 const unsigned int dimension,
659 const unsigned int set_num,
662 unsigned int new_dim;
681 for (
unsigned int d = 0; d < new_dim; ++d)
684 data_sets.back()[r * new_dim + d] = data_vectors(set_num + d, i);
700 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
702 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
704 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
719 template <
int dim,
int spacedim>
720 std::array<unsigned int, 3>
722 const bool write_higher_order_cells)
724 std::array<unsigned int, 3> vtk_cell_id = {
730 if (write_higher_order_cells)
733 vtk_cell_id[2] = patch.
data.n_cols();
739 patch.
data.n_cols() == 6)
743 vtk_cell_id[2] = patch.
data.n_cols();
746 patch.
data.n_cols() == 10)
750 vtk_cell_id[2] = patch.
data.n_cols();
761 vtk_cell_id[2] = patch.
data.n_cols();
780 template <
int dim,
int spacedim>
782 get_equispaced_location(
784 const std::initializer_list<unsigned int> &lattice_location,
785 const unsigned int n_subdivisions)
792 const unsigned int xstep = (dim > 0 ? *(lattice_location.begin() + 0) : 0);
793 const unsigned int ystep = (dim > 1 ? *(lattice_location.begin() + 1) : 0);
794 const unsigned int zstep = (dim > 2 ? *(lattice_location.begin() + 2) : 0);
802 unsigned int point_no = 0;
807 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
811 point_no += (n_subdivisions + 1) * ystep;
825 for (
unsigned int d = 0;
d < spacedim; ++
d)
826 node[d] = patch.
data(patch.
data.size(0) - spacedim + d, point_no);
838 const double stepsize = 1. / n_subdivisions;
839 const double xfrac = xstep * stepsize;
845 const double yfrac = ystep * stepsize;
847 node += ((patch.
vertices[3] * xfrac) +
848 (patch.
vertices[2] * (1 - xfrac))) *
852 const double zfrac = zstep * stepsize;
854 node += (((patch.
vertices[5] * xfrac) +
855 (patch.
vertices[4] * (1 - xfrac))) *
858 (patch.
vertices[6] * (1 - xfrac))) *
871 template <
int dim,
int spacedim>
874 const unsigned int node_index)
879 unsigned int point_no_actual = node_index;
884 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
885 point_no_actual = table[node_index];
893 for (
unsigned int d = 0;
d < spacedim; ++
d)
895 patch.
data(patch.
data.size(0) - spacedim + d, point_no_actual);
908 return patch.
vertices[point_no_actual];
919 template <
int dim,
int spacedim>
920 std::tuple<unsigned int, unsigned int>
921 count_nodes_and_cells(
924 unsigned int n_nodes = 0;
926 for (
const auto &patch : patches)
930 "The reference cell for this patch is set to 'Invalid', "
931 "but that is clearly not a valid choice. Did you forget "
932 "to set the reference cell for the patch?"));
947 return std::make_tuple(n_nodes, n_cells);
957 template <
int dim,
int spacedim>
958 std::tuple<unsigned int, unsigned int, unsigned int>
959 count_nodes_and_cells_and_points(
961 const bool write_higher_order_cells)
963 unsigned int n_nodes = 0;
965 unsigned int n_points_and_n_cells = 0;
967 for (
const auto &patch : patches)
973 if (write_higher_order_cells)
979 n_points_and_n_cells +=
988 const unsigned int n_subcells =
991 n_points_and_n_cells +=
997 n_nodes += patch.
data.n_cols();
999 n_points_and_n_cells += patch.
data.n_cols() + 1;
1003 return std::make_tuple(n_nodes, n_cells, n_points_and_n_cells);
1011 template <
typename FlagsType>
1018 StreamBase(std::ostream &stream,
const FlagsType &flags)
1019 : selected_component(
numbers::invalid_unsigned_int)
1030 write_point(
const unsigned int,
const Point<dim> &)
1033 ExcMessage(
"The derived class you are using needs to "
1034 "reimplement this function if you want to call "
1054 write_cell(
const unsigned int ,
1055 const unsigned int ,
1056 std::array<unsigned int, dim> & )
1059 ExcMessage(
"The derived class you are using needs to "
1060 "reimplement this function if you want to call "
1071 write_cell_single(
const unsigned int index,
1072 const unsigned int start,
1073 const unsigned int n_points,
1079 (void)reference_cell;
1082 ExcMessage(
"The derived class you are using needs to "
1083 "reimplement this function if you want to call "
1101 template <
typename T>
1115 unsigned int selected_component;
1122 std::ostream &stream;
1127 const FlagsType flags;
1133 class DXStream :
public StreamBase<DataOutBase::DXFlags>
1140 write_point(
const unsigned int index,
const Point<dim> &);
1152 write_cell(
const unsigned int index,
1153 const unsigned int start,
1154 const std::array<unsigned int, dim> &offsets);
1162 template <
typename data>
1164 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1170 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
1177 write_point(
const unsigned int index,
const Point<dim> &);
1189 write_cell(
const unsigned int index,
1190 const unsigned int start,
1191 const std::array<unsigned int, dim> &offsets);
1197 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
1204 write_point(
const unsigned int index,
const Point<dim> &);
1216 write_cell(
const unsigned int index,
1217 const unsigned int start,
1218 const std::array<unsigned int, dim> &offsets);
1224 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1231 write_point(
const unsigned int index,
const Point<dim> &);
1245 write_cell(
const unsigned int index,
1246 const unsigned int start,
1247 const std::array<unsigned int, dim> &offsets);
1255 template <
typename data>
1257 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1263 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1270 write_point(
const unsigned int index,
const Point<dim> &);
1282 write_cell(
const unsigned int index,
1283 const unsigned int start,
1284 const std::array<unsigned int, dim> &offsets);
1290 write_cell_single(
const unsigned int index,
1291 const unsigned int start,
1292 const unsigned int n_points,
1304 write_high_order_cell(
const unsigned int start,
1305 const std::vector<unsigned> &connectivity);
1318 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1320 if (flags.coordinates_binary)
1323 for (
unsigned int d = 0;
d < dim; ++
d)
1325 stream.write(
reinterpret_cast<const char *
>(
data), dim *
sizeof(*
data));
1329 for (
unsigned int d = 0;
d < dim; ++
d)
1330 stream << p[d] <<
'\t';
1344 std::array<unsigned int, GeometryInfo<0>::vertices_per_cell>
1345 set_node_numbers(
const unsigned int ,
1346 const std::array<unsigned int, 0> & )
1354 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
1355 set_node_numbers(
const unsigned int start,
1356 const std::array<unsigned int, 1> &offsets)
1358 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
1360 nodes[1] = start + offsets[0];
1366 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
1367 set_node_numbers(
const unsigned int start,
1368 const std::array<unsigned int, 2> &offsets)
1371 const unsigned int d1 = offsets[0];
1372 const unsigned int d2 = offsets[1];
1374 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
1376 nodes[1] = start + d1;
1377 nodes[2] = start + d2;
1378 nodes[3] = start + d2 + d1;
1384 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
1385 set_node_numbers(
const unsigned int start,
1386 const std::array<unsigned int, 3> &offsets)
1388 const unsigned int d1 = offsets[0];
1389 const unsigned int d2 = offsets[1];
1390 const unsigned int d3 = offsets[2];
1392 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
1394 nodes[1] = start + d1;
1395 nodes[2] = start + d2;
1396 nodes[3] = start + d2 + d1;
1397 nodes[4] = start + d3;
1398 nodes[5] = start + d3 + d1;
1399 nodes[6] = start + d3 + d2;
1400 nodes[7] = start + d3 + d2 + d1;
1409 DXStream::write_cell(
const unsigned int,
1410 const unsigned int start,
1411 const std::array<unsigned int, dim> &offsets)
1414 DataOutBaseImplementation::set_node_numbers(start, offsets);
1416 if (flags.int_binary)
1418 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell> temp;
1419 for (
unsigned int i = 0; i < nodes.size(); ++i)
1421 stream.write(
reinterpret_cast<const char *
>(temp.data()),
1422 temp.size() *
sizeof(temp[0]));
1426 for (
unsigned int i = 0; i < nodes.size() - 1; ++i)
1428 stream << nodes[GeometryInfo<dim>::dx_to_deal[nodes.size() - 1]]
1435 template <
typename data>
1437 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &values)
1439 if (flags.data_binary)
1441 stream.write(
reinterpret_cast<const char *
>(
values.data()),
1446 for (
unsigned int i = 0; i <
values.size(); ++i)
1447 stream <<
'\t' << values[i];
1463 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1467 stream << p[selected_component] <<
' ';
1474 GmvStream::write_cell(
const unsigned int,
1475 const unsigned int s,
1476 const std::array<unsigned int, dim> &offsets)
1479 const unsigned int start = s + 1;
1480 stream << gmv_cell_type[dim] <<
'\n';
1492 const unsigned int d1 = offsets[0];
1494 stream <<
'\t' << start + d1;
1500 const unsigned int d1 = offsets[0];
1501 const unsigned int d2 = offsets[1];
1503 stream <<
'\t' << start + d1;
1504 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1510 const unsigned int d1 = offsets[0];
1511 const unsigned int d2 = offsets[1];
1512 const unsigned int d3 = offsets[2];
1514 stream <<
'\t' << start + d1;
1515 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1516 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1517 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1529 TecplotStream::TecplotStream(std::ostream &out,
1537 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1541 stream << p[selected_component] <<
'\n';
1548 TecplotStream::write_cell(
const unsigned int,
1549 const unsigned int s,
1550 const std::array<unsigned int, dim> &offsets)
1552 const unsigned int start = s + 1;
1564 const unsigned int d1 = offsets[0];
1566 stream <<
'\t' << start + d1;
1572 const unsigned int d1 = offsets[0];
1573 const unsigned int d2 = offsets[1];
1575 stream <<
'\t' << start + d1;
1576 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1582 const unsigned int d1 = offsets[0];
1583 const unsigned int d2 = offsets[1];
1584 const unsigned int d3 = offsets[2];
1586 stream <<
'\t' << start + d1;
1587 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1588 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1589 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1608 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1610 stream <<
index + 1 <<
" ";
1612 for (
unsigned int i = 0; i < dim; ++i)
1613 stream << p[i] <<
' ';
1615 for (
unsigned int i = dim; i < 3; ++i)
1624 UcdStream::write_cell(
const unsigned int index,
1625 const unsigned int start,
1626 const std::array<unsigned int, dim> &offsets)
1629 DataOutBaseImplementation::set_node_numbers(start, offsets);
1632 stream <<
index + 1 <<
"\t0 " << ucd_cell_type[dim];
1633 for (
unsigned int i = 0; i < nodes.size(); ++i)
1640 template <
typename data>
1642 UcdStream::write_dataset(
const unsigned int index,
1643 const std::vector<data> &values)
1645 stream <<
index + 1;
1646 for (
unsigned int i = 0; i <
values.size(); ++i)
1647 stream <<
'\t' << values[i];
1662 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1667 for (
unsigned int i = dim; i < 3; ++i)
1676 VtkStream::write_cell(
const unsigned int,
1677 const unsigned int start,
1678 const std::array<unsigned int, dim> &offsets)
1680 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t';
1692 const unsigned int d1 = offsets[0];
1694 stream <<
'\t' << start + d1;
1700 const unsigned int d1 = offsets[0];
1701 const unsigned int d2 = offsets[1];
1703 stream <<
'\t' << start + d1;
1704 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1710 const unsigned int d1 = offsets[0];
1711 const unsigned int d2 = offsets[1];
1712 const unsigned int d3 = offsets[2];
1714 stream <<
'\t' << start + d1;
1715 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1716 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1717 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1730 VtkStream::write_cell_single(
const unsigned int index,
1731 const unsigned int start,
1732 const unsigned int n_points,
1737 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1739 stream <<
'\t' << n_points;
1740 for (
unsigned int i = 0; i < n_points; ++i)
1749 VtkStream::write_high_order_cell(
const unsigned int start,
1750 const std::vector<unsigned> &connectivity)
1752 stream << connectivity.size();
1753 for (
const auto &c : connectivity)
1754 stream <<
'\t' << start + c;
1766 template <
int dim,
int spacedim>
1770 template <
int dim,
int spacedim>
1774 template <
int dim,
int spacedim>
1776 : patch_index(no_neighbor)
1778 , points_are_available(false)
1792 template <
int dim,
int spacedim>
1800 const double epsilon = 3e-16;
1802 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1818 if (
data.n_rows() != patch.
data.n_rows())
1821 if (
data.n_cols() != patch.
data.n_cols())
1824 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1825 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1826 if (
data[i][j] != patch.
data[i][j])
1834 template <
int dim,
int spacedim>
1838 return (
sizeof(vertices) /
sizeof(vertices[0]) *
1840 sizeof(neighbors) /
sizeof(neighbors[0]) *
1846 sizeof(reference_cell));
1851 template <
int dim,
int spacedim>
1855 std::swap(vertices, other_patch.vertices);
1856 std::swap(neighbors, other_patch.neighbors);
1857 std::swap(patch_index, other_patch.patch_index);
1858 std::swap(n_subdivisions, other_patch.n_subdivisions);
1859 data.swap(other_patch.data);
1860 std::swap(points_are_available, other_patch.points_are_available);
1861 std::swap(reference_cell, other_patch.reference_cell);
1866 template <
int spacedim>
1870 template <
int spacedim>
1874 template <
int spacedim>
1878 template <
int spacedim>
1881 template <
int spacedim>
1885 template <
int spacedim>
1887 : patch_index(no_neighbor)
1888 , points_are_available(false)
1895 template <
int spacedim>
1899 const unsigned int dim = 0;
1902 const double epsilon = 3e-16;
1904 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1913 if (
data.n_rows() != patch.
data.n_rows())
1916 if (
data.n_cols() != patch.
data.n_cols())
1919 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1920 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1921 if (
data[i][j] != patch.
data[i][j])
1929 template <
int spacedim>
1933 return (
sizeof(vertices) /
sizeof(vertices[0]) *
1941 template <
int spacedim>
1945 std::swap(vertices, other_patch.vertices);
1946 std::swap(patch_index, other_patch.patch_index);
1947 data.swap(other_patch.data);
1948 std::swap(points_are_available, other_patch.points_are_available);
1954 : write_preamble(write_preamble)
1969 : space_dimension_labels(labels)
1983 const bool bicubic_patch,
1984 const bool external_data)
1986 , bicubic_patch(bicubic_patch)
1987 , external_data(external_data)
1992 const bool xdmf_hdf5_output)
1993 : filter_duplicate_vertices(filter_duplicate_vertices)
1994 , xdmf_hdf5_output(xdmf_hdf5_output)
2002 "Filter duplicate vertices",
2005 "Whether to remove duplicate vertex values. deal.II duplicates "
2006 "vertices once for each adjacent cell so that it can output "
2007 "discontinuous quantities for which there may be more than one "
2008 "value for each vertex position. Setting this flag to "
2009 "'true' will merge all of these values by selecting a "
2010 "random one and outputting this as 'the' value for the vertex. "
2011 "As long as the data to be output corresponds to continuous "
2012 "fields, merging vertices has no effect. On the other hand, "
2013 "if the data to be output corresponds to discontinuous fields "
2014 "(either because you are using a discontinuous finite element, "
2015 "or because you are using a DataPostprocessor that yields "
2016 "discontinuous data, or because the data to be output has been "
2017 "produced by entirely different means), then the data in the "
2018 "output file no longer faithfully represents the underlying data "
2019 "because the discontinuous field has been replaced by a "
2020 "continuous one. Note also that the filtering can not occur "
2021 "on processor boundaries. Thus, a filtered discontinuous field "
2022 "looks like a continuous field inside of a subdomain, "
2023 "but like a discontinuous field at the subdomain boundary."
2025 "In any case, filtering results in drastically smaller output "
2026 "files (smaller by about a factor of 2^dim).");
2031 "Whether the data will be used in an XDMF/HDF5 combination.");
2046 const bool int_binary,
2047 const bool coordinates_binary,
2048 const bool data_binary)
2049 : write_neighbors(write_neighbors)
2050 , int_binary(int_binary)
2051 , coordinates_binary(coordinates_binary)
2052 , data_binary(data_binary)
2053 , data_double(false)
2063 "A boolean field indicating whether neighborship "
2064 "information between cells is to be written to the "
2065 "OpenDX output file");
2069 "Output format of integer numbers, which is "
2070 "either a text representation (ascii) or binary integer "
2071 "values of 32 or 64 bits length");
2075 "Output format of vertex coordinates, which is "
2076 "either a text representation (ascii) or binary "
2077 "floating point values of 32 or 64 bits length");
2081 "Output format of data values, which is "
2082 "either a text representation (ascii) or binary "
2083 "floating point values of 32 or 64 bits length");
2103 "A flag indicating whether a comment should be "
2104 "written to the beginning of the output file "
2105 "indicating date and time of creation as well "
2106 "as the creating program");
2120 const int azimuth_angle,
2121 const int polar_angle,
2122 const unsigned int line_thickness,
2124 const bool draw_colorbar)
2127 , height_vector(height_vector)
2128 , azimuth_angle(azimuth_angle)
2129 , polar_angle(polar_angle)
2130 , line_thickness(line_thickness)
2132 , draw_colorbar(draw_colorbar)
2143 "A flag indicating whether POVRAY should use smoothed "
2144 "triangles instead of the usual ones");
2148 "Whether POVRAY should use bicubic patches");
2152 "Whether camera and lighting information should "
2153 "be put into an external file \"data.inc\" or into "
2154 "the POVRAY input file");
2170 const unsigned int color_vector,
2172 const unsigned int size,
2173 const double line_width,
2174 const double azimut_angle,
2175 const double turn_angle,
2176 const double z_scaling,
2177 const bool draw_mesh,
2178 const bool draw_cells,
2179 const bool shade_cells,
2181 : height_vector(height_vector)
2182 , color_vector(color_vector)
2183 , size_type(size_type)
2185 , line_width(line_width)
2186 , azimut_angle(azimut_angle)
2187 , turn_angle(turn_angle)
2188 , z_scaling(z_scaling)
2189 , draw_mesh(draw_mesh)
2190 , draw_cells(draw_cells)
2191 , shade_cells(shade_cells)
2192 , color_function(color_function)
2231 double sum = xmax + xmin;
2232 double sum13 = xmin + 3 * xmax;
2233 double sum22 = 2 * xmin + 2 * xmax;
2234 double sum31 = 3 * xmin + xmax;
2235 double dif = xmax - xmin;
2236 double rezdif = 1.0 / dif;
2240 if (x < (sum31) / 4)
2242 else if (x < (sum22) / 4)
2244 else if (x < (sum13) / 4)
2255 rgb_values.
green = 0;
2256 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2260 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2261 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2264 rgb_values.
red = (4 * x - 2 * sum) * rezdif;
2265 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2266 rgb_values.
blue = 0;
2270 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2271 rgb_values.
blue = (4. * x - sum13) * rezdif;
2278 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2292 (x - xmin) / (xmax - xmin);
2305 1 - (x - xmin) / (xmax - xmin);
2317 "Number of the input vector that is to be used to "
2318 "generate height information");
2322 "Number of the input vector that is to be used to "
2323 "generate color information");
2327 "Whether width or height should be scaled to match "
2332 "The size (width or height) to which the eps output "
2333 "file is to be scaled");
2337 "The width in which the postscript renderer is to "
2342 "Angle of the viewing position against the vertical "
2347 "Angle of the viewing direction against the y-axis");
2351 "Scaling for the z-direction relative to the scaling "
2352 "used in x- and y-directions");
2356 "Whether the mesh lines, or only the surface should be "
2361 "Whether only the mesh lines, or also the interior of "
2362 "cells should be plotted. If this flag is false, then "
2363 "one can see through the mesh");
2367 "Whether the interior of cells shall be shaded");
2371 "default|grey scale|reverse grey scale"),
2372 "Name of a color function used to colorize mesh lines "
2373 "and/or cell interiors");
2383 if (prm.
get(
"Scale to width or height") ==
"width")
2395 if (prm.
get(
"Color function") ==
"default")
2397 else if (prm.
get(
"Color function") ==
"grey scale")
2399 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2409 : compression_level(compression_level)
2414 : zone_name(zone_name)
2415 , solution_time(solution_time)
2429 const unsigned int cycle,
2430 const bool print_date_and_time,
2432 const bool write_higher_order_cells,
2433 const std::map<std::string, std::string> &physical_units)
2436 , print_date_and_time(print_date_and_time)
2437 , compression_level(compression_level)
2438 , write_higher_order_cells(write_higher_order_cells)
2439 , physical_units(physical_units)
2447 if (format_name ==
"none")
2450 if (format_name ==
"dx")
2453 if (format_name ==
"ucd")
2456 if (format_name ==
"gnuplot")
2459 if (format_name ==
"povray")
2462 if (format_name ==
"eps")
2465 if (format_name ==
"gmv")
2468 if (format_name ==
"tecplot")
2471 if (format_name ==
"vtk")
2474 if (format_name ==
"vtu")
2477 if (format_name ==
"deal.II intermediate")
2480 if (format_name ==
"hdf5")
2484 ExcMessage(
"The given file format name is not recognized: <" +
2485 format_name +
">"));
2496 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|vtk|vtu|hdf5|svg|deal.II intermediate";
2504 switch (output_format)
2546 template <
int dim,
int spacedim>
2547 std::vector<Point<spacedim>>
2551 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
2553 std::vector<Point<spacedim>> node_positions;
2554 for (
const auto &patch : patches)
2557 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2559 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2561 node_positions.emplace_back(get_node_location(
2570 const unsigned int n = n_subdivisions + 1;
2575 node_positions.emplace_back(
2576 get_equispaced_location(patch, {}, n_subdivisions));
2579 for (
unsigned int i1 = 0; i1 < n; ++i1)
2580 node_positions.emplace_back(
2581 get_equispaced_location(patch, {i1}, n_subdivisions));
2584 for (
unsigned int i2 = 0; i2 < n; ++i2)
2585 for (
unsigned int i1 = 0; i1 < n; ++i1)
2586 node_positions.emplace_back(get_equispaced_location(
2587 patch, {i1, i2}, n_subdivisions));
2590 for (
unsigned int i3 = 0; i3 < n; ++i3)
2591 for (
unsigned int i2 = 0; i2 < n; ++i2)
2592 for (
unsigned int i1 = 0; i1 < n; ++i1)
2593 node_positions.emplace_back(get_equispaced_location(
2594 patch, {i1, i2, i3}, n_subdivisions));
2603 return node_positions;
2607 template <
int dim,
int spacedim,
typename StreamType>
2613 const std::vector<Point<spacedim>> node_positions =
2617 for (
const auto &node : node_positions)
2618 out.write_point(count++, node);
2624 template <
int dim,
int spacedim,
typename StreamType>
2629 unsigned int count = 0;
2630 unsigned int first_vertex_of_patch = 0;
2631 for (
const auto &patch : patches)
2634 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2636 out.write_cell_single(count++,
2637 first_vertex_of_patch,
2638 patch.
data.n_cols(),
2640 first_vertex_of_patch += patch.
data.n_cols();
2645 const unsigned int n = n_subdivisions + 1;
2651 const unsigned int offset = first_vertex_of_patch;
2652 out.template write_cell<0>(count++, offset, {});
2658 constexpr unsigned int d1 = 1;
2660 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
2662 const unsigned int offset =
2663 first_vertex_of_patch + i1 * d1;
2664 out.template write_cell<1>(count++, offset, {{d1}});
2672 constexpr unsigned int d1 = 1;
2673 const unsigned int d2 = n;
2675 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
2676 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
2678 const unsigned int offset =
2679 first_vertex_of_patch + i2 * d2 + i1 * d1;
2680 out.template write_cell<2>(count++,
2690 constexpr unsigned int d1 = 1;
2691 const unsigned int d2 = n;
2692 const unsigned int d3 = n * n;
2694 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
2695 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
2696 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
2698 const unsigned int offset = first_vertex_of_patch +
2701 out.template write_cell<3>(count++,
2713 first_vertex_of_patch +=
2714 Utilities::fixed_power<dim>(n_subdivisions + 1);
2723 template <
int dim,
int spacedim,
typename StreamType>
2727 const bool legacy_format)
2730 unsigned int first_vertex_of_patch = 0;
2732 std::vector<unsigned> connectivity;
2734 for (
const auto &patch : patches)
2736 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2738 connectivity.resize(patch.
data.n_cols());
2740 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2741 connectivity[i] = i;
2743 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2746 first_vertex_of_patch += patch.
data.n_cols();
2751 const unsigned int n = n_subdivisions + 1;
2753 connectivity.resize(Utilities::fixed_power<dim>(n));
2760 ExcMessage(
"Point-like cells should not be possible "
2761 "when writing higher-order cells."));
2766 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
2768 const unsigned int local_index = i1;
2769 const unsigned int connectivity_index =
2771 .template vtk_lexicographic_to_node_index<1>(
2772 {{i1}}, {{n_subdivisions}}, legacy_format);
2773 connectivity[connectivity_index] = local_index;
2780 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1; ++i2)
2781 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
2783 const unsigned int local_index = i2 * n + i1;
2784 const unsigned int connectivity_index =
2786 .template vtk_lexicographic_to_node_index<2>(
2788 {{n_subdivisions, n_subdivisions}},
2790 connectivity[connectivity_index] = local_index;
2797 for (
unsigned int i3 = 0; i3 < n_subdivisions + 1; ++i3)
2798 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1; ++i2)
2799 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
2801 const unsigned int local_index =
2802 i3 * n * n + i2 * n + i1;
2803 const unsigned int connectivity_index =
2805 .template vtk_lexicographic_to_node_index<3>(
2811 connectivity[connectivity_index] = local_index;
2822 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2826 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
2834 template <
int dim,
int spacedim,
typename StreamType>
2837 unsigned int n_data_sets,
2838 const bool double_precision,
2842 unsigned int count = 0;
2844 for (
const auto &patch : patches)
2847 const unsigned int n = n_subdivisions + 1;
2849 Assert((patch.
data.n_rows() == n_data_sets &&
2851 (patch.
data.n_rows() == n_data_sets + spacedim &&
2854 (n_data_sets + spacedim) :
2857 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
2860 std::vector<float> floats(n_data_sets);
2861 std::vector<double> doubles(n_data_sets);
2864 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2866 if (double_precision)
2868 for (
unsigned int data_set = 0; data_set < n_data_sets;
2870 doubles[data_set] = patch.
data(data_set, i);
2871 out.write_dataset(count, doubles);
2875 for (
unsigned int data_set = 0; data_set < n_data_sets;
2877 floats[data_set] = patch.
data(data_set, i);
2878 out.write_dataset(count, floats);
2903 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
2904 camera_horizontal[2] * camera_direction[1];
2905 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
2906 camera_horizontal[0] * camera_direction[2];
2907 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
2908 camera_horizontal[1] * camera_direction[0];
2912 phi /= (
point[0] - camera_position[0]) * camera_direction[0] +
2913 (
point[1] - camera_position[1]) * camera_direction[1] +
2914 (
point[2] - camera_position[2]) * camera_direction[2];
2918 camera_position[0] + phi * (point[0] - camera_position[0]);
2920 camera_position[1] + phi * (point[1] - camera_position[1]);
2922 camera_position[2] + phi * (point[2] - camera_position[2]);
2925 projection_decomposition[0] = (projection[0] - camera_position[0] -
2926 camera_focus * camera_direction[0]) *
2927 camera_horizontal[0];
2928 projection_decomposition[0] += (projection[1] - camera_position[1] -
2929 camera_focus * camera_direction[1]) *
2930 camera_horizontal[1];
2931 projection_decomposition[0] += (projection[2] - camera_position[2] -
2932 camera_focus * camera_direction[2]) *
2933 camera_horizontal[2];
2935 projection_decomposition[1] = (projection[0] - camera_position[0] -
2936 camera_focus * camera_direction[0]) *
2938 projection_decomposition[1] += (projection[1] - camera_position[1] -
2939 camera_focus * camera_direction[1]) *
2941 projection_decomposition[1] += (projection[2] - camera_position[2] -
2942 camera_focus * camera_direction[2]) *
2945 return projection_decomposition;
2954 svg_get_gradient_parameters(
Point<3> points[])
2960 for (
int i = 0; i < 2; ++i)
2962 for (
int j = 0; j < 2 - i; ++j)
2964 if (points[j][2] > points[j + 1][2])
2967 points[j] = points[j + 1];
2968 points[j + 1] = temp;
2975 v_inter = points[1];
2982 A[0][0] = v_max[0] - v_min[0];
2983 A[0][1] = v_inter[0] - v_min[0];
2984 A[1][0] = v_max[1] - v_min[1];
2985 A[1][1] = v_inter[1] - v_min[1];
2991 bool col_change =
false;
3000 double temp = A[1][0];
3005 for (
unsigned int k = 0; k < 1; ++k)
3007 for (
unsigned int i = k + 1; i < 2; ++i)
3009 x = A[i][k] / A[k][k];
3011 for (
unsigned int j = k + 1; j < 2; ++j)
3012 A[i][j] = A[i][j] - A[k][j] * x;
3014 b[i] = b[i] - b[k] * x;
3018 b[1] =
b[1] / A[1][1];
3020 for (
int i = 0; i >= 0; i--)
3024 for (
unsigned int j = i + 1; j < 2; ++j)
3025 sum = sum - A[i][j] * b[j];
3027 b[i] = sum / A[i][i];
3037 double c = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) +
3041 A[0][0] = v_max[0] - v_min[0];
3042 A[0][1] = v_inter[0] - v_min[0];
3043 A[1][0] = v_max[1] - v_min[1];
3044 A[1][1] = v_inter[1] - v_min[1];
3046 b[0] = 1.0 - v_min[0];
3058 double temp = A[1][0];
3063 for (
unsigned int k = 0; k < 1; ++k)
3065 for (
unsigned int i = k + 1; i < 2; ++i)
3067 x = A[i][k] / A[k][k];
3069 for (
unsigned int j = k + 1; j < 2; ++j)
3070 A[i][j] = A[i][j] - A[k][j] * x;
3072 b[i] = b[i] - b[k] * x;
3076 b[1] =
b[1] / A[1][1];
3078 for (
int i = 0; i >= 0; i--)
3082 for (
unsigned int j = i + 1; j < 2; ++j)
3083 sum = sum - A[i][j] * b[j];
3085 b[i] = sum / A[i][i];
3095 gradient[0] = b[0] * (v_max[2] - v_min[2]) +
3096 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3099 A[0][0] = v_max[0] - v_min[0];
3100 A[0][1] = v_inter[0] - v_min[0];
3101 A[1][0] = v_max[1] - v_min[1];
3102 A[1][1] = v_inter[1] - v_min[1];
3105 b[1] = 1.0 - v_min[1];
3116 double temp = A[1][0];
3121 for (
unsigned int k = 0; k < 1; ++k)
3123 for (
unsigned int i = k + 1; i < 2; ++i)
3125 x = A[i][k] / A[k][k];
3127 for (
unsigned int j = k + 1; j < 2; ++j)
3128 A[i][j] = A[i][j] - A[k][j] * x;
3130 b[i] =
b[i] -
b[k] * x;
3134 b[1] =
b[1] / A[1][1];
3136 for (
int i = 0; i >= 0; i--)
3140 for (
unsigned int j = i + 1; j < 2; ++j)
3141 sum = sum - A[i][j] * b[j];
3143 b[i] =
sum / A[i][i];
3153 gradient[1] =
b[0] * (v_max[2] - v_min[2]) +
3154 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3160 gradient[1] * (v_min[1] - v_max[1]);
3164 gradient_parameters[0] = v_min[0];
3165 gradient_parameters[1] = v_min[1];
3170 gradient_parameters[4] = v_min[2];
3171 gradient_parameters[5] = v_max[2];
3173 return gradient_parameters;
3179 template <
int dim,
int spacedim>
3183 const std::vector<std::string> &data_names,
3185 std::tuple<
unsigned int,
3198#ifndef DEAL_II_WITH_MPI
3207 if (patches.empty())
3211 const unsigned int n_data_sets = data_names.size();
3213 UcdStream ucd_out(out, flags);
3216 unsigned int n_nodes;
3217 unsigned int n_cells;
3218 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
3224 <<
"# This file was generated by the deal.II library." <<
'\n'
3228 <<
"# For a description of the UCD format see the AVS Developer's guide."
3234 out << n_nodes <<
' ' << n_cells <<
' ' << n_data_sets <<
' ' << 0
3247 if (n_data_sets != 0)
3249 out << n_data_sets <<
" ";
3250 for (
unsigned int i = 0; i < n_data_sets; ++i)
3255 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3256 out << data_names[data_set]
3260 write_data(patches, n_data_sets,
true, ucd_out);
3270 template <
int dim,
int spacedim>
3274 const std::vector<std::string> &data_names,
3276 std::tuple<
unsigned int,
3288#ifndef DEAL_II_WITH_MPI
3297 if (patches.empty())
3301 DXStream dx_out(out, flags);
3304 unsigned int offset = 0;
3306 const unsigned int n_data_sets = data_names.size();
3309 unsigned int n_nodes;
3310 unsigned int n_cells;
3311 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
3314 out <<
"object \"vertices\" class array type float rank 1 shape "
3315 << spacedim <<
" items " << n_nodes;
3319 out <<
" lsb ieee data 0" <<
'\n';
3320 offset += n_nodes * spacedim *
sizeof(float);
3324 out <<
" data follows" <<
'\n';
3333 out <<
"object \"cells\" class array type int rank 1 shape "
3338 out <<
" lsb binary data " << offset <<
'\n';
3339 offset += n_cells *
sizeof(
int);
3343 out <<
" data follows" <<
'\n';
3349 out <<
"attribute \"element type\" string \"";
3356 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3363 out <<
"object \"neighbors\" class array type int rank 1 shape "
3367 for (
const auto &patch : patches)
3370 const unsigned int n1 = (dim > 0) ? n : 1;
3371 const unsigned int n2 = (dim > 1) ? n : 1;
3372 const unsigned int n3 = (dim > 2) ? n : 1;
3373 const unsigned int x_minus = (dim > 0) ? 0 : 0;
3374 const unsigned int x_plus = (dim > 0) ? 1 : 0;
3375 const unsigned int y_minus = (dim > 1) ? 2 : 0;
3376 const unsigned int y_plus = (dim > 1) ? 3 : 0;
3377 const unsigned int z_minus = (dim > 2) ? 4 : 0;
3378 const unsigned int z_plus = (dim > 2) ? 5 : 0;
3379 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3380 unsigned int dx = 1;
3381 unsigned int dy = n;
3382 unsigned int dz = n * n;
3384 const unsigned int patch_start =
3387 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3388 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3389 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3391 const unsigned int nx = i1 *
dx;
3392 const unsigned int ny = i2 * dy;
3393 const unsigned int nz = i3 * dz;
3405 const unsigned int nn = patch.
neighbors[x_minus];
3409 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3415 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3420 const unsigned int nn = patch.
neighbors[x_plus];
3423 out << (nn * cells_per_patch + ny + nz);
3429 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3436 const unsigned int nn = patch.
neighbors[y_minus];
3440 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3446 out <<
'\t' << patch_start + nx + ny - dy + nz;
3451 const unsigned int nn = patch.
neighbors[y_plus];
3454 out << (nn * cells_per_patch + nx + nz);
3460 out <<
'\t' << patch_start + nx + ny + dy + nz;
3468 const unsigned int nn = patch.
neighbors[z_minus];
3472 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3478 out <<
'\t' << patch_start + nx + ny + nz - dz;
3483 const unsigned int nn = patch.
neighbors[z_plus];
3486 out << (nn * cells_per_patch + nx + ny);
3492 out <<
'\t' << patch_start + nx + ny + nz + dz;
3500 if (n_data_sets != 0)
3502 out <<
"object \"data\" class array type float rank 1 shape "
3503 << n_data_sets <<
" items " << n_nodes;
3507 out <<
" lsb ieee data " << offset <<
'\n';
3508 offset += n_data_sets * n_nodes *
3509 ((flags.
data_double) ?
sizeof(
double) :
sizeof(float));
3513 out <<
" data follows" <<
'\n';
3518 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3522 out <<
"object \"data\" class constantarray type float rank 0 items "
3523 << n_nodes <<
" data follows" <<
'\n'
3529 out <<
"object \"deal data\" class field" <<
'\n'
3530 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3531 <<
"component \"connections\" value \"cells\"" <<
'\n'
3532 <<
"component \"data\" value \"data\"" <<
'\n';
3535 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3542 out <<
"end" <<
'\n';
3560 template <
int dim,
int spacedim>
3564 const std::vector<std::string> &data_names,
3566 std::tuple<
unsigned int,
3575#ifndef DEAL_II_WITH_MPI
3585 if (patches.empty())
3589 const unsigned int n_data_sets = data_names.size();
3593 out <<
"# This file was generated by the deal.II library." <<
'\n'
3597 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3604 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3609 for (
const auto &data_name : data_names)
3610 out <<
'<' << data_name <<
"> ";
3616 for (
const auto &patch : patches)
3619 const unsigned int n_points_per_direction = n_subdivisions + 1;
3621 Assert((patch.
data.n_rows() == n_data_sets &&
3623 (patch.
data.n_rows() == n_data_sets + spacedim &&
3626 (n_data_sets + spacedim) :
3628 patch.
data.n_rows()));
3630 auto output_point_data =
3631 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3632 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3633 out << patch.data(data_set, point_index) <<
' ';
3642 Assert(patch.data.n_cols() == 1,
3644 n_subdivisions + 1));
3648 out << get_equispaced_location(patch, {}, n_subdivisions)
3650 output_point_data(0);
3660 Assert(patch.data.n_cols() ==
3661 Utilities::fixed_power<dim>(n_points_per_direction),
3663 n_subdivisions + 1));
3665 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3668 out << get_equispaced_location(patch, {i1}, n_subdivisions)
3671 output_point_data(i1);
3684 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3685 n_points_per_direction),
3687 n_subdivisions + 1));
3689 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3691 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3695 out << get_equispaced_location(patch,
3700 output_point_data(i1 + i2 * n_points_per_direction);
3725 out << get_node_location(patch, 0) <<
' ';
3726 output_point_data(0);
3729 out << get_node_location(patch, 1) <<
' ';
3730 output_point_data(1);
3734 out << get_node_location(patch, 2) <<
' ';
3735 output_point_data(2);
3738 out << get_node_location(patch, 2) <<
' ';
3739 output_point_data(2);
3759 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3760 n_points_per_direction),
3762 n_subdivisions + 1));
3767 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3768 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3770 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3775 get_equispaced_location(patch,
3779 if (i1 < n_subdivisions)
3782 out << this_point <<
' ';
3783 output_point_data(i1 +
3784 i2 * n_points_per_direction +
3785 i3 * n_points_per_direction *
3786 n_points_per_direction);
3790 out << get_equispaced_location(patch,
3795 output_point_data((i1 + 1) +
3796 i2 * n_points_per_direction +
3797 i3 * n_points_per_direction *
3798 n_points_per_direction);
3802 out <<
'\n' <<
'\n';
3806 if (i2 < n_subdivisions)
3809 out << this_point <<
' ';
3810 output_point_data(i1 +
3811 i2 * n_points_per_direction +
3812 i3 * n_points_per_direction *
3813 n_points_per_direction);
3817 out << get_equispaced_location(patch,
3823 i1 + (i2 + 1) * n_points_per_direction +
3824 i3 * n_points_per_direction *
3825 n_points_per_direction);
3829 out <<
'\n' <<
'\n';
3833 if (i3 < n_subdivisions)
3836 out << this_point <<
' ';
3837 output_point_data(i1 +
3838 i2 * n_points_per_direction +
3839 i3 * n_points_per_direction *
3840 n_points_per_direction);
3844 out << get_equispaced_location(patch,
3850 i1 + i2 * n_points_per_direction +
3851 (i3 + 1) * n_points_per_direction *
3852 n_points_per_direction);
3855 out <<
'\n' <<
'\n';
3864 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3866 out << get_node_location(patch, v) <<
' ';
3867 output_point_data(v);
3872 for (
const unsigned int v : {3, 1})
3874 out << get_node_location(patch, v) <<
' ';
3875 output_point_data(v);
3885 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
3887 out << get_node_location(patch, v) <<
' ';
3888 output_point_data(v);
3893 for (
const unsigned int v : {2, 4, 3})
3895 out << get_node_location(patch, v) <<
' ';
3896 output_point_data(v);
3910 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
3912 out << get_node_location(patch, v) <<
' ';
3913 output_point_data(v);
3918 for (
const unsigned int v : {1, 4})
3920 out << get_node_location(patch, v) <<
' ';
3921 output_point_data(v);
3926 for (
const unsigned int v : {2, 5})
3928 out << get_node_location(patch, v) <<
' ';
3929 output_point_data(v);
3954 template <
int dim,
int spacedim>
3956 do_write_povray(
const std::vector<Patch<dim, spacedim>> &,
3957 const std::vector<std::string> &,
3958 const PovrayFlags &,
3962 ExcMessage(
"Writing files in POVRAY format is only supported "
3963 "for two-dimensional meshes."));
3969 do_write_povray(
const std::vector<Patch<2, 2>> &patches,
3970 const std::vector<std::string> &data_names,
3971 const PovrayFlags &flags,
3976#ifndef DEAL_II_WITH_MPI
3985 if (patches.empty())
3988 constexpr int dim = 2;
3990 constexpr int spacedim = 2;
3992 const unsigned int n_data_sets = data_names.size();
3998 <<
"/* This file was generated by the deal.II library." <<
'\n'
4002 <<
" For a description of the POVRAY format see the POVRAY manual."
4007 out <<
"#include \"colors.inc\" " <<
'\n'
4008 <<
"#include \"textures.inc\" " <<
'\n';
4012 if (flags.external_data)
4013 out <<
"#include \"data.inc\" " <<
'\n';
4019 <<
"camera {" <<
'\n'
4020 <<
" location <1,4,-7>" <<
'\n'
4021 <<
" look_at <0,0,0>" <<
'\n'
4022 <<
" angle 30" <<
'\n'
4027 <<
"light_source {" <<
'\n'
4028 <<
" <1,4,-7>" <<
'\n'
4029 <<
" color Grey" <<
'\n'
4032 <<
"light_source {" <<
'\n'
4033 <<
" <0,20,0>" <<
'\n'
4034 <<
" color White" <<
'\n'
4041 double hmin = patches[0].data(0, 0);
4042 double hmax = patches[0].data(0, 0);
4044 for (
const auto &patch : patches)
4048 Assert((patch.
data.n_rows() == n_data_sets &&
4050 (patch.
data.n_rows() == n_data_sets + spacedim &&
4053 (n_data_sets + spacedim) :
4055 patch.
data.n_rows()));
4057 Utilities::fixed_power<dim>(n_subdivisions + 1),
4059 n_subdivisions + 1));
4061 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4062 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4064 const int dl = i * (n_subdivisions + 1) + j;
4065 if (patch.
data(0, dl) < hmin)
4066 hmin = patch.
data(0, dl);
4067 if (patch.
data(0, dl) > hmax)
4068 hmax = patch.
data(0, dl);
4072 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
4073 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
4076 if (!flags.external_data)
4079 out <<
"#declare Tex=texture{" <<
'\n'
4080 <<
" pigment {" <<
'\n'
4081 <<
" gradient y" <<
'\n'
4082 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
4083 <<
" color_map {" <<
'\n'
4084 <<
" [0.00 color Light_Purple] " <<
'\n'
4085 <<
" [0.95 color Light_Purple] " <<
'\n'
4086 <<
" [1.00 color White] " <<
'\n'
4091 if (!flags.bicubic_patch)
4094 out <<
'\n' <<
"mesh {" <<
'\n';
4098 for (
const auto &patch : patches)
4101 const unsigned int n = n_subdivisions + 1;
4102 const unsigned int d1 = 1;
4103 const unsigned int d2 = n;
4105 Assert((patch.
data.n_rows() == n_data_sets &&
4107 (patch.
data.n_rows() == n_data_sets + spacedim &&
4110 (n_data_sets + spacedim) :
4112 patch.
data.n_rows()));
4113 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
4115 n_subdivisions + 1));
4118 std::vector<Point<spacedim>> ver(n * n);
4120 for (
unsigned int i2 = 0; i2 < n; ++i2)
4121 for (
unsigned int i1 = 0; i1 < n; ++i1)
4124 ver[i1 * d1 + i2 * d2] =
4125 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4129 if (!flags.bicubic_patch)
4132 std::vector<Point<3>> nrml;
4142 for (
unsigned int i = 0; i < n; ++i)
4143 for (
unsigned int j = 0; j < n; ++j)
4145 const unsigned int il = (i == 0) ? i : (i - 1);
4146 const unsigned int ir =
4147 (i == n_subdivisions) ? i : (i + 1);
4148 const unsigned int jl = (j == 0) ? j : (j - 1);
4149 const unsigned int jr =
4150 (j == n_subdivisions) ? j : (j + 1);
4153 ver[ir * d1 + j * d2][0] - ver[il * d1 + j * d2][0];
4154 h1[1] = patch.
data(0, ir * d1 + j * d2) -
4155 patch.
data(0, il * d1 + j * d2);
4157 ver[ir * d1 + j * d2][1] - ver[il * d1 + j * d2][1];
4160 ver[i * d1 + jr * d2][0] - ver[i * d1 + jl * d2][0];
4161 h2[1] = patch.
data(0, i * d1 + jr * d2) -
4162 patch.
data(0, i * d1 + jl * d2);
4164 ver[i * d1 + jr * d2][1] - ver[i * d1 + jl * d2][1];
4166 nrml[i * d1 + j * d2][0] =
4167 h1[1] * h2[2] - h1[2] * h2[1];
4168 nrml[i * d1 + j * d2][1] =
4169 h1[2] * h2[0] - h1[0] * h2[2];
4170 nrml[i * d1 + j * d2][2] =
4171 h1[0] * h2[1] - h1[1] * h2[0];
4174 double norm = std::hypot(nrml[i * d1 + j * d2][0],
4175 nrml[i * d1 + j * d2][1],
4176 nrml[i * d1 + j * d2][2]);
4178 if (nrml[i * d1 + j * d2][1] < 0)
4181 for (
unsigned int k = 0; k < 3; ++k)
4182 nrml[i * d1 + j * d2][k] /= norm;
4187 for (
unsigned int i = 0; i < n_subdivisions; ++i)
4188 for (
unsigned int j = 0; j < n_subdivisions; ++j)
4191 const int dl = i * d1 + j * d2;
4197 out <<
"smooth_triangle {" <<
'\n'
4198 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4199 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4200 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4202 out <<
" \t<" << ver[dl + d1][0] <<
","
4203 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4204 <<
">, <" << nrml[dl + d1][0] <<
", "
4205 << nrml[dl + d1][1] <<
", " << nrml[dl + d1][2]
4207 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4208 << patch.
data(0, dl + d1 + d2) <<
","
4209 << ver[dl + d1 + d2][1] <<
">, <"
4210 << nrml[dl + d1 + d2][0] <<
", "
4211 << nrml[dl + d1 + d2][1] <<
", "
4212 << nrml[dl + d1 + d2][2] <<
">}" <<
'\n';
4215 out <<
"smooth_triangle {" <<
'\n'
4216 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4217 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4218 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4220 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4221 << patch.
data(0, dl + d1 + d2) <<
","
4222 << ver[dl + d1 + d2][1] <<
">, <"
4223 << nrml[dl + d1 + d2][0] <<
", "
4224 << nrml[dl + d1 + d2][1] <<
", "
4225 << nrml[dl + d1 + d2][2] <<
">," <<
'\n';
4226 out <<
"\t<" << ver[dl + d2][0] <<
","
4227 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4228 <<
">, <" << nrml[dl + d2][0] <<
", "
4229 << nrml[dl + d2][1] <<
", " << nrml[dl + d2][2]
4235 out <<
"triangle {" <<
'\n'
4236 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4237 <<
"," << ver[dl][1] <<
">," <<
'\n';
4238 out <<
"\t<" << ver[dl + d1][0] <<
","
4239 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4241 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4242 << patch.
data(0, dl + d1 + d2) <<
","
4243 << ver[dl + d1 + d2][1] <<
">}" <<
'\n';
4246 out <<
"triangle {" <<
'\n'
4247 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4248 <<
"," << ver[dl][1] <<
">," <<
'\n';
4249 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4250 << patch.
data(0, dl + d1 + d2) <<
","
4251 << ver[dl + d1 + d2][1] <<
">," <<
'\n';
4252 out <<
"\t<" << ver[dl + d2][0] <<
","
4253 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4261 Assert(n_subdivisions == 3,
4264 <<
"bicubic_patch {" <<
'\n'
4265 <<
" type 0" <<
'\n'
4266 <<
" flatness 0" <<
'\n'
4267 <<
" u_steps 0" <<
'\n'
4268 <<
" v_steps 0" <<
'\n';
4269 for (
int i = 0; i < 16; ++i)
4271 out <<
"\t<" << ver[i][0] <<
"," << patch.
data(0, i) <<
","
4272 << ver[i][1] <<
">";
4277 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4281 if (!flags.bicubic_patch)
4284 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4296 template <
int dim,
int spacedim>
4300 const std::vector<std::string> &data_names,
4302 std::tuple<
unsigned int,
4309 do_write_povray(patches, data_names, flags, out);
4314 template <
int dim,
int spacedim>
4318 const std::vector<std::string> & ,
4320 std::tuple<
unsigned int,
4332 template <
int spacedim>
4336 const std::vector<std::string> & ,
4338 std::tuple<
unsigned int,
4347#ifndef DEAL_II_WITH_MPI
4356 if (patches.empty())
4366 std::multiset<EpsCell2d> cells;
4370 float min_color_value = std::numeric_limits<float>::max();
4371 float max_color_value = std::numeric_limits<float>::min();
4375 double heights[4] = {0, 0, 0, 0};
4379 for (
const auto &patch : patches)
4382 const unsigned int n = n_subdivisions + 1;
4383 const unsigned int d1 = 1;
4384 const unsigned int d2 = n;
4386 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4387 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4391 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4393 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
4395 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
4396 points[3] = get_equispaced_location(patch,
4404 patch.
data.n_rows() == 0,
4407 patch.
data.n_rows()));
4409 patch.
data.n_rows() != 0 ?
4413 heights[1] = patch.
data.n_rows() != 0 ?
4415 (i1 + 1) * d1 + i2 * d2) *
4418 heights[2] = patch.
data.n_rows() != 0 ?
4420 i1 * d1 + (i2 + 1) * d2) *
4423 heights[3] = patch.
data.n_rows() != 0 ?
4425 (i1 + 1) * d1 + (i2 + 1) * d2) *
4432 for (
unsigned int i = 0; i < 4; ++i)
4433 heights[i] = points[i][2];
4458 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4460 const double x = points[vertex][0], y = points[vertex][1],
4461 z = -heights[vertex];
4463 eps_cell.vertices[vertex][0] = -cz * x + sz * y;
4464 eps_cell.vertices[vertex][1] =
4465 -cx * sz * x - cx * cz * y - sx * z;
4489 (points[0] + points[1] + points[2] + points[3]) / 4;
4490 const double center_height =
4491 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4494 eps_cell.depth = -sx * sz * center_point[0] -
4495 sx * cz * center_point[1] + cx * center_height;
4500 patch.
data.n_rows() == 0,
4503 patch.
data.n_rows()));
4504 const double color_values[4] = {
4505 patch.
data.n_rows() != 0 ?
4509 patch.
data.n_rows() != 0 ?
4513 patch.
data.n_rows() != 0 ?
4517 patch.
data.n_rows() != 0 ?
4519 (i1 + 1) * d1 + (i2 + 1) * d2) :
4523 eps_cell.color_value = (color_values[0] + color_values[1] +
4524 color_values[3] + color_values[2]) /
4529 std::min(min_color_value, eps_cell.color_value);
4531 std::max(max_color_value, eps_cell.color_value);
4535 cells.insert(eps_cell);
4541 double x_min = cells.begin()->vertices[0][0];
4542 double x_max = x_min;
4543 double y_min = cells.begin()->vertices[0][1];
4544 double y_max = y_min;
4546 for (
const auto &cell : cells)
4547 for (
const auto &vertex : cell.vertices)
4549 x_min =
std::min(x_min, vertex[0]);
4550 x_max =
std::max(x_max, vertex[0]);
4551 y_min =
std::min(y_min, vertex[1]);
4552 y_max =
std::max(y_max, vertex[1]);
4557 const double scale =
4561 const Point<2> offset(x_min, y_min);
4566 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4567 <<
"%%Title: deal.II Output" <<
'\n'
4568 <<
"%%Creator: the deal.II library" <<
'\n'
4571 <<
"%%BoundingBox: "
4575 <<
static_cast<unsigned int>((x_max - x_min) * scale + 0.5) <<
' '
4576 <<
static_cast<unsigned int>((y_max - y_min) * scale + 0.5) <<
'\n';
4585 out <<
"/m {moveto} bind def" <<
'\n'
4586 <<
"/l {lineto} bind def" <<
'\n'
4587 <<
"/s {setrgbcolor} bind def" <<
'\n'
4588 <<
"/sg {setgray} bind def" <<
'\n'
4589 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4590 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4592 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4594 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4602 if (max_color_value == min_color_value)
4603 max_color_value = min_color_value + 1;
4607 for (
const auto &cell : cells)
4620 out << rgb_values.
red <<
" sg ";
4622 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4623 << rgb_values.
blue <<
" s ";
4628 out << (cell.vertices[0] - offset) * scale <<
" m "
4629 << (cell.vertices[1] - offset) * scale <<
" l "
4630 << (cell.vertices[3] - offset) * scale <<
" l "
4631 << (cell.vertices[2] - offset) * scale <<
" lf" <<
'\n';
4636 << (cell.vertices[0] - offset) * scale <<
" m "
4637 << (cell.vertices[1] - offset) * scale <<
" l "
4638 << (cell.vertices[3] - offset) * scale <<
" l "
4639 << (cell.vertices[2] - offset) * scale <<
" lx" <<
'\n';
4641 out <<
"showpage" <<
'\n';
4650 template <
int dim,
int spacedim>
4654 const std::vector<std::string> &data_names,
4656 std::tuple<
unsigned int,
4672#ifndef DEAL_II_WITH_MPI
4681 if (patches.empty())
4685 GmvStream gmv_out(out, flags);
4686 const unsigned int n_data_sets = data_names.size();
4689 Assert((patches[0].
data.n_rows() == n_data_sets &&
4690 !patches[0].points_are_available) ||
4691 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4692 patches[0].points_are_available),
4694 (n_data_sets + spacedim) :
4696 patches[0].data.n_rows()));
4700 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4703 unsigned int n_nodes;
4704 unsigned int n_cells;
4705 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
4720 [&patches]() {
return create_global_data_table(patches); });
4726 out <<
"nodes " << n_nodes <<
'\n';
4727 for (
unsigned int d = 0; d < spacedim; ++d)
4729 gmv_out.selected_component = d;
4735 for (
unsigned int d = spacedim; d < 3; ++d)
4737 for (
unsigned int i = 0; i < n_nodes; ++i)
4744 out <<
"cells " << n_cells <<
'\n';
4749 out <<
"variable" <<
'\n';
4753 std::move(*create_global_data_table_task.
return_value());
4757 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4759 out << data_names[data_set] <<
" 1" <<
'\n';
4760 std::copy(data_vectors[data_set].begin(),
4761 data_vectors[data_set].end(),
4762 std::ostream_iterator<double>(out,
" "));
4763 out <<
'\n' <<
'\n';
4769 out <<
"endvars" <<
'\n';
4772 out <<
"endgmv" <<
'\n';
4783 template <
int dim,
int spacedim>
4787 const std::vector<std::string> &data_names,
4789 std::tuple<
unsigned int,
4803#ifndef DEAL_II_WITH_MPI
4812 if (patches.empty())
4816 TecplotStream tecplot_out(out, flags);
4818 const unsigned int n_data_sets = data_names.size();
4821 Assert((patches[0].
data.n_rows() == n_data_sets &&
4822 !patches[0].points_are_available) ||
4823 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4824 patches[0].points_are_available),
4826 (n_data_sets + spacedim) :
4828 patches[0].data.n_rows()));
4831 unsigned int n_nodes;
4832 unsigned int n_cells;
4833 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
4839 <<
"# This file was generated by the deal.II library." <<
'\n'
4843 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4848 out <<
"Variables=";
4856 out <<
"\"x\", \"y\"";
4859 out <<
"\"x\", \"y\", \"z\"";
4865 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4866 out <<
", \"" << data_names[data_set] <<
"\"";
4872 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4875 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4877 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4878 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4895 [&patches]() {
return create_global_data_table(patches); });
4901 for (
unsigned int d = 0; d < spacedim; ++d)
4903 tecplot_out.selected_component = d;
4914 std::move(*create_global_data_table_task.
return_value());
4917 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4919 std::copy(data_vectors[data_set].begin(),
4920 data_vectors[data_set].end(),
4921 std::ostream_iterator<double>(out,
"\n"));
4936 template <
int dim,
int spacedim>
4940 const std::vector<std::string> &data_names,
4942 std::tuple<
unsigned int,
4946 &nonscalar_data_ranges,
4952#ifndef DEAL_II_WITH_MPI
4961 if (patches.empty())
4965 VtkStream vtk_out(out, flags);
4967 const unsigned int n_data_sets = data_names.size();
4969 if (patches[0].points_are_available)
4981 out <<
"# vtk DataFile Version 3.0" <<
'\n'
4982 <<
"#This file was generated by the deal.II library";
4990 out <<
'\n' <<
"ASCII" <<
'\n';
4992 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
4999 const unsigned int n_metadata =
5000 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5001 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5004 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5006 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5008 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5010 if (flags.
time != std::numeric_limits<double>::min())
5012 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5018 unsigned int n_nodes;
5019 unsigned int n_cells;
5020 unsigned int n_points_and_n_cells;
5021 std::tie(n_nodes, n_cells, n_points_and_n_cells) =
5037 [&patches]() {
return create_global_data_table(patches); });
5043 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5048 out <<
"CELLS " << n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5056 out <<
"CELL_TYPES " << n_cells <<
'\n';
5060 for (
const auto &patch : patches)
5062 const auto vtk_cell_id =
5065 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5066 out <<
' ' << vtk_cell_id[0];
5075 std::move(*create_global_data_table_task.
return_value());
5080 out <<
"POINT_DATA " << n_nodes <<
'\n';
5084 std::vector<bool> data_set_written(n_data_sets,
false);
5085 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5090 "The VTK writer does not currently support outputting "
5091 "tensor data. Use the VTU writer instead."));
5094 std::get<0>(nonscalar_data_range),
5096 std::get<0>(nonscalar_data_range)));
5097 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5101 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5102 std::get<0>(nonscalar_data_range) <=
5105 "Can't declare a vector with more than 3 components "
5109 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5110 i <= std::get<1>(nonscalar_data_range);
5112 data_set_written[i] =
true;
5118 if (!std::get<2>(nonscalar_data_range).empty())
5119 out << std::get<2>(nonscalar_data_range);
5122 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5123 i < std::get<1>(nonscalar_data_range);
5125 out << data_names[i] <<
"__";
5126 out << data_names[std::get<1>(nonscalar_data_range)];
5129 out <<
" double" <<
'\n';
5132 for (
unsigned int n = 0; n < n_nodes; ++n)
5134 switch (std::get<1>(nonscalar_data_range) -
5135 std::get<0>(nonscalar_data_range))
5138 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5143 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5145 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5149 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5151 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5153 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5166 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5167 if (data_set_written[data_set] ==
false)
5169 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5170 <<
"LOOKUP_TABLE default" <<
'\n';
5171 std::copy(data_vectors[data_set].begin(),
5172 data_vectors[data_set].end(),
5173 std::ostream_iterator<double>(out,
" "));
5189 out <<
"<?xml version=\"1.0\" ?> \n";
5191 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5192 <<
"#This file was generated by the deal.II library";
5203 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"2.2\"";
5205 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5206 if (deal_ii_with_zlib &&
5208 out <<
" compressor=\"vtkZLibDataCompressor\"";
5209#ifdef DEAL_II_WORDS_BIGENDIAN
5210 out <<
" byte_order=\"BigEndian\"";
5212 out <<
" byte_order=\"LittleEndian\"";
5216 out <<
"<UnstructuredGrid>";
5226 out <<
" </UnstructuredGrid>\n";
5227 out <<
"</VTKFile>\n";
5232 template <
int dim,
int spacedim>
5236 const std::vector<std::string> &data_names,
5238 std::tuple<
unsigned int,
5242 &nonscalar_data_ranges,
5247 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5254 template <
int dim,
int spacedim>
5258 const std::vector<std::string> &data_names,
5260 std::tuple<
unsigned int,
5264 &nonscalar_data_ranges,
5278 unit.second.find(
'\"') == std::string::npos,
5280 "A physical unit you provided, <" + unit.second +
5281 ">, contained a quotation mark character. This is not allowed."));
5284#ifndef DEAL_II_WITH_MPI
5293 if (patches.empty())
5298 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5300 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5302 <<
" <PointData Scalars=\"scalars\">\n";
5303 std::vector<bool> data_set_written(data_names.size(),
false);
5304 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5307 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5308 i <= std::get<1>(nonscalar_data_range);
5310 data_set_written[i] =
true;
5314 out <<
" <DataArray type=\"Float32\" Name=\"";
5316 if (!std::get<2>(nonscalar_data_range).empty())
5317 out << std::get<2>(nonscalar_data_range);
5320 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5321 i < std::get<1>(nonscalar_data_range);
5323 out << data_names[i] <<
"__";
5324 out << data_names[std::get<1>(nonscalar_data_range)];
5327 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5330 for (
unsigned int data_set = 0; data_set < data_names.size();
5332 if (data_set_written[data_set] ==
false)
5334 out <<
" <DataArray type=\"Float32\" Name=\""
5335 << data_names[data_set] <<
"\"></DataArray>\n";
5338 out <<
" </PointData>\n";
5339 out <<
"</Piece>\n";
5353 const unsigned int n_metadata =
5354 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5355 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5357 out <<
"<FieldData>\n";
5359 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5362 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5363 << flags.
cycle <<
"</DataArray>\n";
5365 if (flags.
time != std::numeric_limits<double>::min())
5368 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5369 << flags.
time <<
"</DataArray>\n";
5373 out <<
"</FieldData>\n";
5377 const unsigned int n_data_sets = data_names.size();
5380 if (patches[0].points_are_available)
5389 const char *ascii_or_binary =
5390 (deal_ii_with_zlib &&
5397 unsigned int n_nodes;
5398 unsigned int n_cells;
5399 std::tie(n_nodes, n_cells, std::ignore) =
5407 const auto stringize_vertex_information = [&patches,
5411 ascii_or_binary]() {
5412 std::ostringstream o;
5414 o <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5415 << ascii_or_binary <<
"\">\n";
5416 const std::vector<Point<spacedim>> node_positions =
5421 std::vector<float> node_coordinates_3d;
5422 node_coordinates_3d.reserve(node_positions.size() * 3);
5423 for (
const auto &node_position : node_positions)
5425 for (
unsigned int d = 0; d < 3; ++d)
5427 node_coordinates_3d.emplace_back(node_position[d]);
5429 node_coordinates_3d.emplace_back(0.0f);
5431 o << vtu_stringize_array(node_coordinates_3d,
5435 o <<
" </DataArray>\n";
5436 o <<
" </Points>\n\n";
5445 const auto stringize_cell_to_vertex_information = [&patches,
5449 out.precision()]() {
5450 std::ostringstream o;
5453 o <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5454 << ascii_or_binary <<
"\">\n";
5456 std::vector<int32_t> cells;
5459 unsigned int first_vertex_of_patch = 0;
5461 for (
const auto &patch : patches)
5473 const unsigned int n_points = patch.
data.n_cols();
5474 Assert((dim == 2 && n_points == 6) ||
5475 (dim == 3 && n_points == 10),
5478 if (deal_ii_with_zlib &&
5482 for (
unsigned int i = 0; i < n_points; ++i)
5483 cells.push_back(first_vertex_of_patch + i);
5487 for (
unsigned int i = 0; i < n_points; ++i)
5488 o <<
'\t' << first_vertex_of_patch + i;
5492 first_vertex_of_patch += n_points;
5497 else if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
5501 const unsigned int n_points = patch.
data.n_cols();
5503 if (deal_ii_with_zlib &&
5507 for (
unsigned int i = 0; i < n_points; ++i)
5509 first_vertex_of_patch +
5514 for (
unsigned int i = 0; i < n_points; ++i)
5516 << (first_vertex_of_patch +
5521 first_vertex_of_patch += n_points;
5526 const unsigned int n_points_per_direction = n_subdivisions + 1;
5528 std::vector<unsigned> local_vertex_order;
5532 const auto flush_current_cell = [&flags,
5535 first_vertex_of_patch,
5536 &local_vertex_order]() {
5537 if (deal_ii_with_zlib &&
5541 for (
const auto &c : local_vertex_order)
5542 cells.push_back(first_vertex_of_patch + c);
5546 for (
const auto &c : local_vertex_order)
5547 o <<
'\t' << first_vertex_of_patch + c;
5551 local_vertex_order.clear();
5556 local_vertex_order.reserve(Utilities::fixed_power<dim>(2));
5562 local_vertex_order.emplace_back(0);
5563 flush_current_cell();
5569 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5571 const unsigned int starting_offset = i1;
5572 local_vertex_order.emplace_back(starting_offset);
5573 local_vertex_order.emplace_back(starting_offset +
5575 flush_current_cell();
5582 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5583 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5585 const unsigned int starting_offset =
5586 i2 * n_points_per_direction + i1;
5587 local_vertex_order.emplace_back(
5589 local_vertex_order.emplace_back(
5590 starting_offset + 1);
5591 local_vertex_order.emplace_back(
5592 starting_offset + n_points_per_direction + 1);
5593 local_vertex_order.emplace_back(
5594 starting_offset + n_points_per_direction);
5595 flush_current_cell();
5602 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5603 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5604 for (
unsigned int i1 = 0; i1 < n_subdivisions;
5607 const unsigned int starting_offset =
5608 i3 * n_points_per_direction *
5609 n_points_per_direction +
5610 i2 * n_points_per_direction + i1;
5611 local_vertex_order.emplace_back(
5613 local_vertex_order.emplace_back(
5614 starting_offset + 1);
5615 local_vertex_order.emplace_back(
5616 starting_offset + n_points_per_direction +
5618 local_vertex_order.emplace_back(
5619 starting_offset + n_points_per_direction);
5620 local_vertex_order.emplace_back(
5621 starting_offset + n_points_per_direction *
5622 n_points_per_direction);
5623 local_vertex_order.emplace_back(
5625 n_points_per_direction *
5626 n_points_per_direction +
5628 local_vertex_order.emplace_back(
5630 n_points_per_direction *
5631 n_points_per_direction +
5632 n_points_per_direction + 1);
5633 local_vertex_order.emplace_back(
5635 n_points_per_direction *
5636 n_points_per_direction +
5637 n_points_per_direction);
5638 flush_current_cell();
5649 local_vertex_order.resize(
5650 Utilities::fixed_power<dim>(n_points_per_direction));
5658 "Point-like cells should not be possible "
5659 "when writing higher-order cells."));
5664 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5667 const unsigned int local_index = i1;
5668 const unsigned int connectivity_index =
5670 .template vtk_lexicographic_to_node_index<1>(
5674 local_vertex_order[connectivity_index] =
5676 flush_current_cell();
5683 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1;
5685 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5688 const unsigned int local_index =
5689 i2 * n_points_per_direction + i1;
5690 const unsigned int connectivity_index =
5692 .template vtk_lexicographic_to_node_index<
5694 {{n_subdivisions, n_subdivisions}},
5696 local_vertex_order[connectivity_index] =
5699 flush_current_cell();
5705 for (
unsigned int i3 = 0; i3 < n_subdivisions + 1;
5707 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1;
5709 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5712 const unsigned int local_index =
5713 i3 * n_points_per_direction *
5714 n_points_per_direction +
5715 i2 * n_points_per_direction + i1;
5716 const unsigned int connectivity_index =
5718 .template vtk_lexicographic_to_node_index<
5724 local_vertex_order[connectivity_index] =
5728 flush_current_cell();
5738 first_vertex_of_patch +=
5747 o << vtu_stringize_array(cells,
5752 o <<
" </DataArray>\n";
5772 const auto stringize_cell_offset_and_type_information =
5777 output_precision = out.precision()]() {
5778 std::ostringstream o;
5780 o <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5781 << ascii_or_binary <<
"\">\n";
5783 std::vector<int32_t> offsets;
5784 offsets.reserve(n_cells);
5788 std::vector<unsigned int> cell_types;
5789 cell_types.reserve(n_cells);
5791 unsigned int first_vertex_of_patch = 0;
5793 for (
const auto &patch : patches)
5795 const auto vtk_cell_id =
5798 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5800 cell_types.push_back(vtk_cell_id[0]);
5801 first_vertex_of_patch += vtk_cell_id[2];
5802 offsets.push_back(first_vertex_of_patch);
5806 o << vtu_stringize_array(offsets,
5810 o <<
" </DataArray>\n";
5812 o <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5813 << ascii_or_binary <<
"\">\n";
5815 if (deal_ii_with_zlib &&
5818 std::vector<uint8_t> cell_types_uint8_t(cell_types.size());
5819 for (
unsigned int i = 0; i < cell_types.size(); ++i)
5820 cell_types_uint8_t[i] =
static_cast<std::uint8_t
>(cell_types[i]);
5822 o << vtu_stringize_array(cell_types_uint8_t,
5828 o << vtu_stringize_array(cell_types,
5834 o <<
" </DataArray>\n";
5844 const auto stringize_nonscalar_data_range =
5850 output_precision = out.precision()](
const Table<2, float> &data_vectors,
5851 const auto &range) {
5852 std::ostringstream o;
5854 const auto first_component = std::get<0>(range);
5855 const auto last_component = std::get<1>(range);
5856 const auto &name = std::get<2>(range);
5857 const bool is_tensor =
5858 (std::get<3>(range) ==
5860 const unsigned int n_components = (is_tensor ? 9 : 3);
5867 AssertThrow((last_component + 1 - first_component <= 9),
5869 "Can't declare a tensor with more than 9 components "
5870 "in VTK/VTU format."));
5874 AssertThrow((last_component + 1 - first_component <= 3),
5876 "Can't declare a vector with more than 3 components "
5877 "in VTK/VTU format."));
5882 o <<
" <DataArray type=\"Float32\" Name=\"";
5888 for (
unsigned int i = first_component; i < last_component; ++i)
5889 o << data_names[i] <<
"__";
5890 o << data_names[last_component];
5893 o <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5894 << ascii_or_binary <<
"\"";
5913 std::vector<float>
data;
5914 data.reserve(n_nodes * n_components);
5916 for (
unsigned int n = 0; n < n_nodes; ++n)
5920 switch (last_component - first_component)
5923 data.push_back(data_vectors(first_component, n));
5929 data.push_back(data_vectors(first_component, n));
5930 data.push_back(data_vectors(first_component + 1, n));
5935 data.push_back(data_vectors(first_component, n));
5936 data.push_back(data_vectors(first_component + 1, n));
5937 data.push_back(data_vectors(first_component + 2, n));
5950 const unsigned int size = last_component - first_component + 1;
5954 vtk_data[0][0] = data_vectors(first_component, n);
5959 for (
unsigned int c = 0; c <
size; ++c)
5963 vtk_data[ind[0]][ind[1]] =
5964 data_vectors(first_component + c, n);
5970 for (
unsigned int c = 0; c <
size; ++c)
5974 vtk_data[ind[0]][ind[1]] =
5975 data_vectors(first_component + c, n);
5986 for (
unsigned int i = 0; i < 3; ++i)
5987 for (
unsigned int j = 0; j < 3; ++j)
5988 data.push_back(vtk_data[i][j]);
5992 o << vtu_stringize_array(
data,
5996 o <<
" </DataArray>\n";
6001 const auto stringize_scalar_data_set =
6005 output_precision = out.precision()](
const Table<2, float> &data_vectors,
6006 const unsigned int data_set) {
6007 std::ostringstream o;
6009 o <<
" <DataArray type=\"Float32\" Name=\"" << data_names[data_set]
6010 <<
"\" format=\"" << ascii_or_binary <<
"\"";
6014 o <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6019 const std::vector<float>
data(data_vectors[data_set].begin(),
6020 data_vectors[data_set].end());
6021 o << vtu_stringize_array(
data,
6025 o <<
" </DataArray>\n";
6044 return create_global_data_table<dim, spacedim, float>(patches);
6058 std::move(*create_global_data_table_task.
return_value());
6064 std::vector<bool> data_set_handled(n_data_sets,
false);
6065 for (
const auto &range : nonscalar_data_ranges)
6068 const auto first_component = std::get<0>(range);
6069 const auto last_component = std::get<1>(range);
6070 for (
unsigned int i = first_component; i <= last_component; ++i)
6071 data_set_handled[i] =
true;
6074 return stringize_nonscalar_data_range(data_vectors, range);
6079 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6080 if (data_set_handled[data_set] ==
false)
6083 return stringize_scalar_data_set(data_vectors, data_set);
6089 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
6090 << n_cells <<
"\" >\n";
6091 for (
const auto &s : mesh_tasks.return_values())
6093 out <<
" <PointData Scalars=\"scalars\">\n";
6096 out <<
" </PointData>\n";
6097 out <<
" </Piece>\n";
6111 const std::vector<std::string> &piece_names,
6112 const std::vector<std::string> &data_names,
6114 std::tuple<
unsigned int,
6118 &nonscalar_data_ranges,
6131 unit.second.find(
'\"') == std::string::npos,
6133 "A physical unit you provided, <" + unit.second +
6134 ">, contained a quotation mark character. This is not allowed."));
6137 const unsigned int n_data_sets = data_names.size();
6139 out <<
"<?xml version=\"1.0\"?>\n";
6142 out <<
"#This file was generated by the deal.II library"
6147 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
6148 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
6149 out <<
" <PPointData Scalars=\"scalars\">\n";
6152 std::vector<bool> data_set_written(n_data_sets,
false);
6153 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
6155 const auto first_component = std::get<0>(nonscalar_data_range);
6156 const auto last_component = std::get<1>(nonscalar_data_range);
6157 const bool is_tensor =
6158 (std::get<3>(nonscalar_data_range) ==
6160 const unsigned int n_components = (is_tensor ? 9 : 3);
6167 AssertThrow((last_component + 1 - first_component <= 9),
6169 "Can't declare a tensor with more than 9 components "
6174 Assert((last_component + 1 - first_component <= 3),
6176 "Can't declare a vector with more than 3 components "
6181 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6182 i <= std::get<1>(nonscalar_data_range);
6184 data_set_written[i] =
true;
6188 out <<
" <PDataArray type=\"Float32\" Name=\"";
6190 const std::string &name = std::get<2>(nonscalar_data_range);
6195 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6196 i < std::get<1>(nonscalar_data_range);
6198 out << data_names[i] <<
"__";
6199 out << data_names[std::get<1>(nonscalar_data_range)];
6202 out <<
"\" NumberOfComponents=\"" << n_components
6203 <<
"\" format=\"ascii\"";
6215 data_names[std::get<1>(nonscalar_data_range)]) !=
6219 data_names[std::get<1>(nonscalar_data_range)])
6227 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6228 if (data_set_written[data_set] ==
false)
6230 out <<
" <PDataArray type=\"Float32\" Name=\""
6231 << data_names[data_set] <<
"\" format=\"ascii\"";
6235 out <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6241 out <<
" </PPointData>\n";
6243 out <<
" <PPoints>\n";
6244 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
6245 out <<
" </PPoints>\n";
6247 for (
const auto &piece_name : piece_names)
6248 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
6250 out <<
" </PUnstructuredGrid>\n";
6251 out <<
"</VTKFile>\n";
6264 const std::vector<std::pair<double, std::string>> ×_and_names)
6268 out <<
"<?xml version=\"1.0\"?>\n";
6271 out <<
"#This file was generated by the deal.II library"
6276 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
6277 out <<
" <Collection>\n";
6279 std::streamsize ss = out.precision();
6282 for (
const auto &time_and_name : times_and_names)
6283 out <<
" <DataSet timestep=\"" << time_and_name.first
6284 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
6287 out <<
" </Collection>\n";
6288 out <<
"</VTKFile>\n";
6300 const std::vector<std::string> &piece_names)
6302 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
6303 for (
const auto &piece_name : piece_names)
6304 out << piece_name <<
'\n';
6313 const std::vector<std::vector<std::string>> &piece_names)
6317 if (piece_names.empty())
6320 const double nblocks = piece_names[0].size();
6322 ExcMessage(
"piece_names should be a vector of nonempty vectors."));
6324 out <<
"!NBLOCKS " << nblocks <<
'\n';
6325 for (
const auto &domain : piece_names)
6327 Assert(domain.size() == nblocks,
6329 "piece_names should be a vector of equal sized vectors."));
6330 for (
const auto &subdomain : domain)
6331 out << subdomain <<
'\n';
6342 const std::vector<std::pair<
double, std::vector<std::string>>>
6343 ×_and_piece_names)
6347 if (times_and_piece_names.empty())
6350 const double nblocks = times_and_piece_names[0].second.size();
6354 "time_and_piece_names should contain nonempty vectors of filenames for every timestep."));
6356 for (
const auto &domain : times_and_piece_names)
6357 out <<
"!TIME " << domain.first <<
'\n';
6359 out <<
"!NBLOCKS " << nblocks <<
'\n';
6360 for (
const auto &domain : times_and_piece_names)
6362 Assert(domain.second.size() == nblocks,
6364 "piece_names should be a vector of equal sized vectors."));
6365 for (
const auto &subdomain : domain.second)
6366 out << subdomain <<
'\n';
6374 template <
int dim,
int spacedim>
6378 const std::vector<std::string> &,
6380 std::tuple<
unsigned int,
6390 template <
int spacedim>
6394 const std::vector<std::string> & ,
6396 std::tuple<
unsigned int,
6404 const unsigned int height = flags.
height;
6405 unsigned int width = flags.
width;
6408 unsigned int margin_in_percent = 0;
6410 margin_in_percent = 5;
6414 double x_dimension, y_dimension, z_dimension;
6416 const auto &first_patch = patches[0];
6418 unsigned int n_subdivisions = first_patch.n_subdivisions;
6419 unsigned int n = n_subdivisions + 1;
6420 const unsigned int d1 = 1;
6421 const unsigned int d2 = n;
6424 std::array<Point<spacedim>, 4> projected_points;
6427 std::array<Point<2>, 4> projection_decompositions;
6430 get_equispaced_location(first_patch, {0, 0}, n_subdivisions);
6432 if (first_patch.data.n_rows() != 0)
6437 double x_min = projected_point[0];
6438 double x_max = x_min;
6439 double y_min = projected_point[1];
6440 double y_max = y_min;
6441 double z_min = first_patch.data.n_rows() != 0 ?
6444 double z_max = z_min;
6447 for (
const auto &patch : patches)
6450 n = n_subdivisions + 1;
6452 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6454 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6456 projected_points[0] =
6457 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
6458 projected_points[1] =
6459 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
6460 projected_points[2] =
6461 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
6462 projected_points[3] = get_equispaced_location(patch,
6466 x_min =
std::min(x_min, projected_points[0][0]);
6467 x_min =
std::min(x_min, projected_points[1][0]);
6468 x_min =
std::min(x_min, projected_points[2][0]);
6469 x_min =
std::min(x_min, projected_points[3][0]);
6471 x_max =
std::max(x_max, projected_points[0][0]);
6472 x_max =
std::max(x_max, projected_points[1][0]);
6473 x_max =
std::max(x_max, projected_points[2][0]);
6474 x_max =
std::max(x_max, projected_points[3][0]);
6476 y_min =
std::min(y_min, projected_points[0][1]);
6477 y_min =
std::min(y_min, projected_points[1][1]);
6478 y_min =
std::min(y_min, projected_points[2][1]);
6479 y_min =
std::min(y_min, projected_points[3][1]);
6481 y_max =
std::max(y_max, projected_points[0][1]);
6482 y_max =
std::max(y_max, projected_points[1][1]);
6483 y_max =
std::max(y_max, projected_points[2][1]);
6484 y_max =
std::max(y_max, projected_points[3][1]);
6487 patch.
data.n_rows() == 0,
6490 patch.
data.n_rows()));
6492 z_min = std::min<double>(z_min,
6494 i1 * d1 + i2 * d2));
6495 z_min = std::min<double>(z_min,
6497 (i1 + 1) * d1 + i2 * d2));
6498 z_min = std::min<double>(z_min,
6500 i1 * d1 + (i2 + 1) * d2));
6502 std::min<double>(z_min,
6504 (i1 + 1) * d1 + (i2 + 1) * d2));
6506 z_max = std::max<double>(z_max,
6508 i1 * d1 + i2 * d2));
6509 z_max = std::max<double>(z_max,
6511 (i1 + 1) * d1 + i2 * d2));
6512 z_max = std::max<double>(z_max,
6514 i1 * d1 + (i2 + 1) * d2));
6516 std::max<double>(z_max,
6518 (i1 + 1) * d1 + (i2 + 1) * d2));
6523 x_dimension = x_max - x_min;
6524 y_dimension = y_max - y_min;
6525 z_dimension = z_max - z_min;
6532 float camera_focus = 0;
6535 camera_position[0] = 0.;
6536 camera_position[1] = 0.;
6537 camera_position[2] = z_min + 2. * z_dimension;
6539 camera_direction[0] = 0.;
6540 camera_direction[1] = 0.;
6541 camera_direction[2] = -1.;
6543 camera_horizontal[0] = 1.;
6544 camera_horizontal[1] = 0.;
6545 camera_horizontal[2] = 0.;
6547 camera_focus = .5 * z_dimension;
6553 const float angle_factor = 3.14159265f / 180.f;
6556 camera_position_temp[1] =
6559 camera_position_temp[2] =
6563 camera_direction_temp[1] =
6566 camera_direction_temp[2] =
6570 camera_horizontal_temp[1] =
6573 camera_horizontal_temp[2] =
6577 camera_position[1] = camera_position_temp[1];
6578 camera_position[2] = camera_position_temp[2];
6580 camera_direction[1] = camera_direction_temp[1];
6581 camera_direction[2] = camera_direction_temp[2];
6583 camera_horizontal[1] = camera_horizontal_temp[1];
6584 camera_horizontal[2] = camera_horizontal_temp[2];
6587 camera_position_temp[0] =
6590 camera_position_temp[1] =
6594 camera_direction_temp[0] =
6597 camera_direction_temp[1] =
6601 camera_horizontal_temp[0] =
6604 camera_horizontal_temp[1] =
6608 camera_position[0] = camera_position_temp[0];
6609 camera_position[1] = camera_position_temp[1];
6611 camera_direction[0] = camera_direction_temp[0];
6612 camera_direction[1] = camera_direction_temp[1];
6614 camera_horizontal[0] = camera_horizontal_temp[0];
6615 camera_horizontal[1] = camera_horizontal_temp[1];
6618 camera_position[0] = x_min + .5 * x_dimension;
6619 camera_position[1] = y_min + .5 * y_dimension;
6621 camera_position[0] += (z_min + 2. * z_dimension) *
6624 camera_position[1] -= (z_min + 2. * z_dimension) *
6630 double x_min_perspective, y_min_perspective;
6631 double x_max_perspective, y_max_perspective;
6632 double x_dimension_perspective, y_dimension_perspective;
6634 n_subdivisions = first_patch.n_subdivisions;
6635 n = n_subdivisions + 1;
6640 get_equispaced_location(first_patch, {0, 0}, n_subdivisions);
6642 if (first_patch.data.n_rows() != 0)
6647 point[0] = projected_point[0];
6648 point[1] = projected_point[1];
6649 point[2] = first_patch.data.n_rows() != 0 ?
6653 projection_decomposition = svg_project_point(point,
6659 x_min_perspective = projection_decomposition[0];
6660 x_max_perspective = projection_decomposition[0];
6661 y_min_perspective = projection_decomposition[1];
6662 y_max_perspective = projection_decomposition[1];
6665 for (
const auto &patch : patches)
6668 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6670 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6672 const std::array<Point<spacedim>, 4> projected_vertices{
6673 {get_equispaced_location(patch, {i1, i2}, n_subdivisions),
6674 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions),
6675 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions),
6676 get_equispaced_location(patch,
6681 patch.
data.n_rows() == 0,
6684 patch.
data.n_rows()));
6686 const std::array<Point<3>, 4> vertices = {
6687 {
Point<3>{projected_vertices[0][0],
6688 projected_vertices[0][1],
6689 patch.
data.n_rows() != 0 ?
6690 patch.
data(0, i1 * d1 + i2 * d2) :
6693 projected_vertices[1][1],
6694 patch.
data.n_rows() != 0 ?
6695 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6698 projected_vertices[2][1],
6699 patch.
data.n_rows() != 0 ?
6700 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6703 projected_vertices[3][1],
6704 patch.
data.n_rows() != 0 ?
6705 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6708 projection_decompositions = {
6709 {svg_project_point(vertices[0],
6714 svg_project_point(vertices[1],
6719 svg_project_point(vertices[2],
6724 svg_project_point(vertices[3],
6732 static_cast<double>(
6733 projection_decompositions[0][0]));
6736 static_cast<double>(
6737 projection_decompositions[1][0]));
6740 static_cast<double>(
6741 projection_decompositions[2][0]));
6744 static_cast<double>(
6745 projection_decompositions[3][0]));
6749 static_cast<double>(
6750 projection_decompositions[0][0]));
6753 static_cast<double>(
6754 projection_decompositions[1][0]));
6757 static_cast<double>(
6758 projection_decompositions[2][0]));
6761 static_cast<double>(
6762 projection_decompositions[3][0]));
6766 static_cast<double>(
6767 projection_decompositions[0][1]));
6770 static_cast<double>(
6771 projection_decompositions[1][1]));
6774 static_cast<double>(
6775 projection_decompositions[2][1]));
6778 static_cast<double>(
6779 projection_decompositions[3][1]));
6783 static_cast<double>(
6784 projection_decompositions[0][1]));
6787 static_cast<double>(
6788 projection_decompositions[1][1]));
6791 static_cast<double>(
6792 projection_decompositions[2][1]));
6795 static_cast<double>(
6796 projection_decompositions[3][1]));
6801 x_dimension_perspective = x_max_perspective - x_min_perspective;
6802 y_dimension_perspective = y_max_perspective - y_min_perspective;
6804 std::multiset<SvgCell> cells;
6807 for (
const auto &patch : patches)
6811 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6813 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6815 const std::array<Point<spacedim>, 4> projected_vertices = {
6816 {get_equispaced_location(patch, {i1, i2}, n_subdivisions),
6817 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions),
6818 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions),
6819 get_equispaced_location(patch,
6824 patch.
data.n_rows() == 0,
6827 patch.
data.n_rows()));
6831 cell.vertices[0][0] = projected_vertices[0][0];
6832 cell.vertices[0][1] = projected_vertices[0][1];
6833 cell.vertices[0][2] = patch.
data.n_rows() != 0 ?
6834 patch.
data(0, i1 * d1 + i2 * d2) :
6837 cell.vertices[1][0] = projected_vertices[1][0];
6838 cell.vertices[1][1] = projected_vertices[1][1];
6839 cell.vertices[1][2] = patch.
data.n_rows() != 0 ?
6840 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6843 cell.vertices[2][0] = projected_vertices[2][0];
6844 cell.vertices[2][1] = projected_vertices[2][1];
6845 cell.vertices[2][2] = patch.
data.n_rows() != 0 ?
6846 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6849 cell.vertices[3][0] = projected_vertices[3][0];
6850 cell.vertices[3][1] = projected_vertices[3][1];
6851 cell.vertices[3][2] =
6852 patch.
data.n_rows() != 0 ?
6853 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6856 cell.projected_vertices[0] =
6857 svg_project_point(cell.vertices[0],
6862 cell.projected_vertices[1] =
6863 svg_project_point(cell.vertices[1],
6868 cell.projected_vertices[2] =
6869 svg_project_point(cell.vertices[2],
6874 cell.projected_vertices[3] =
6875 svg_project_point(cell.vertices[3],
6881 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] +
6882 cell.vertices[2] + cell.vertices[3]);
6883 cell.projected_center = svg_project_point(cell.center,
6889 cell.depth = cell.center.distance(camera_position);
6899 width =
static_cast<unsigned int>(
6900 .5 + height * (x_dimension_perspective / y_dimension_perspective));
6901 unsigned int additional_width = 0;
6904 additional_width =
static_cast<unsigned int>(
6908 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\""
6909 << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
6911 <<
" <rect width=\"" << width + additional_width <<
"\" height=\""
6912 << height <<
"\" style=\"fill:white\"/>" <<
'\n'
6915 unsigned int triangle_counter = 0;
6918 for (
const auto &cell : cells)
6922 for (
unsigned int triangle_index = 0; triangle_index < 4;
6925 switch (triangle_index)
6928 points3d_triangle[0] = cell.vertices[0],
6929 points3d_triangle[1] = cell.vertices[1],
6930 points3d_triangle[2] = cell.center;
6933 points3d_triangle[0] = cell.vertices[1],
6934 points3d_triangle[1] = cell.vertices[3],
6935 points3d_triangle[2] = cell.center;
6938 points3d_triangle[0] = cell.vertices[3],
6939 points3d_triangle[1] = cell.vertices[2],
6940 points3d_triangle[2] = cell.center;
6943 points3d_triangle[0] = cell.vertices[2],
6944 points3d_triangle[1] = cell.vertices[0],
6945 points3d_triangle[2] = cell.center;
6952 svg_get_gradient_parameters(points3d_triangle);
6955 .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
6957 .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
6959 unsigned int start_r = 0;
6960 unsigned int start_g = 0;
6961 unsigned int start_b = 0;
6963 unsigned int stop_r = 0;
6964 unsigned int stop_g = 0;
6965 unsigned int stop_b = 0;
6967 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6968 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6970 double start_f = start_h * 6. - start_i;
6971 double start_q = 1. - start_f;
6973 double stop_f = stop_h * 6. - stop_i;
6974 double stop_q = 1. - stop_f;
6976 switch (start_i % 6)
6980 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6983 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
6988 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6991 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
6995 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7000 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7010 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7013 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7018 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7021 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7025 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7030 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7036 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
7038 gradient_start_point_3d[0] = gradient_param[0];
7039 gradient_start_point_3d[1] = gradient_param[1];
7040 gradient_start_point_3d[2] = gradient_param[4];
7042 gradient_stop_point_3d[0] = gradient_param[2];
7043 gradient_stop_point_3d[1] = gradient_param[3];
7044 gradient_stop_point_3d[2] = gradient_param[5];
7047 svg_project_point(gradient_start_point_3d,
7053 svg_project_point(gradient_stop_point_3d,
7060 out <<
" <linearGradient id=\"" << triangle_counter
7061 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7063 <<
static_cast<unsigned int>(
7065 ((gradient_start_point[0] - x_min_perspective) /
7066 x_dimension_perspective) *
7067 (width - (width / 100.) * 2. * margin_in_percent) +
7068 ((width / 100.) * margin_in_percent))
7071 <<
static_cast<unsigned int>(
7072 .5 + height - (height / 100.) * margin_in_percent -
7073 ((gradient_start_point[1] - y_min_perspective) /
7074 y_dimension_perspective) *
7075 (height - (height / 100.) * 2. * margin_in_percent))
7078 <<
static_cast<unsigned int>(
7080 ((gradient_stop_point[0] - x_min_perspective) /
7081 x_dimension_perspective) *
7082 (width - (width / 100.) * 2. * margin_in_percent) +
7083 ((width / 100.) * margin_in_percent))
7086 <<
static_cast<unsigned int>(
7087 .5 + height - (height / 100.) * margin_in_percent -
7088 ((gradient_stop_point[1] - y_min_perspective) /
7089 y_dimension_perspective) *
7090 (height - (height / 100.) * 2. * margin_in_percent))
7093 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7094 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7095 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7096 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7097 <<
" </linearGradient>" <<
'\n';
7100 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
7101 double x3 = cell.projected_center[0];
7102 double y3 = cell.projected_center[1];
7104 switch (triangle_index)
7107 x1 = cell.projected_vertices[0][0],
7108 y1 = cell.projected_vertices[0][1],
7109 x2 = cell.projected_vertices[1][0],
7110 y2 = cell.projected_vertices[1][1];
7113 x1 = cell.projected_vertices[1][0],
7114 y1 = cell.projected_vertices[1][1],
7115 x2 = cell.projected_vertices[3][0],
7116 y2 = cell.projected_vertices[3][1];
7119 x1 = cell.projected_vertices[3][0],
7120 y1 = cell.projected_vertices[3][1],
7121 x2 = cell.projected_vertices[2][0],
7122 y2 = cell.projected_vertices[2][1];
7125 x1 = cell.projected_vertices[2][0],
7126 y1 = cell.projected_vertices[2][1],
7127 x2 = cell.projected_vertices[0][0],
7128 y2 = cell.projected_vertices[0][1];
7134 out <<
" <path d=\"M "
7135 <<
static_cast<unsigned int>(
7137 ((x1 - x_min_perspective) / x_dimension_perspective) *
7138 (width - (width / 100.) * 2. * margin_in_percent) +
7139 ((width / 100.) * margin_in_percent))
7141 <<
static_cast<unsigned int>(
7142 .5 + height - (height / 100.) * margin_in_percent -
7143 ((y1 - y_min_perspective) / y_dimension_perspective) *
7144 (height - (height / 100.) * 2. * margin_in_percent))
7146 <<
static_cast<unsigned int>(
7148 ((x2 - x_min_perspective) / x_dimension_perspective) *
7149 (width - (width / 100.) * 2. * margin_in_percent) +
7150 ((width / 100.) * margin_in_percent))
7152 <<
static_cast<unsigned int>(
7153 .5 + height - (height / 100.) * margin_in_percent -
7154 ((y2 - y_min_perspective) / y_dimension_perspective) *
7155 (height - (height / 100.) * 2. * margin_in_percent))
7157 <<
static_cast<unsigned int>(
7159 ((x3 - x_min_perspective) / x_dimension_perspective) *
7160 (width - (width / 100.) * 2. * margin_in_percent) +
7161 ((width / 100.) * margin_in_percent))
7163 <<
static_cast<unsigned int>(
7164 .5 + height - (height / 100.) * margin_in_percent -
7165 ((y3 - y_min_perspective) / y_dimension_perspective) *
7166 (height - (height / 100.) * 2. * margin_in_percent))
7168 <<
static_cast<unsigned int>(
7170 ((x1 - x_min_perspective) / x_dimension_perspective) *
7171 (width - (width / 100.) * 2. * margin_in_percent) +
7172 ((width / 100.) * margin_in_percent))
7174 <<
static_cast<unsigned int>(
7175 .5 + height - (height / 100.) * margin_in_percent -
7176 ((y1 - y_min_perspective) / y_dimension_perspective) *
7177 (height - (height / 100.) * 2. * margin_in_percent))
7178 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter
7189 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
7191 unsigned int element_height =
static_cast<unsigned int>(
7192 ((height / 100.) * (71. - 2. * margin_in_percent)) / 4);
7193 unsigned int element_width =
7194 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
7196 additional_width = 0;
7199 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
7201 for (
unsigned int index = 0; index < 4; ++index)
7203 double start_h = .667 - ((index + 1) / 4.) * .667;
7204 double stop_h = .667 - (index / 4.) * .667;
7206 unsigned int start_r = 0;
7207 unsigned int start_g = 0;
7208 unsigned int start_b = 0;
7210 unsigned int stop_r = 0;
7211 unsigned int stop_g = 0;
7212 unsigned int stop_b = 0;
7214 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
7215 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
7217 double start_f = start_h * 6. - start_i;
7218 double start_q = 1. - start_f;
7220 double stop_f = stop_h * 6. - stop_i;
7221 double stop_q = 1. - stop_f;
7223 switch (start_i % 6)
7227 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
7230 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
7235 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
7238 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
7242 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7247 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7257 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7260 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7265 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7268 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7272 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7277 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7284 out <<
" <linearGradient id=\"colorbar_" << index
7285 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7286 <<
"x1=\"" << width + additional_width <<
"\" "
7288 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7289 (margin_in_percent + 29)) +
7290 (3 - index) * element_height
7292 <<
"x2=\"" << width + additional_width <<
"\" "
7294 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7295 (margin_in_percent + 29)) +
7296 (4 - index) * element_height
7299 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7300 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7301 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7302 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7303 <<
" </linearGradient>" <<
'\n';
7308 <<
" x=\"" << width + additional_width <<
"\" y=\""
7309 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7310 (margin_in_percent + 29)) +
7311 (3 - index) * element_height
7312 <<
"\" width=\"" << element_width <<
"\" height=\""
7314 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_"
7315 << index <<
")\"/>" <<
'\n';
7318 for (
unsigned int index = 0; index < 5; ++index)
7322 << width + additional_width +
7323 static_cast<unsigned int>(1.5 * element_width)
7325 <<
static_cast<unsigned int>(
7326 .5 + (height / 100.) * (margin_in_percent + 29) +
7327 (4. - index) * element_height + 30.)
7329 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
7331 if (index == 0 || index == 4)
7332 out <<
"; font-weight:bold";
7335 <<
static_cast<float>(
7336 (
static_cast<int>((z_min + index * (z_dimension / 4.)) *
7345 out <<
"</text>" <<
'\n';
7350 out <<
'\n' <<
"</svg>";
7356 template <
int dim,
int spacedim>
7360 const std::vector<std::string> &data_names,
7362 std::tuple<
unsigned int,
7366 &nonscalar_data_ranges,
7375 out << dim <<
' ' << spacedim <<
'\n';
7378 out <<
"[deal.II intermediate format graphics data]" <<
'\n'
7384 out << data_names.size() <<
'\n';
7385 for (
const auto &data_name : data_names)
7386 out << data_name <<
'\n';
7388 out << patches.size() <<
'\n';
7389 for (
unsigned int i = 0; i < patches.size(); ++i)
7390 out << patches[i] <<
'\n';
7392 out << nonscalar_data_ranges.size() <<
'\n';
7393 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
7394 out << std::get<0>(nonscalar_data_range) <<
' '
7395 << std::get<1>(nonscalar_data_range) <<
'\n'
7396 << std::get<2>(nonscalar_data_range) <<
'\n';
7404 template <
int dim,
int spacedim>
7408 const std::vector<std::string> &data_names,
7410 std::tuple<
unsigned int,
7414 &nonscalar_data_ranges,
7416 const std::string &filename,
7420#ifndef DEAL_II_WITH_MPI
7423 (void)nonscalar_data_ranges;
7430 ExcMessage(
"This functionality requires MPI to be enabled."));
7449 std::vector<char> my_buffer;
7451 boost::iostreams::filtering_ostream f;
7457# ifdef DEAL_II_WITH_ZLIB
7458 f.push(boost::iostreams::zlib_compressor(
7459 get_boost_zlib_compression_level(compression)));
7464 "Compression requires deal.II to be configured with ZLIB support."));
7467 boost::iostreams::back_insert_device<std::vector<char>> inserter(
7471 write_deal_II_intermediate<dim, spacedim>(
7472 patches, data_names, nonscalar_data_ranges, flags, f);
7474 const std::uint64_t my_size = my_buffer.size();
7480 const ParallelIntermediateHeader header{
7483 static_cast<std::uint64_t
>(compression),
7493 std::vector<std::uint64_t> chunk_sizes(n_ranks);
7494 int ierr = MPI_Gather(&my_size,
7497 static_cast<std::uint64_t *
>(chunk_sizes.data()),
7505 ierr = MPI_Info_create(&info);
7508 ierr = MPI_File_open(
7509 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7511 ierr = MPI_Info_free(&info);
7515 ierr = MPI_File_set_size(fh, 0);
7519 ierr = MPI_Barrier(
comm);
7526 fh, 0, &header,
sizeof(header), MPI_CHAR, MPI_STATUS_IGNORE);
7541 std::uint64_t prefix_sum = 0;
7542 ierr = MPI_Exscan(&my_size, &prefix_sum, 1, MPI_UINT64_T, MPI_SUM,
comm);
7546 const MPI_Offset offset =
static_cast<MPI_Offset
>(
sizeof(header)) +
7547 n_ranks *
sizeof(std::uint64_t) + prefix_sum;
7550 fh, offset, my_buffer.data(), my_size, MPI_CHAR, MPI_STATUS_IGNORE);
7559 ierr = MPI_File_sync(fh);
7562 ierr = MPI_File_close(&fh);
7569 std::pair<unsigned int, unsigned int>
7574 unsigned int dim, spacedim;
7575 input >> dim >> spacedim;
7577 return std::make_pair(dim, spacedim);
7586template <
int dim,
int spacedim>
7588 : default_subdivisions(1)
7594template <
int dim,
int spacedim>
7599 get_dataset_names(),
7600 get_nonscalar_data_ranges(),
7607template <
int dim,
int spacedim>
7612 get_dataset_names(),
7613 get_nonscalar_data_ranges(),
7620template <
int dim,
int spacedim>
7625 get_dataset_names(),
7626 get_nonscalar_data_ranges(),
7633template <
int dim,
int spacedim>
7638 get_dataset_names(),
7639 get_nonscalar_data_ranges(),
7646template <
int dim,
int spacedim>
7651 get_dataset_names(),
7652 get_nonscalar_data_ranges(),
7659template <
int dim,
int spacedim>
7664 get_dataset_names(),
7665 get_nonscalar_data_ranges(),
7672template <
int dim,
int spacedim>
7677 get_dataset_names(),
7678 get_nonscalar_data_ranges(),
7685template <
int dim,
int spacedim>
7690 get_dataset_names(),
7691 get_nonscalar_data_ranges(),
7696template <
int dim,
int spacedim>
7701 get_dataset_names(),
7702 get_nonscalar_data_ranges(),
7707template <
int dim,
int spacedim>
7712 get_dataset_names(),
7713 get_nonscalar_data_ranges(),
7719template <
int dim,
int spacedim>
7722 const std::string &filename,
7725#ifndef DEAL_II_WITH_MPI
7729 std::ofstream f(filename);
7737 int ierr = MPI_Info_create(&info);
7740 ierr = MPI_File_open(
7741 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7744 ierr = MPI_File_set_size(fh, 0);
7748 ierr = MPI_Barrier(
comm);
7750 ierr = MPI_Info_free(&info);
7754 unsigned int header_size;
7755 std::uint64_t footer_offset;
7760 std::stringstream ss;
7762 header_size = ss.str().size();
7765 fh, 0, ss.str().c_str(), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
7769 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0,
comm);
7773 const auto &patches = get_patches();
7782 std::stringstream ss;
7783 if (my_n_patches > 0 || (global_n_patches == 0 && myrank == 0))
7785 get_dataset_names(),
7786 get_nonscalar_data_ranges(),
7791 const std::uint64_t size_on_proc = ss.str().size();
7792 std::uint64_t prefix_sum = 0;
7794 MPI_Exscan(&size_on_proc, &prefix_sum, 1, MPI_UINT64_T, MPI_SUM,
comm);
7798 const MPI_Offset offset =
static_cast<MPI_Offset
>(header_size) + prefix_sum;
7808 if (myrank == n_ranks - 1)
7811 footer_offset = size_on_proc + offset;
7813 std::stringstream ss;
7815 const unsigned int footer_size = ss.str().size();
7833 ierr = MPI_File_sync(fh);
7836 ierr = MPI_File_close(&fh);
7843template <
int dim,
int spacedim>
7847 const std::vector<std::string> &piece_names)
const
7851 get_dataset_names(),
7852 get_nonscalar_data_ranges(),
7858template <
int dim,
int spacedim>
7861 const std::string &directory,
7862 const std::string &filename_without_extension,
7863 const unsigned int counter,
7865 const unsigned int n_digits_for_counter,
7866 const unsigned int n_groups)
const
7869 const unsigned int n_ranks =
7871 const unsigned int n_files_written =
7872 (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
7877 const unsigned int n_digits =
7880 const unsigned int color = rank % n_files_written;
7881 const std::string filename =
7882 directory + filename_without_extension +
"_" +
7886 if (n_groups == 0 || n_groups > n_ranks)
7889 std::ofstream output(filename);
7891 this->write_vtu(output);
7893 else if (n_groups == 1)
7896 this->write_vtu_in_parallel(filename, mpi_communicator);
7900#ifdef DEAL_II_WITH_MPI
7903 int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group);
7905 this->write_vtu_in_parallel(filename, comm_group);
7913 const std::string pvtu_filename =
7914 filename_without_extension +
"_" +
7919 std::vector<std::string> filename_vector;
7920 for (
unsigned int i = 0; i < n_files_written; ++i)
7922 const std::string filename =
7923 filename_without_extension +
"_" +
7927 filename_vector.emplace_back(filename);
7930 std::ofstream pvtu_output(directory + pvtu_filename);
7931 this->write_pvtu_record(pvtu_output, filename_vector);
7934 return pvtu_filename;
7939template <
int dim,
int spacedim>
7942 std::ostream &out)
const
7945 get_dataset_names(),
7946 get_nonscalar_data_ranges(),
7947 deal_II_intermediate_flags,
7953template <
int dim,
int spacedim>
7956 const std::string &filename,
7962 get_dataset_names(),
7963 get_nonscalar_data_ranges(),
7964 deal_II_intermediate_flags,
7972template <
int dim,
int spacedim>
7976 const std::string &h5_filename,
7977 const double cur_time,
7980 return create_xdmf_entry(
7981 data_filter, h5_filename, h5_filename, cur_time,
comm);
7986template <
int dim,
int spacedim>
7990 const std::string &h5_mesh_filename,
7991 const std::string &h5_solution_filename,
7992 const double cur_time,
7996 ExcMessage(
"XDMF only supports 2 or 3 space dimensions."));
7998#ifndef DEAL_II_WITH_HDF5
8002 (void)h5_mesh_filename;
8003 (void)h5_solution_filename;
8012 std::uint64_t local_node_cell_count[2], global_node_cell_count[2];
8014 local_node_cell_count[0] = data_filter.
n_nodes();
8015 local_node_cell_count[1] = data_filter.
n_cells();
8019 int ierr = MPI_Allreduce(local_node_cell_count,
8020 global_node_cell_count,
8034 const bool have_data = (data_filter.
n_nodes() > 0);
8037 const int key = myrank;
8038 const int color = (have_data ? 1 : 0);
8039 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8043 const bool am_i_first_rank_with_data =
8046 ierr = MPI_Comm_free(&split_comm);
8049 const int tag = 47381;
8052 if (am_i_first_rank_with_data)
8054 const auto &patches = get_patches();
8059 for (
const auto &patch : patches)
8065 h5_solution_filename,
8067 global_node_cell_count[0],
8068 global_node_cell_count[1],
8071 patches[0].reference_cell);
8072 const unsigned int n_data_sets = data_filter.
n_data_sets();
8076 for (
unsigned int i = 0; i < n_data_sets; ++i)
8086 ierr = MPI_Send(buffer.data(), buffer.size(), MPI_BYTE, 0, tag,
comm);
8095 if (myrank == 0 && !am_i_first_rank_with_data)
8100 int ierr = MPI_Probe(MPI_ANY_SOURCE, tag,
comm, &status);
8104 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
8107 std::vector<char> buffer(len);
8108 ierr = MPI_Recv(buffer.data(),
8117 return Utilities::unpack<XDMFEntry>(buffer,
false);
8125template <
int dim,
int spacedim>
8128 const std::vector<XDMFEntry> &entries,
8129 const std::string &filename,
8132#ifdef DEAL_II_WITH_MPI
8136 const int myrank = 0;
8142 std::ofstream xdmf_file(filename);
8144 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
8145 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
8146 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
8147 xdmf_file <<
" <Domain>\n";
8149 <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
8151 for (
const auto &entry : entries)
8153 xdmf_file << entry.get_xdmf_content(3);
8156 xdmf_file <<
" </Grid>\n";
8157 xdmf_file <<
" </Domain>\n";
8158 xdmf_file <<
"</Xdmf>\n";
8170template <
int dim,
int spacedim>
8176 get_dataset_names(),
8177 get_nonscalar_data_ranges(),
8184#ifdef DEAL_II_WITH_HDF5
8188 template <
int dim,
int spacedim>
8193 const bool write_mesh_file,
8194 const std::string &mesh_filename,
8195 const std::string &solution_filename,
8198 hid_t h5_mesh_file_id = -1, h5_solution_file_id, file_plist_id, plist_id;
8199 hid_t node_dataspace, node_dataset, node_file_dataspace,
8200 node_memory_dataspace, node_dataset_id;
8201 hid_t cell_dataspace, cell_dataset, cell_file_dataspace,
8202 cell_memory_dataspace;
8203 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace,
8204 pt_data_memory_dataspace;
8206 std::uint64_t local_node_cell_count[2];
8207 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
8208 std::vector<double> node_data_vec;
8209 std::vector<unsigned int> cell_data_vec;
8213 local_node_cell_count[0] = data_filter.
n_nodes();
8214 local_node_cell_count[1] = data_filter.
n_cells();
8217 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
8220# ifdef DEAL_II_WITH_MPI
8221# ifdef H5_HAVE_PARALLEL
8223 status = H5Pset_fapl_mpio(file_plist_id,
comm, MPI_INFO_NULL);
8228# ifndef DEAL_II_WITH_ZLIB
8235 std::uint64_t global_node_cell_count[2] = {0, 0};
8236 std::uint64_t global_node_cell_offsets[2] = {0, 0};
8238# ifdef DEAL_II_WITH_MPI
8239 int ierr = MPI_Allreduce(local_node_cell_count,
8240 global_node_cell_count,
8246 ierr = MPI_Exscan(local_node_cell_count,
8247 global_node_cell_offsets,
8254 global_node_cell_count[0] = local_node_cell_count[0];
8255 global_node_cell_count[1] = local_node_cell_count[1];
8256 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
8260 plist_id = H5Pcreate(H5P_DATASET_XFER);
8262# ifdef DEAL_II_WITH_MPI
8263# ifdef H5_HAVE_PARALLEL
8264 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
8269 if (write_mesh_file)
8272 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(),
8280 node_ds_dim[0] = global_node_cell_count[0];
8281 node_ds_dim[1] = (spacedim < 2) ? 2 : spacedim;
8282 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8285 cell_ds_dim[0] = global_node_cell_count[1];
8286 cell_ds_dim[1] = patches[0].reference_cell.n_vertices();
8287 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
8291# if H5Gcreate_vers == 1
8292 node_dataset = H5Dcreate(h5_mesh_file_id,
8298 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8299# ifdef DEAL_II_WITH_ZLIB
8300 H5Pset_deflate(node_dataset_id,
8302 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8304 node_dataset = H5Dcreate(h5_mesh_file_id,
8311 H5Pclose(node_dataset_id);
8314# if H5Gcreate_vers == 1
8315 cell_dataset = H5Dcreate(h5_mesh_file_id,
8321 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8322# ifdef DEAL_II_WITH_ZLIB
8323 H5Pset_deflate(node_dataset_id,
8325 H5Pset_chunk(node_dataset_id, 2, cell_ds_dim);
8327 cell_dataset = H5Dcreate(h5_mesh_file_id,
8334 H5Pclose(node_dataset_id);
8339 status = H5Sclose(node_dataspace);
8341 status = H5Sclose(cell_dataspace);
8346 count[0] = local_node_cell_count[0];
8347 count[1] = (spacedim < 2) ? 2 : spacedim;
8349 offset[0] = global_node_cell_offsets[0];
8352 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8356 node_file_dataspace = H5Dget_space(node_dataset);
8358 status = H5Sselect_hyperslab(
8359 node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8363 count[0] = local_node_cell_count[1];
8364 count[1] = patches[0].reference_cell.n_vertices();
8365 offset[0] = global_node_cell_offsets[1];
8367 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8370 cell_file_dataspace = H5Dget_space(cell_dataset);
8372 status = H5Sselect_hyperslab(
8373 cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8378 status = H5Dwrite(node_dataset,
8380 node_memory_dataspace,
8381 node_file_dataspace,
8383 node_data_vec.data());
8385 node_data_vec.clear();
8388 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
8389 status = H5Dwrite(cell_dataset,
8391 cell_memory_dataspace,
8392 cell_file_dataspace,
8394 cell_data_vec.data());
8396 cell_data_vec.clear();
8399 status = H5Sclose(node_file_dataspace);
8401 status = H5Sclose(cell_file_dataspace);
8405 status = H5Sclose(node_memory_dataspace);
8407 status = H5Sclose(cell_memory_dataspace);
8411 status = H5Dclose(node_dataset);
8413 status = H5Dclose(cell_dataset);
8417 if (mesh_filename != solution_filename)
8419 status = H5Fclose(h5_mesh_file_id);
8425 if (mesh_filename == solution_filename && write_mesh_file)
8427 h5_solution_file_id = h5_mesh_file_id;
8432 h5_solution_file_id = H5Fcreate(solution_filename.c_str(),
8442 std::string vector_name;
8451 node_ds_dim[0] = global_node_cell_count[0];
8452 node_ds_dim[1] = pt_data_vector_dim;
8453 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8456# if H5Gcreate_vers == 1
8457 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8458 vector_name.c_str(),
8463 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8464# ifdef DEAL_II_WITH_ZLIB
8465 H5Pset_deflate(node_dataset_id,
8467 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8469 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8470 vector_name.c_str(),
8476 H5Pclose(node_dataset_id);
8481 count[0] = local_node_cell_count[0];
8482 count[1] = pt_data_vector_dim;
8483 offset[0] = global_node_cell_offsets[0];
8485 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8489 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
8491 status = H5Sselect_hyperslab(pt_data_file_dataspace,
8500 status = H5Dwrite(pt_data_dataset,
8502 pt_data_memory_dataspace,
8503 pt_data_file_dataspace,
8509 status = H5Sclose(pt_data_dataspace);
8511 status = H5Sclose(pt_data_memory_dataspace);
8513 status = H5Sclose(pt_data_file_dataspace);
8516 status = H5Dclose(pt_data_dataset);
8521 status = H5Pclose(file_plist_id);
8525 status = H5Pclose(plist_id);
8529 status = H5Fclose(h5_solution_file_id);
8537template <
int dim,
int spacedim>
8541 const std::vector<std::string> &data_names,
8543 std::tuple<
unsigned int,
8547 &nonscalar_data_ranges,
8550 const unsigned int n_data_sets = data_names.size();
8552#ifndef DEAL_II_WITH_MPI
8559 Assert(patches.size() > 0, ExcNoPatches());
8561 if (patches.empty())
8565 unsigned int n_nodes;
8566 std::tie(n_nodes, std::ignore) = count_nodes_and_cells(patches);
8581 [&patches]() {
return create_global_data_table(patches); });
8589 std::move(*create_global_data_table_task.
return_value());
8593 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
8594 std::string vector_name;
8595 for (n_th_vector = 0, data_set = 0; data_set < n_data_sets;)
8598 while (n_th_vector < nonscalar_data_ranges.size() &&
8599 std::get<0>(nonscalar_data_ranges[n_th_vector]) < data_set)
8603 if (n_th_vector < nonscalar_data_ranges.size() &&
8604 std::get<0>(nonscalar_data_ranges[n_th_vector]) == data_set)
8607 pt_data_vector_dim = std::get<1>(nonscalar_data_ranges[n_th_vector]) -
8608 std::get<0>(nonscalar_data_ranges[n_th_vector]) +
8613 std::get<1>(nonscalar_data_ranges[n_th_vector]) >=
8614 std::get<0>(nonscalar_data_ranges[n_th_vector]),
8615 ExcLowerRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8616 std::get<0>(nonscalar_data_ranges[n_th_vector])));
8618 std::get<1>(nonscalar_data_ranges[n_th_vector]) < n_data_sets,
8619 ExcIndexRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8625 if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
8627 vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
8632 for (i = std::get<0>(nonscalar_data_ranges[n_th_vector]);
8633 i < std::get<1>(nonscalar_data_ranges[n_th_vector]);
8635 vector_name += data_names[i] +
"__";
8637 data_names[std::get<1>(nonscalar_data_ranges[n_th_vector])];
8643 pt_data_vector_dim = 1;
8644 vector_name = data_names[data_set];
8654 data_set += pt_data_vector_dim;
8660template <
int dim,
int spacedim>
8664 const std::string &filename,
8668 get_patches(), data_filter, hdf5_flags, filename,
comm);
8673template <
int dim,
int spacedim>
8677 const bool write_mesh_file,
8678 const std::string &mesh_filename,
8679 const std::string &solution_filename,
8693template <
int dim,
int spacedim>
8699 const std::string &filename,
8703 patches, data_filter, flags,
true, filename, filename,
comm);
8708template <
int dim,
int spacedim>
8714 const bool write_mesh_file,
8715 const std::string &mesh_filename,
8716 const std::string &solution_filename,
8722 "DataOutBase was asked to write HDF5 output for a space dimension of 1. "
8723 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
8725#ifndef DEAL_II_WITH_HDF5
8731 (void)write_mesh_file;
8732 (void)mesh_filename;
8733 (void)solution_filename;
8742# ifndef H5_HAVE_PARALLEL
8746 "Serial HDF5 output on multiple processes is not yet supported."));
8756 Assert((patches.size() > 0) || (n_ranks > 1), ExcNoPatches());
8763 const bool have_patches = (patches.size() > 0);
8767 const int color = (have_patches ? 1 : 0);
8768 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8774 do_write_hdf5<dim, spacedim>(patches,
8783 const int ierr = MPI_Comm_free(&split_comm);
8791template <
int dim,
int spacedim>
8799 output_format = default_fmt;
8801 switch (output_format)
8847 write_deal_II_intermediate(out);
8857template <
int dim,
int spacedim>
8866template <
int dim,
int spacedim>
8867template <
typename FlagType>
8871 if constexpr (std::is_same_v<FlagType, DataOutBase::DXFlags>)
8873 else if constexpr (std::is_same_v<FlagType, DataOutBase::UcdFlags>)
8875 else if constexpr (std::is_same_v<FlagType, DataOutBase::PovrayFlags>)
8876 povray_flags = flags;
8877 else if constexpr (std::is_same_v<FlagType, DataOutBase::EpsFlags>)
8879 else if constexpr (std::is_same_v<FlagType, DataOutBase::GmvFlags>)
8881 else if constexpr (std::is_same_v<FlagType, DataOutBase::Hdf5Flags>)
8883 else if constexpr (std::is_same_v<FlagType, DataOutBase::TecplotFlags>)
8884 tecplot_flags = flags;
8885 else if constexpr (std::is_same_v<FlagType, DataOutBase::VtkFlags>)
8887 else if constexpr (std::is_same_v<FlagType, DataOutBase::SvgFlags>)
8889 else if constexpr (std::is_same_v<FlagType, DataOutBase::GnuplotFlags>)
8890 gnuplot_flags = flags;
8891 else if constexpr (std::is_same_v<FlagType,
8893 deal_II_intermediate_flags = flags;
8900template <
int dim,
int spacedim>
8913template <
int dim,
int spacedim>
8920 "A name for the output format to be used");
8924 "Number of subdivisions of each mesh cell");
8970template <
int dim,
int spacedim>
8974 const std::string &output_name = prm.
get(
"Output format");
8976 default_subdivisions = prm.
get_integer(
"Subdivisions");
8979 dx_flags.parse_parameters(prm);
8983 ucd_flags.parse_parameters(prm);
8987 gnuplot_flags.parse_parameters(prm);
8991 povray_flags.parse_parameters(prm);
8995 eps_flags.parse_parameters(prm);
8999 gmv_flags.parse_parameters(prm);
9003 hdf5_flags.parse_parameters(prm);
9007 tecplot_flags.parse_parameters(prm);
9011 vtk_flags.parse_parameters(prm);
9015 deal_II_intermediate_flags.parse_parameters(prm);
9021template <
int dim,
int spacedim>
9025 return (
sizeof(default_fmt) +
9041template <
int dim,
int spacedim>
9043 std::tuple<
unsigned int,
9050 std::tuple<
unsigned int,
9057template <
int dim,
int spacedim>
9065 std::set<std::string> all_names;
9068 std::tuple<
unsigned int,
9072 ranges = this->get_nonscalar_data_ranges();
9073 const std::vector<std::string> data_names = this->get_dataset_names();
9074 const unsigned int n_data_sets = data_names.size();
9075 std::vector<bool> data_set_written(n_data_sets,
false);
9077 for (
const auto &range : ranges)
9079 const std::string &name = std::get<2>(range);
9082 Assert(all_names.find(name) == all_names.end(),
9084 "Error: names of fields in DataOut need to be unique, "
9086 name +
"' is used more than once."));
9087 all_names.insert(name);
9088 for (
unsigned int i = std::get<0>(range); i <= std::get<1>(range);
9090 data_set_written[i] =
true;
9094 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
9095 if (data_set_written[data_set] ==
false)
9097 const std::string &name = data_names[data_set];
9098 Assert(all_names.find(name) == all_names.end(),
9100 "Error: names of fields in DataOut need to be unique, "
9102 name +
"' is used more than once."));
9103 all_names.insert(name);
9113template <
int dim,
int spacedim>
9121 std::vector<typename ::DataOutBase::Patch<dim, spacedim>> tmp;
9125 std::vector<std::string> tmp;
9126 tmp.swap(dataset_names);
9130 std::tuple<
unsigned int,
9135 tmp.swap(nonscalar_data_ranges);
9142 std::pair<unsigned int, unsigned int> dimension_info =
9145 (dimension_info.second == spacedim),
9146 ExcIncompatibleDimensions(
9147 dimension_info.first, dim, dimension_info.second, spacedim));
9156 getline(in, header);
9158 std::ostringstream s;
9159 s <<
"[deal.II intermediate format graphics data]";
9161 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9165 getline(in, header);
9167 std::ostringstream s;
9171 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9175 getline(in, header);
9177 std::ostringstream s;
9181 Assert(header == s.str(),
9183 "Invalid or incompatible file format. Intermediate format "
9184 "files can only be read by the same deal.II version as they "
9185 "are written by."));
9189 unsigned int n_datasets;
9191 dataset_names.resize(n_datasets);
9192 for (
unsigned int i = 0; i < n_datasets; ++i)
9193 in >> dataset_names[i];
9195 unsigned int n_patches;
9197 patches.resize(n_patches);
9198 for (
unsigned int i = 0; i < n_patches; ++i)
9201 unsigned int n_nonscalar_data_ranges;
9202 in >> n_nonscalar_data_ranges;
9203 nonscalar_data_ranges.resize(n_nonscalar_data_ranges);
9204 for (
unsigned int i = 0; i < n_nonscalar_data_ranges; ++i)
9206 in >> std::get<0>(nonscalar_data_ranges[i]) >>
9207 std::get<1>(nonscalar_data_ranges[i]);
9216 std::get<2>(nonscalar_data_ranges[i]) = name;
9224template <
int dim,
int spacedim>
9230 ParallelIntermediateHeader header;
9231 in.read(
reinterpret_cast<char *
>(&header),
sizeof(header));
9233 header.magic == 0x00dea111,
9235 "Invalid header of parallel deal.II intermediate format encountered."));
9239 "Incorrect header version of parallel deal.II intermediate format."));
9241 std::vector<std::uint64_t> chunk_sizes(header.n_ranks);
9242 in.read(
reinterpret_cast<char *
>(chunk_sizes.data()),
9243 header.n_ranks *
sizeof(std::uint64_t));
9245 for (
unsigned int n = 0; n < header.n_ranks; ++n)
9249 std::vector<char> temp_buffer(chunk_sizes[n]);
9250 in.read(temp_buffer.data(), chunk_sizes[n]);
9253 header.compression) !=
9257 boost::iostreams::filtering_istreambuf f;
9260#ifdef DEAL_II_WITH_ZLIB
9261 f.push(boost::iostreams::zlib_decompressor());
9266 "Decompression requires deal.II to be configured with ZLIB support."));
9269 boost::iostreams::basic_array_source<char> source(temp_buffer.data(),
9270 temp_buffer.size());
9273 std::stringstream datastream;
9274 boost::iostreams::copy(f, datastream);
9284 temp_reader.
read(datastream);
9292template <
int dim,
int spacedim>
9296 using Patch = typename ::DataOutBase::Patch<dim, spacedim>;
9299 const std::vector<Patch> &source_patches = source.
get_patches();
9304 ExcIncompatibleDatasetNames());
9309 ExcMessage(
"Both sources need to declare the same components "
9311 for (
unsigned int i = 0; i < get_nonscalar_data_ranges().size(); ++i)
9313 Assert(std::get<0>(get_nonscalar_data_ranges()[i]) ==
9315 ExcMessage(
"Both sources need to declare the same components "
9317 Assert(std::get<1>(get_nonscalar_data_ranges()[i]) ==
9319 ExcMessage(
"Both sources need to declare the same components "
9321 Assert(std::get<2>(get_nonscalar_data_ranges()[i]) ==
9323 ExcMessage(
"Both sources need to declare the same components "
9328 Assert(patches[0].n_subdivisions == source_patches[0].n_subdivisions,
9329 ExcIncompatiblePatchLists());
9330 Assert(patches[0].
data.n_rows() == source_patches[0].data.n_rows(),
9331 ExcIncompatiblePatchLists());
9332 Assert(patches[0].
data.n_cols() == source_patches[0].data.n_cols(),
9333 ExcIncompatiblePatchLists());
9337 const unsigned int old_n_patches = patches.size();
9338 patches.insert(patches.end(), source_patches.begin(), source_patches.end());
9341 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
9342 patches[i].patch_index += old_n_patches;
9345 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
9347 if (patches[i].neighbors[n] !=
9349 patches[i].neighbors[n] += old_n_patches;
9354template <
int dim,
int spacedim>
9355const std::vector<typename ::DataOutBase::Patch<dim, spacedim>> &
9363template <
int dim,
int spacedim>
9364std::vector<std::string>
9367 return dataset_names;
9372template <
int dim,
int spacedim>
9374 std::tuple<
unsigned int,
9380 return nonscalar_data_ranges;
9389 , h5_sol_filename(
"")
9390 , h5_mesh_filename(
"")
9392 , num_nodes(
numbers::invalid_unsigned_int)
9393 , num_cells(
numbers::invalid_unsigned_int)
9394 , dimension(
numbers::invalid_unsigned_int)
9395 , space_dimension(
numbers::invalid_unsigned_int)
9403 const std::uint64_t nodes,
9404 const std::uint64_t cells,
9405 const unsigned int dim,
9407 :
XDMFEntry(filename, filename, time, nodes, cells, dim, dim, cell_type)
9413 const std::string &solution_filename,
9415 const std::uint64_t nodes,
9416 const std::uint64_t cells,
9417 const unsigned int dim,
9439 const unsigned int dimension)
9446 return ReferenceCells::get_hypercube<0>();
9448 return ReferenceCells::get_hypercube<1>();
9450 return ReferenceCells::get_hypercube<2>();
9452 return ReferenceCells::get_hypercube<3>();
9465 const std::string &solution_filename,
9467 const std::uint64_t nodes,
9468 const std::uint64_t cells,
9469 const unsigned int dim,
9470 const unsigned int spacedim,
9473 , h5_sol_filename(solution_filename)
9474 , h5_mesh_filename(mesh_filename)
9479 , space_dimension(spacedim)
9480 , cell_type(cell_type_hex_if_invalid(cell_type_, dim))
9487 const unsigned int dimension)
9500 indent(
const unsigned int indent_level)
9502 std::string res =
"";
9503 for (
unsigned int i = 0; i < indent_level; ++i)
9517 std::stringstream ss;
9519 ss << indent(indent_level + 0)
9520 <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
9521 ss << indent(indent_level + 1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
9522 ss << indent(indent_level + 1) <<
"<Geometry GeometryType=\""
9524 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
9526 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
9528 ss << indent(indent_level + 2) <<
"</DataItem>\n";
9529 ss << indent(indent_level + 1) <<
"</Geometry>\n";
9534 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\"";
9552 ss <<
"Quadrilateral";
9571 ss <<
"Tetrahedron";
9575 ss <<
"\" NumberOfElements=\"" <<
num_cells;
9577 ss <<
"\" NodesPerElement=\"1\">\n";
9579 ss <<
"\" NodesPerElement=\"2\">\n";
9584 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_cells
9586 <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
9589 ss << indent(indent_level + 2) <<
"</DataItem>\n";
9590 ss << indent(indent_level + 1) <<
"</Topology>\n";
9596 ss << indent(indent_level + 1)
9597 <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\""
9599 ss << indent(indent_level + 1) <<
"</Topology>\n";
9604 ss << indent(indent_level + 1) <<
"<Attribute Name=\""
9605 << attribute_dim.first <<
"\" AttributeType=\""
9606 << (attribute_dim.second > 1 ?
"Vector" :
"Scalar")
9607 <<
"\" Center=\"Node\">\n";
9609 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
9610 <<
" " << (attribute_dim.second > 1 ? 3 : 1)
9611 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
9613 << attribute_dim.first <<
'\n';
9614 ss << indent(indent_level + 2) <<
"</DataItem>\n";
9615 ss << indent(indent_level + 1) <<
"</Attribute>\n";
9618 ss << indent(indent_level + 0) <<
"</Grid>\n";
9627 template <
int dim,
int spacedim>
9632 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]"
9651 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
9652 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
9653 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
9654 out << patch.
data[i][j] <<
' ';
9663 template <
int dim,
int spacedim>
9675 getline(in, header);
9676 while ((header.size() != 0) && (header.back() ==
' '))
9677 header.erase(header.size() - 1);
9679 while ((header.empty()) && in);
9681 std::ostringstream s;
9682 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
9684 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9688 if constexpr (dim > 0)
9702 unsigned int n_subdivisions;
9703 in >> n_subdivisions;
9704 if constexpr (dim > 1)
9709 unsigned int n_rows, n_cols;
9710 in >> n_rows >> n_cols;
9711 patch.
data.reinit(n_rows, n_cols);
9712 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
9713 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
9714 in >> patch.
data[i][j];
9725#include "data_out_base.inst"
const double * get_data_set(const unsigned int set_num) const
std::map< unsigned int, unsigned int > filtered_points
std::string get_data_set_name(const unsigned int set_num) const
void internal_add_cell(const unsigned int cell_index, const unsigned int pt_index)
void write_cell(const unsigned int index, const unsigned int start, const std::array< unsigned int, dim > &offsets)
std::vector< unsigned int > data_set_dims
unsigned int n_nodes() const
void fill_node_data(std::vector< double > &node_data) const
std::vector< std::vector< double > > data_sets
unsigned int get_data_set_dim(const unsigned int set_num) const
void write_data_set(const std::string &name, const unsigned int dimension, const unsigned int set_num, const Table< 2, double > &data_vectors)
std::map< unsigned int, unsigned int > filtered_cells
void write_cell_single(const unsigned int index, const unsigned int start, const unsigned int n_points, const ReferenceCell &reference_cell)
std::vector< std::string > data_set_names
void fill_cell_data(const unsigned int local_node_offset, std::vector< unsigned int > &cell_data) const
void write_point(const unsigned int index, const Point< dim > &p)
unsigned int n_cells() const
DataOutBase::DataOutFilterFlags flags
Map3DPoint existing_points
unsigned int n_data_sets() const
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, const MPI_Comm comm) const
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const
void parse_parameters(ParameterHandler &prm)
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static void declare_parameters(ParameterHandler &prm)
void write_ucd(std::ostream &out) const
void write_povray(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, const MPI_Comm comm) const
std::size_t memory_consumption() const
void set_default_format(const DataOutBase::OutputFormat default_format)
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void write_gnuplot(std::ostream &out) const
void write_vtu(std::ostream &out) const
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm comm) const
void write_tecplot(std::ostream &out) const
void write_deal_II_intermediate_in_parallel(const std::string &filename, const MPI_Comm comm, const DataOutBase::CompressionLevel compression) const
void write_svg(std::ostream &out) const
void write_vtu_in_parallel(const std::string &filename, const MPI_Comm comm) const
void validate_dataset_names() const
void set_flags(const FlagType &flags)
void write_vtk(std::ostream &out) const
void write_gmv(std::ostream &out) const
std::string write_vtu_with_pvtu_record(const std::string &directory, const std::string &filename_without_extension, const unsigned int counter, const MPI_Comm mpi_communicator, const unsigned int n_digits_for_counter=numbers::invalid_unsigned_int, const unsigned int n_groups=0) const
void write_eps(std::ostream &out) const
void write_dx(std::ostream &out) const
void write_deal_II_intermediate(std::ostream &out) const
void merge(const DataOutReader< dim, spacedim > &other)
void read_whole_parallel_file(std::istream &in)
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const override
void read(std::istream &in)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
virtual std::vector< std::string > get_dataset_names() const override
void enter_subsection(const std::string &subsection, const bool create_path_if_needed=true)
long int get_integer(const std::string &entry_string) const
bool get_bool(const std::string &entry_name) const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
std::string get(const std::string &entry_string) const
double get_double(const std::string &entry_name) const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices() const
unsigned int n_vertices() const
bool is_hyper_cube() const
unsigned int vtk_linear_type() const
unsigned int vtk_vertex_to_deal_vertex(const unsigned int vertex_index) const
unsigned int vtk_quadratic_type() const
unsigned int vtk_lagrange_type() const
std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices() const
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
std::vector< RT > return_values()
internal::return_value< RT >::reference_type return_value()
std::string h5_sol_filename
std::string h5_mesh_filename
std::string get_xdmf_content(const unsigned int indent_level) const
void add_attribute(const std::string &attr_name, const unsigned int dimension)
std::map< std::string, unsigned int > attribute_dims
unsigned int space_dimension
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_PACKAGE_VERSION
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_FALLTHROUGH
#define DEAL_II_PACKAGE_NAME
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcFileNotOpen(std::string arg1)
static ::ExceptionBase & ExcNotEnoughSpaceDimensionLabels()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNoPatches()
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNeedsHDF5()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Task< RT > new_task(const std::function< RT()> &function)
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
const unsigned int my_rank
std::vector< index_type > data
DataComponentInterpretation
@ component_is_part_of_tensor
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const EpsFlags &flags, std::ostream &out)
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
void write_nodes(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_deal_II_intermediate_in_parallel(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, const std::string &filename, const MPI_Comm comm, const CompressionLevel compression)
void write_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const UcdFlags &flags, std::ostream &out)
void write_dx(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const DXFlags &flags, std::ostream &out)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_gmv(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GmvFlags &flags, std::ostream &out)
void write_data(const std::vector< Patch< dim, spacedim > > &patches, unsigned int n_data_sets, const bool double_precision, StreamType &out)
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names)
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
void write_vtu_footer(std::ostream &out)
void write_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, DataOutFilter &filtered_data)
OutputFormat parse_output_format(const std::string &format_name)
std::vector< Point< spacedim > > get_node_positions(const std::vector< Patch< dim, spacedim > > &patches)
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim > > &patches, const DataOutFilter &data_filter, const DataOutBase::Hdf5Flags &flags, const std::string &filename, const MPI_Comm comm)
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
std::string get_output_format_names()
void write_svg(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const SvgFlags &flags, std::ostream &out)
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names)
void write_high_order_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out, const bool legacy_format)
std::string default_suffix(const OutputFormat output_format)
void write_povray(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const PovrayFlags &flags, std::ostream &out)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GnuplotFlags &flags, std::ostream &out)
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags)
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Invalid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell Vertex
constexpr const ReferenceCell Line
int File_write_at_c(MPI_File fh, MPI_Offset offset, const void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
int File_write_at_all_c(MPI_File fh, MPI_Offset offset, const void *buf, MPI_Count count, MPI_Datatype datatype, MPI_Status *status)
T sum(const T &t, const MPI_Comm mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
void free_communicator(MPI_Comm mpi_communicator)
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
std::string encode_base64(const std::vector< unsigned char > &binary_input)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
unsigned int needed_digits(const unsigned int max_number)
constexpr T pow(const T base, const int iexp)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
static constexpr double PI
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
void parse_parameters(const ParameterHandler &prm)
DXFlags(const bool write_neighbors=false, const bool int_binary=false, const bool coordinates_binary=false, const bool data_binary=false)
static void declare_parameters(ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
void parse_parameters(const ParameterHandler &prm)
bool filter_duplicate_vertices
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
static void declare_parameters(ParameterHandler &prm)
static RgbValues default_color_function(const double value, const double min_value, const double max_value)
void parse_parameters(const ParameterHandler &prm)
ColorFunction color_function
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
EpsFlags(const unsigned int height_vector=0, const unsigned int color_vector=0, const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const double azimut_angle=60, const double turn_angle=30, const double z_scaling=1.0, const bool draw_mesh=true, const bool draw_cells=true, const bool shade_cells=true, const ColorFunction color_function=&default_color_function)
unsigned int color_vector
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
@ width
Scale to given width.
@ height
Scale to given height.
unsigned int height_vector
std::vector< std::string > space_dimension_labels
std::size_t memory_consumption() const
DataOutBase::CompressionLevel compression_level
Hdf5Flags(const CompressionLevel compression_level=CompressionLevel::best_speed)
static void declare_parameters(ParameterHandler &prm)
std::size_t memory_consumption() const
ReferenceCell reference_cell
static const unsigned int no_neighbor
bool operator==(const Patch &patch) const
void swap(Patch< dim, spacedim > &other_patch) noexcept
static const unsigned int space_dim
unsigned int n_subdivisions
std::array< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > vertices
bool points_are_available
std::array< unsigned int, GeometryInfo< dim >::faces_per_cell > neighbors
static void declare_parameters(ParameterHandler &prm)
PovrayFlags(const bool smooth=false, const bool bicubic_patch=false, const bool external_data=false)
void parse_parameters(const ParameterHandler &prm)
unsigned int height_vector
SvgFlags(const unsigned int height_vector=0, const int azimuth_angle=37, const int polar_angle=45, const unsigned int line_thickness=1, const bool margin=true, const bool draw_colorbar=true)
unsigned int line_thickness
std::size_t memory_consumption() const
TecplotFlags(const char *zone_name=nullptr, const double solution_time=-1.0)
void parse_parameters(const ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
UcdFlags(const bool write_preamble=false)
VtkFlags(const double time=std::numeric_limits< double >::min(), const unsigned int cycle=std::numeric_limits< unsigned int >::min(), const bool print_date_and_time=true, const CompressionLevel compression_level=CompressionLevel::best_speed, const bool write_higher_order_cells=false, const std::map< std::string, std::string > &physical_units={})
std::map< std::string, std::string > physical_units
bool write_higher_order_cells
DataOutBase::CompressionLevel compression_level
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)