41#ifdef DEAL_II_WITH_ZLIB
45#ifdef DEAL_II_WITH_HDF5
49#include <boost/iostreams/copy.hpp>
50#include <boost/iostreams/device/back_inserter.hpp>
51#include <boost/iostreams/filtering_stream.hpp>
52#ifdef DEAL_II_WITH_ZLIB
53# include <boost/iostreams/filter/zlib.hpp>
68 <<
"Unexpected input: expected line\n <" << arg1
69 <<
">\nbut got\n <" << arg2 <<
">");
71# ifdef DEAL_II_WITH_ZLIB
72 constexpr bool deal_ii_with_zlib =
true;
74 constexpr bool deal_ii_with_zlib =
false;
78# ifdef DEAL_II_WITH_ZLIB
89 return Z_NO_COMPRESSION;
93 return Z_BEST_COMPRESSION;
95 return Z_DEFAULT_COMPRESSION;
98 return Z_NO_COMPRESSION;
102# ifdef DEAL_II_WITH_MPI
113 return boost::iostreams::zlib::no_compression;
115 return boost::iostreams::zlib::best_speed;
117 return boost::iostreams::zlib::best_compression;
119 return boost::iostreams::zlib::default_compression;
122 return boost::iostreams::zlib::no_compression;
132 template <
typename T>
134 compress_array(
const std::vector<T> &data,
137# ifdef DEAL_II_WITH_ZLIB
138 if (data.size() != 0)
140 const std::size_t uncompressed_size = (data.size() *
sizeof(T));
148 std::numeric_limits<std::uint32_t>::max(),
152 auto compressed_data_length = compressBound(uncompressed_size);
154 std::numeric_limits<std::uint32_t>::max(),
157 std::vector<unsigned char> compressed_data(compressed_data_length);
159 int err = compress2(&compressed_data[0],
160 &compressed_data_length,
161 reinterpret_cast<const Bytef *
>(data.data()),
163 get_zlib_compression_level(compression_level));
168 compressed_data.resize(compressed_data_length);
171 const std::uint32_t compression_header[4] = {
173 static_cast<std::uint32_t
>(uncompressed_size),
174 static_cast<std::uint32_t
>(
176 static_cast<std::uint32_t
>(
177 compressed_data_length)};
179 const auto *
const header_start =
180 reinterpret_cast<const unsigned char *
>(&compression_header[0]);
183 {header_start, header_start + 4 *
sizeof(std::uint32_t)}) +
190 (void)compression_level;
192 ExcMessage(
"This function can only be called if cmake found "
193 "a working libz installation."));
208 template <
typename T>
210 vtu_stringize_array(
const std::vector<T> &data,
214 if (deal_ii_with_zlib &&
218 return compress_array(data, compression_level);
222 std::ostringstream stream;
223 stream.precision(precision);
224 for (
const T &el : data)
239 struct ParallelIntermediateHeader
242 std::uint64_t version;
243 std::uint64_t compression;
246 std::uint64_t n_ranks;
247 std::uint64_t n_patches;
273 Point<3> vertices[4];
284 Point<2> projected_vertices[4];
287 Point<2> projected_center;
297 SvgCell::operator<(
const SvgCell &e)
const
300 return depth >
e.depth;
316 Point<2> vertices[4];
338 EpsCell2d::operator<(
const EpsCell2d &e)
const
341 return depth >
e.depth;
357 template <
int dim,
int spacedim,
typename Number =
double>
358 std::unique_ptr<Table<2, Number>>
363 return std::make_unique<Table<2, Number>>();
372 const unsigned int n_data_sets = patches[0].points_are_available ?
373 (patches[0].data.n_rows() - spacedim) :
374 patches[0].data.n_rows();
375 const unsigned int n_data_points =
376 std::accumulate(patches.begin(),
379 [](
const unsigned int count,
381 return count + patch.data.n_cols();
384 std::unique_ptr<Table<2, Number>> global_data_table =
385 std::make_unique<Table<2, Number>>(n_data_sets, n_data_points);
388 unsigned int next_value = 0;
389 for (
const auto &patch : patches)
394 Assert((patch.data.n_rows() == n_data_sets &&
395 !patch.points_are_available) ||
396 (patch.data.n_rows() == n_data_sets + spacedim &&
397 patch.points_are_available),
399 (n_data_sets + spacedim) :
401 patch.data.n_rows()));
403 (n_data_sets == 0) ||
404 (patch.data.n_cols() ==
409 for (
unsigned int i = 0; i < patch.data.n_cols(); ++i, ++next_value)
410 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
411 (*global_data_table)[data_set][next_value] =
412 patch.data(data_set, i);
416 return global_data_table;
447 for (
unsigned int d = 0; d < dim; ++d)
451 unsigned int internal_ind;
462 internal_ind = it->second;
472 const unsigned int pt_index)
490 for (
unsigned int d = 0; d <
node_dim; ++d)
491 node_data[
node_dim * existing_point.second + d] =
492 existing_point.first[d];
500 std::vector<unsigned int> &cell_data)
const
506 cell_data[filtered_cell.first] =
507 filtered_cell.second + local_node_offset;
576 const unsigned int start,
577 const std::array<unsigned int, dim> &offsets)
581 const unsigned int base_entry =
594 const unsigned int d1 = offsets[0];
603 const unsigned int d1 = offsets[0];
604 const unsigned int d2 = offsets[1];
615 const unsigned int d1 = offsets[0];
616 const unsigned int d2 = offsets[1];
617 const unsigned int d3 = offsets[2];
639 const unsigned int start,
640 const unsigned int n_points,
645 const unsigned int base_entry = index * n_points;
647 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
649 for (
unsigned int i = 0; i < n_points; ++i)
661 const unsigned int set_num,
664 unsigned int new_dim;
683 for (
unsigned int d = 0; d < new_dim; ++d)
686 data_sets.back()[r * new_dim + d] = data_vectors(set_num + d, i);
702 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
704 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
706 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
721 template <
int dim,
int spacedim>
722 std::array<unsigned int, 3>
724 const bool write_higher_order_cells)
726 std::array<unsigned int, 3> vtk_cell_id = {
732 if (write_higher_order_cells)
735 vtk_cell_id[2] = patch.
data.n_cols();
741 patch.
data.n_cols() == 6)
745 vtk_cell_id[2] = patch.
data.n_cols();
748 patch.
data.n_cols() == 10)
752 vtk_cell_id[2] = patch.
data.n_cols();
763 vtk_cell_id[2] = patch.
data.n_cols();
782 template <
int dim,
int spacedim>
784 get_equispaced_location(
786 const std::initializer_list<unsigned int> &lattice_location,
787 const unsigned int n_subdivisions)
794 const unsigned int xstep = (dim > 0 ? *(lattice_location.begin() + 0) : 0);
795 const unsigned int ystep = (dim > 1 ? *(lattice_location.begin() + 1) : 0);
796 const unsigned int zstep = (dim > 2 ? *(lattice_location.begin() + 2) : 0);
804 unsigned int point_no = 0;
809 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
813 point_no += (n_subdivisions + 1) * ystep;
827 for (
unsigned int d = 0;
d < spacedim; ++
d)
828 node[d] = patch.
data(patch.
data.size(0) - spacedim + d, point_no);
835 if constexpr (dim == 0)
840 const double stepsize = 1. / n_subdivisions;
841 const double xfrac = xstep * stepsize;
847 const double yfrac = ystep * stepsize;
849 node += ((patch.
vertices[3] * xfrac) +
850 (patch.
vertices[2] * (1 - xfrac))) *
854 const double zfrac = zstep * stepsize;
856 node += (((patch.
vertices[5] * xfrac) +
857 (patch.
vertices[4] * (1 - xfrac))) *
860 (patch.
vertices[6] * (1 - xfrac))) *
873 template <
int dim,
int spacedim>
876 const unsigned int node_index)
881 unsigned int point_no_actual = node_index;
886 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
887 point_no_actual = table[node_index];
895 for (
unsigned int d = 0;
d < spacedim; ++
d)
897 patch.
data(patch.
data.size(0) - spacedim + d, point_no_actual);
910 return patch.
vertices[point_no_actual];
921 template <
int dim,
int spacedim>
922 std::tuple<unsigned int, unsigned int>
923 count_nodes_and_cells(
926 unsigned int n_nodes = 0;
928 for (
const auto &patch : patches)
932 "The reference cell for this patch is set to 'Invalid', "
933 "but that is clearly not a valid choice. Did you forget "
934 "to set the reference cell for the patch?"));
949 return std::make_tuple(n_nodes, n_cells);
959 template <
int dim,
int spacedim>
960 std::tuple<unsigned int, unsigned int, unsigned int>
961 count_nodes_and_cells_and_points(
963 const bool write_higher_order_cells)
965 unsigned int n_nodes = 0;
967 unsigned int n_points_and_n_cells = 0;
969 for (
const auto &patch : patches)
975 if (write_higher_order_cells)
981 n_points_and_n_cells +=
990 const unsigned int n_subcells =
993 n_points_and_n_cells +=
999 n_nodes += patch.
data.n_cols();
1001 n_points_and_n_cells += patch.
data.n_cols() + 1;
1005 return std::make_tuple(n_nodes, n_cells, n_points_and_n_cells);
1013 template <
typename FlagsType>
1020 StreamBase(std::ostream &stream,
const FlagsType &flags)
1032 write_point(
const unsigned int,
const Point<dim> &)
1035 ExcMessage(
"The derived class you are using needs to "
1036 "reimplement this function if you want to call "
1056 write_cell(
const unsigned int ,
1057 const unsigned int ,
1058 std::array<unsigned int, dim> & )
1061 ExcMessage(
"The derived class you are using needs to "
1062 "reimplement this function if you want to call "
1073 write_cell_single(
const unsigned int index,
1074 const unsigned int start,
1075 const unsigned int n_points,
1076 const ReferenceCell &reference_cell)
1081 (void)reference_cell;
1084 ExcMessage(
"The derived class you are using needs to "
1085 "reimplement this function if you want to call "
1103 template <
typename T>
1117 unsigned int selected_component;
1124 std::ostream &stream;
1129 const FlagsType flags;
1135 class DXStream :
public StreamBase<DataOutBase::DXFlags>
1138 DXStream(std::ostream &stream,
const DataOutBase::DXFlags &flags);
1142 write_point(
const unsigned int index,
const Point<dim> &);
1154 write_cell(
const unsigned int index,
1155 const unsigned int start,
1156 const std::array<unsigned int, dim> &offsets);
1164 template <
typename data>
1166 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1172 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
1175 GmvStream(std::ostream &stream,
const DataOutBase::GmvFlags &flags);
1179 write_point(
const unsigned int index,
const Point<dim> &);
1191 write_cell(
const unsigned int index,
1192 const unsigned int start,
1193 const std::array<unsigned int, dim> &offsets);
1199 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
1202 TecplotStream(std::ostream &stream,
const DataOutBase::TecplotFlags &flags);
1206 write_point(
const unsigned int index,
const Point<dim> &);
1218 write_cell(
const unsigned int index,
1219 const unsigned int start,
1220 const std::array<unsigned int, dim> &offsets);
1226 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1229 UcdStream(std::ostream &stream,
const DataOutBase::UcdFlags &flags);
1233 write_point(
const unsigned int index,
const Point<dim> &);
1247 write_cell(
const unsigned int index,
1248 const unsigned int start,
1249 const std::array<unsigned int, dim> &offsets);
1257 template <
typename data>
1259 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1265 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1268 VtkStream(std::ostream &stream,
const DataOutBase::VtkFlags &flags);
1272 write_point(
const unsigned int index,
const Point<dim> &);
1284 write_cell(
const unsigned int index,
1285 const unsigned int start,
1286 const std::array<unsigned int, dim> &offsets);
1292 write_cell_single(
const unsigned int index,
1293 const unsigned int start,
1294 const unsigned int n_points,
1295 const ReferenceCell &reference_cell);
1306 write_high_order_cell(
const unsigned int start,
1307 const std::vector<unsigned> &connectivity);
1320 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1322 if (flags.coordinates_binary)
1325 for (
unsigned int d = 0;
d < dim; ++
d)
1327 stream.write(
reinterpret_cast<const char *
>(data), dim *
sizeof(*data));
1331 for (
unsigned int d = 0;
d < dim; ++
d)
1332 stream << p[d] <<
'\t';
1346 std::array<unsigned int, GeometryInfo<0>::vertices_per_cell>
1347 set_node_numbers(
const unsigned int ,
1348 const std::array<unsigned int, 0> & )
1356 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
1357 set_node_numbers(
const unsigned int start,
1358 const std::array<unsigned int, 1> &offsets)
1360 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
1362 nodes[1] = start + offsets[0];
1368 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
1369 set_node_numbers(
const unsigned int start,
1370 const std::array<unsigned int, 2> &offsets)
1373 const unsigned int d1 = offsets[0];
1374 const unsigned int d2 = offsets[1];
1376 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
1378 nodes[1] = start + d1;
1379 nodes[2] = start + d2;
1380 nodes[3] = start + d2 + d1;
1386 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
1387 set_node_numbers(
const unsigned int start,
1388 const std::array<unsigned int, 3> &offsets)
1390 const unsigned int d1 = offsets[0];
1391 const unsigned int d2 = offsets[1];
1392 const unsigned int d3 = offsets[2];
1394 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
1396 nodes[1] = start + d1;
1397 nodes[2] = start + d2;
1398 nodes[3] = start + d2 + d1;
1399 nodes[4] = start + d3;
1400 nodes[5] = start + d3 + d1;
1401 nodes[6] = start + d3 + d2;
1402 nodes[7] = start + d3 + d2 + d1;
1411 DXStream::write_cell(
const unsigned int,
1412 const unsigned int start,
1413 const std::array<unsigned int, dim> &offsets)
1416 DataOutBaseImplementation::set_node_numbers(start, offsets);
1418 if (flags.int_binary)
1420 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell> temp;
1421 for (
unsigned int i = 0; i < nodes.size(); ++i)
1423 stream.write(
reinterpret_cast<const char *
>(temp.data()),
1424 temp.size() *
sizeof(temp[0]));
1428 for (
unsigned int i = 0; i < nodes.size() - 1; ++i)
1430 stream << nodes[GeometryInfo<dim>::dx_to_deal[nodes.size() - 1]]
1437 template <
typename data>
1439 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &values)
1441 if (flags.data_binary)
1443 stream.write(
reinterpret_cast<const char *
>(
values.data()),
1444 values.size() *
sizeof(data));
1448 for (
unsigned int i = 0; i <
values.size(); ++i)
1449 stream <<
'\t' << values[i];
1458 GmvStream::GmvStream(std::ostream &out,
const DataOutBase::GmvFlags &f)
1459 : StreamBase<DataOutBase::
GmvFlags>(out, f)
1465 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1469 stream << p[selected_component] <<
' ';
1476 GmvStream::write_cell(
const unsigned int,
1477 const unsigned int s,
1478 const std::array<unsigned int, dim> &offsets)
1481 const unsigned int start = s + 1;
1482 stream << gmv_cell_type[dim] <<
'\n';
1494 const unsigned int d1 = offsets[0];
1496 stream <<
'\t' << start + d1;
1502 const unsigned int d1 = offsets[0];
1503 const unsigned int d2 = offsets[1];
1505 stream <<
'\t' << start + d1;
1506 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1512 const unsigned int d1 = offsets[0];
1513 const unsigned int d2 = offsets[1];
1514 const unsigned int d3 = offsets[2];
1516 stream <<
'\t' << start + d1;
1517 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1518 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1519 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1531 TecplotStream::TecplotStream(std::ostream &out,
1532 const DataOutBase::TecplotFlags &f)
1533 : StreamBase<DataOutBase::TecplotFlags>(out, f)
1539 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1543 stream << p[selected_component] <<
'\n';
1550 TecplotStream::write_cell(
const unsigned int,
1551 const unsigned int s,
1552 const std::array<unsigned int, dim> &offsets)
1554 const unsigned int start = s + 1;
1566 const unsigned int d1 = offsets[0];
1568 stream <<
'\t' << start + d1;
1574 const unsigned int d1 = offsets[0];
1575 const unsigned int d2 = offsets[1];
1577 stream <<
'\t' << start + d1;
1578 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1584 const unsigned int d1 = offsets[0];
1585 const unsigned int d2 = offsets[1];
1586 const unsigned int d3 = offsets[2];
1588 stream <<
'\t' << start + d1;
1589 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1590 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1591 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1603 UcdStream::UcdStream(std::ostream &out,
const DataOutBase::UcdFlags &f)
1604 : StreamBase<DataOutBase::UcdFlags>(out, f)
1610 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1612 stream <<
index + 1 <<
" ";
1614 for (
unsigned int i = 0; i < dim; ++i)
1615 stream << p[i] <<
' ';
1617 for (
unsigned int i = dim; i < 3; ++i)
1626 UcdStream::write_cell(
const unsigned int index,
1627 const unsigned int start,
1628 const std::array<unsigned int, dim> &offsets)
1631 DataOutBaseImplementation::set_node_numbers(start, offsets);
1634 stream <<
index + 1 <<
"\t0 " << ucd_cell_type[dim];
1635 for (
unsigned int i = 0; i < nodes.size(); ++i)
1642 template <
typename data>
1644 UcdStream::write_dataset(
const unsigned int index,
1645 const std::vector<data> &values)
1647 stream <<
index + 1;
1648 for (
unsigned int i = 0; i <
values.size(); ++i)
1649 stream <<
'\t' << values[i];
1657 VtkStream::VtkStream(std::ostream &out,
const DataOutBase::VtkFlags &f)
1658 : StreamBase<DataOutBase::VtkFlags>(out, f)
1664 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1669 for (
unsigned int i = dim; i < 3; ++i)
1678 VtkStream::write_cell(
const unsigned int,
1679 const unsigned int start,
1680 const std::array<unsigned int, dim> &offsets)
1682 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t';
1694 const unsigned int d1 = offsets[0];
1696 stream <<
'\t' << start + d1;
1702 const unsigned int d1 = offsets[0];
1703 const unsigned int d2 = offsets[1];
1705 stream <<
'\t' << start + d1;
1706 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1712 const unsigned int d1 = offsets[0];
1713 const unsigned int d2 = offsets[1];
1714 const unsigned int d3 = offsets[2];
1716 stream <<
'\t' << start + d1;
1717 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1718 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1719 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1732 VtkStream::write_cell_single(
const unsigned int index,
1733 const unsigned int start,
1734 const unsigned int n_points,
1735 const ReferenceCell &reference_cell)
1739 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1741 stream <<
'\t' << n_points;
1742 for (
unsigned int i = 0; i < n_points; ++i)
1751 VtkStream::write_high_order_cell(
const unsigned int start,
1752 const std::vector<unsigned> &connectivity)
1754 stream << connectivity.size();
1755 for (
const auto &c : connectivity)
1756 stream <<
'\t' << start + c;
1763namespace DataOutBase
1765 const unsigned int Deal_II_IntermediateFlags::format_version = 4;
1768 template <
int dim,
int spacedim>
1772 template <
int dim,
int spacedim>
1776 template <
int dim,
int spacedim>
1794 template <
int dim,
int spacedim>
1802 const double epsilon = 3e-16;
1820 if (
data.n_rows() != patch.
data.n_rows())
1823 if (
data.n_cols() != patch.
data.n_cols())
1826 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1827 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1828 if (
data[i][j] != patch.
data[i][j])
1836 template <
int dim,
int spacedim>
1853 template <
int dim,
int spacedim>
1857 std::swap(
vertices, other_patch.vertices);
1858 std::swap(
neighbors, other_patch.neighbors);
1861 data.swap(other_patch.data);
1868 template <
int spacedim>
1872 template <
int spacedim>
1876 template <
int spacedim>
1880 template <
int spacedim>
1883 template <
int spacedim>
1887 template <
int spacedim>
1897 template <
int spacedim>
1901 const unsigned int dim = 0;
1904 const double epsilon = 3e-16;
1915 if (
data.n_rows() != patch.
data.n_rows())
1918 if (
data.n_cols() != patch.
data.n_cols())
1921 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1922 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1923 if (
data[i][j] != patch.
data[i][j])
1931 template <
int spacedim>
1943 template <
int spacedim>
1947 std::swap(
vertices, other_patch.vertices);
1949 data.swap(other_patch.data);
2004 "Filter duplicate vertices",
2007 "Whether to remove duplicate vertex values. deal.II duplicates "
2008 "vertices once for each adjacent cell so that it can output "
2009 "discontinuous quantities for which there may be more than one "
2010 "value for each vertex position. Setting this flag to "
2011 "'true' will merge all of these values by selecting a "
2012 "random one and outputting this as 'the' value for the vertex. "
2013 "As long as the data to be output corresponds to continuous "
2014 "fields, merging vertices has no effect. On the other hand, "
2015 "if the data to be output corresponds to discontinuous fields "
2016 "(either because you are using a discontinuous finite element, "
2017 "or because you are using a DataPostprocessor that yields "
2018 "discontinuous data, or because the data to be output has been "
2019 "produced by entirely different means), then the data in the "
2020 "output file no longer faithfully represents the underlying data "
2021 "because the discontinuous field has been replaced by a "
2022 "continuous one. Note also that the filtering can not occur "
2023 "on processor boundaries. Thus, a filtered discontinuous field "
2024 "looks like a continuous field inside of a subdomain, "
2025 "but like a discontinuous field at the subdomain boundary."
2027 "In any case, filtering results in drastically smaller output "
2028 "files (smaller by about a factor of 2^dim).");
2033 "Whether the data will be used in an XDMF/HDF5 combination.");
2065 "A boolean field indicating whether neighborship "
2066 "information between cells is to be written to the "
2067 "OpenDX output file");
2071 "Output format of integer numbers, which is "
2072 "either a text representation (ascii) or binary integer "
2073 "values of 32 or 64 bits length");
2077 "Output format of vertex coordinates, which is "
2078 "either a text representation (ascii) or binary "
2079 "floating point values of 32 or 64 bits length");
2083 "Output format of data values, which is "
2084 "either a text representation (ascii) or binary "
2085 "floating point values of 32 or 64 bits length");
2105 "A flag indicating whether a comment should be "
2106 "written to the beginning of the output file "
2107 "indicating date and time of creation as well "
2108 "as the creating program");
2145 "A flag indicating whether POVRAY should use smoothed "
2146 "triangles instead of the usual ones");
2150 "Whether POVRAY should use bicubic patches");
2154 "Whether camera and lighting information should "
2155 "be put into an external file \"data.inc\" or into "
2156 "the POVRAY input file");
2174 const unsigned int size,
2233 double sum = xmax + xmin;
2234 double sum13 = xmin + 3 * xmax;
2235 double sum22 = 2 * xmin + 2 * xmax;
2236 double sum31 = 3 * xmin + xmax;
2237 double dif = xmax - xmin;
2238 double rezdif = 1.0 / dif;
2242 if (x < (sum31) / 4)
2244 else if (x < (sum22) / 4)
2246 else if (x < (sum13) / 4)
2257 rgb_values.
green = 0;
2258 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2262 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2263 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2266 rgb_values.
red = (4 * x - 2 * sum) * rezdif;
2267 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2268 rgb_values.
blue = 0;
2272 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2273 rgb_values.
blue = (4. * x - sum13) * rezdif;
2280 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2294 (x - xmin) / (xmax - xmin);
2307 1 - (x - xmin) / (xmax - xmin);
2319 "Number of the input vector that is to be used to "
2320 "generate height information");
2324 "Number of the input vector that is to be used to "
2325 "generate color information");
2329 "Whether width or height should be scaled to match "
2334 "The size (width or height) to which the eps output "
2335 "file is to be scaled");
2339 "The width in which the postscript renderer is to "
2344 "Angle of the viewing position against the vertical "
2349 "Angle of the viewing direction against the y-axis");
2353 "Scaling for the z-direction relative to the scaling "
2354 "used in x- and y-directions");
2358 "Whether the mesh lines, or only the surface should be "
2363 "Whether only the mesh lines, or also the interior of "
2364 "cells should be plotted. If this flag is false, then "
2365 "one can see through the mesh");
2369 "Whether the interior of cells shall be shaded");
2373 "default|grey scale|reverse grey scale"),
2374 "Name of a color function used to colorize mesh lines "
2375 "and/or cell interiors");
2385 if (prm.
get(
"Scale to width or height") ==
"width")
2397 if (prm.
get(
"Color function") ==
"default")
2399 else if (prm.
get(
"Color function") ==
"grey scale")
2401 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2431 const unsigned int cycle,
2449 if (format_name ==
"none")
2452 if (format_name ==
"dx")
2455 if (format_name ==
"ucd")
2458 if (format_name ==
"gnuplot")
2461 if (format_name ==
"povray")
2464 if (format_name ==
"eps")
2467 if (format_name ==
"gmv")
2470 if (format_name ==
"tecplot")
2473 if (format_name ==
"vtk")
2476 if (format_name ==
"vtu")
2479 if (format_name ==
"deal.II intermediate")
2482 if (format_name ==
"hdf5")
2486 ExcMessage(
"The given file format name is not recognized: <" +
2487 format_name +
">"));
2498 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|vtk|vtu|hdf5|svg|deal.II intermediate";
2506 switch (output_format)
2548 template <
int dim,
int spacedim>
2549 std::vector<Point<spacedim>>
2553 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
2555 std::vector<Point<spacedim>> node_positions;
2556 for (
const auto &patch : patches)
2561 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2563 node_positions.emplace_back(get_node_location(
2577 node_positions.emplace_back(
2581 for (
unsigned int i1 = 0; i1 < n; ++i1)
2582 node_positions.emplace_back(
2586 for (
unsigned int i2 = 0; i2 < n; ++i2)
2587 for (
unsigned int i1 = 0; i1 < n; ++i1)
2588 node_positions.emplace_back(get_equispaced_location(
2592 for (
unsigned int i3 = 0; i3 < n; ++i3)
2593 for (
unsigned int i2 = 0; i2 < n; ++i2)
2594 for (
unsigned int i1 = 0; i1 < n; ++i1)
2595 node_positions.emplace_back(get_equispaced_location(
2605 return node_positions;
2609 template <
int dim,
int spacedim,
typename StreamType>
2615 const std::vector<Point<spacedim>> node_positions =
2619 for (
const auto &node : node_positions)
2620 out.write_point(count++, node);
2626 template <
int dim,
int spacedim,
typename StreamType>
2631 unsigned int count = 0;
2632 unsigned int first_vertex_of_patch = 0;
2633 for (
const auto &patch : patches)
2638 out.write_cell_single(count++,
2639 first_vertex_of_patch,
2640 patch.
data.n_cols(),
2642 first_vertex_of_patch += patch.
data.n_cols();
2653 const unsigned int offset = first_vertex_of_patch;
2654 out.template write_cell<0>(count++, offset, {});
2660 constexpr unsigned int d1 = 1;
2664 const unsigned int offset =
2665 first_vertex_of_patch + i1 * d1;
2666 out.template write_cell<1>(count++, offset, {{d1}});
2674 constexpr unsigned int d1 = 1;
2675 const unsigned int d2 = n;
2680 const unsigned int offset =
2681 first_vertex_of_patch + i2 * d2 + i1 * d1;
2682 out.template write_cell<2>(count++,
2692 constexpr unsigned int d1 = 1;
2693 const unsigned int d2 = n;
2694 const unsigned int d3 = n * n;
2700 const unsigned int offset = first_vertex_of_patch +
2703 out.template write_cell<3>(count++,
2715 first_vertex_of_patch +=
2725 template <
int dim,
int spacedim,
typename StreamType>
2729 const bool legacy_format)
2731 unsigned int first_vertex_of_patch = 0;
2733 std::vector<unsigned> connectivity;
2735 for (
const auto &patch : patches)
2739 connectivity.resize(patch.
data.n_cols());
2741 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2742 connectivity[i] = i;
2744 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2747 first_vertex_of_patch += patch.
data.n_cols();
2761 ExcMessage(
"Point-like cells should not be possible "
2762 "when writing higher-order cells."));
2769 const unsigned int local_index = i1;
2770 const unsigned int connectivity_index =
2772 .template vtk_lexicographic_to_node_index<1>(
2774 connectivity[connectivity_index] = local_index;
2784 const unsigned int local_index = i2 * n + i1;
2785 const unsigned int connectivity_index =
2787 .template vtk_lexicographic_to_node_index<2>(
2791 connectivity[connectivity_index] = local_index;
2802 const unsigned int local_index =
2803 i3 * n * n + i2 * n + i1;
2804 const unsigned int connectivity_index =
2806 .template vtk_lexicographic_to_node_index<3>(
2812 connectivity[connectivity_index] = local_index;
2823 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2835 template <
int dim,
int spacedim,
typename StreamType>
2838 unsigned int n_data_sets,
2839 const bool double_precision,
2843 unsigned int count = 0;
2845 for (
const auto &patch : patches)
2850 Assert((patch.
data.n_rows() == n_data_sets &&
2852 (patch.
data.n_rows() == n_data_sets + spacedim &&
2855 (n_data_sets + spacedim) :
2857 patch.
data.n_rows()));
2861 std::vector<float> floats(n_data_sets);
2862 std::vector<double> doubles(n_data_sets);
2865 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2867 if (double_precision)
2869 for (
unsigned int data_set = 0; data_set < n_data_sets;
2871 doubles[data_set] = patch.
data(data_set, i);
2872 out.write_dataset(count, doubles);
2876 for (
unsigned int data_set = 0; data_set < n_data_sets;
2878 floats[data_set] = patch.
data(data_set, i);
2879 out.write_dataset(count, floats);
2897 svg_project_point(Point<3>
point,
2898 Point<3> camera_position,
2899 Point<3> camera_direction,
2900 Point<3> camera_horizontal,
2903 Point<3> camera_vertical;
2904 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
2905 camera_horizontal[2] * camera_direction[1];
2906 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
2907 camera_horizontal[0] * camera_direction[2];
2908 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
2909 camera_horizontal[1] * camera_direction[0];
2913 phi /= (
point[0] - camera_position[0]) * camera_direction[0] +
2914 (
point[1] - camera_position[1]) * camera_direction[1] +
2915 (
point[2] - camera_position[2]) * camera_direction[2];
2917 Point<3> projection;
2919 camera_position[0] + phi * (point[0] - camera_position[0]);
2921 camera_position[1] + phi * (point[1] - camera_position[1]);
2923 camera_position[2] + phi * (point[2] - camera_position[2]);
2926 projection_decomposition[0] = (projection[0] - camera_position[0] -
2927 camera_focus * camera_direction[0]) *
2928 camera_horizontal[0];
2929 projection_decomposition[0] += (projection[1] - camera_position[1] -
2930 camera_focus * camera_direction[1]) *
2931 camera_horizontal[1];
2932 projection_decomposition[0] += (projection[2] - camera_position[2] -
2933 camera_focus * camera_direction[2]) *
2934 camera_horizontal[2];
2936 projection_decomposition[1] = (projection[0] - camera_position[0] -
2937 camera_focus * camera_direction[0]) *
2939 projection_decomposition[1] += (projection[1] - camera_position[1] -
2940 camera_focus * camera_direction[1]) *
2942 projection_decomposition[1] += (projection[2] - camera_position[2] -
2943 camera_focus * camera_direction[2]) *
2946 return projection_decomposition;
2955 svg_get_gradient_parameters(
Point<3> points[])
2961 for (
int i = 0; i < 2; ++i)
2963 for (
int j = 0; j < 2 - i; ++j)
2965 if (points[j][2] > points[j + 1][2])
2968 points[j] = points[j + 1];
2969 points[j + 1] = temp;
2976 v_inter = points[1];
2983 A[0][0] = v_max[0] - v_min[0];
2984 A[0][1] = v_inter[0] - v_min[0];
2985 A[1][0] = v_max[1] - v_min[1];
2986 A[1][1] = v_inter[1] - v_min[1];
2992 bool col_change =
false;
3001 double temp = A[1][0];
3006 for (
unsigned int k = 0; k < 1; ++k)
3008 for (
unsigned int i = k + 1; i < 2; ++i)
3010 x = A[i][k] / A[k][k];
3012 for (
unsigned int j = k + 1; j < 2; ++j)
3013 A[i][j] = A[i][j] - A[k][j] * x;
3015 b[i] = b[i] - b[k] * x;
3019 b[1] =
b[1] /
A[1][1];
3021 for (
int i = 0; i >= 0; i--)
3025 for (
unsigned int j = i + 1; j < 2; ++j)
3026 sum = sum - A[i][j] * b[j];
3028 b[i] = sum / A[i][i];
3038 double c = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) +
3042 A[0][0] = v_max[0] - v_min[0];
3043 A[0][1] = v_inter[0] - v_min[0];
3044 A[1][0] = v_max[1] - v_min[1];
3045 A[1][1] = v_inter[1] - v_min[1];
3047 b[0] = 1.0 - v_min[0];
3059 double temp = A[1][0];
3064 for (
unsigned int k = 0; k < 1; ++k)
3066 for (
unsigned int i = k + 1; i < 2; ++i)
3068 x = A[i][k] / A[k][k];
3070 for (
unsigned int j = k + 1; j < 2; ++j)
3071 A[i][j] = A[i][j] - A[k][j] * x;
3073 b[i] = b[i] - b[k] * x;
3077 b[1] =
b[1] /
A[1][1];
3079 for (
int i = 0; i >= 0; i--)
3083 for (
unsigned int j = i + 1; j < 2; ++j)
3084 sum = sum - A[i][j] * b[j];
3086 b[i] = sum / A[i][i];
3096 gradient[0] = b[0] * (v_max[2] - v_min[2]) +
3097 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3100 A[0][0] = v_max[0] - v_min[0];
3101 A[0][1] = v_inter[0] - v_min[0];
3102 A[1][0] = v_max[1] - v_min[1];
3103 A[1][1] = v_inter[1] - v_min[1];
3106 b[1] = 1.0 - v_min[1];
3117 double temp = A[1][0];
3122 for (
unsigned int k = 0; k < 1; ++k)
3124 for (
unsigned int i = k + 1; i < 2; ++i)
3126 x =
A[i][k] /
A[k][k];
3128 for (
unsigned int j = k + 1; j < 2; ++j)
3129 A[i][j] = A[i][j] - A[k][j] * x;
3131 b[i] =
b[i] -
b[k] * x;
3135 b[1] =
b[1] /
A[1][1];
3137 for (
int i = 0; i >= 0; i--)
3141 for (
unsigned int j = i + 1; j < 2; ++j)
3142 sum = sum - A[i][j] * b[j];
3144 b[i] =
sum /
A[i][i];
3154 gradient[1] =
b[0] * (v_max[2] - v_min[2]) +
3155 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3161 gradient[1] * (v_min[1] - v_max[1]);
3163 Point<6> gradient_parameters;
3165 gradient_parameters[0] = v_min[0];
3166 gradient_parameters[1] = v_min[1];
3171 gradient_parameters[4] = v_min[2];
3172 gradient_parameters[5] = v_max[2];
3174 return gradient_parameters;
3180 template <
int dim,
int spacedim>
3184 const std::vector<std::string> &data_names,
3186 std::tuple<
unsigned int,
3199#ifndef DEAL_II_WITH_MPI
3208 if (patches.empty())
3212 const unsigned int n_data_sets = data_names.size();
3214 UcdStream ucd_out(out, flags);
3217 unsigned int n_nodes;
3218 unsigned int n_cells;
3219 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
3225 <<
"# This file was generated by the deal.II library." <<
'\n'
3229 <<
"# For a description of the UCD format see the AVS Developer's guide."
3235 out << n_nodes <<
' ' << n_cells <<
' ' << n_data_sets <<
' ' << 0
3248 if (n_data_sets != 0)
3250 out << n_data_sets <<
" ";
3251 for (
unsigned int i = 0; i < n_data_sets; ++i)
3256 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3257 out << data_names[data_set]
3261 write_data(patches, n_data_sets,
true, ucd_out);
3271 template <
int dim,
int spacedim>
3275 const std::vector<std::string> &data_names,
3277 std::tuple<
unsigned int,
3289#ifndef DEAL_II_WITH_MPI
3298 if (patches.empty())
3302 DXStream dx_out(out, flags);
3305 unsigned int offset = 0;
3307 const unsigned int n_data_sets = data_names.size();
3310 unsigned int n_nodes;
3311 unsigned int n_cells;
3312 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
3315 out <<
"object \"vertices\" class array type float rank 1 shape "
3316 << spacedim <<
" items " << n_nodes;
3320 out <<
" lsb ieee data 0" <<
'\n';
3321 offset += n_nodes * spacedim *
sizeof(float);
3325 out <<
" data follows" <<
'\n';
3334 out <<
"object \"cells\" class array type int rank 1 shape "
3339 out <<
" lsb binary data " << offset <<
'\n';
3340 offset += n_cells *
sizeof(
int);
3344 out <<
" data follows" <<
'\n';
3350 out <<
"attribute \"element type\" string \"";
3351 if constexpr (dim == 1)
3353 else if constexpr (dim == 2)
3355 else if constexpr (dim == 3)
3357 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3364 out <<
"object \"neighbors\" class array type int rank 1 shape "
3368 for (
const auto &patch : patches)
3371 const unsigned int n1 = (dim > 0) ? n : 1;
3372 const unsigned int n2 = (dim > 1) ? n : 1;
3373 const unsigned int n3 = (dim > 2) ? n : 1;
3374 const unsigned int x_minus = (dim > 0) ? 0 : 0;
3375 const unsigned int x_plus = (dim > 0) ? 1 : 0;
3376 const unsigned int y_minus = (dim > 1) ? 2 : 0;
3377 const unsigned int y_plus = (dim > 1) ? 3 : 0;
3378 const unsigned int z_minus = (dim > 2) ? 4 : 0;
3379 const unsigned int z_plus = (dim > 2) ? 5 : 0;
3381 unsigned int dx = 1;
3382 unsigned int dy = n;
3383 unsigned int dz = n * n;
3385 const unsigned int patch_start =
3388 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3389 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3390 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3392 const unsigned int nx = i1 *
dx;
3393 const unsigned int ny = i2 * dy;
3394 const unsigned int nz = i3 * dz;
3406 const unsigned int nn = patch.
neighbors[x_minus];
3410 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3416 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3421 const unsigned int nn = patch.
neighbors[x_plus];
3424 out << (nn * cells_per_patch + ny + nz);
3430 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3437 const unsigned int nn = patch.
neighbors[y_minus];
3441 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3447 out <<
'\t' << patch_start + nx + ny - dy + nz;
3452 const unsigned int nn = patch.
neighbors[y_plus];
3455 out << (nn * cells_per_patch + nx + nz);
3461 out <<
'\t' << patch_start + nx + ny + dy + nz;
3469 const unsigned int nn = patch.
neighbors[z_minus];
3473 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3479 out <<
'\t' << patch_start + nx + ny + nz - dz;
3484 const unsigned int nn = patch.
neighbors[z_plus];
3487 out << (nn * cells_per_patch + nx + ny);
3493 out <<
'\t' << patch_start + nx + ny + nz + dz;
3501 if (n_data_sets != 0)
3503 out <<
"object \"data\" class array type float rank 1 shape "
3504 << n_data_sets <<
" items " << n_nodes;
3508 out <<
" lsb ieee data " << offset <<
'\n';
3509 offset += n_data_sets * n_nodes *
3510 ((flags.
data_double) ?
sizeof(double) :
sizeof(float));
3514 out <<
" data follows" <<
'\n';
3519 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3523 out <<
"object \"data\" class constantarray type float rank 0 items "
3524 << n_nodes <<
" data follows" <<
'\n'
3530 out <<
"object \"deal data\" class field" <<
'\n'
3531 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3532 <<
"component \"connections\" value \"cells\"" <<
'\n'
3533 <<
"component \"data\" value \"data\"" <<
'\n';
3536 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3543 out <<
"end" <<
'\n';
3561 template <
int dim,
int spacedim>
3565 const std::vector<std::string> &data_names,
3567 std::tuple<
unsigned int,
3576#ifndef DEAL_II_WITH_MPI
3586 if (patches.empty())
3590 const unsigned int n_data_sets = data_names.size();
3594 out <<
"# This file was generated by the deal.II library." <<
'\n'
3598 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3605 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3610 for (
const auto &data_name : data_names)
3611 out <<
'<' << data_name <<
"> ";
3617 for (
const auto &patch : patches)
3622 Assert((patch.
data.n_rows() == n_data_sets &&
3624 (patch.
data.n_rows() == n_data_sets + spacedim &&
3627 (n_data_sets + spacedim) :
3629 patch.
data.n_rows()));
3631 auto output_point_data =
3632 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3633 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3634 out << patch.data(data_set, point_index) <<
' ';
3643 Assert(patch.data.n_cols() == 1,
3651 output_point_data(0);
3661 Assert(patch.data.n_cols() ==
3666 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3672 output_point_data(i1);
3686 n_points_per_direction),
3690 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3692 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3696 out << get_equispaced_location(patch,
3701 output_point_data(i1 + i2 * n_points_per_direction);
3726 out << get_node_location(patch, 0) <<
' ';
3727 output_point_data(0);
3730 out << get_node_location(patch, 1) <<
' ';
3731 output_point_data(1);
3735 out << get_node_location(patch, 2) <<
' ';
3736 output_point_data(2);
3739 out << get_node_location(patch, 2) <<
' ';
3740 output_point_data(2);
3761 n_points_per_direction),
3768 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3769 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3771 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3776 get_equispaced_location(patch,
3783 out << this_point <<
' ';
3784 output_point_data(i1 +
3785 i2 * n_points_per_direction +
3786 i3 * n_points_per_direction *
3787 n_points_per_direction);
3791 out << get_equispaced_location(patch,
3796 output_point_data((i1 + 1) +
3797 i2 * n_points_per_direction +
3798 i3 * n_points_per_direction *
3799 n_points_per_direction);
3803 out <<
'\n' <<
'\n';
3810 out << this_point <<
' ';
3811 output_point_data(i1 +
3812 i2 * n_points_per_direction +
3813 i3 * n_points_per_direction *
3814 n_points_per_direction);
3818 out << get_equispaced_location(patch,
3824 i1 + (i2 + 1) * n_points_per_direction +
3825 i3 * n_points_per_direction *
3826 n_points_per_direction);
3830 out <<
'\n' <<
'\n';
3837 out << this_point <<
' ';
3838 output_point_data(i1 +
3839 i2 * n_points_per_direction +
3840 i3 * n_points_per_direction *
3841 n_points_per_direction);
3845 out << get_equispaced_location(patch,
3851 i1 + i2 * n_points_per_direction +
3852 (i3 + 1) * n_points_per_direction *
3853 n_points_per_direction);
3856 out <<
'\n' <<
'\n';
3865 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3867 out << get_node_location(patch, v) <<
' ';
3868 output_point_data(v);
3873 for (
const unsigned int v : {3, 1})
3875 out << get_node_location(patch, v) <<
' ';
3876 output_point_data(v);
3886 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
3888 out << get_node_location(patch, v) <<
' ';
3889 output_point_data(v);
3894 for (
const unsigned int v : {2, 4, 3})
3896 out << get_node_location(patch, v) <<
' ';
3897 output_point_data(v);
3911 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
3913 out << get_node_location(patch, v) <<
' ';
3914 output_point_data(v);
3919 for (
const unsigned int v : {1, 4})
3921 out << get_node_location(patch, v) <<
' ';
3922 output_point_data(v);
3927 for (
const unsigned int v : {2, 5})
3929 out << get_node_location(patch, v) <<
' ';
3930 output_point_data(v);
3955 template <
int dim,
int spacedim>
3957 do_write_povray(
const std::vector<Patch<dim, spacedim>> &,
3958 const std::vector<std::string> &,
3959 const PovrayFlags &,
3963 ExcMessage(
"Writing files in POVRAY format is only supported "
3964 "for two-dimensional meshes."));
3970 do_write_povray(
const std::vector<
Patch<2, 2>> &patches,
3971 const std::vector<std::string> &data_names,
3977#ifndef DEAL_II_WITH_MPI
3986 if (patches.empty())
3989 constexpr int dim = 2;
3991 constexpr int spacedim = 2;
3993 const unsigned int n_data_sets = data_names.size();
3999 <<
"/* This file was generated by the deal.II library." <<
'\n'
4003 <<
" For a description of the POVRAY format see the POVRAY manual."
4008 out <<
"#include \"colors.inc\" " <<
'\n'
4009 <<
"#include \"textures.inc\" " <<
'\n';
4013 if (flags.external_data)
4014 out <<
"#include \"data.inc\" " <<
'\n';
4020 <<
"camera {" <<
'\n'
4021 <<
" location <1,4,-7>" <<
'\n'
4022 <<
" look_at <0,0,0>" <<
'\n'
4023 <<
" angle 30" <<
'\n'
4028 <<
"light_source {" <<
'\n'
4029 <<
" <1,4,-7>" <<
'\n'
4030 <<
" color Grey" <<
'\n'
4033 <<
"light_source {" <<
'\n'
4034 <<
" <0,20,0>" <<
'\n'
4035 <<
" color White" <<
'\n'
4042 double hmin = patches[0].data(0, 0);
4043 double hmax = patches[0].data(0, 0);
4045 for (
const auto &patch : patches)
4049 Assert((patch.
data.n_rows() == n_data_sets &&
4051 (patch.
data.n_rows() == n_data_sets + spacedim &&
4054 (n_data_sets + spacedim) :
4056 patch.
data.n_rows()));
4066 if (patch.
data(0, dl) < hmin)
4067 hmin = patch.
data(0, dl);
4068 if (patch.
data(0, dl) > hmax)
4069 hmax = patch.
data(0, dl);
4073 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
4074 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
4077 if (!flags.external_data)
4080 out <<
"#declare Tex=texture{" <<
'\n'
4081 <<
" pigment {" <<
'\n'
4082 <<
" gradient y" <<
'\n'
4083 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
4084 <<
" color_map {" <<
'\n'
4085 <<
" [0.00 color Light_Purple] " <<
'\n'
4086 <<
" [0.95 color Light_Purple] " <<
'\n'
4087 <<
" [1.00 color White] " <<
'\n'
4092 if (!flags.bicubic_patch)
4095 out <<
'\n' <<
"mesh {" <<
'\n';
4099 for (
const auto &patch : patches)
4103 const unsigned int d1 = 1;
4104 const unsigned int d2 = n;
4106 Assert((patch.
data.n_rows() == n_data_sets &&
4108 (patch.
data.n_rows() == n_data_sets + spacedim &&
4111 (n_data_sets + spacedim) :
4113 patch.
data.n_rows()));
4119 std::vector<Point<spacedim>> ver(n * n);
4121 for (
unsigned int i2 = 0; i2 < n; ++i2)
4122 for (
unsigned int i1 = 0; i1 < n; ++i1)
4125 ver[i1 * d1 + i2 * d2] =
4130 if (!flags.bicubic_patch)
4133 std::vector<Point<3>> nrml;
4143 for (
unsigned int i = 0; i < n; ++i)
4144 for (
unsigned int j = 0; j < n; ++j)
4146 const unsigned int il = (i == 0) ? i : (i - 1);
4147 const unsigned int ir =
4149 const unsigned int jl = (j == 0) ? j : (j - 1);
4150 const unsigned int jr =
4154 ver[ir * d1 + j * d2][0] - ver[il * d1 + j * d2][0];
4155 h1[1] = patch.
data(0, ir * d1 + j * d2) -
4156 patch.
data(0, il * d1 + j * d2);
4158 ver[ir * d1 + j * d2][1] - ver[il * d1 + j * d2][1];
4161 ver[i * d1 + jr * d2][0] - ver[i * d1 + jl * d2][0];
4162 h2[1] = patch.
data(0, i * d1 + jr * d2) -
4163 patch.
data(0, i * d1 + jl * d2);
4165 ver[i * d1 + jr * d2][1] - ver[i * d1 + jl * d2][1];
4167 nrml[i * d1 + j * d2][0] =
4168 h1[1] * h2[2] - h1[2] * h2[1];
4169 nrml[i * d1 + j * d2][1] =
4170 h1[2] * h2[0] - h1[0] * h2[2];
4171 nrml[i * d1 + j * d2][2] =
4172 h1[0] * h2[1] - h1[1] * h2[0];
4175 double norm = std::hypot(nrml[i * d1 + j * d2][0],
4176 nrml[i * d1 + j * d2][1],
4177 nrml[i * d1 + j * d2][2]);
4179 if (nrml[i * d1 + j * d2][1] < 0)
4182 for (
unsigned int k = 0; k < 3; ++k)
4183 nrml[i * d1 + j * d2][k] /=
norm;
4192 const int dl = i * d1 + j * d2;
4198 out <<
"smooth_triangle {" <<
'\n'
4199 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4200 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4201 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4203 out <<
" \t<" << ver[dl + d1][0] <<
","
4204 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4205 <<
">, <" << nrml[dl + d1][0] <<
", "
4206 << nrml[dl + d1][1] <<
", " << nrml[dl + d1][2]
4208 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4209 << patch.
data(0, dl + d1 + d2) <<
","
4210 << ver[dl + d1 + d2][1] <<
">, <"
4211 << nrml[dl + d1 + d2][0] <<
", "
4212 << nrml[dl + d1 + d2][1] <<
", "
4213 << nrml[dl + d1 + d2][2] <<
">}" <<
'\n';
4216 out <<
"smooth_triangle {" <<
'\n'
4217 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4218 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4219 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4221 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4222 << patch.
data(0, dl + d1 + d2) <<
","
4223 << ver[dl + d1 + d2][1] <<
">, <"
4224 << nrml[dl + d1 + d2][0] <<
", "
4225 << nrml[dl + d1 + d2][1] <<
", "
4226 << nrml[dl + d1 + d2][2] <<
">," <<
'\n';
4227 out <<
"\t<" << ver[dl + d2][0] <<
","
4228 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4229 <<
">, <" << nrml[dl + d2][0] <<
", "
4230 << nrml[dl + d2][1] <<
", " << nrml[dl + d2][2]
4236 out <<
"triangle {" <<
'\n'
4237 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4238 <<
"," << ver[dl][1] <<
">," <<
'\n';
4239 out <<
"\t<" << ver[dl + d1][0] <<
","
4240 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4242 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4243 << patch.
data(0, dl + d1 + d2) <<
","
4244 << ver[dl + d1 + d2][1] <<
">}" <<
'\n';
4247 out <<
"triangle {" <<
'\n'
4248 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4249 <<
"," << ver[dl][1] <<
">," <<
'\n';
4250 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4251 << patch.
data(0, dl + d1 + d2) <<
","
4252 << ver[dl + d1 + d2][1] <<
">," <<
'\n';
4253 out <<
"\t<" << ver[dl + d2][0] <<
","
4254 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4265 <<
"bicubic_patch {" <<
'\n'
4266 <<
" type 0" <<
'\n'
4267 <<
" flatness 0" <<
'\n'
4268 <<
" u_steps 0" <<
'\n'
4269 <<
" v_steps 0" <<
'\n';
4270 for (
int i = 0; i < 16; ++i)
4272 out <<
"\t<" << ver[i][0] <<
"," << patch.
data(0, i) <<
","
4273 << ver[i][1] <<
">";
4278 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4282 if (!flags.bicubic_patch)
4285 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4297 template <
int dim,
int spacedim>
4301 const std::vector<std::string> &data_names,
4303 std::tuple<
unsigned int,
4310 do_write_povray(patches, data_names, flags, out);
4315 template <
int dim,
int spacedim>
4319 const std::vector<std::string> & ,
4321 std::tuple<
unsigned int,
4333 template <
int spacedim>
4337 const std::vector<std::string> & ,
4339 std::tuple<
unsigned int,
4348#ifndef DEAL_II_WITH_MPI
4357 if (patches.empty())
4367 std::multiset<EpsCell2d> cells;
4371 float min_color_value = std::numeric_limits<float>::max();
4372 float max_color_value = std::numeric_limits<float>::min();
4376 double heights[4] = {0, 0, 0, 0};
4380 for (
const auto &patch : patches)
4384 const unsigned int d1 = 1;
4385 const unsigned int d2 = n;
4397 points[3] = get_equispaced_location(patch,
4405 patch.
data.n_rows() == 0,
4408 patch.
data.n_rows()));
4410 patch.
data.n_rows() != 0 ?
4414 heights[1] = patch.
data.n_rows() != 0 ?
4416 (i1 + 1) * d1 + i2 * d2) *
4419 heights[2] = patch.
data.n_rows() != 0 ?
4421 i1 * d1 + (i2 + 1) * d2) *
4424 heights[3] = patch.
data.n_rows() != 0 ?
4426 (i1 + 1) * d1 + (i2 + 1) * d2) *
4433 for (
unsigned int i = 0; i < 4; ++i)
4434 heights[i] = points[i][2];
4459 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4461 const double x = points[vertex][0], y = points[vertex][1],
4462 z = -heights[vertex];
4464 eps_cell.vertices[vertex][0] = -cz * x + sz * y;
4465 eps_cell.vertices[vertex][1] =
4466 -cx * sz * x - cx * cz * y - sx * z;
4490 (points[0] + points[1] + points[2] + points[3]) / 4;
4491 const double center_height =
4492 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4495 eps_cell.depth = -sx * sz * center_point[0] -
4496 sx * cz * center_point[1] + cx * center_height;
4501 patch.
data.n_rows() == 0,
4504 patch.
data.n_rows()));
4505 const double color_values[4] = {
4506 patch.
data.n_rows() != 0 ?
4510 patch.
data.n_rows() != 0 ?
4514 patch.
data.n_rows() != 0 ?
4518 patch.
data.n_rows() != 0 ?
4520 (i1 + 1) * d1 + (i2 + 1) * d2) :
4524 eps_cell.color_value = (color_values[0] + color_values[1] +
4525 color_values[3] + color_values[2]) /
4530 std::min(min_color_value, eps_cell.color_value);
4532 std::max(max_color_value, eps_cell.color_value);
4536 cells.insert(eps_cell);
4542 double x_min = cells.begin()->vertices[0][0];
4543 double x_max = x_min;
4544 double y_min = cells.begin()->vertices[0][1];
4545 double y_max = y_min;
4547 for (
const auto &cell : cells)
4548 for (
const auto &vertex : cell.vertices)
4550 x_min =
std::min(x_min, vertex[0]);
4551 x_max =
std::max(x_max, vertex[0]);
4552 y_min =
std::min(y_min, vertex[1]);
4553 y_max =
std::max(y_max, vertex[1]);
4558 const double scale =
4562 const Point<2> offset(x_min, y_min);
4567 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4568 <<
"%%Title: deal.II Output" <<
'\n'
4569 <<
"%%Creator: the deal.II library" <<
'\n'
4572 <<
"%%BoundingBox: "
4576 <<
static_cast<unsigned int>((x_max - x_min) * scale + 0.5) <<
' '
4577 <<
static_cast<unsigned int>((y_max - y_min) * scale + 0.5) <<
'\n';
4586 out <<
"/m {moveto} bind def" <<
'\n'
4587 <<
"/l {lineto} bind def" <<
'\n'
4588 <<
"/s {setrgbcolor} bind def" <<
'\n'
4589 <<
"/sg {setgray} bind def" <<
'\n'
4590 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4591 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4593 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4595 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4603 if (max_color_value == min_color_value)
4604 max_color_value = min_color_value + 1;
4608 for (
const auto &cell : cells)
4621 out << rgb_values.
red <<
" sg ";
4623 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4624 << rgb_values.
blue <<
" s ";
4629 out << (cell.vertices[0] - offset) * scale <<
" m "
4630 << (cell.vertices[1] - offset) * scale <<
" l "
4631 << (cell.vertices[3] - offset) * scale <<
" l "
4632 << (cell.vertices[2] - offset) * scale <<
" lf" <<
'\n';
4637 << (cell.vertices[0] - offset) * scale <<
" m "
4638 << (cell.vertices[1] - offset) * scale <<
" l "
4639 << (cell.vertices[3] - offset) * scale <<
" l "
4640 << (cell.vertices[2] - offset) * scale <<
" lx" <<
'\n';
4642 out <<
"showpage" <<
'\n';
4651 template <
int dim,
int spacedim>
4655 const std::vector<std::string> &data_names,
4657 std::tuple<
unsigned int,
4673#ifndef DEAL_II_WITH_MPI
4682 if (patches.empty())
4686 GmvStream gmv_out(out, flags);
4687 const unsigned int n_data_sets = data_names.size();
4690 Assert((patches[0].data.n_rows() == n_data_sets &&
4691 !patches[0].points_are_available) ||
4692 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4693 patches[0].points_are_available),
4695 (n_data_sets + spacedim) :
4697 patches[0].data.n_rows()));
4701 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4704 unsigned int n_nodes;
4705 unsigned int n_cells;
4706 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
4721 [&patches]() {
return create_global_data_table(patches); });
4727 out <<
"nodes " << n_nodes <<
'\n';
4728 for (
unsigned int d = 0; d < spacedim; ++d)
4730 gmv_out.selected_component = d;
4736 for (
unsigned int d = spacedim; d < 3; ++d)
4738 for (
unsigned int i = 0; i < n_nodes; ++i)
4745 out <<
"cells " << n_cells <<
'\n';
4750 out <<
"variable" <<
'\n';
4754 std::move(*create_global_data_table_task.
return_value());
4758 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4760 out << data_names[data_set] <<
" 1" <<
'\n';
4761 std::copy(data_vectors[data_set].begin(),
4762 data_vectors[data_set].end(),
4763 std::ostream_iterator<double>(out,
" "));
4764 out <<
'\n' <<
'\n';
4770 out <<
"endvars" <<
'\n';
4773 out <<
"endgmv" <<
'\n';
4784 template <
int dim,
int spacedim>
4788 const std::vector<std::string> &data_names,
4790 std::tuple<
unsigned int,
4804#ifndef DEAL_II_WITH_MPI
4813 if (patches.empty())
4817 TecplotStream tecplot_out(out, flags);
4819 const unsigned int n_data_sets = data_names.size();
4822 Assert((patches[0].data.n_rows() == n_data_sets &&
4823 !patches[0].points_are_available) ||
4824 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4825 patches[0].points_are_available),
4827 (n_data_sets + spacedim) :
4829 patches[0].data.n_rows()));
4832 unsigned int n_nodes;
4833 unsigned int n_cells;
4834 std::tie(n_nodes, n_cells) = count_nodes_and_cells(patches);
4840 <<
"# This file was generated by the deal.II library." <<
'\n'
4844 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4849 out <<
"Variables=";
4857 out <<
"\"x\", \"y\"";
4860 out <<
"\"x\", \"y\", \"z\"";
4866 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4867 out <<
", \"" << data_names[data_set] <<
"\"";
4873 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4876 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4878 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4879 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4896 [&patches]() {
return create_global_data_table(patches); });
4902 for (
unsigned int d = 0; d < spacedim; ++d)
4904 tecplot_out.selected_component = d;
4915 std::move(*create_global_data_table_task.
return_value());
4918 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4920 std::copy(data_vectors[data_set].begin(),
4921 data_vectors[data_set].end(),
4922 std::ostream_iterator<double>(out,
"\n"));
4937 template <
int dim,
int spacedim>
4941 const std::vector<std::string> &data_names,
4943 std::tuple<
unsigned int,
4947 &nonscalar_data_ranges,
4953#ifndef DEAL_II_WITH_MPI
4962 if (patches.empty())
4966 VtkStream vtk_out(out, flags);
4968 const unsigned int n_data_sets = data_names.size();
4970 if (patches[0].points_are_available)
4982 out <<
"# vtk DataFile Version 3.0" <<
'\n'
4983 <<
"#This file was generated by the deal.II library";
4991 out <<
'\n' <<
"ASCII" <<
'\n';
4993 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
5000 const unsigned int n_metadata =
5001 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5002 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5005 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5007 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5009 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5011 if (flags.
time != std::numeric_limits<double>::min())
5013 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5019 unsigned int n_nodes;
5020 unsigned int n_cells;
5021 unsigned int n_points_and_n_cells;
5022 std::tie(n_nodes, n_cells, n_points_and_n_cells) =
5038 [&patches]() {
return create_global_data_table(patches); });
5044 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5049 out <<
"CELLS " << n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5057 out <<
"CELL_TYPES " << n_cells <<
'\n';
5061 for (
const auto &patch : patches)
5063 const auto vtk_cell_id =
5066 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5067 out <<
' ' << vtk_cell_id[0];
5076 std::move(*create_global_data_table_task.
return_value());
5081 out <<
"POINT_DATA " << n_nodes <<
'\n';
5085 std::vector<bool> data_set_written(n_data_sets,
false);
5086 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5091 "The VTK writer does not currently support outputting "
5092 "tensor data. Use the VTU writer instead."));
5095 std::get<0>(nonscalar_data_range),
5097 std::get<0>(nonscalar_data_range)));
5098 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5102 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5103 std::get<0>(nonscalar_data_range) <=
5106 "Can't declare a vector with more than 3 components "
5110 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5111 i <= std::get<1>(nonscalar_data_range);
5113 data_set_written[i] =
true;
5119 if (!std::get<2>(nonscalar_data_range).empty())
5120 out << std::get<2>(nonscalar_data_range);
5123 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5124 i < std::get<1>(nonscalar_data_range);
5126 out << data_names[i] <<
"__";
5127 out << data_names[std::get<1>(nonscalar_data_range)];
5130 out <<
" double" <<
'\n';
5133 for (
unsigned int n = 0; n < n_nodes; ++n)
5135 switch (std::get<1>(nonscalar_data_range) -
5136 std::get<0>(nonscalar_data_range))
5139 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5144 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5146 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5150 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5152 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5154 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5167 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5168 if (data_set_written[data_set] ==
false)
5170 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5171 <<
"LOOKUP_TABLE default" <<
'\n';
5172 std::copy(data_vectors[data_set].begin(),
5173 data_vectors[data_set].end(),
5174 std::ostream_iterator<double>(out,
" "));
5190 out <<
"<?xml version=\"1.0\" ?> \n";
5192 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5193 <<
"#This file was generated by the deal.II library";
5204 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"2.2\"";
5206 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5207 if (deal_ii_with_zlib &&
5209 out <<
" compressor=\"vtkZLibDataCompressor\"";
5210#ifdef DEAL_II_WORDS_BIGENDIAN
5211 out <<
" byte_order=\"BigEndian\"";
5213 out <<
" byte_order=\"LittleEndian\"";
5217 out <<
"<UnstructuredGrid>";
5227 out <<
" </UnstructuredGrid>\n";
5228 out <<
"</VTKFile>\n";
5233 template <
int dim,
int spacedim>
5237 const std::vector<std::string> &data_names,
5239 std::tuple<
unsigned int,
5243 &nonscalar_data_ranges,
5248 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5255 template <
int dim,
int spacedim>
5259 const std::vector<std::string> &data_names,
5261 std::tuple<
unsigned int,
5265 &nonscalar_data_ranges,
5279 unit.second.find(
'\"') == std::string::npos,
5281 "A physical unit you provided, <" + unit.second +
5282 ">, contained a quotation mark character. This is not allowed."));
5285#ifndef DEAL_II_WITH_MPI
5294 if (patches.empty())
5299 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5301 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5303 <<
" <PointData Scalars=\"scalars\">\n";
5304 std::vector<bool> data_set_written(data_names.size(),
false);
5305 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5308 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5309 i <= std::get<1>(nonscalar_data_range);
5311 data_set_written[i] =
true;
5315 out <<
" <DataArray type=\"Float32\" Name=\"";
5317 if (!std::get<2>(nonscalar_data_range).empty())
5318 out << std::get<2>(nonscalar_data_range);
5321 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5322 i < std::get<1>(nonscalar_data_range);
5324 out << data_names[i] <<
"__";
5325 out << data_names[std::get<1>(nonscalar_data_range)];
5328 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5331 for (
unsigned int data_set = 0; data_set < data_names.size();
5333 if (data_set_written[data_set] ==
false)
5335 out <<
" <DataArray type=\"Float32\" Name=\""
5336 << data_names[data_set] <<
"\"></DataArray>\n";
5339 out <<
" </PointData>\n";
5340 out <<
"</Piece>\n";
5354 const unsigned int n_metadata =
5355 ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0) +
5356 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5358 out <<
"<FieldData>\n";
5360 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5363 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5364 << flags.
cycle <<
"</DataArray>\n";
5366 if (flags.
time != std::numeric_limits<double>::min())
5369 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5370 << flags.
time <<
"</DataArray>\n";
5374 out <<
"</FieldData>\n";
5378 const unsigned int n_data_sets = data_names.size();
5381 if (patches[0].points_are_available)
5390 const char *ascii_or_binary =
5391 (deal_ii_with_zlib &&
5398 unsigned int n_nodes;
5399 unsigned int n_cells;
5400 std::tie(n_nodes, n_cells, std::ignore) =
5408 const auto stringize_vertex_information = [&patches,
5412 ascii_or_binary]() {
5413 std::ostringstream o;
5415 o <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5416 << ascii_or_binary <<
"\">\n";
5417 const std::vector<Point<spacedim>> node_positions =
5422 std::vector<float> node_coordinates_3d;
5423 node_coordinates_3d.reserve(node_positions.size() * 3);
5424 for (
const auto &node_position : node_positions)
5426 for (
unsigned int d = 0; d < 3; ++d)
5428 node_coordinates_3d.emplace_back(node_position[d]);
5430 node_coordinates_3d.emplace_back(0.0f);
5432 o << vtu_stringize_array(node_coordinates_3d,
5436 o <<
" </DataArray>\n";
5437 o <<
" </Points>\n\n";
5446 const auto stringize_cell_to_vertex_information = [&patches,
5450 out.precision()]() {
5451 std::ostringstream o;
5454 o <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5455 << ascii_or_binary <<
"\">\n";
5457 std::vector<std::int32_t> cells;
5460 unsigned int first_vertex_of_patch = 0;
5462 for (
const auto &patch : patches)
5474 const unsigned int n_points = patch.
data.n_cols();
5475 Assert((dim == 2 && n_points == 6) ||
5476 (dim == 3 && n_points == 10),
5479 if (deal_ii_with_zlib &&
5483 for (
unsigned int i = 0; i < n_points; ++i)
5484 cells.push_back(first_vertex_of_patch + i);
5488 for (
unsigned int i = 0; i < n_points; ++i)
5489 o <<
'\t' << first_vertex_of_patch + i;
5493 first_vertex_of_patch += n_points;
5502 const unsigned int n_points = patch.
data.n_cols();
5504 if (deal_ii_with_zlib &&
5508 for (
unsigned int i = 0; i < n_points; ++i)
5510 first_vertex_of_patch +
5515 for (
unsigned int i = 0; i < n_points; ++i)
5517 << (first_vertex_of_patch +
5522 first_vertex_of_patch += n_points;
5529 std::vector<unsigned> local_vertex_order;
5533 const auto flush_current_cell = [&flags,
5536 first_vertex_of_patch,
5537 &local_vertex_order]() {
5538 if (deal_ii_with_zlib &&
5542 for (
const auto &c : local_vertex_order)
5543 cells.push_back(first_vertex_of_patch + c);
5547 for (
const auto &c : local_vertex_order)
5548 o <<
'\t' << first_vertex_of_patch + c;
5552 local_vertex_order.clear();
5563 local_vertex_order.emplace_back(0);
5564 flush_current_cell();
5572 const unsigned int starting_offset = i1;
5573 local_vertex_order.emplace_back(starting_offset);
5574 local_vertex_order.emplace_back(starting_offset +
5576 flush_current_cell();
5586 const unsigned int starting_offset =
5587 i2 * n_points_per_direction + i1;
5588 local_vertex_order.emplace_back(
5590 local_vertex_order.emplace_back(
5591 starting_offset + 1);
5592 local_vertex_order.emplace_back(
5593 starting_offset + n_points_per_direction + 1);
5594 local_vertex_order.emplace_back(
5595 starting_offset + n_points_per_direction);
5596 flush_current_cell();
5608 const unsigned int starting_offset =
5609 i3 * n_points_per_direction *
5610 n_points_per_direction +
5611 i2 * n_points_per_direction + i1;
5612 local_vertex_order.emplace_back(
5614 local_vertex_order.emplace_back(
5615 starting_offset + 1);
5616 local_vertex_order.emplace_back(
5617 starting_offset + n_points_per_direction +
5619 local_vertex_order.emplace_back(
5620 starting_offset + n_points_per_direction);
5621 local_vertex_order.emplace_back(
5622 starting_offset + n_points_per_direction *
5623 n_points_per_direction);
5624 local_vertex_order.emplace_back(
5626 n_points_per_direction *
5627 n_points_per_direction +
5629 local_vertex_order.emplace_back(
5631 n_points_per_direction *
5632 n_points_per_direction +
5633 n_points_per_direction + 1);
5634 local_vertex_order.emplace_back(
5636 n_points_per_direction *
5637 n_points_per_direction +
5638 n_points_per_direction);
5639 flush_current_cell();
5650 local_vertex_order.resize(
5659 "Point-like cells should not be possible "
5660 "when writing higher-order cells."));
5668 const unsigned int local_index = i1;
5669 const unsigned int connectivity_index =
5671 .template vtk_lexicographic_to_node_index<1>(
5675 local_vertex_order[connectivity_index] =
5678 flush_current_cell();
5689 const unsigned int local_index =
5690 i2 * n_points_per_direction + i1;
5691 const unsigned int connectivity_index =
5693 .template vtk_lexicographic_to_node_index<
5697 local_vertex_order[connectivity_index] =
5700 flush_current_cell();
5713 const unsigned int local_index =
5714 i3 * n_points_per_direction *
5715 n_points_per_direction +
5716 i2 * n_points_per_direction + i1;
5717 const unsigned int connectivity_index =
5719 .template vtk_lexicographic_to_node_index<
5725 local_vertex_order[connectivity_index] =
5729 flush_current_cell();
5739 first_vertex_of_patch +=
5748 o << vtu_stringize_array(cells,
5753 o <<
" </DataArray>\n";
5773 const auto stringize_cell_offset_and_type_information =
5778 output_precision = out.precision()]() {
5779 std::ostringstream o;
5781 o <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5782 << ascii_or_binary <<
"\">\n";
5784 std::vector<std::int32_t> offsets;
5785 offsets.reserve(n_cells);
5789 std::vector<unsigned int> cell_types;
5790 cell_types.reserve(n_cells);
5792 unsigned int first_vertex_of_patch = 0;
5794 for (
const auto &patch : patches)
5796 const auto vtk_cell_id =
5799 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5801 cell_types.push_back(vtk_cell_id[0]);
5802 first_vertex_of_patch += vtk_cell_id[2];
5803 offsets.push_back(first_vertex_of_patch);
5807 o << vtu_stringize_array(offsets,
5811 o <<
" </DataArray>\n";
5813 o <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5814 << ascii_or_binary <<
"\">\n";
5816 if (deal_ii_with_zlib &&
5819 std::vector<std::uint8_t> cell_types_uint8_t(cell_types.size());
5820 for (
unsigned int i = 0; i < cell_types.size(); ++i)
5821 cell_types_uint8_t[i] =
static_cast<std::uint8_t
>(cell_types[i]);
5823 o << vtu_stringize_array(cell_types_uint8_t,
5829 o << vtu_stringize_array(cell_types,
5835 o <<
" </DataArray>\n";
5845 const auto stringize_nonscalar_data_range =
5851 output_precision = out.precision()](
const Table<2, float> &data_vectors,
5852 const auto &range) {
5853 std::ostringstream o;
5855 const auto first_component = std::get<0>(range);
5856 const auto last_component = std::get<1>(range);
5857 const auto &name = std::get<2>(range);
5858 const bool is_tensor =
5859 (std::get<3>(range) ==
5861 const unsigned int n_components = (is_tensor ? 9 : 3);
5868 AssertThrow((last_component + 1 - first_component <= 9),
5870 "Can't declare a tensor with more than 9 components "
5871 "in VTK/VTU format."));
5875 AssertThrow((last_component + 1 - first_component <= 3),
5877 "Can't declare a vector with more than 3 components "
5878 "in VTK/VTU format."));
5883 o <<
" <DataArray type=\"Float32\" Name=\"";
5889 for (
unsigned int i = first_component; i < last_component; ++i)
5890 o << data_names[i] <<
"__";
5891 o << data_names[last_component];
5894 o <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5895 << ascii_or_binary <<
"\"";
5914 std::vector<float> data;
5915 data.reserve(n_nodes * n_components);
5917 for (
unsigned int n = 0; n < n_nodes; ++n)
5921 switch (last_component - first_component)
5924 data.push_back(data_vectors(first_component, n));
5930 data.push_back(data_vectors(first_component, n));
5931 data.push_back(data_vectors(first_component + 1, n));
5936 data.push_back(data_vectors(first_component, n));
5937 data.push_back(data_vectors(first_component + 1, n));
5938 data.push_back(data_vectors(first_component + 2, n));
5951 const unsigned int size = last_component - first_component + 1;
5955 vtk_data[0][0] = data_vectors(first_component, n);
5960 for (
unsigned int c = 0; c < size; ++c)
5964 vtk_data[ind[0]][ind[1]] =
5965 data_vectors(first_component + c, n);
5971 for (
unsigned int c = 0; c < size; ++c)
5975 vtk_data[ind[0]][ind[1]] =
5976 data_vectors(first_component + c, n);
5987 for (
unsigned int i = 0; i < 3; ++i)
5988 for (
unsigned int j = 0; j < 3; ++j)
5989 data.push_back(vtk_data[i][j]);
5993 o << vtu_stringize_array(data,
5997 o <<
" </DataArray>\n";
6002 const auto stringize_scalar_data_set =
6006 output_precision = out.precision()](
const Table<2, float> &data_vectors,
6007 const unsigned int data_set) {
6008 std::ostringstream o;
6010 o <<
" <DataArray type=\"Float32\" Name=\"" << data_names[data_set]
6011 <<
"\" format=\"" << ascii_or_binary <<
"\"";
6015 o <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6020 const std::vector<float> data(data_vectors[data_set].begin(),
6021 data_vectors[data_set].end());
6022 o << vtu_stringize_array(data,
6026 o <<
" </DataArray>\n";
6045 return create_global_data_table<dim, spacedim, float>(patches);
6059 std::move(*create_global_data_table_task.
return_value());
6065 std::vector<bool> data_set_handled(n_data_sets,
false);
6066 for (
const auto &range : nonscalar_data_ranges)
6069 const auto first_component = std::get<0>(range);
6070 const auto last_component = std::get<1>(range);
6071 for (
unsigned int i = first_component; i <= last_component; ++i)
6072 data_set_handled[i] =
true;
6075 return stringize_nonscalar_data_range(data_vectors, range);
6080 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6081 if (data_set_handled[data_set] ==
false)
6084 return stringize_scalar_data_set(data_vectors, data_set);
6090 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
6091 << n_cells <<
"\" >\n";
6092 for (
const auto &s : mesh_tasks.return_values())
6094 out <<
" <PointData Scalars=\"scalars\">\n";
6097 out <<
" </PointData>\n";
6098 out <<
" </Piece>\n";
6112 const std::vector<std::string> &piece_names,
6113 const std::vector<std::string> &data_names,
6115 std::tuple<
unsigned int,
6119 &nonscalar_data_ranges,
6132 unit.second.find(
'\"') == std::string::npos,
6134 "A physical unit you provided, <" + unit.second +
6135 ">, contained a quotation mark character. This is not allowed."));
6138 const unsigned int n_data_sets = data_names.size();
6140 out <<
"<?xml version=\"1.0\"?>\n";
6143 out <<
"#This file was generated by the deal.II library"
6148 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
6149 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
6150 out <<
" <PPointData Scalars=\"scalars\">\n";
6153 std::vector<bool> data_set_written(n_data_sets,
false);
6154 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
6156 const auto first_component = std::get<0>(nonscalar_data_range);
6157 const auto last_component = std::get<1>(nonscalar_data_range);
6158 const bool is_tensor =
6159 (std::get<3>(nonscalar_data_range) ==
6161 const unsigned int n_components = (is_tensor ? 9 : 3);
6168 AssertThrow((last_component + 1 - first_component <= 9),
6170 "Can't declare a tensor with more than 9 components "
6175 Assert((last_component + 1 - first_component <= 3),
6177 "Can't declare a vector with more than 3 components "
6182 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6183 i <= std::get<1>(nonscalar_data_range);
6185 data_set_written[i] =
true;
6189 out <<
" <PDataArray type=\"Float32\" Name=\"";
6191 const std::string &name = std::get<2>(nonscalar_data_range);
6196 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6197 i < std::get<1>(nonscalar_data_range);
6199 out << data_names[i] <<
"__";
6200 out << data_names[std::get<1>(nonscalar_data_range)];
6203 out <<
"\" NumberOfComponents=\"" << n_components
6204 <<
"\" format=\"ascii\"";
6216 data_names[std::get<1>(nonscalar_data_range)]) !=
6220 data_names[std::get<1>(nonscalar_data_range)])
6228 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6229 if (data_set_written[data_set] ==
false)
6231 out <<
" <PDataArray type=\"Float32\" Name=\""
6232 << data_names[data_set] <<
"\" format=\"ascii\"";
6236 out <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6242 out <<
" </PPointData>\n";
6244 out <<
" <PPoints>\n";
6245 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
6246 out <<
" </PPoints>\n";
6248 for (
const auto &piece_name : piece_names)
6249 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
6251 out <<
" </PUnstructuredGrid>\n";
6252 out <<
"</VTKFile>\n";
6265 const std::vector<std::pair<double, std::string>> ×_and_names)
6269 out <<
"<?xml version=\"1.0\"?>\n";
6272 out <<
"#This file was generated by the deal.II library"
6277 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
6278 out <<
" <Collection>\n";
6280 std::streamsize ss = out.precision();
6283 for (
const auto &time_and_name : times_and_names)
6284 out <<
" <DataSet timestep=\"" << time_and_name.first
6285 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
6288 out <<
" </Collection>\n";
6289 out <<
"</VTKFile>\n";
6301 const std::vector<std::string> &piece_names)
6303 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
6304 for (
const auto &piece_name : piece_names)
6305 out << piece_name <<
'\n';
6314 const std::vector<std::vector<std::string>> &piece_names)
6318 if (piece_names.empty())
6321 const double nblocks = piece_names[0].size();
6323 ExcMessage(
"piece_names should be a vector of nonempty vectors."));
6325 out <<
"!NBLOCKS " << nblocks <<
'\n';
6326 for (
const auto &domain : piece_names)
6328 Assert(domain.size() == nblocks,
6330 "piece_names should be a vector of equal sized vectors."));
6331 for (
const auto &subdomain : domain)
6332 out << subdomain <<
'\n';
6343 const std::vector<std::pair<
double, std::vector<std::string>>>
6344 ×_and_piece_names)
6348 if (times_and_piece_names.empty())
6351 const double nblocks = times_and_piece_names[0].second.size();
6355 "time_and_piece_names should contain nonempty vectors of filenames for every timestep."));
6357 for (
const auto &domain : times_and_piece_names)
6358 out <<
"!TIME " << domain.first <<
'\n';
6360 out <<
"!NBLOCKS " << nblocks <<
'\n';
6361 for (
const auto &domain : times_and_piece_names)
6363 Assert(domain.second.size() == nblocks,
6365 "piece_names should be a vector of equal sized vectors."));
6366 for (
const auto &subdomain : domain.second)
6367 out << subdomain <<
'\n';
6375 template <
int dim,
int spacedim>
6379 const std::vector<std::string> &,
6381 std::tuple<
unsigned int,
6391 template <
int spacedim>
6395 const std::vector<std::string> & ,
6397 std::tuple<
unsigned int,
6405 const unsigned int height = flags.
height;
6406 unsigned int width = flags.
width;
6409 unsigned int margin_in_percent = 0;
6411 margin_in_percent = 5;
6415 double x_dimension, y_dimension, z_dimension;
6417 const auto &first_patch = patches[0];
6421 const unsigned int d1 = 1;
6422 const unsigned int d2 = n;
6425 std::array<Point<spacedim>, 4> projected_points;
6428 std::array<Point<2>, 4> projection_decompositions;
6433 if (first_patch.data.n_rows() != 0)
6438 double x_min = projected_point[0];
6439 double x_max = x_min;
6440 double y_min = projected_point[1];
6441 double y_max = y_min;
6442 double z_min = first_patch.data.n_rows() != 0 ?
6445 double z_max = z_min;
6448 for (
const auto &patch : patches)
6457 projected_points[0] =
6459 projected_points[1] =
6461 projected_points[2] =
6463 projected_points[3] = get_equispaced_location(patch,
6467 x_min =
std::min(x_min, projected_points[0][0]);
6468 x_min =
std::min(x_min, projected_points[1][0]);
6469 x_min =
std::min(x_min, projected_points[2][0]);
6470 x_min =
std::min(x_min, projected_points[3][0]);
6472 x_max =
std::max(x_max, projected_points[0][0]);
6473 x_max =
std::max(x_max, projected_points[1][0]);
6474 x_max =
std::max(x_max, projected_points[2][0]);
6475 x_max =
std::max(x_max, projected_points[3][0]);
6477 y_min =
std::min(y_min, projected_points[0][1]);
6478 y_min =
std::min(y_min, projected_points[1][1]);
6479 y_min =
std::min(y_min, projected_points[2][1]);
6480 y_min =
std::min(y_min, projected_points[3][1]);
6482 y_max =
std::max(y_max, projected_points[0][1]);
6483 y_max =
std::max(y_max, projected_points[1][1]);
6484 y_max =
std::max(y_max, projected_points[2][1]);
6485 y_max =
std::max(y_max, projected_points[3][1]);
6488 patch.
data.n_rows() == 0,
6491 patch.
data.n_rows()));
6495 i1 * d1 + i2 * d2));
6498 (i1 + 1) * d1 + i2 * d2));
6501 i1 * d1 + (i2 + 1) * d2));
6505 (i1 + 1) * d1 + (i2 + 1) * d2));
6509 i1 * d1 + i2 * d2));
6512 (i1 + 1) * d1 + i2 * d2));
6515 i1 * d1 + (i2 + 1) * d2));
6519 (i1 + 1) * d1 + (i2 + 1) * d2));
6524 x_dimension = x_max - x_min;
6525 y_dimension = y_max - y_min;
6526 z_dimension = z_max - z_min;
6533 float camera_focus = 0;
6536 camera_position[0] = 0.;
6537 camera_position[1] = 0.;
6538 camera_position[2] = z_min + 2. * z_dimension;
6540 camera_direction[0] = 0.;
6541 camera_direction[1] = 0.;
6542 camera_direction[2] = -1.;
6544 camera_horizontal[0] = 1.;
6545 camera_horizontal[1] = 0.;
6546 camera_horizontal[2] = 0.;
6548 camera_focus = .5 * z_dimension;
6554 const float angle_factor = 3.14159265f / 180.f;
6557 camera_position_temp[1] =
6560 camera_position_temp[2] =
6564 camera_direction_temp[1] =
6567 camera_direction_temp[2] =
6571 camera_horizontal_temp[1] =
6574 camera_horizontal_temp[2] =
6578 camera_position[1] = camera_position_temp[1];
6579 camera_position[2] = camera_position_temp[2];
6581 camera_direction[1] = camera_direction_temp[1];
6582 camera_direction[2] = camera_direction_temp[2];
6584 camera_horizontal[1] = camera_horizontal_temp[1];
6585 camera_horizontal[2] = camera_horizontal_temp[2];
6588 camera_position_temp[0] =
6591 camera_position_temp[1] =
6595 camera_direction_temp[0] =
6598 camera_direction_temp[1] =
6602 camera_horizontal_temp[0] =
6605 camera_horizontal_temp[1] =
6609 camera_position[0] = camera_position_temp[0];
6610 camera_position[1] = camera_position_temp[1];
6612 camera_direction[0] = camera_direction_temp[0];
6613 camera_direction[1] = camera_direction_temp[1];
6615 camera_horizontal[0] = camera_horizontal_temp[0];
6616 camera_horizontal[1] = camera_horizontal_temp[1];
6619 camera_position[0] = x_min + .5 * x_dimension;
6620 camera_position[1] = y_min + .5 * y_dimension;
6622 camera_position[0] += (z_min + 2. * z_dimension) *
6625 camera_position[1] -= (z_min + 2. * z_dimension) *
6631 double x_min_perspective, y_min_perspective;
6632 double x_max_perspective, y_max_perspective;
6633 double x_dimension_perspective, y_dimension_perspective;
6643 if (first_patch.data.n_rows() != 0)
6648 point[0] = projected_point[0];
6649 point[1] = projected_point[1];
6650 point[2] = first_patch.data.n_rows() != 0 ?
6654 projection_decomposition = svg_project_point(point,
6660 x_min_perspective = projection_decomposition[0];
6661 x_max_perspective = projection_decomposition[0];
6662 y_min_perspective = projection_decomposition[1];
6663 y_max_perspective = projection_decomposition[1];
6666 for (
const auto &patch : patches)
6673 const std::array<Point<spacedim>, 4> projected_vertices{
6677 get_equispaced_location(patch,
6682 patch.
data.n_rows() == 0,
6685 patch.
data.n_rows()));
6687 const std::array<Point<3>, 4> vertices = {
6688 {
Point<3>{projected_vertices[0][0],
6689 projected_vertices[0][1],
6690 patch.
data.n_rows() != 0 ?
6691 patch.
data(0, i1 * d1 + i2 * d2) :
6694 projected_vertices[1][1],
6695 patch.
data.n_rows() != 0 ?
6696 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6699 projected_vertices[2][1],
6700 patch.
data.n_rows() != 0 ?
6701 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6704 projected_vertices[3][1],
6705 patch.
data.n_rows() != 0 ?
6706 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6709 projection_decompositions = {
6710 {svg_project_point(vertices[0],
6715 svg_project_point(vertices[1],
6720 svg_project_point(vertices[2],
6725 svg_project_point(vertices[3],
6733 static_cast<double>(
6734 projection_decompositions[0][0]));
6737 static_cast<double>(
6738 projection_decompositions[1][0]));
6741 static_cast<double>(
6742 projection_decompositions[2][0]));
6745 static_cast<double>(
6746 projection_decompositions[3][0]));
6750 static_cast<double>(
6751 projection_decompositions[0][0]));
6754 static_cast<double>(
6755 projection_decompositions[1][0]));
6758 static_cast<double>(
6759 projection_decompositions[2][0]));
6762 static_cast<double>(
6763 projection_decompositions[3][0]));
6767 static_cast<double>(
6768 projection_decompositions[0][1]));
6771 static_cast<double>(
6772 projection_decompositions[1][1]));
6775 static_cast<double>(
6776 projection_decompositions[2][1]));
6779 static_cast<double>(
6780 projection_decompositions[3][1]));
6784 static_cast<double>(
6785 projection_decompositions[0][1]));
6788 static_cast<double>(
6789 projection_decompositions[1][1]));
6792 static_cast<double>(
6793 projection_decompositions[2][1]));
6796 static_cast<double>(
6797 projection_decompositions[3][1]));
6802 x_dimension_perspective = x_max_perspective - x_min_perspective;
6803 y_dimension_perspective = y_max_perspective - y_min_perspective;
6805 std::multiset<SvgCell> cells;
6808 for (
const auto &patch : patches)
6816 const std::array<Point<spacedim>, 4> projected_vertices = {
6820 get_equispaced_location(patch,
6825 patch.
data.n_rows() == 0,
6828 patch.
data.n_rows()));
6832 cell.vertices[0][0] = projected_vertices[0][0];
6833 cell.vertices[0][1] = projected_vertices[0][1];
6834 cell.vertices[0][2] = patch.
data.n_rows() != 0 ?
6835 patch.
data(0, i1 * d1 + i2 * d2) :
6838 cell.vertices[1][0] = projected_vertices[1][0];
6839 cell.vertices[1][1] = projected_vertices[1][1];
6840 cell.vertices[1][2] = patch.
data.n_rows() != 0 ?
6841 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6844 cell.vertices[2][0] = projected_vertices[2][0];
6845 cell.vertices[2][1] = projected_vertices[2][1];
6846 cell.vertices[2][2] = patch.
data.n_rows() != 0 ?
6847 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6850 cell.vertices[3][0] = projected_vertices[3][0];
6851 cell.vertices[3][1] = projected_vertices[3][1];
6852 cell.vertices[3][2] =
6853 patch.
data.n_rows() != 0 ?
6854 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6857 cell.projected_vertices[0] =
6858 svg_project_point(cell.vertices[0],
6863 cell.projected_vertices[1] =
6864 svg_project_point(cell.vertices[1],
6869 cell.projected_vertices[2] =
6870 svg_project_point(cell.vertices[2],
6875 cell.projected_vertices[3] =
6876 svg_project_point(cell.vertices[3],
6882 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] +
6883 cell.vertices[2] + cell.vertices[3]);
6884 cell.projected_center = svg_project_point(cell.center,
6890 cell.depth = cell.center.distance(camera_position);
6900 width =
static_cast<unsigned int>(
6901 .5 + height * (x_dimension_perspective / y_dimension_perspective));
6902 unsigned int additional_width = 0;
6905 additional_width =
static_cast<unsigned int>(
6909 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\""
6910 << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
6912 <<
" <rect width=\"" << width + additional_width <<
"\" height=\""
6913 << height <<
"\" style=\"fill:white\"/>" <<
'\n'
6916 unsigned int triangle_counter = 0;
6919 for (
const auto &cell : cells)
6923 for (
unsigned int triangle_index = 0; triangle_index < 4;
6926 switch (triangle_index)
6929 points3d_triangle[0] = cell.vertices[0],
6930 points3d_triangle[1] = cell.vertices[1],
6931 points3d_triangle[2] = cell.center;
6934 points3d_triangle[0] = cell.vertices[1],
6935 points3d_triangle[1] = cell.vertices[3],
6936 points3d_triangle[2] = cell.center;
6939 points3d_triangle[0] = cell.vertices[3],
6940 points3d_triangle[1] = cell.vertices[2],
6941 points3d_triangle[2] = cell.center;
6944 points3d_triangle[0] = cell.vertices[2],
6945 points3d_triangle[1] = cell.vertices[0],
6946 points3d_triangle[2] = cell.center;
6953 svg_get_gradient_parameters(points3d_triangle);
6956 .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
6958 .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
6960 unsigned int start_r = 0;
6961 unsigned int start_g = 0;
6962 unsigned int start_b = 0;
6964 unsigned int stop_r = 0;
6965 unsigned int stop_g = 0;
6966 unsigned int stop_b = 0;
6968 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6969 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6971 double start_f = start_h * 6. - start_i;
6972 double start_q = 1. - start_f;
6974 double stop_f = stop_h * 6. - stop_i;
6975 double stop_q = 1. - stop_f;
6977 switch (start_i % 6)
6981 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6984 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
6989 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6992 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
6996 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7001 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7011 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7014 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7019 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7022 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7026 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7031 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7037 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
7039 gradient_start_point_3d[0] = gradient_param[0];
7040 gradient_start_point_3d[1] = gradient_param[1];
7041 gradient_start_point_3d[2] = gradient_param[4];
7043 gradient_stop_point_3d[0] = gradient_param[2];
7044 gradient_stop_point_3d[1] = gradient_param[3];
7045 gradient_stop_point_3d[2] = gradient_param[5];
7048 svg_project_point(gradient_start_point_3d,
7054 svg_project_point(gradient_stop_point_3d,
7061 out <<
" <linearGradient id=\"" << triangle_counter
7062 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7064 <<
static_cast<unsigned int>(
7066 ((gradient_start_point[0] - x_min_perspective) /
7067 x_dimension_perspective) *
7068 (width - (width / 100.) * 2. * margin_in_percent) +
7069 ((width / 100.) * margin_in_percent))
7072 <<
static_cast<unsigned int>(
7073 .5 + height - (height / 100.) * margin_in_percent -
7074 ((gradient_start_point[1] - y_min_perspective) /
7075 y_dimension_perspective) *
7076 (height - (height / 100.) * 2. * margin_in_percent))
7079 <<
static_cast<unsigned int>(
7081 ((gradient_stop_point[0] - x_min_perspective) /
7082 x_dimension_perspective) *
7083 (width - (width / 100.) * 2. * margin_in_percent) +
7084 ((width / 100.) * margin_in_percent))
7087 <<
static_cast<unsigned int>(
7088 .5 + height - (height / 100.) * margin_in_percent -
7089 ((gradient_stop_point[1] - y_min_perspective) /
7090 y_dimension_perspective) *
7091 (height - (height / 100.) * 2. * margin_in_percent))
7094 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7095 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7096 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7097 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7098 <<
" </linearGradient>" <<
'\n';
7101 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
7102 double x3 = cell.projected_center[0];
7103 double y3 = cell.projected_center[1];
7105 switch (triangle_index)
7108 x1 = cell.projected_vertices[0][0],
7109 y1 = cell.projected_vertices[0][1],
7110 x2 = cell.projected_vertices[1][0],
7111 y2 = cell.projected_vertices[1][1];
7114 x1 = cell.projected_vertices[1][0],
7115 y1 = cell.projected_vertices[1][1],
7116 x2 = cell.projected_vertices[3][0],
7117 y2 = cell.projected_vertices[3][1];
7120 x1 = cell.projected_vertices[3][0],
7121 y1 = cell.projected_vertices[3][1],
7122 x2 = cell.projected_vertices[2][0],
7123 y2 = cell.projected_vertices[2][1];
7126 x1 = cell.projected_vertices[2][0],
7127 y1 = cell.projected_vertices[2][1],
7128 x2 = cell.projected_vertices[0][0],
7129 y2 = cell.projected_vertices[0][1];
7135 out <<
" <path d=\"M "
7136 <<
static_cast<unsigned int>(
7138 ((x1 - x_min_perspective) / x_dimension_perspective) *
7139 (width - (width / 100.) * 2. * margin_in_percent) +
7140 ((width / 100.) * margin_in_percent))
7142 <<
static_cast<unsigned int>(
7143 .5 + height - (height / 100.) * margin_in_percent -
7144 ((y1 - y_min_perspective) / y_dimension_perspective) *
7145 (height - (height / 100.) * 2. * margin_in_percent))
7147 <<
static_cast<unsigned int>(
7149 ((x2 - x_min_perspective) / x_dimension_perspective) *
7150 (width - (width / 100.) * 2. * margin_in_percent) +
7151 ((width / 100.) * margin_in_percent))
7153 <<
static_cast<unsigned int>(
7154 .5 + height - (height / 100.) * margin_in_percent -
7155 ((y2 - y_min_perspective) / y_dimension_perspective) *
7156 (height - (height / 100.) * 2. * margin_in_percent))
7158 <<
static_cast<unsigned int>(
7160 ((x3 - x_min_perspective) / x_dimension_perspective) *
7161 (width - (width / 100.) * 2. * margin_in_percent) +
7162 ((width / 100.) * margin_in_percent))
7164 <<
static_cast<unsigned int>(
7165 .5 + height - (height / 100.) * margin_in_percent -
7166 ((y3 - y_min_perspective) / y_dimension_perspective) *
7167 (height - (height / 100.) * 2. * margin_in_percent))
7169 <<
static_cast<unsigned int>(
7171 ((x1 - x_min_perspective) / x_dimension_perspective) *
7172 (width - (width / 100.) * 2. * margin_in_percent) +
7173 ((width / 100.) * margin_in_percent))
7175 <<
static_cast<unsigned int>(
7176 .5 + height - (height / 100.) * margin_in_percent -
7177 ((y1 - y_min_perspective) / y_dimension_perspective) *
7178 (height - (height / 100.) * 2. * margin_in_percent))
7179 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter
7190 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
7192 unsigned int element_height =
static_cast<unsigned int>(
7193 ((height / 100.) * (71. - 2. * margin_in_percent)) / 4);
7194 unsigned int element_width =
7195 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
7197 additional_width = 0;
7200 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
7202 for (
unsigned int index = 0; index < 4; ++index)
7204 double start_h = .667 - ((index + 1) / 4.) * .667;
7205 double stop_h = .667 - (index / 4.) * .667;
7207 unsigned int start_r = 0;
7208 unsigned int start_g = 0;
7209 unsigned int start_b = 0;
7211 unsigned int stop_r = 0;
7212 unsigned int stop_g = 0;
7213 unsigned int stop_b = 0;
7215 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
7216 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
7218 double start_f = start_h * 6. - start_i;
7219 double start_q = 1. - start_f;
7221 double stop_f = stop_h * 6. - stop_i;
7222 double stop_q = 1. - stop_f;
7224 switch (start_i % 6)
7228 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
7231 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
7236 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
7239 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
7243 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7248 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7258 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7261 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7266 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7269 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7273 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7278 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7285 out <<
" <linearGradient id=\"colorbar_" << index
7286 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7287 <<
"x1=\"" << width + additional_width <<
"\" "
7289 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7290 (margin_in_percent + 29)) +
7291 (3 - index) * element_height
7293 <<
"x2=\"" << width + additional_width <<
"\" "
7295 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7296 (margin_in_percent + 29)) +
7297 (4 - index) * element_height
7300 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7301 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7302 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7303 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7304 <<
" </linearGradient>" <<
'\n';
7309 <<
" x=\"" << width + additional_width <<
"\" y=\""
7310 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7311 (margin_in_percent + 29)) +
7312 (3 - index) * element_height
7313 <<
"\" width=\"" << element_width <<
"\" height=\""
7315 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_"
7316 << index <<
")\"/>" <<
'\n';
7319 for (
unsigned int index = 0; index < 5; ++index)
7323 << width + additional_width +
7324 static_cast<unsigned int>(1.5 * element_width)
7326 <<
static_cast<unsigned int>(
7327 .5 + (height / 100.) * (margin_in_percent + 29) +
7328 (4. - index) * element_height + 30.)
7330 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
7332 if (index == 0 || index == 4)
7333 out <<
"; font-weight:bold";
7336 <<
static_cast<float>(
7337 (
static_cast<int>((z_min + index * (z_dimension / 4.)) *
7346 out <<
"</text>" <<
'\n';
7351 out <<
'\n' <<
"</svg>";
7357 template <
int dim,
int spacedim>
7361 const std::vector<std::string> &data_names,
7363 std::tuple<
unsigned int,
7367 &nonscalar_data_ranges,
7376 out << dim <<
' ' << spacedim <<
'\n';
7379 out <<
"[deal.II intermediate format graphics data]" <<
'\n'
7385 out << data_names.size() <<
'\n';
7386 for (
const auto &data_name : data_names)
7387 out << data_name <<
'\n';
7389 out << patches.size() <<
'\n';
7390 for (
unsigned int i = 0; i < patches.size(); ++i)
7391 out << patches[i] <<
'\n';
7393 out << nonscalar_data_ranges.size() <<
'\n';
7394 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
7395 out << std::get<0>(nonscalar_data_range) <<
' '
7396 << std::get<1>(nonscalar_data_range) <<
'\n'
7397 << std::get<2>(nonscalar_data_range) <<
'\n';
7405 template <
int dim,
int spacedim>
7409 const std::vector<std::string> &data_names,
7411 std::tuple<
unsigned int,
7415 &nonscalar_data_ranges,
7417 const std::string &filename,
7421#ifndef DEAL_II_WITH_MPI
7424 (void)nonscalar_data_ranges;
7431 ExcMessage(
"This functionality requires MPI to be enabled."));
7450 std::vector<char> my_buffer;
7452 boost::iostreams::filtering_ostream f;
7458# ifdef DEAL_II_WITH_ZLIB
7459 f.push(boost::iostreams::zlib_compressor(
7460 get_boost_zlib_compression_level(compression)));
7465 "Compression requires deal.II to be configured with ZLIB support."));
7468 boost::iostreams::back_insert_device<std::vector<char>> inserter(
7473 patches, data_names, nonscalar_data_ranges, flags, f);
7475 const std::uint64_t my_size = my_buffer.size();
7481 const ParallelIntermediateHeader header{
7484 static_cast<std::uint64_t
>(compression),
7494 std::vector<std::uint64_t> chunk_sizes(n_ranks);
7495 int ierr = MPI_Gather(&my_size,
7498 static_cast<std::uint64_t *
>(chunk_sizes.data()),
7506 ierr = MPI_Info_create(&info);
7509 ierr = MPI_File_open(
7510 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7512 ierr = MPI_Info_free(&info);
7516 ierr = MPI_File_set_size(fh, 0);
7520 ierr = MPI_Barrier(
comm);
7527 fh, 0, &header,
sizeof(header), MPI_CHAR, MPI_STATUS_IGNORE);
7542 std::uint64_t prefix_sum = 0;
7543 ierr = MPI_Exscan(&my_size,
7552 const MPI_Offset offset =
static_cast<MPI_Offset
>(
sizeof(header)) +
7553 n_ranks *
sizeof(std::uint64_t) + prefix_sum;
7556 fh, offset, my_buffer.data(), my_size, MPI_CHAR, MPI_STATUS_IGNORE);
7565 ierr = MPI_File_sync(fh);
7568 ierr = MPI_File_close(&fh);
7575 std::pair<unsigned int, unsigned int>
7580 unsigned int dim, spacedim;
7581 input >> dim >> spacedim;
7583 return std::make_pair(dim, spacedim);
7592template <
int dim,
int spacedim>
7600template <
int dim,
int spacedim>
7613template <
int dim,
int spacedim>
7626template <
int dim,
int spacedim>
7639template <
int dim,
int spacedim>
7652template <
int dim,
int spacedim>
7665template <
int dim,
int spacedim>
7678template <
int dim,
int spacedim>
7691template <
int dim,
int spacedim>
7702template <
int dim,
int spacedim>
7713template <
int dim,
int spacedim>
7725template <
int dim,
int spacedim>
7728 const std::string &filename,
7731#ifndef DEAL_II_WITH_MPI
7735 std::ofstream f(filename);
7743 int ierr = MPI_Info_create(&info);
7746 ierr = MPI_File_open(
7747 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7750 ierr = MPI_File_set_size(fh, 0);
7754 ierr = MPI_Barrier(
comm);
7756 ierr = MPI_Info_free(&info);
7760 unsigned int header_size;
7761 std::uint64_t footer_offset;
7766 std::stringstream ss;
7768 header_size = ss.str().size();
7771 fh, 0, ss.str().c_str(), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
7775 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0,
comm);
7788 std::stringstream ss;
7789 if (my_n_patches > 0 || (global_n_patches == 0 && myrank == 0))
7797 const std::uint64_t size_on_proc = ss.str().size();
7798 std::uint64_t prefix_sum = 0;
7799 ierr = MPI_Exscan(&size_on_proc,
7808 const MPI_Offset offset =
static_cast<MPI_Offset
>(header_size) + prefix_sum;
7818 if (myrank == n_ranks - 1)
7821 footer_offset = size_on_proc + offset;
7823 std::stringstream ss;
7825 const unsigned int footer_size = ss.str().size();
7843 ierr = MPI_File_sync(fh);
7846 ierr = MPI_File_close(&fh);
7853template <
int dim,
int spacedim>
7857 const std::vector<std::string> &piece_names)
const
7868template <
int dim,
int spacedim>
7871 const std::string &directory,
7872 const std::string &filename_without_extension,
7873 const unsigned int counter,
7875 const unsigned int n_digits_for_counter,
7876 const unsigned int n_groups)
const
7879 const unsigned int n_ranks =
7881 const unsigned int n_files_written =
7882 (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
7887 const unsigned int n_digits =
7890 const unsigned int color = rank % n_files_written;
7891 const std::string filename =
7892 directory + filename_without_extension +
"_" +
7896 if (n_groups == 0 || n_groups > n_ranks)
7899 std::ofstream output(filename);
7903 else if (n_groups == 1)
7910#ifdef DEAL_II_WITH_MPI
7913 int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group);
7923 const std::string pvtu_filename =
7924 filename_without_extension +
"_" +
7929 std::vector<std::string> filename_vector;
7930 for (
unsigned int i = 0; i < n_files_written; ++i)
7932 const std::string filename =
7933 filename_without_extension +
"_" +
7937 filename_vector.emplace_back(filename);
7940 std::ofstream pvtu_output(directory + pvtu_filename);
7944 return pvtu_filename;
7949template <
int dim,
int spacedim>
7952 std::ostream &out)
const
7963template <
int dim,
int spacedim>
7966 const std::string &filename,
7982template <
int dim,
int spacedim>
7986 const std::string &h5_filename,
7987 const double cur_time,
7991 data_filter, h5_filename, h5_filename, cur_time,
comm);
7996template <
int dim,
int spacedim>
8000 const std::string &h5_mesh_filename,
8001 const std::string &h5_solution_filename,
8002 const double cur_time,
8006 ExcMessage(
"XDMF only supports 2 or 3 space dimensions."));
8008#ifndef DEAL_II_WITH_HDF5
8012 (void)h5_mesh_filename;
8013 (void)h5_solution_filename;
8022 std::uint64_t local_node_cell_count[2], global_node_cell_count[2];
8024 local_node_cell_count[0] = data_filter.
n_nodes();
8025 local_node_cell_count[1] = data_filter.
n_cells();
8029 int ierr = MPI_Allreduce(local_node_cell_count,
8030 global_node_cell_count,
8044 const bool have_data = (data_filter.
n_nodes() > 0);
8047 const int key = myrank;
8048 const int color = (have_data ? 1 : 0);
8049 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8053 const bool am_i_first_rank_with_data =
8056 ierr = MPI_Comm_free(&split_comm);
8059 const int tag = 47381;
8062 if (am_i_first_rank_with_data)
8070 for (
const auto &patch : patches)
8076 h5_solution_filename,
8078 global_node_cell_count[0],
8079 global_node_cell_count[1],
8082 patches[0].reference_cell);
8083 const unsigned int n_data_sets = data_filter.
n_data_sets();
8087 for (
unsigned int i = 0; i < n_data_sets; ++i)
8097 ierr = MPI_Send(buffer.data(), buffer.size(), MPI_BYTE, 0, tag,
comm);
8106 if (myrank == 0 && !am_i_first_rank_with_data)
8111 int ierr = MPI_Probe(MPI_ANY_SOURCE, tag,
comm, &status);
8115 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
8118 std::vector<char> buffer(len);
8119 ierr = MPI_Recv(buffer.data(),
8136template <
int dim,
int spacedim>
8139 const std::vector<XDMFEntry> &entries,
8140 const std::string &filename,
8143#ifdef DEAL_II_WITH_MPI
8147 const int myrank = 0;
8153 std::ofstream xdmf_file(filename);
8155 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
8156 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
8157 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
8158 xdmf_file <<
" <Domain>\n";
8160 <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
8162 for (
const auto &entry : entries)
8164 xdmf_file << entry.get_xdmf_content(3);
8167 xdmf_file <<
" </Grid>\n";
8168 xdmf_file <<
" </Domain>\n";
8169 xdmf_file <<
"</Xdmf>\n";
8181template <
int dim,
int spacedim>
8195#ifdef DEAL_II_WITH_HDF5
8199 template <
int dim,
int spacedim>
8204 const bool write_mesh_file,
8205 const std::string &mesh_filename,
8206 const std::string &solution_filename,
8209 hid_t h5_mesh_file_id = -1, h5_solution_file_id, file_plist_id, plist_id;
8210 hid_t node_dataspace, node_dataset, node_file_dataspace,
8211 node_memory_dataspace, node_dataset_id;
8212 hid_t cell_dataspace, cell_dataset, cell_file_dataspace,
8213 cell_memory_dataspace;
8214 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace,
8215 pt_data_memory_dataspace;
8217 std::uint64_t local_node_cell_count[2];
8218 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
8219 std::vector<double> node_data_vec;
8220 std::vector<unsigned int> cell_data_vec;
8224 local_node_cell_count[0] = data_filter.
n_nodes();
8225 local_node_cell_count[1] = data_filter.
n_cells();
8228 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
8231# ifdef DEAL_II_WITH_MPI
8232# ifdef H5_HAVE_PARALLEL
8234 status = H5Pset_fapl_mpio(file_plist_id,
comm, MPI_INFO_NULL);
8239# ifndef DEAL_II_WITH_ZLIB
8246 std::uint64_t global_node_cell_count[2] = {0, 0};
8247 std::uint64_t global_node_cell_offsets[2] = {0, 0};
8249# ifdef DEAL_II_WITH_MPI
8251 MPI_Allreduce(local_node_cell_count,
8252 global_node_cell_count,
8258 ierr = MPI_Exscan(local_node_cell_count,
8259 global_node_cell_offsets,
8266 global_node_cell_count[0] = local_node_cell_count[0];
8267 global_node_cell_count[1] = local_node_cell_count[1];
8268 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
8272 plist_id = H5Pcreate(H5P_DATASET_XFER);
8274# ifdef DEAL_II_WITH_MPI
8275# ifdef H5_HAVE_PARALLEL
8276 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
8281 if (write_mesh_file)
8284 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(),
8292 node_ds_dim[0] = global_node_cell_count[0];
8293 node_ds_dim[1] = (spacedim < 2) ? 2 : spacedim;
8294 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8297 cell_ds_dim[0] = global_node_cell_count[1];
8298 cell_ds_dim[1] = patches[0].reference_cell.n_vertices();
8299 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
8303# if H5Gcreate_vers == 1
8304 node_dataset = H5Dcreate(h5_mesh_file_id,
8310 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8311# ifdef DEAL_II_WITH_ZLIB
8312 H5Pset_deflate(node_dataset_id,
8314 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8316 node_dataset = H5Dcreate(h5_mesh_file_id,
8323 H5Pclose(node_dataset_id);
8326# if H5Gcreate_vers == 1
8327 cell_dataset = H5Dcreate(h5_mesh_file_id,
8333 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8334# ifdef DEAL_II_WITH_ZLIB
8335 H5Pset_deflate(node_dataset_id,
8337 H5Pset_chunk(node_dataset_id, 2, cell_ds_dim);
8339 cell_dataset = H5Dcreate(h5_mesh_file_id,
8346 H5Pclose(node_dataset_id);
8351 status = H5Sclose(node_dataspace);
8353 status = H5Sclose(cell_dataspace);
8358 count[0] = local_node_cell_count[0];
8359 count[1] = (spacedim < 2) ? 2 : spacedim;
8361 offset[0] = global_node_cell_offsets[0];
8364 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8368 node_file_dataspace = H5Dget_space(node_dataset);
8370 status = H5Sselect_hyperslab(
8371 node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8375 count[0] = local_node_cell_count[1];
8376 count[1] = patches[0].reference_cell.n_vertices();
8377 offset[0] = global_node_cell_offsets[1];
8379 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8382 cell_file_dataspace = H5Dget_space(cell_dataset);
8384 status = H5Sselect_hyperslab(
8385 cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8390 status = H5Dwrite(node_dataset,
8392 node_memory_dataspace,
8393 node_file_dataspace,
8395 node_data_vec.data());
8397 node_data_vec.clear();
8400 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
8401 status = H5Dwrite(cell_dataset,
8403 cell_memory_dataspace,
8404 cell_file_dataspace,
8406 cell_data_vec.data());
8408 cell_data_vec.clear();
8411 status = H5Sclose(node_file_dataspace);
8413 status = H5Sclose(cell_file_dataspace);
8417 status = H5Sclose(node_memory_dataspace);
8419 status = H5Sclose(cell_memory_dataspace);
8423 status = H5Dclose(node_dataset);
8425 status = H5Dclose(cell_dataset);
8429 if (mesh_filename != solution_filename)
8431 status = H5Fclose(h5_mesh_file_id);
8437 if (mesh_filename == solution_filename && write_mesh_file)
8439 h5_solution_file_id = h5_mesh_file_id;
8444 h5_solution_file_id = H5Fcreate(solution_filename.c_str(),
8454 std::string vector_name;
8463 node_ds_dim[0] = global_node_cell_count[0];
8464 node_ds_dim[1] = pt_data_vector_dim;
8465 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8468# if H5Gcreate_vers == 1
8469 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8470 vector_name.c_str(),
8475 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8476# ifdef DEAL_II_WITH_ZLIB
8477 H5Pset_deflate(node_dataset_id,
8479 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8481 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8482 vector_name.c_str(),
8488 H5Pclose(node_dataset_id);
8493 count[0] = local_node_cell_count[0];
8494 count[1] = pt_data_vector_dim;
8495 offset[0] = global_node_cell_offsets[0];
8497 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8501 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
8503 status = H5Sselect_hyperslab(pt_data_file_dataspace,
8512 status = H5Dwrite(pt_data_dataset,
8514 pt_data_memory_dataspace,
8515 pt_data_file_dataspace,
8521 status = H5Sclose(pt_data_dataspace);
8523 status = H5Sclose(pt_data_memory_dataspace);
8525 status = H5Sclose(pt_data_file_dataspace);
8528 status = H5Dclose(pt_data_dataset);
8533 status = H5Pclose(file_plist_id);
8537 status = H5Pclose(plist_id);
8541 status = H5Fclose(h5_solution_file_id);
8549template <
int dim,
int spacedim>
8553 const std::vector<std::string> &data_names,
8555 std::tuple<
unsigned int,
8559 &nonscalar_data_ranges,
8562 const unsigned int n_data_sets = data_names.size();
8564#ifndef DEAL_II_WITH_MPI
8573 if (patches.empty())
8577 unsigned int n_nodes;
8578 std::tie(n_nodes, std::ignore) = count_nodes_and_cells(patches);
8593 [&patches]() {
return create_global_data_table(patches); });
8601 std::move(*create_global_data_table_task.
return_value());
8605 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
8606 std::string vector_name;
8607 for (n_th_vector = 0, data_set = 0; data_set < n_data_sets;)
8610 while (n_th_vector < nonscalar_data_ranges.size() &&
8611 std::get<0>(nonscalar_data_ranges[n_th_vector]) < data_set)
8615 if (n_th_vector < nonscalar_data_ranges.size() &&
8616 std::get<0>(nonscalar_data_ranges[n_th_vector]) == data_set)
8619 pt_data_vector_dim = std::get<1>(nonscalar_data_ranges[n_th_vector]) -
8620 std::get<0>(nonscalar_data_ranges[n_th_vector]) +
8625 std::get<1>(nonscalar_data_ranges[n_th_vector]) >=
8626 std::get<0>(nonscalar_data_ranges[n_th_vector]),
8627 ExcLowerRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8628 std::get<0>(nonscalar_data_ranges[n_th_vector])));
8630 std::get<1>(nonscalar_data_ranges[n_th_vector]) < n_data_sets,
8631 ExcIndexRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8637 if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
8639 vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
8644 for (i = std::get<0>(nonscalar_data_ranges[n_th_vector]);
8645 i < std::get<1>(nonscalar_data_ranges[n_th_vector]);
8647 vector_name += data_names[i] +
"__";
8649 data_names[std::get<1>(nonscalar_data_ranges[n_th_vector])];
8655 pt_data_vector_dim = 1;
8656 vector_name = data_names[data_set];
8666 data_set += pt_data_vector_dim;
8672template <
int dim,
int spacedim>
8676 const std::string &filename,
8685template <
int dim,
int spacedim>
8689 const bool write_mesh_file,
8690 const std::string &mesh_filename,
8691 const std::string &solution_filename,
8705template <
int dim,
int spacedim>
8711 const std::string &filename,
8715 patches, data_filter, flags,
true, filename, filename,
comm);
8720template <
int dim,
int spacedim>
8726 const bool write_mesh_file,
8727 const std::string &mesh_filename,
8728 const std::string &solution_filename,
8734 "DataOutBase was asked to write HDF5 output for a space dimension of 1. "
8735 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
8737#ifndef DEAL_II_WITH_HDF5
8743 (void)write_mesh_file;
8744 (void)mesh_filename;
8745 (void)solution_filename;
8754# ifndef H5_HAVE_PARALLEL
8758 "Serial HDF5 output on multiple processes is not yet supported."));
8775 const bool have_patches = (patches.size() > 0);
8779 const int color = (have_patches ? 1 : 0);
8780 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8786 do_write_hdf5<dim, spacedim>(patches,
8795 const int ierr = MPI_Comm_free(&split_comm);
8803template <
int dim,
int spacedim>
8813 switch (output_format)
8869template <
int dim,
int spacedim>
8878template <
int dim,
int spacedim>
8879template <
typename FlagType>
8883 if constexpr (std::is_same_v<FlagType, DataOutBase::DXFlags>)
8885 else if constexpr (std::is_same_v<FlagType, DataOutBase::UcdFlags>)
8887 else if constexpr (std::is_same_v<FlagType, DataOutBase::PovrayFlags>)
8889 else if constexpr (std::is_same_v<FlagType, DataOutBase::EpsFlags>)
8891 else if constexpr (std::is_same_v<FlagType, DataOutBase::GmvFlags>)
8893 else if constexpr (std::is_same_v<FlagType, DataOutBase::Hdf5Flags>)
8895 else if constexpr (std::is_same_v<FlagType, DataOutBase::TecplotFlags>)
8897 else if constexpr (std::is_same_v<FlagType, DataOutBase::VtkFlags>)
8899 else if constexpr (std::is_same_v<FlagType, DataOutBase::SvgFlags>)
8901 else if constexpr (std::is_same_v<FlagType, DataOutBase::GnuplotFlags>)
8903 else if constexpr (std::is_same_v<FlagType,
8912template <
int dim,
int spacedim>
8925template <
int dim,
int spacedim>
8932 "A name for the output format to be used");
8936 "Number of subdivisions of each mesh cell");
8982template <
int dim,
int spacedim>
8986 const std::string &output_name = prm.
get(
"Output format");
9033template <
int dim,
int spacedim>
9053template <
int dim,
int spacedim>
9055 std::tuple<
unsigned int,
9062 std::tuple<
unsigned int,
9069template <
int dim,
int spacedim>
9078 std::set<std::string> all_names;
9081 std::tuple<
unsigned int,
9087 const unsigned int n_data_sets = data_names.size();
9088 std::vector<bool> data_set_written(n_data_sets,
false);
9090 for (
const auto &range : ranges)
9092 const std::string &name = std::get<2>(range);
9095 Assert(all_names.find(name) == all_names.end(),
9097 "Error: names of fields in DataOut need to be unique, "
9099 name +
"' is used more than once."));
9100 all_names.insert(name);
9101 for (
unsigned int i = std::get<0>(range);
9102 i <= std::get<1>(range);
9104 data_set_written[i] =
true;
9108 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
9109 if (data_set_written[data_set] ==
false)
9111 const std::string &name = data_names[data_set];
9112 Assert(all_names.find(name) == all_names.end(),
9114 "Error: names of fields in DataOut need to be unique, "
9116 name +
"' is used more than once."));
9117 all_names.insert(name);
9127template <
int dim,
int spacedim>
9135 std::vector<typename ::DataOutBase::Patch<dim, spacedim>> tmp;
9139 std::vector<std::string> tmp;
9144 std::tuple<
unsigned int,
9156 std::pair<unsigned int, unsigned int> dimension_info =
9159 (dimension_info.second == spacedim),
9161 dimension_info.first, dim, dimension_info.second, spacedim));
9170 getline(in, header);
9172 std::ostringstream s;
9173 s <<
"[deal.II intermediate format graphics data]";
9175 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9179 getline(in, header);
9181 std::ostringstream s;
9185 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9189 getline(in, header);
9191 std::ostringstream s;
9195 Assert(header == s.str(),
9197 "Invalid or incompatible file format. Intermediate format "
9198 "files can only be read by the same deal.II version as they "
9199 "are written by."));
9203 unsigned int n_datasets;
9206 for (
unsigned int i = 0; i < n_datasets; ++i)
9209 unsigned int n_patches;
9212 for (
unsigned int i = 0; i < n_patches; ++i)
9215 unsigned int n_nonscalar_data_ranges;
9216 in >> n_nonscalar_data_ranges;
9218 for (
unsigned int i = 0; i < n_nonscalar_data_ranges; ++i)
9238template <
int dim,
int spacedim>
9244 ParallelIntermediateHeader header;
9245 in.read(
reinterpret_cast<char *
>(&header),
sizeof(header));
9247 header.magic == 0x00dea111,
9249 "Invalid header of parallel deal.II intermediate format encountered."));
9253 "Incorrect header version of parallel deal.II intermediate format."));
9255 std::vector<std::uint64_t> chunk_sizes(header.n_ranks);
9256 in.read(
reinterpret_cast<char *
>(chunk_sizes.data()),
9257 header.n_ranks *
sizeof(std::uint64_t));
9259 for (
unsigned int n = 0; n < header.n_ranks; ++n)
9263 std::vector<char> temp_buffer(chunk_sizes[n]);
9264 in.read(temp_buffer.data(), chunk_sizes[n]);
9267 header.compression) !=
9271 boost::iostreams::filtering_istreambuf f;
9274#ifdef DEAL_II_WITH_ZLIB
9275 f.push(boost::iostreams::zlib_decompressor());
9280 "Decompression requires deal.II to be configured with ZLIB support."));
9283 boost::iostreams::basic_array_source<char> source(temp_buffer.data(),
9284 temp_buffer.size());
9287 std::stringstream datastream;
9288 boost::iostreams::copy(f, datastream);
9298 temp_reader.
read(datastream);
9306template <
int dim,
int spacedim>
9310 using Patch = typename ::DataOutBase::Patch<dim, spacedim>;
9313 const std::vector<Patch> &source_patches = source.
get_patches();
9323 ExcMessage(
"Both sources need to declare the same components "
9329 ExcMessage(
"Both sources need to declare the same components "
9333 ExcMessage(
"Both sources need to declare the same components "
9337 ExcMessage(
"Both sources need to declare the same components "
9342 Assert(
patches[0].n_subdivisions == source_patches[0].n_subdivisions,
9344 Assert(
patches[0].data.n_rows() == source_patches[0].data.n_rows(),
9346 Assert(
patches[0].data.n_cols() == source_patches[0].data.n_cols(),
9351 const unsigned int old_n_patches =
patches.size();
9352 patches.insert(
patches.end(), source_patches.begin(), source_patches.end());
9355 for (
unsigned int i = old_n_patches; i <
patches.size(); ++i)
9356 patches[i].patch_index += old_n_patches;
9359 for (
unsigned int i = old_n_patches; i <
patches.size(); ++i)
9361 if (
patches[i].neighbors[n] !=
9363 patches[i].neighbors[n] += old_n_patches;
9368template <
int dim,
int spacedim>
9369const std::vector<typename ::DataOutBase::Patch<dim, spacedim>> &
9377template <
int dim,
int spacedim>
9378std::vector<std::string>
9386template <
int dim,
int spacedim>
9388 std::tuple<
unsigned int,
9417 const std::uint64_t nodes,
9418 const std::uint64_t cells,
9419 const unsigned int dim,
9427 const std::string &solution_filename,
9429 const std::uint64_t nodes,
9430 const std::uint64_t cells,
9431 const unsigned int dim,
9479 const std::string &solution_filename,
9481 const std::uint64_t nodes,
9482 const std::uint64_t cells,
9483 const unsigned int dim,
9484 const unsigned int spacedim,
9494 ,
cell_type(cell_type_hex_if_invalid(cell_type_, dim))
9514 indent(
const unsigned int indent_level)
9516 std::string res =
"";
9517 for (
unsigned int i = 0; i < indent_level; ++i)
9531 std::stringstream ss;
9533 ss << indent(indent_level + 0)
9534 <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
9535 ss << indent(indent_level + 1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
9536 ss << indent(indent_level + 1) <<
"<Geometry GeometryType=\""
9538 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
9540 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
9542 ss << indent(indent_level + 2) <<
"</DataItem>\n";
9543 ss << indent(indent_level + 1) <<
"</Geometry>\n";
9548 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\"";
9566 ss <<
"Quadrilateral";
9585 ss <<
"Tetrahedron";
9589 ss <<
"\" NumberOfElements=\"" <<
num_cells;
9591 ss <<
"\" NodesPerElement=\"1\">\n";
9593 ss <<
"\" NodesPerElement=\"2\">\n";
9598 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_cells
9600 <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
9603 ss << indent(indent_level + 2) <<
"</DataItem>\n";
9604 ss << indent(indent_level + 1) <<
"</Topology>\n";
9610 ss << indent(indent_level + 1)
9611 <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\""
9613 ss << indent(indent_level + 1) <<
"</Topology>\n";
9618 ss << indent(indent_level + 1) <<
"<Attribute Name=\""
9619 << attribute_dim.first <<
"\" AttributeType=\""
9620 << (attribute_dim.second > 1 ?
"Vector" :
"Scalar")
9621 <<
"\" Center=\"Node\">\n";
9623 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
9624 <<
" " << (attribute_dim.second > 1 ? 3 : 1)
9625 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
9627 << attribute_dim.first <<
'\n';
9628 ss << indent(indent_level + 2) <<
"</DataItem>\n";
9629 ss << indent(indent_level + 1) <<
"</Attribute>\n";
9632 ss << indent(indent_level + 0) <<
"</Grid>\n";
9641 template <
int dim,
int spacedim>
9646 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]"
9665 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
9666 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
9667 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
9668 out << patch.
data[i][j] <<
' ';
9677 template <
int dim,
int spacedim>
9689 getline(in, header);
9690 while ((header.size() != 0) && (header.back() ==
' '))
9691 header.erase(header.size() - 1);
9693 while ((header.empty()) && in);
9695 std::ostringstream s;
9696 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
9698 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9702 if constexpr (dim > 0)
9718 if constexpr (dim > 1)
9723 unsigned int n_rows, n_cols;
9724 in >> n_rows >> n_cols;
9725 patch.
data.reinit(n_rows, n_cols);
9726 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
9727 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
9728 in >> patch.
data[i][j];
9739#include "base/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
unsigned int default_subdivisions
void parse_parameters(ParameterHandler &prm)
DataOutBase::Deal_II_IntermediateFlags deal_II_intermediate_flags
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)
virtual std::vector< std::string > get_dataset_names() const =0
DataOutBase::TecplotFlags tecplot_flags
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
DataOutBase::GmvFlags gmv_flags
std::size_t memory_consumption() const
void set_default_format(const DataOutBase::OutputFormat default_format)
DataOutBase::Hdf5Flags hdf5_flags
DataOutBase::PovrayFlags povray_flags
DataOutBase::UcdFlags ucd_flags
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
DataOutBase::OutputFormat default_fmt
DataOutBase::GnuplotFlags gnuplot_flags
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
DataOutBase::SvgFlags svg_flags
void validate_dataset_names() const
void set_flags(const FlagType &flags)
void write_vtk(std::ostream &out) const
virtual const std::vector< DataOutBase::Patch< dim, spacedim > > & get_patches() const =0
DataOutBase::VtkFlags vtk_flags
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
DataOutBase::EpsFlags eps_flags
void write_eps(std::ostream &out) const
DataOutBase::DXFlags dx_flags
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)
std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > nonscalar_data_ranges
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
std::vector< std::string > dataset_names
std::vector<::DataOutBase::Patch< dim, spacedim > > patches
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
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_FALLTHROUGH
#define DEAL_II_PACKAGE_NAME
const unsigned int DoFAccessor< structdim, dim, spacedim, level_dof_access >::space_dimension
const unsigned int DoFAccessor< structdim, dim, spacedim, level_dof_access >::dimension
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcIncompatiblePatchLists()
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)
static ::ExceptionBase & ExcIncompatibleDimensions(int arg1, int arg2, int arg3, int arg4)
#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 & ExcIncompatibleDatasetNames()
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)
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)
const unsigned int Patch< 0, spacedim >::n_subdivisions
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)
const ReferenceCell Patch< 0, spacedim >::reference_cell
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 ReferenceCell Triangle
constexpr ReferenceCell Hexahedron
constexpr ReferenceCell Pyramid
constexpr ReferenceCell Wedge
constexpr ReferenceCell Vertex
constexpr const ReferenceCell & get_hypercube()
constexpr ReferenceCell Invalid
constexpr ReferenceCell Quadrilateral
constexpr ReferenceCell Tetrahedron
constexpr const ReferenceCell & get_simplex()
constexpr 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)
const MPI_Datatype mpi_type_id_for_type
void free_communicator(MPI_Comm mpi_communicator)
std::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)
constexpr T fixed_power(const T t)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
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)
constexpr 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 > &)
unsigned int global_dof_index
*braid_SplitCommworld & comm
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)
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
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
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)
Point< spacedim > vertices[1]
bool points_are_available
static const unsigned int no_neighbor
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 constexpr unsigned int vertices_per_cell
static constexpr std::array< unsigned int, vertices_per_cell > ucd_to_deal
static constexpr unsigned int faces_per_cell
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static constexpr std::array< unsigned int, vertices_per_cell > dx_to_deal
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)