44#ifdef DEAL_II_WITH_ZLIB
48#ifdef DEAL_II_WITH_HDF5
52#ifdef DEAL_II_WITH_NETCDF
54# include <netcdf_meta.h>
55# include <netcdf_par.h>
58#include <boost/archive/iterators/base64_from_binary.hpp>
59#include <boost/archive/iterators/transform_width.hpp>
60#include <boost/iostreams/copy.hpp>
61#include <boost/iostreams/device/back_inserter.hpp>
62#include <boost/iostreams/filtering_stream.hpp>
63#ifdef DEAL_II_WITH_ZLIB
64# include <boost/iostreams/filter/zlib.hpp>
79 <<
"Unexpected input: expected line\n <" << arg1
80 <<
">\nbut got\n <" << arg2 <<
">");
82# ifdef DEAL_II_WITH_ZLIB
83 constexpr bool deal_ii_with_zlib =
true;
85 constexpr bool deal_ii_with_zlib =
false;
89# ifdef DEAL_II_WITH_ZLIB
100 return Z_NO_COMPRESSION;
104 return Z_BEST_COMPRESSION;
106 return Z_DEFAULT_COMPRESSION;
109 return Z_NO_COMPRESSION;
113# ifdef DEAL_II_WITH_MPI
124 return boost::iostreams::zlib::no_compression;
126 return boost::iostreams::zlib::best_speed;
128 return boost::iostreams::zlib::best_compression;
130 return boost::iostreams::zlib::default_compression;
133 return boost::iostreams::zlib::no_compression;
143 template <
typename T>
145 compress_array(
const std::vector<T> &
data,
147 std::ostringstream &output)
149# ifdef DEAL_II_WITH_ZLIB
150 if (
data.size() != 0)
152 const std::size_t uncompressed_size = (
data.size() *
sizeof(
T));
160 std::numeric_limits<std::uint32_t>::max(),
164 auto compressed_data_length = compressBound(uncompressed_size);
166 std::numeric_limits<std::uint32_t>::max(),
169 std::vector<unsigned char> compressed_data(compressed_data_length);
171 int err = compress2(&compressed_data[0],
172 &compressed_data_length,
173 reinterpret_cast<const Bytef *
>(
data.data()),
175 get_zlib_compression_level(compression_level));
179 compressed_data.resize(compressed_data_length);
182 const std::uint32_t compression_header[4] = {
184 static_cast<std::uint32_t
>(uncompressed_size),
185 static_cast<std::uint32_t
>(
187 static_cast<std::uint32_t
>(
188 compressed_data_length)};
191 const std::array<std::string, 3> paddings{{
"",
"==",
"="}};
195 static_assert(
sizeof(compressed_data[0]) == 1);
196 using namespace boost::archive::iterators;
198 base64_from_binary<transform_width<const unsigned char *, 6, 8>>;
200 auto char_begin =
reinterpret_cast<const unsigned char *
>(
201 std::begin(compression_header)),
202 char_end =
reinterpret_cast<const unsigned char *
>(
203 std::end(compression_header));
205 for (
auto it =
begin; it !=
end; ++it)
208 output << paddings[(char_end - char_begin) % 3];
215 auto it =
iterator(compressed_data.data()),
216 end =
iterator(compressed_data.data() + compressed_data.size());
217 std::array<char, 128> buffer;
220 std::streamsize count = 0;
221 for (; count < static_cast<std::streamsize>(buffer.size());
229 output.write(buffer.data(), count);
232 output << paddings[compressed_data.size() % 3];
237 (void)compression_level;
240 ExcMessage(
"This function can only be called if cmake found "
241 "a working libz installation."));
255 template <
typename T>
257 vtu_stringize_array(
const std::vector<T> &
data,
260 std::ostringstream &output)
262 if (deal_ii_with_zlib &&
266 compress_array(
data, compression_level, output);
270 const auto old_precision = output.precision(precision);
271 for (
const T &el :
data)
273 output.precision(old_precision);
286 struct ParallelIntermediateHeader
289 std::uint64_t version;
290 std::uint64_t compression;
291 std::uint64_t dimension;
292 std::uint64_t space_dimension;
293 std::uint64_t n_ranks;
294 std::uint64_t n_patches;
344 SvgCell::operator<(
const SvgCell &e)
const
347 return depth >
e.depth;
385 EpsCell2d::operator<(
const EpsCell2d &e)
const
388 return depth > e.depth;
404 template <
int dim,
int spacedim,
typename Number =
double>
405 std::unique_ptr<Table<2, Number>>
406 create_global_data_table(
const std::vector<Patch<dim, spacedim>> &patches)
410 return std::make_unique<Table<2, Number>>();
419 const unsigned int n_data_sets = patches[0].points_are_available ?
420 (patches[0].data.n_rows() - spacedim) :
421 patches[0].
data.n_rows();
422 const unsigned int n_data_points =
423 std::accumulate(patches.begin(),
426 [](
const unsigned int count,
427 const Patch<dim, spacedim> &patch) {
428 return count + patch.data.n_cols();
431 std::unique_ptr<Table<2, Number>> global_data_table =
432 std::make_unique<Table<2, Number>>(n_data_sets, n_data_points);
435 unsigned int next_value = 0;
436 for (
const auto &patch : patches)
438 const unsigned int n_subdivisions = patch.n_subdivisions;
440 Assert((patch.data.n_rows() == n_data_sets &&
441 !patch.points_are_available) ||
442 (patch.data.n_rows() == n_data_sets + spacedim &&
443 patch.points_are_available),
445 (n_data_sets + spacedim) :
447 patch.
data.n_rows()));
448 Assert(patch.reference_cell != ReferenceCells::get_hypercube<dim>() ||
449 (n_data_sets == 0) ||
450 (patch.data.n_cols() ==
451 Utilities::fixed_power<dim>(n_subdivisions + 1)),
453 n_subdivisions + 1));
455 for (
unsigned int i = 0; i < patch.data.n_cols(); ++i, ++next_value)
456 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
457 (*global_data_table)[data_set][next_value] =
458 patch.data(data_set, i);
462 return global_data_table;
472 , node_dim(
numbers::invalid_unsigned_int)
480 , node_dim(
numbers::invalid_unsigned_int)
493 for (
unsigned int d = 0; d < dim; ++d)
497 unsigned int internal_ind;
508 internal_ind = it->second;
518 const unsigned int pt_index)
536 for (
unsigned int d = 0; d <
node_dim; ++d)
537 node_data[
node_dim * existing_point.second + d] =
538 existing_point.first[d];
546 std::vector<unsigned int> &cell_data)
const
552 cell_data[filtered_cell.first] =
553 filtered_cell.second + local_node_offset;
622 const unsigned int start,
623 const std::array<unsigned int, dim> &offsets)
627 const unsigned int base_entry =
640 const unsigned int d1 = offsets[0];
649 const unsigned int d1 = offsets[0];
650 const unsigned int d2 = offsets[1];
661 const unsigned int d1 = offsets[0];
662 const unsigned int d2 = offsets[1];
663 const unsigned int d3 = offsets[2];
686 const unsigned int start,
687 const unsigned int n_points,
692 const unsigned int base_entry = index * n_points;
694 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
696 for (
unsigned int i = 0; i < n_points; ++i)
707 const unsigned int dimension,
708 const unsigned int set_num,
711 unsigned int new_dim;
730 for (
unsigned int d = 0; d < new_dim; ++d)
733 data_sets.back()[r * new_dim + d] = data_vectors(set_num + d, i);
749 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
751 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
753 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
768 template <
int dim,
int spacedim>
769 std::array<unsigned int, 3>
771 const bool write_higher_order_cells)
773 std::array<unsigned int, 3> vtk_cell_id = {
779 if (write_higher_order_cells)
782 vtk_cell_id[2] = patch.
data.n_cols();
788 patch.
data.n_cols() == 6)
792 vtk_cell_id[2] = patch.
data.n_cols();
795 patch.
data.n_cols() == 10)
799 vtk_cell_id[2] = patch.
data.n_cols();
810 vtk_cell_id[2] = patch.
data.n_cols();
829 template <
int dim,
int spacedim>
831 get_equispaced_location(
833 const std::initializer_list<unsigned int> &lattice_location,
834 const unsigned int n_subdivisions)
841 const unsigned int xstep = (dim > 0 ? *(lattice_location.begin() + 0) : 0);
842 const unsigned int ystep = (dim > 1 ? *(lattice_location.begin() + 1) : 0);
843 const unsigned int zstep = (dim > 2 ? *(lattice_location.begin() + 2) : 0);
851 unsigned int point_no = 0;
856 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
860 point_no += (n_subdivisions + 1) * ystep;
874 for (
unsigned int d = 0;
d < spacedim; ++
d)
875 node[d] = patch.
data(patch.
data.size(0) - spacedim + d, point_no);
882 if constexpr (dim == 0)
887 const double stepsize = 1. / n_subdivisions;
888 const double xfrac = xstep * stepsize;
894 const double yfrac = ystep * stepsize;
896 node += ((patch.
vertices[3] * xfrac) +
897 (patch.
vertices[2] * (1 - xfrac))) *
901 const double zfrac = zstep * stepsize;
903 node += (((patch.
vertices[5] * xfrac) +
904 (patch.
vertices[4] * (1 - xfrac))) *
907 (patch.
vertices[6] * (1 - xfrac))) *
920 template <
int dim,
int spacedim>
923 const unsigned int node_index)
928 unsigned int point_no_actual = node_index;
933 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
934 point_no_actual = table[node_index];
942 for (
unsigned int d = 0;
d < spacedim; ++
d)
944 patch.
data(patch.
data.size(0) - spacedim + d, point_no_actual);
957 return patch.
vertices[point_no_actual];
968 template <
int dim,
int spacedim>
969 std::tuple<unsigned int, unsigned int>
970 count_nodes_and_cells(
973 unsigned int n_nodes = 0;
975 for (
const auto &patch : patches)
979 "The reference cell for this patch is set to 'Invalid', "
980 "but that is clearly not a valid choice. Did you forget "
981 "to set the reference cell for the patch?"));
996 return std::make_tuple(n_nodes, n_cells);
1006 template <
int dim,
int spacedim>
1007 std::tuple<unsigned int, unsigned int, unsigned int>
1008 count_nodes_and_cells_and_points(
1010 const bool write_higher_order_cells)
1012 unsigned int n_nodes = 0;
1014 unsigned int n_points_and_n_cells = 0;
1016 for (
const auto &patch : patches)
1020 n_nodes += Utilities::fixed_power<dim>(patch.
n_subdivisions + 1);
1022 if (write_higher_order_cells)
1028 n_points_and_n_cells +=
1037 const unsigned int n_subcells =
1040 n_points_and_n_cells +=
1046 n_nodes += patch.
data.n_cols();
1048 n_points_and_n_cells += patch.
data.n_cols() + 1;
1052 return std::make_tuple(n_nodes, n_cells, n_points_and_n_cells);
1060 template <
typename FlagsType>
1067 StreamBase(std::ostream &stream,
const FlagsType &flags)
1079 write_point(
const unsigned int,
const Point<dim> &)
1082 ExcMessage(
"The derived class you are using needs to "
1083 "reimplement this function if you want to call "
1103 write_cell(
const unsigned int ,
1104 const unsigned int ,
1105 std::array<unsigned int, dim> & )
1108 ExcMessage(
"The derived class you are using needs to "
1109 "reimplement this function if you want to call "
1121 write_cell_single(
const unsigned int index,
1122 const unsigned int start,
1123 const unsigned int n_points,
1129 (void)reference_cell;
1132 ExcMessage(
"The derived class you are using needs to "
1133 "reimplement this function if you want to call "
1151 template <
typename T>
1165 unsigned int selected_component;
1172 std::ostream &stream;
1177 const FlagsType flags;
1183 class DXStream :
public StreamBase<DataOutBase::DXFlags>
1190 write_point(
const unsigned int index,
const Point<dim> &);
1202 write_cell(
const unsigned int index,
1203 const unsigned int start,
1204 const std::array<unsigned int, dim> &offsets);
1212 template <
typename data>
1214 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1220 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
1227 write_point(
const unsigned int index,
const Point<dim> &);
1239 write_cell(
const unsigned int index,
1240 const unsigned int start,
1241 const std::array<unsigned int, dim> &offsets);
1247 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
1254 write_point(
const unsigned int index,
const Point<dim> &);
1266 write_cell(
const unsigned int index,
1267 const unsigned int start,
1268 const std::array<unsigned int, dim> &offsets);
1274 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1281 write_point(
const unsigned int index,
const Point<dim> &);
1295 write_cell(
const unsigned int index,
1296 const unsigned int start,
1297 const std::array<unsigned int, dim> &offsets);
1305 template <
typename data>
1307 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1313 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1320 write_point(
const unsigned int index,
const Point<dim> &);
1332 write_cell(
const unsigned int index,
1333 const unsigned int start,
1334 const std::array<unsigned int, dim> &offsets);
1341 write_cell_single(
const unsigned int index,
1342 const unsigned int start,
1343 const unsigned int n_points,
1355 write_high_order_cell(
const unsigned int start,
1356 const std::vector<unsigned> &connectivity);
1369 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1371 if (flags.coordinates_binary)
1374 for (
unsigned int d = 0;
d < dim; ++
d)
1376 stream.write(
reinterpret_cast<const char *
>(
data), dim *
sizeof(*
data));
1380 for (
unsigned int d = 0;
d < dim; ++
d)
1381 stream << p[d] <<
'\t';
1395 std::array<unsigned int, GeometryInfo<0>::vertices_per_cell>
1396 set_node_numbers(
const unsigned int ,
1397 const std::array<unsigned int, 0> & )
1405 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
1406 set_node_numbers(
const unsigned int start,
1407 const std::array<unsigned int, 1> &offsets)
1409 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
1411 nodes[1] = start + offsets[0];
1417 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
1418 set_node_numbers(
const unsigned int start,
1419 const std::array<unsigned int, 2> &offsets)
1422 const unsigned int d1 = offsets[0];
1423 const unsigned int d2 = offsets[1];
1425 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
1427 nodes[1] = start + d1;
1428 nodes[2] = start + d2;
1429 nodes[3] = start + d2 + d1;
1435 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
1436 set_node_numbers(
const unsigned int start,
1437 const std::array<unsigned int, 3> &offsets)
1439 const unsigned int d1 = offsets[0];
1440 const unsigned int d2 = offsets[1];
1441 const unsigned int d3 = offsets[2];
1443 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
1445 nodes[1] = start + d1;
1446 nodes[2] = start + d2;
1447 nodes[3] = start + d2 + d1;
1448 nodes[4] = start + d3;
1449 nodes[5] = start + d3 + d1;
1450 nodes[6] = start + d3 + d2;
1451 nodes[7] = start + d3 + d2 + d1;
1460 DXStream::write_cell(
const unsigned int,
1461 const unsigned int start,
1462 const std::array<unsigned int, dim> &offsets)
1465 DataOutBaseImplementation::set_node_numbers(start, offsets);
1467 if (flags.int_binary)
1469 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell> temp;
1470 for (
unsigned int i = 0; i < nodes.size(); ++i)
1472 stream.write(
reinterpret_cast<const char *
>(temp.data()),
1473 temp.size() *
sizeof(temp[0]));
1477 for (
unsigned int i = 0; i < nodes.size() - 1; ++i)
1479 stream << nodes[GeometryInfo<dim>::dx_to_deal[nodes.size() - 1]]
1486 template <
typename data>
1488 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &values)
1490 if (flags.data_binary)
1492 stream.write(
reinterpret_cast<const char *
>(
values.data()),
1497 for (
unsigned int i = 0; i <
values.size(); ++i)
1498 stream <<
'\t' << values[i];
1514 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1518 stream << p[selected_component] <<
' ';
1525 GmvStream::write_cell(
const unsigned int,
1526 const unsigned int s,
1527 const std::array<unsigned int, dim> &offsets)
1530 const unsigned int start = s + 1;
1531 stream << gmv_cell_type[dim] <<
'\n';
1543 const unsigned int d1 = offsets[0];
1545 stream <<
'\t' << start + d1;
1551 const unsigned int d1 = offsets[0];
1552 const unsigned int d2 = offsets[1];
1554 stream <<
'\t' << start + d1;
1555 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1561 const unsigned int d1 = offsets[0];
1562 const unsigned int d2 = offsets[1];
1563 const unsigned int d3 = offsets[2];
1565 stream <<
'\t' << start + d1;
1566 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1567 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1568 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1580 TecplotStream::TecplotStream(std::ostream &out,
1588 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1592 stream << p[selected_component] <<
'\n';
1599 TecplotStream::write_cell(
const unsigned int,
1600 const unsigned int s,
1601 const std::array<unsigned int, dim> &offsets)
1603 const unsigned int start = s + 1;
1615 const unsigned int d1 = offsets[0];
1617 stream <<
'\t' << start + d1;
1623 const unsigned int d1 = offsets[0];
1624 const unsigned int d2 = offsets[1];
1626 stream <<
'\t' << start + d1;
1627 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1633 const unsigned int d1 = offsets[0];
1634 const unsigned int d2 = offsets[1];
1635 const unsigned int d3 = offsets[2];
1637 stream <<
'\t' << start + d1;
1638 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1639 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1640 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1659 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1661 stream <<
index + 1 <<
" ";
1663 for (
unsigned int i = 0; i < dim; ++i)
1664 stream << p[i] <<
' ';
1666 for (
unsigned int i = dim; i < 3; ++i)
1675 UcdStream::write_cell(
const unsigned int index,
1676 const unsigned int start,
1677 const std::array<unsigned int, dim> &offsets)
1680 DataOutBaseImplementation::set_node_numbers(start, offsets);
1683 stream <<
index + 1 <<
"\t0 " << ucd_cell_type[dim];
1684 for (
unsigned int i = 0; i < nodes.size(); ++i)
1691 template <
typename data>
1693 UcdStream::write_dataset(
const unsigned int index,
1694 const std::vector<data> &values)
1696 stream <<
index + 1;
1697 for (
unsigned int i = 0; i <
values.size(); ++i)
1698 stream <<
'\t' << values[i];
1713 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1718 for (
unsigned int i = dim; i < 3; ++i)
1727 VtkStream::write_cell(
const unsigned int,
1728 const unsigned int start,
1729 const std::array<unsigned int, dim> &offsets)
1731 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t';
1743 const unsigned int d1 = offsets[0];
1745 stream <<
'\t' << start + d1;
1751 const unsigned int d1 = offsets[0];
1752 const unsigned int d2 = offsets[1];
1754 stream <<
'\t' << start + d1;
1755 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1761 const unsigned int d1 = offsets[0];
1762 const unsigned int d2 = offsets[1];
1763 const unsigned int d3 = offsets[2];
1765 stream <<
'\t' << start + d1;
1766 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1767 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1768 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1782 VtkStream::write_cell_single(
const unsigned int ,
1783 const unsigned int start,
1784 const unsigned int n_points,
1787 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1789 stream <<
'\t' << n_points;
1790 for (
unsigned int i = 0; i < n_points; ++i)
1801 VtkStream::write_high_order_cell(
const unsigned int start,
1802 const std::vector<unsigned> &connectivity)
1804 stream << connectivity.size();
1805 for (
const auto &c : connectivity)
1806 stream <<
'\t' << start + c;
1818 template <
int dim,
int spacedim>
1822 template <
int dim,
int spacedim>
1826 template <
int dim,
int spacedim>
1828 : patch_index(no_neighbor)
1830 , points_are_available(false)
1844 template <
int dim,
int spacedim>
1852 const double epsilon = 3e-16;
1854 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1870 if (
data.n_rows() != patch.
data.n_rows())
1873 if (
data.n_cols() != patch.
data.n_cols())
1876 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1877 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1878 if (
data[i][j] != patch.
data[i][j])
1886 template <
int dim,
int spacedim>
1890 return (
sizeof(vertices) /
sizeof(vertices[0]) *
1892 sizeof(neighbors) /
sizeof(neighbors[0]) *
1898 sizeof(reference_cell));
1903 template <
int dim,
int spacedim>
1907 std::swap(vertices, other_patch.vertices);
1908 std::swap(neighbors, other_patch.neighbors);
1909 std::swap(patch_index, other_patch.patch_index);
1910 std::swap(n_subdivisions, other_patch.n_subdivisions);
1911 data.swap(other_patch.data);
1912 std::swap(points_are_available, other_patch.points_are_available);
1913 std::swap(reference_cell, other_patch.reference_cell);
1918 template <
int spacedim>
1922 template <
int spacedim>
1926 template <
int spacedim>
1930 template <
int spacedim>
1933 template <
int spacedim>
1937 template <
int spacedim>
1939 : patch_index(no_neighbor)
1940 , points_are_available(false)
1947 template <
int spacedim>
1951 const unsigned int dim = 0;
1954 const double epsilon = 3e-16;
1956 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1965 if (
data.n_rows() != patch.
data.n_rows())
1968 if (
data.n_cols() != patch.
data.n_cols())
1971 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1972 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1973 if (
data[i][j] != patch.
data[i][j])
1981 template <
int spacedim>
1985 return (
sizeof(vertices) /
sizeof(vertices[0]) *
1993 template <
int spacedim>
1997 std::swap(vertices, other_patch.vertices);
1998 std::swap(patch_index, other_patch.patch_index);
1999 data.swap(other_patch.data);
2000 std::swap(points_are_available, other_patch.points_are_available);
2006 : write_preamble(write_preamble)
2021 : space_dimension_labels(labels)
2035 const bool bicubic_patch,
2036 const bool external_data)
2038 , bicubic_patch(bicubic_patch)
2039 , external_data(external_data)
2044 const bool xdmf_hdf5_output)
2045 : filter_duplicate_vertices(filter_duplicate_vertices)
2046 , xdmf_hdf5_output(xdmf_hdf5_output)
2054 "Filter duplicate vertices",
2057 "Whether to remove duplicate vertex values. deal.II duplicates "
2058 "vertices once for each adjacent cell so that it can output "
2059 "discontinuous quantities for which there may be more than one "
2060 "value for each vertex position. Setting this flag to "
2061 "'true' will merge all of these values by selecting a "
2062 "random one and outputting this as 'the' value for the vertex. "
2063 "As long as the data to be output corresponds to continuous "
2064 "fields, merging vertices has no effect. On the other hand, "
2065 "if the data to be output corresponds to discontinuous fields "
2066 "(either because you are using a discontinuous finite element, "
2067 "or because you are using a DataPostprocessor that yields "
2068 "discontinuous data, or because the data to be output has been "
2069 "produced by entirely different means), then the data in the "
2070 "output file no longer faithfully represents the underlying data "
2071 "because the discontinuous field has been replaced by a "
2072 "continuous one. Note also that the filtering can not occur "
2073 "on processor boundaries. Thus, a filtered discontinuous field "
2074 "looks like a continuous field inside of a subdomain, "
2075 "but like a discontinuous field at the subdomain boundary."
2077 "In any case, filtering results in drastically smaller output "
2078 "files (smaller by about a factor of 2^dim).");
2083 "Whether the data will be used in an XDMF/HDF5 combination.");
2098 const bool int_binary,
2099 const bool coordinates_binary,
2100 const bool data_binary)
2101 : write_neighbors(write_neighbors)
2102 , int_binary(int_binary)
2103 , coordinates_binary(coordinates_binary)
2104 , data_binary(data_binary)
2105 , data_double(false)
2115 "A boolean field indicating whether neighborship "
2116 "information between cells is to be written to the "
2117 "OpenDX output file");
2121 "Output format of integer numbers, which is "
2122 "either a text representation (ascii) or binary integer "
2123 "values of 32 or 64 bits length");
2127 "Output format of vertex coordinates, which is "
2128 "either a text representation (ascii) or binary "
2129 "floating point values of 32 or 64 bits length");
2133 "Output format of data values, which is "
2134 "either a text representation (ascii) or binary "
2135 "floating point values of 32 or 64 bits length");
2155 "A flag indicating whether a comment should be "
2156 "written to the beginning of the output file "
2157 "indicating date and time of creation as well "
2158 "as the creating program");
2172 const int azimuth_angle,
2173 const int polar_angle,
2174 const unsigned int line_thickness,
2176 const bool draw_colorbar)
2179 , height_vector(height_vector)
2180 , azimuth_angle(azimuth_angle)
2181 , polar_angle(polar_angle)
2182 , line_thickness(line_thickness)
2184 , draw_colorbar(draw_colorbar)
2195 "A flag indicating whether POVRAY should use smoothed "
2196 "triangles instead of the usual ones");
2200 "Whether POVRAY should use bicubic patches");
2204 "Whether camera and lighting information should "
2205 "be put into an external file \"data.inc\" or into "
2206 "the POVRAY input file");
2222 const unsigned int color_vector,
2224 const unsigned int size,
2225 const double line_width,
2226 const double azimut_angle,
2227 const double turn_angle,
2228 const double z_scaling,
2229 const bool draw_mesh,
2230 const bool draw_cells,
2231 const bool shade_cells,
2233 : height_vector(height_vector)
2234 , color_vector(color_vector)
2235 , size_type(size_type)
2237 , line_width(line_width)
2238 , azimut_angle(azimut_angle)
2239 , turn_angle(turn_angle)
2240 , z_scaling(z_scaling)
2241 , draw_mesh(draw_mesh)
2242 , draw_cells(draw_cells)
2243 , shade_cells(shade_cells)
2244 , color_function(color_function)
2283 double sum = xmax + xmin;
2284 double sum13 = xmin + 3 * xmax;
2285 double sum22 = 2 * xmin + 2 * xmax;
2286 double sum31 = 3 * xmin + xmax;
2287 double dif = xmax - xmin;
2288 double rezdif = 1.0 / dif;
2292 if (x < (sum31) / 4)
2294 else if (x < (sum22) / 4)
2296 else if (x < (sum13) / 4)
2307 rgb_values.
green = 0;
2308 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2312 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2313 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2316 rgb_values.
red = (4 * x - 2 * sum) * rezdif;
2317 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2318 rgb_values.
blue = 0;
2322 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2323 rgb_values.
blue = (4. * x - sum13) * rezdif;
2330 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2344 (x - xmin) / (xmax - xmin);
2357 1 - (x - xmin) / (xmax - xmin);
2369 "Number of the input vector that is to be used to "
2370 "generate height information");
2374 "Number of the input vector that is to be used to "
2375 "generate color information");
2379 "Whether width or height should be scaled to match "
2384 "The size (width or height) to which the eps output "
2385 "file is to be scaled");
2389 "The width in which the postscript renderer is to "
2394 "Angle of the viewing position against the vertical "
2399 "Angle of the viewing direction against the y-axis");
2403 "Scaling for the z-direction relative to the scaling "
2404 "used in x- and y-directions");
2408 "Whether the mesh lines, or only the surface should be "
2413 "Whether only the mesh lines, or also the interior of "
2414 "cells should be plotted. If this flag is false, then "
2415 "one can see through the mesh");
2419 "Whether the interior of cells shall be shaded");
2423 "default|grey scale|reverse grey scale"),
2424 "Name of a color function used to colorize mesh lines "
2425 "and/or cell interiors");
2435 if (prm.
get(
"Scale to width or height") ==
"width")
2447 if (prm.
get(
"Color function") ==
"default")
2449 else if (prm.
get(
"Color function") ==
"grey scale")
2451 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2461 const bool keep_existing_file,
2462 const std::map<std::string,
2463 std::vector<std::pair<std::string, AttributeValue>>>
2466 , keep_existing_file(keep_existing_file)
2467 , attributes(attributes)
2471 : compression_level(compression_level)
2476 : zone_name(zone_name)
2477 , solution_time(solution_time)
2491 const unsigned int cycle,
2492 const bool print_date_and_time,
2494 const bool write_higher_order_cells,
2495 const std::map<std::string, std::string> &physical_units)
2498 , print_date_and_time(print_date_and_time)
2499 , compression_level(compression_level)
2500 , write_higher_order_cells(write_higher_order_cells)
2501 , physical_units(physical_units)
2509 if (format_name ==
"none")
2512 if (format_name ==
"dx")
2515 if (format_name ==
"ucd")
2518 if (format_name ==
"gnuplot")
2521 if (format_name ==
"povray")
2524 if (format_name ==
"eps")
2527 if (format_name ==
"gmv")
2530 if (format_name ==
"tecplot")
2533 if (format_name ==
"vtk")
2536 if (format_name ==
"vtu")
2539 if (format_name ==
"deal.II intermediate")
2542 if (format_name ==
"hdf5")
2546 ExcMessage(
"The given file format name is not recognized: <" +
2547 format_name +
">"));
2558 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|vtk|vtu|hdf5|svg|deal.II intermediate";
2566 switch (output_format)
2608 template <
int dim,
int spacedim>
2609 std::vector<Point<spacedim>>
2613 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
2615 std::vector<Point<spacedim>> node_positions;
2616 std::size_t n_nodes = 0;
2617 for (
const auto &patch : patches)
2619 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2620 n_nodes += patch.
data.n_cols();
2622 n_nodes += Utilities::fixed_power<dim>(patch.
n_subdivisions + 1);
2624 node_positions.reserve(n_nodes);
2626 for (
const auto &patch : patches)
2629 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2631 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2633 node_positions.emplace_back(get_node_location(
2642 const unsigned int n = n_subdivisions + 1;
2647 node_positions.emplace_back(
2648 get_equispaced_location(patch, {}, n_subdivisions));
2651 for (
unsigned int i1 = 0; i1 < n; ++i1)
2652 node_positions.emplace_back(
2653 get_equispaced_location(patch, {i1}, n_subdivisions));
2656 for (
unsigned int i2 = 0; i2 < n; ++i2)
2657 for (
unsigned int i1 = 0; i1 < n; ++i1)
2658 node_positions.emplace_back(get_equispaced_location(
2659 patch, {i1, i2}, n_subdivisions));
2662 for (
unsigned int i3 = 0; i3 < n; ++i3)
2663 for (
unsigned int i2 = 0; i2 < n; ++i2)
2664 for (
unsigned int i1 = 0; i1 < n; ++i1)
2665 node_positions.emplace_back(get_equispaced_location(
2666 patch, {i1, i2, i3}, n_subdivisions));
2675 return node_positions;
2679 template <
int dim,
int spacedim,
typename StreamType>
2685 const std::vector<Point<spacedim>> node_positions =
2689 for (
const auto &node : node_positions)
2690 out.write_point(count++, node);
2696 template <
int dim,
int spacedim,
typename StreamType>
2701 unsigned int count = 0;
2702 unsigned int first_vertex_of_patch = 0;
2703 for (
const auto &patch : patches)
2706 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2708 out.write_cell_single(count++,
2709 first_vertex_of_patch,
2710 patch.
data.n_cols(),
2712 first_vertex_of_patch += patch.
data.n_cols();
2717 const unsigned int n = n_subdivisions + 1;
2723 const unsigned int offset = first_vertex_of_patch;
2724 out.template write_cell<0>(count++, offset, {});
2730 constexpr unsigned int d1 = 1;
2732 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
2734 const unsigned int offset =
2735 first_vertex_of_patch + i1 * d1;
2736 out.template write_cell<1>(count++, offset, {{d1}});
2744 constexpr unsigned int d1 = 1;
2745 const unsigned int d2 = n;
2747 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
2748 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
2750 const unsigned int offset =
2751 first_vertex_of_patch + i2 * d2 + i1 * d1;
2752 out.template write_cell<2>(count++,
2762 constexpr unsigned int d1 = 1;
2763 const unsigned int d2 = n;
2764 const unsigned int d3 = n * n;
2766 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
2767 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
2768 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
2770 const unsigned int offset = first_vertex_of_patch +
2773 out.template write_cell<3>(count++,
2785 first_vertex_of_patch +=
2786 Utilities::fixed_power<dim>(n_subdivisions + 1);
2795 template <
int dim,
int spacedim,
typename StreamType>
2799 const bool legacy_format)
2803 (void)legacy_format;
2805 unsigned int first_vertex_of_patch = 0;
2807 std::vector<unsigned> connectivity;
2809 for (
const auto &patch : patches)
2811 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2813 connectivity.resize(patch.
data.n_cols());
2815 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2816 connectivity[i] = i;
2818 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2821 first_vertex_of_patch += patch.
data.n_cols();
2826 const unsigned int n = n_subdivisions + 1;
2828 connectivity.resize(Utilities::fixed_power<dim>(n));
2830 if constexpr (dim == 0)
2833 ExcMessage(
"Point-like cells should not be possible "
2834 "when writing higher-order cells."));
2836 else if constexpr (dim == 1)
2838 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
2840 const unsigned int local_index = i1;
2841 const unsigned int connectivity_index =
2843 {{i1}}, {{n_subdivisions}}, legacy_format);
2844 connectivity[connectivity_index] = local_index;
2847 else if constexpr (dim == 2)
2849 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1; ++i2)
2850 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
2852 const unsigned int local_index = i2 * n + i1;
2853 const unsigned int connectivity_index =
2856 {{n_subdivisions, n_subdivisions}},
2858 connectivity[connectivity_index] = local_index;
2861 else if constexpr (dim == 3)
2863 for (
unsigned int i3 = 0; i3 < n_subdivisions + 1; ++i3)
2864 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1; ++i2)
2865 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
2867 const unsigned int local_index =
2868 i3 * n * n + i2 * n + i1;
2869 const unsigned int connectivity_index =
2872 {{n_subdivisions, n_subdivisions, n_subdivisions}},
2874 connectivity[connectivity_index] = local_index;
2882 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2886 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
2894 template <
int dim,
int spacedim,
typename StreamType>
2897 unsigned int n_data_sets,
2898 const bool double_precision,
2902 unsigned int count = 0;
2904 for (
const auto &patch : patches)
2907 const unsigned int n = n_subdivisions + 1;
2909 Assert((patch.
data.n_rows() == n_data_sets &&
2911 (patch.
data.n_rows() == n_data_sets + spacedim &&
2914 (n_data_sets + spacedim) :
2916 patch.
data.n_rows()));
2917 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
2920 std::vector<float> floats(n_data_sets);
2921 std::vector<double> doubles(n_data_sets);
2924 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2926 if (double_precision)
2928 for (
unsigned int data_set = 0; data_set < n_data_sets;
2930 doubles[data_set] = patch.
data(data_set, i);
2931 out.write_dataset(count, doubles);
2935 for (
unsigned int data_set = 0; data_set < n_data_sets;
2937 floats[data_set] = patch.
data(data_set, i);
2938 out.write_dataset(count, floats);
2963 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
2964 camera_horizontal[2] * camera_direction[1];
2965 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
2966 camera_horizontal[0] * camera_direction[2];
2967 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
2968 camera_horizontal[1] * camera_direction[0];
2972 phi /= (point[0] - camera_position[0]) * camera_direction[0] +
2973 (point[1] - camera_position[1]) * camera_direction[1] +
2974 (point[2] - camera_position[2]) * camera_direction[2];
2978 camera_position[0] + phi * (point[0] - camera_position[0]);
2980 camera_position[1] + phi * (point[1] - camera_position[1]);
2982 camera_position[2] + phi * (point[2] - camera_position[2]);
2985 projection_decomposition[0] = (projection[0] - camera_position[0] -
2986 camera_focus * camera_direction[0]) *
2987 camera_horizontal[0];
2988 projection_decomposition[0] += (projection[1] - camera_position[1] -
2989 camera_focus * camera_direction[1]) *
2990 camera_horizontal[1];
2991 projection_decomposition[0] += (projection[2] - camera_position[2] -
2992 camera_focus * camera_direction[2]) *
2993 camera_horizontal[2];
2995 projection_decomposition[1] = (projection[0] - camera_position[0] -
2996 camera_focus * camera_direction[0]) *
2998 projection_decomposition[1] += (projection[1] - camera_position[1] -
2999 camera_focus * camera_direction[1]) *
3001 projection_decomposition[1] += (projection[2] - camera_position[2] -
3002 camera_focus * camera_direction[2]) *
3005 return projection_decomposition;
3014 svg_get_gradient_parameters(
Point<3> points[])
3020 for (
int i = 0; i < 2; ++i)
3022 for (
int j = 0; j < 2 - i; ++j)
3024 if (points[j][2] > points[j + 1][2])
3027 points[j] = points[j + 1];
3028 points[j + 1] = temp;
3035 v_inter = points[1];
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];
3051 bool col_change =
false;
3060 double temp = A[1][0];
3065 for (
unsigned int k = 0; k < 1; ++k)
3067 for (
unsigned int i = k + 1; i < 2; ++i)
3069 x = A[i][k] / A[k][k];
3071 for (
unsigned int j = k + 1; j < 2; ++j)
3072 A[i][j] = A[i][j] - A[k][j] * x;
3074 b[i] = b[i] - b[k] * x;
3078 b[1] =
b[1] /
A[1][1];
3080 for (
int i = 0; i >= 0; i--)
3084 for (
unsigned int j = i + 1; j < 2; ++j)
3087 b[i] =
sum /
A[i][i];
3097 double c =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) +
3101 A[0][0] = v_max[0] - v_min[0];
3102 A[0][1] = v_inter[0] - v_min[0];
3103 A[1][0] = v_max[1] - v_min[1];
3104 A[1][1] = v_inter[1] - v_min[1];
3106 b[0] = 1.0 - v_min[0];
3118 double temp =
A[1][0];
3123 for (
unsigned int k = 0; k < 1; ++k)
3125 for (
unsigned int i = k + 1; i < 2; ++i)
3127 x = A[i][k] / A[k][k];
3129 for (
unsigned int j = k + 1; j < 2; ++j)
3130 A[i][j] = A[i][j] - A[k][j] * x;
3132 b[i] = b[i] - b[k] * x;
3136 b[1] =
b[1] /
A[1][1];
3138 for (
int i = 0; i >= 0; i--)
3142 for (
unsigned int j = i + 1; j < 2; ++j)
3145 b[i] = sum / A[i][i];
3155 gradient[0] = b[0] * (v_max[2] - v_min[2]) +
3156 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3159 A[0][0] = v_max[0] - v_min[0];
3160 A[0][1] = v_inter[0] - v_min[0];
3161 A[1][0] = v_max[1] - v_min[1];
3162 A[1][1] = v_inter[1] - v_min[1];
3165 b[1] = 1.0 - v_min[1];
3176 double temp = A[1][0];
3181 for (
unsigned int k = 0; k < 1; ++k)
3183 for (
unsigned int i = k + 1; i < 2; ++i)
3185 x = A[i][k] / A[k][k];
3187 for (
unsigned int j = k + 1; j < 2; ++j)
3188 A[i][j] = A[i][j] - A[k][j] * x;
3190 b[i] = b[i] - b[k] * x;
3194 b[1] =
b[1] /
A[1][1];
3196 for (
int i = 0; i >= 0; i--)
3200 for (
unsigned int j = i + 1; j < 2; ++j)
3201 sum = sum - A[i][j] * b[j];
3203 b[i] = sum / A[i][i];
3213 gradient[1] = b[0] * (v_max[2] - v_min[2]) +
3214 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3217 gradient /= gradient.norm();
3219 const double lambda = -gradient[0] * (v_min[0] - v_max[0]) -
3220 gradient[1] * (v_min[1] - v_max[1]);
3224 gradient_parameters[0] = v_min[0];
3225 gradient_parameters[1] = v_min[1];
3227 gradient_parameters[2] = v_min[0] + lambda * gradient[0];
3228 gradient_parameters[3] = v_min[1] + lambda * gradient[1];
3230 gradient_parameters[4] = v_min[2];
3231 gradient_parameters[5] = v_max[2];
3233 return gradient_parameters;
3239 template <
int dim,
int spacedim>
3243 const std::vector<std::string> &data_names,
3245 std::tuple<
unsigned int,
3258#ifndef DEAL_II_WITH_MPI
3267 if (patches.empty())
3271 const unsigned int n_data_sets = data_names.size();
3273 UcdStream ucd_out(out, flags);
3277 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
3283 <<
"# This file was generated by the deal.II library." <<
'\n'
3287 <<
"# For a description of the UCD format see the AVS Developer's guide."
3293 out << n_nodes <<
' ' << n_cells <<
' ' << n_data_sets <<
' ' << 0
3306 if (n_data_sets != 0)
3308 out << n_data_sets <<
" ";
3309 for (
unsigned int i = 0; i < n_data_sets; ++i)
3314 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3315 out << data_names[data_set]
3319 write_data(patches, n_data_sets,
true, ucd_out);
3329 template <
int dim,
int spacedim>
3333 const std::vector<std::string> &data_names,
3335 std::tuple<
unsigned int,
3347#ifndef DEAL_II_WITH_MPI
3356 if (patches.empty())
3360 DXStream dx_out(out, flags);
3363 unsigned int offset = 0;
3365 const unsigned int n_data_sets = data_names.size();
3369 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
3372 out <<
"object \"vertices\" class array type float rank 1 shape "
3373 << spacedim <<
" items " << n_nodes;
3377 out <<
" lsb ieee data 0" <<
'\n';
3378 offset += n_nodes * spacedim *
sizeof(float);
3382 out <<
" data follows" <<
'\n';
3391 out <<
"object \"cells\" class array type int rank 1 shape "
3396 out <<
" lsb binary data " << offset <<
'\n';
3397 offset += n_cells *
sizeof(
int);
3401 out <<
" data follows" <<
'\n';
3407 out <<
"attribute \"element type\" string \"";
3408 if constexpr (dim == 1)
3410 else if constexpr (dim == 2)
3412 else if constexpr (dim == 3)
3414 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3421 out <<
"object \"neighbors\" class array type int rank 1 shape "
3425 for (
const auto &patch : patches)
3428 const unsigned int n1 = (dim > 0) ? n : 1;
3429 const unsigned int n2 = (dim > 1) ? n : 1;
3430 const unsigned int n3 = (dim > 2) ? n : 1;
3431 const unsigned int x_minus = (dim > 0) ? 0 : 0;
3432 const unsigned int x_plus = (dim > 0) ? 1 : 0;
3433 const unsigned int y_minus = (dim > 1) ? 2 : 0;
3434 const unsigned int y_plus = (dim > 1) ? 3 : 0;
3435 const unsigned int z_minus = (dim > 2) ? 4 : 0;
3436 const unsigned int z_plus = (dim > 2) ? 5 : 0;
3437 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3438 unsigned int dx = 1;
3439 unsigned int dy = n;
3440 unsigned int dz = n * n;
3442 const unsigned int patch_start =
3445 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3446 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3447 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3449 const unsigned int nx = i1 *
dx;
3450 const unsigned int ny = i2 * dy;
3451 const unsigned int nz = i3 * dz;
3463 const unsigned int nn = patch.
neighbors[x_minus];
3467 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3473 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3478 const unsigned int nn = patch.
neighbors[x_plus];
3481 out << (nn * cells_per_patch + ny + nz);
3487 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3494 const unsigned int nn = patch.
neighbors[y_minus];
3498 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3504 out <<
'\t' << patch_start + nx + ny - dy + nz;
3509 const unsigned int nn = patch.
neighbors[y_plus];
3512 out << (nn * cells_per_patch + nx + nz);
3518 out <<
'\t' << patch_start + nx + ny + dy + nz;
3526 const unsigned int nn = patch.
neighbors[z_minus];
3530 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3536 out <<
'\t' << patch_start + nx + ny + nz - dz;
3541 const unsigned int nn = patch.
neighbors[z_plus];
3544 out << (nn * cells_per_patch + nx + ny);
3550 out <<
'\t' << patch_start + nx + ny + nz + dz;
3558 if (n_data_sets != 0)
3560 out <<
"object \"data\" class array type float rank 1 shape "
3561 << n_data_sets <<
" items " << n_nodes;
3565 out <<
" lsb ieee data " << offset <<
'\n';
3566 offset += n_data_sets * n_nodes *
3567 ((flags.
data_double) ?
sizeof(
double) :
sizeof(float));
3571 out <<
" data follows" <<
'\n';
3576 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3580 out <<
"object \"data\" class constantarray type float rank 0 items "
3581 << n_nodes <<
" data follows" <<
'\n'
3587 out <<
"object \"deal data\" class field" <<
'\n'
3588 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3589 <<
"component \"connections\" value \"cells\"" <<
'\n'
3590 <<
"component \"data\" value \"data\"" <<
'\n';
3593 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3600 out <<
"end" <<
'\n';
3618 template <
int dim,
int spacedim>
3622 const std::vector<std::string> &data_names,
3624 std::tuple<
unsigned int,
3633#ifndef DEAL_II_WITH_MPI
3643 if (patches.empty())
3647 const unsigned int n_data_sets = data_names.size();
3651 out <<
"# This file was generated by the deal.II library." <<
'\n'
3655 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3662 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3667 for (
const auto &data_name : data_names)
3668 out <<
'<' << data_name <<
"> ";
3674 for (
const auto &patch : patches)
3677 const unsigned int n_points_per_direction = n_subdivisions + 1;
3679 Assert((patch.
data.n_rows() == n_data_sets &&
3681 (patch.
data.n_rows() == n_data_sets + spacedim &&
3684 (n_data_sets + spacedim) :
3686 patch.
data.n_rows()));
3688 auto output_point_data =
3689 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3690 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3691 out << patch.data(data_set, point_index) <<
' ';
3700 Assert(patch.data.n_cols() == 1,
3702 n_subdivisions + 1));
3706 out << get_equispaced_location(patch, {}, n_subdivisions)
3708 output_point_data(0);
3718 Assert(patch.data.n_cols() ==
3719 Utilities::fixed_power<dim>(n_points_per_direction),
3721 n_subdivisions + 1));
3723 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3726 out << get_equispaced_location(patch, {i1}, n_subdivisions)
3729 output_point_data(i1);
3742 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3743 n_points_per_direction),
3745 n_subdivisions + 1));
3747 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3749 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3753 out << get_equispaced_location(patch,
3758 output_point_data(i1 + i2 * n_points_per_direction);
3783 out << get_node_location(patch, 0) <<
' ';
3784 output_point_data(0);
3787 out << get_node_location(patch, 1) <<
' ';
3788 output_point_data(1);
3792 out << get_node_location(patch, 2) <<
' ';
3793 output_point_data(2);
3796 out << get_node_location(patch, 2) <<
' ';
3797 output_point_data(2);
3817 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3818 n_points_per_direction),
3820 n_subdivisions + 1));
3825 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3826 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3828 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3833 get_equispaced_location(patch,
3837 if (i1 < n_subdivisions)
3840 out << this_point <<
' ';
3841 output_point_data(i1 +
3842 i2 * n_points_per_direction +
3843 i3 * n_points_per_direction *
3844 n_points_per_direction);
3848 out << get_equispaced_location(patch,
3853 output_point_data((i1 + 1) +
3854 i2 * n_points_per_direction +
3855 i3 * n_points_per_direction *
3856 n_points_per_direction);
3860 out <<
'\n' <<
'\n';
3864 if (i2 < n_subdivisions)
3867 out << this_point <<
' ';
3868 output_point_data(i1 +
3869 i2 * n_points_per_direction +
3870 i3 * n_points_per_direction *
3871 n_points_per_direction);
3875 out << get_equispaced_location(patch,
3881 i1 + (i2 + 1) * n_points_per_direction +
3882 i3 * n_points_per_direction *
3883 n_points_per_direction);
3887 out <<
'\n' <<
'\n';
3891 if (i3 < n_subdivisions)
3894 out << this_point <<
' ';
3895 output_point_data(i1 +
3896 i2 * n_points_per_direction +
3897 i3 * n_points_per_direction *
3898 n_points_per_direction);
3902 out << get_equispaced_location(patch,
3908 i1 + i2 * n_points_per_direction +
3909 (i3 + 1) * n_points_per_direction *
3910 n_points_per_direction);
3913 out <<
'\n' <<
'\n';
3922 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3924 out << get_node_location(patch, v) <<
' ';
3925 output_point_data(v);
3930 for (
const unsigned int v : {3, 1})
3932 out << get_node_location(patch, v) <<
' ';
3933 output_point_data(v);
3943 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
3945 out << get_node_location(patch, v) <<
' ';
3946 output_point_data(v);
3951 for (
const unsigned int v : {2, 4, 3})
3953 out << get_node_location(patch, v) <<
' ';
3954 output_point_data(v);
3968 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
3970 out << get_node_location(patch, v) <<
' ';
3971 output_point_data(v);
3976 for (
const unsigned int v : {1, 4})
3978 out << get_node_location(patch, v) <<
' ';
3979 output_point_data(v);
3984 for (
const unsigned int v : {2, 5})
3986 out << get_node_location(patch, v) <<
' ';
3987 output_point_data(v);
4012 template <
int dim,
int spacedim>
4014 do_write_povray(
const std::vector<Patch<dim, spacedim>> &,
4015 const std::vector<std::string> &,
4016 const PovrayFlags &,
4020 ExcMessage(
"Writing files in POVRAY format is only supported "
4021 "for two-dimensional meshes."));
4027 do_write_povray(
const std::vector<Patch<2, 2>> &patches,
4028 const std::vector<std::string> &data_names,
4029 const PovrayFlags &flags,
4034#ifndef DEAL_II_WITH_MPI
4043 if (patches.empty())
4046 constexpr int dim = 2;
4047 constexpr int spacedim = 2;
4049 const unsigned int n_data_sets = data_names.size();
4054 <<
"/* This file was generated by the deal.II library." <<
'\n'
4058 <<
" For a description of the POVRAY format see the POVRAY manual."
4063 out <<
"#include \"colors.inc\" " <<
'\n'
4064 <<
"#include \"textures.inc\" " <<
'\n';
4068 if (flags.external_data)
4069 out <<
"#include \"data.inc\" " <<
'\n';
4075 <<
"camera {" <<
'\n'
4076 <<
" location <1,4,-7>" <<
'\n'
4077 <<
" look_at <0,0,0>" <<
'\n'
4078 <<
" angle 30" <<
'\n'
4083 <<
"light_source {" <<
'\n'
4084 <<
" <1,4,-7>" <<
'\n'
4085 <<
" color Grey" <<
'\n'
4088 <<
"light_source {" <<
'\n'
4089 <<
" <0,20,0>" <<
'\n'
4090 <<
" color White" <<
'\n'
4097 double hmin = patches[0].data(0, 0);
4098 double hmax = patches[0].data(0, 0);
4100 for (
const auto &patch : patches)
4104 Assert((patch.
data.n_rows() == n_data_sets &&
4106 (patch.
data.n_rows() == n_data_sets + spacedim &&
4109 (n_data_sets + spacedim) :
4111 patch.
data.n_rows()));
4113 Utilities::fixed_power<dim>(n_subdivisions + 1),
4115 n_subdivisions + 1));
4117 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4118 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4120 const int dl = i * (n_subdivisions + 1) + j;
4121 if (patch.
data(0, dl) < hmin)
4122 hmin = patch.
data(0, dl);
4123 if (patch.
data(0, dl) > hmax)
4124 hmax = patch.
data(0, dl);
4128 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
4129 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
4132 if (!flags.external_data)
4135 out <<
"#declare Tex=texture{" <<
'\n'
4136 <<
" pigment {" <<
'\n'
4137 <<
" gradient y" <<
'\n'
4138 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
4139 <<
" color_map {" <<
'\n'
4140 <<
" [0.00 color Light_Purple] " <<
'\n'
4141 <<
" [0.95 color Light_Purple] " <<
'\n'
4142 <<
" [1.00 color White] " <<
'\n'
4147 if (!flags.bicubic_patch)
4150 out <<
'\n' <<
"mesh {" <<
'\n';
4154 for (
const auto &patch : patches)
4157 const unsigned int n = n_subdivisions + 1;
4158 const unsigned int d1 = 1;
4159 const unsigned int d2 = n;
4161 Assert((patch.
data.n_rows() == n_data_sets &&
4163 (patch.
data.n_rows() == n_data_sets + spacedim &&
4166 (n_data_sets + spacedim) :
4168 patch.
data.n_rows()));
4169 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
4171 n_subdivisions + 1));
4174 std::vector<Point<spacedim>> ver(n * n);
4176 for (
unsigned int i2 = 0; i2 < n; ++i2)
4177 for (
unsigned int i1 = 0; i1 < n; ++i1)
4180 ver[i1 * d1 + i2 * d2] =
4181 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4185 if (!flags.bicubic_patch)
4188 std::vector<Point<3>> nrml;
4198 for (
unsigned int i = 0; i < n; ++i)
4199 for (
unsigned int j = 0; j < n; ++j)
4201 const unsigned int il = (i == 0) ? i : (i - 1);
4202 const unsigned int ir =
4203 (i == n_subdivisions) ? i : (i + 1);
4204 const unsigned int jl = (j == 0) ? j : (j - 1);
4205 const unsigned int jr =
4206 (j == n_subdivisions) ? j : (j + 1);
4209 ver[ir * d1 + j * d2][0] - ver[il * d1 + j * d2][0];
4210 h1[1] = patch.
data(0, ir * d1 + j * d2) -
4211 patch.
data(0, il * d1 + j * d2);
4213 ver[ir * d1 + j * d2][1] - ver[il * d1 + j * d2][1];
4216 ver[i * d1 + jr * d2][0] - ver[i * d1 + jl * d2][0];
4217 h2[1] = patch.
data(0, i * d1 + jr * d2) -
4218 patch.
data(0, i * d1 + jl * d2);
4220 ver[i * d1 + jr * d2][1] - ver[i * d1 + jl * d2][1];
4222 nrml[i * d1 + j * d2][0] =
4223 h1[1] * h2[2] - h1[2] * h2[1];
4224 nrml[i * d1 + j * d2][1] =
4225 h1[2] * h2[0] - h1[0] * h2[2];
4226 nrml[i * d1 + j * d2][2] =
4227 h1[0] * h2[1] - h1[1] * h2[0];
4230 double norm = std::hypot(nrml[i * d1 + j * d2][0],
4231 nrml[i * d1 + j * d2][1],
4232 nrml[i * d1 + j * d2][2]);
4234 if (nrml[i * d1 + j * d2][1] < 0)
4237 for (
unsigned int k = 0; k < 3; ++k)
4238 nrml[i * d1 + j * d2][k] /= norm;
4243 for (
unsigned int i = 0; i < n_subdivisions; ++i)
4244 for (
unsigned int j = 0; j < n_subdivisions; ++j)
4247 const int dl = i * d1 + j * d2;
4253 out <<
"smooth_triangle {" <<
'\n'
4254 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4255 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4256 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4258 out <<
" \t<" << ver[dl + d1][0] <<
","
4259 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4260 <<
">, <" << nrml[dl + d1][0] <<
", "
4261 << nrml[dl + d1][1] <<
", " << nrml[dl + d1][2]
4263 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4264 << patch.
data(0, dl + d1 + d2) <<
","
4265 << ver[dl + d1 + d2][1] <<
">, <"
4266 << nrml[dl + d1 + d2][0] <<
", "
4267 << nrml[dl + d1 + d2][1] <<
", "
4268 << nrml[dl + d1 + d2][2] <<
">}" <<
'\n';
4271 out <<
"smooth_triangle {" <<
'\n'
4272 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4273 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4274 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4276 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4277 << patch.
data(0, dl + d1 + d2) <<
","
4278 << ver[dl + d1 + d2][1] <<
">, <"
4279 << nrml[dl + d1 + d2][0] <<
", "
4280 << nrml[dl + d1 + d2][1] <<
", "
4281 << nrml[dl + d1 + d2][2] <<
">," <<
'\n';
4282 out <<
"\t<" << ver[dl + d2][0] <<
","
4283 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4284 <<
">, <" << nrml[dl + d2][0] <<
", "
4285 << nrml[dl + d2][1] <<
", " << nrml[dl + d2][2]
4291 out <<
"triangle {" <<
'\n'
4292 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4293 <<
"," << ver[dl][1] <<
">," <<
'\n';
4294 out <<
"\t<" << ver[dl + d1][0] <<
","
4295 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4297 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4298 << patch.
data(0, dl + d1 + d2) <<
","
4299 << ver[dl + d1 + d2][1] <<
">}" <<
'\n';
4302 out <<
"triangle {" <<
'\n'
4303 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4304 <<
"," << ver[dl][1] <<
">," <<
'\n';
4305 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4306 << patch.
data(0, dl + d1 + d2) <<
","
4307 << ver[dl + d1 + d2][1] <<
">," <<
'\n';
4308 out <<
"\t<" << ver[dl + d2][0] <<
","
4309 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4317 Assert(n_subdivisions == 3,
4320 <<
"bicubic_patch {" <<
'\n'
4321 <<
" type 0" <<
'\n'
4322 <<
" flatness 0" <<
'\n'
4323 <<
" u_steps 0" <<
'\n'
4324 <<
" v_steps 0" <<
'\n';
4325 for (
int i = 0; i < 16; ++i)
4327 out <<
"\t<" << ver[i][0] <<
"," << patch.
data(0, i) <<
","
4328 << ver[i][1] <<
">";
4333 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4337 if (!flags.bicubic_patch)
4340 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4352 template <
int dim,
int spacedim>
4356 const std::vector<std::string> &data_names,
4358 std::tuple<
unsigned int,
4365 do_write_povray(patches, data_names, flags, out);
4370 template <
int dim,
int spacedim>
4374 const std::vector<std::string> & ,
4376 std::tuple<
unsigned int,
4388 template <
int spacedim>
4392 const std::vector<std::string> & ,
4394 std::tuple<
unsigned int,
4403#ifndef DEAL_II_WITH_MPI
4412 if (patches.empty())
4422 std::multiset<EpsCell2d> cells;
4426 float min_color_value = std::numeric_limits<float>::max();
4427 float max_color_value = std::numeric_limits<float>::min();
4431 double heights[4] = {0, 0, 0, 0};
4435 for (
const auto &patch : patches)
4438 const unsigned int n = n_subdivisions + 1;
4439 const unsigned int d1 = 1;
4440 const unsigned int d2 = n;
4442 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4443 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4447 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4449 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
4451 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
4452 points[3] = get_equispaced_location(patch,
4460 patch.
data.n_rows() == 0,
4463 patch.
data.n_rows()));
4465 patch.
data.n_rows() != 0 ?
4469 heights[1] = patch.
data.n_rows() != 0 ?
4471 (i1 + 1) * d1 + i2 * d2) *
4474 heights[2] = patch.
data.n_rows() != 0 ?
4476 i1 * d1 + (i2 + 1) * d2) *
4479 heights[3] = patch.
data.n_rows() != 0 ?
4481 (i1 + 1) * d1 + (i2 + 1) * d2) *
4488 for (
unsigned int i = 0; i < 4; ++i)
4489 heights[i] = points[i][2];
4514 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4516 const double x = points[vertex][0], y = points[vertex][1],
4517 z = -heights[vertex];
4519 eps_cell.vertices[vertex][0] = -cz * x + sz * y;
4520 eps_cell.vertices[vertex][1] =
4521 -cx * sz * x - cx * cz * y - sx * z;
4545 (points[0] + points[1] + points[2] + points[3]) / 4;
4546 const double center_height =
4547 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4550 eps_cell.depth = -sx * sz * center_point[0] -
4551 sx * cz * center_point[1] + cx * center_height;
4556 patch.
data.n_rows() == 0,
4559 patch.
data.n_rows()));
4560 const double color_values[4] = {
4561 patch.
data.n_rows() != 0 ?
4565 patch.
data.n_rows() != 0 ?
4569 patch.
data.n_rows() != 0 ?
4573 patch.
data.n_rows() != 0 ?
4575 (i1 + 1) * d1 + (i2 + 1) * d2) :
4579 eps_cell.color_value = (color_values[0] + color_values[1] +
4580 color_values[3] + color_values[2]) /
4585 std::min(min_color_value, eps_cell.color_value);
4587 std::max(max_color_value, eps_cell.color_value);
4591 cells.insert(eps_cell);
4597 double x_min = cells.begin()->vertices[0][0];
4598 double x_max = x_min;
4599 double y_min = cells.begin()->vertices[0][1];
4600 double y_max = y_min;
4602 for (
const auto &cell : cells)
4603 for (
const auto &vertex : cell.vertices)
4605 x_min =
std::min(x_min, vertex[0]);
4606 x_max =
std::max(x_max, vertex[0]);
4607 y_min =
std::min(y_min, vertex[1]);
4608 y_max =
std::max(y_max, vertex[1]);
4613 const double scale =
4617 const Point<2> offset(x_min, y_min);
4622 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4623 <<
"%%Title: deal.II Output" <<
'\n'
4624 <<
"%%Creator: the deal.II library" <<
'\n'
4627 <<
"%%BoundingBox: "
4631 <<
static_cast<unsigned int>((x_max - x_min) * scale + 0.5) <<
' '
4632 <<
static_cast<unsigned int>((y_max - y_min) * scale + 0.5) <<
'\n';
4641 out <<
"/m {moveto} bind def" <<
'\n'
4642 <<
"/l {lineto} bind def" <<
'\n'
4643 <<
"/s {setrgbcolor} bind def" <<
'\n'
4644 <<
"/sg {setgray} bind def" <<
'\n'
4645 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4646 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4648 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4650 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4658 if (max_color_value == min_color_value)
4659 max_color_value = min_color_value + 1;
4663 for (
const auto &cell : cells)
4676 out << rgb_values.
red <<
" sg ";
4678 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4679 << rgb_values.
blue <<
" s ";
4684 out << (cell.vertices[0] - offset) * scale <<
" m "
4685 << (cell.vertices[1] - offset) * scale <<
" l "
4686 << (cell.vertices[3] - offset) * scale <<
" l "
4687 << (cell.vertices[2] - offset) * scale <<
" lf" <<
'\n';
4692 << (cell.vertices[0] - offset) * scale <<
" m "
4693 << (cell.vertices[1] - offset) * scale <<
" l "
4694 << (cell.vertices[3] - offset) * scale <<
" l "
4695 << (cell.vertices[2] - offset) * scale <<
" lx" <<
'\n';
4697 out <<
"showpage" <<
'\n';
4706 template <
int dim,
int spacedim>
4710 const std::vector<std::string> &data_names,
4712 std::tuple<
unsigned int,
4728#ifndef DEAL_II_WITH_MPI
4737 if (patches.empty())
4741 GmvStream gmv_out(out, flags);
4742 const unsigned int n_data_sets = data_names.size();
4745 Assert((patches[0].
data.n_rows() == n_data_sets &&
4746 !patches[0].points_are_available) ||
4747 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4748 patches[0].points_are_available),
4750 (n_data_sets + spacedim) :
4752 patches[0].data.n_rows()));
4756 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4760 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
4775 [&patches]() {
return create_global_data_table(patches); });
4781 out <<
"nodes " << n_nodes <<
'\n';
4782 for (
unsigned int d = 0; d < spacedim; ++d)
4784 gmv_out.selected_component = d;
4790 for (
unsigned int d = spacedim; d < 3; ++d)
4792 for (
unsigned int i = 0; i < n_nodes; ++i)
4799 out <<
"cells " << n_cells <<
'\n';
4804 out <<
"variable" <<
'\n';
4808 std::move(*create_global_data_table_task.
return_value());
4812 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4814 out << data_names[data_set] <<
" 1" <<
'\n';
4815 std::copy(data_vectors[data_set].
begin(),
4816 data_vectors[data_set].
end(),
4817 std::ostream_iterator<double>(out,
" "));
4818 out <<
'\n' <<
'\n';
4824 out <<
"endvars" <<
'\n';
4827 out <<
"endgmv" <<
'\n';
4838 template <
int dim,
int spacedim>
4842 const std::vector<std::string> &data_names,
4844 std::tuple<
unsigned int,
4858#ifndef DEAL_II_WITH_MPI
4867 if (patches.empty())
4871 TecplotStream tecplot_out(out, flags);
4873 const unsigned int n_data_sets = data_names.size();
4876 Assert((patches[0].
data.n_rows() == n_data_sets &&
4877 !patches[0].points_are_available) ||
4878 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4879 patches[0].points_are_available),
4881 (n_data_sets + spacedim) :
4883 patches[0].data.n_rows()));
4887 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
4893 <<
"# This file was generated by the deal.II library." <<
'\n'
4897 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4902 out <<
"Variables=";
4910 out <<
"\"x\", \"y\"";
4913 out <<
"\"x\", \"y\", \"z\"";
4919 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4920 out <<
", \"" << data_names[data_set] <<
"\"";
4926 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4929 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4931 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4932 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4949 [&patches]() {
return create_global_data_table(patches); });
4955 for (
unsigned int d = 0; d < spacedim; ++d)
4957 tecplot_out.selected_component = d;
4968 std::move(*create_global_data_table_task.
return_value());
4971 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4973 std::copy(data_vectors[data_set].
begin(),
4974 data_vectors[data_set].
end(),
4975 std::ostream_iterator<double>(out,
"\n"));
4990 template <
int dim,
int spacedim>
4994 const std::vector<std::string> &data_names,
4996 std::tuple<
unsigned int,
5000 &nonscalar_data_ranges,
5006#ifndef DEAL_II_WITH_MPI
5015 if (patches.empty())
5019 VtkStream vtk_out(out, flags);
5021 const unsigned int n_data_sets = data_names.size();
5023 if (patches[0].points_are_available)
5035 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5036 <<
"#This file was generated by the deal.II library";
5044 out <<
'\n' <<
"ASCII" <<
'\n';
5046 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
5053 const unsigned int n_metadata =
5055 (flags.
time != std::numeric_limits<double>::lowest() ? 1 : 0));
5058 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5062 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5064 if (flags.
time != std::numeric_limits<double>::lowest())
5066 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5072 unsigned int n_nodes;
5073 unsigned int n_cells;
5074 unsigned int n_points_and_n_cells;
5075 std::tie(n_nodes, n_cells, n_points_and_n_cells) =
5091 [&patches]() {
return create_global_data_table(patches); });
5097 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5102 out <<
"CELLS " << n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5110 out <<
"CELL_TYPES " << n_cells <<
'\n';
5114 for (
const auto &patch : patches)
5116 const auto vtk_cell_id =
5119 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5120 out <<
' ' << vtk_cell_id[0];
5129 std::move(*create_global_data_table_task.
return_value());
5134 out <<
"POINT_DATA " << n_nodes <<
'\n';
5138 std::vector<bool> data_set_written(n_data_sets,
false);
5139 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5144 "The VTK writer does not currently support outputting "
5145 "tensor data. Use the VTU writer instead."));
5148 std::get<0>(nonscalar_data_range),
5150 std::get<0>(nonscalar_data_range)));
5151 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5155 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5156 std::get<0>(nonscalar_data_range) <=
5159 "Can't declare a vector with more than 3 components "
5163 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5164 i <= std::get<1>(nonscalar_data_range);
5166 data_set_written[i] =
true;
5172 if (!std::get<2>(nonscalar_data_range).empty())
5173 out << std::get<2>(nonscalar_data_range);
5176 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5177 i < std::get<1>(nonscalar_data_range);
5179 out << data_names[i] <<
"__";
5180 out << data_names[std::get<1>(nonscalar_data_range)];
5183 out <<
" double" <<
'\n';
5186 for (
unsigned int n = 0; n < n_nodes; ++n)
5188 switch (std::get<1>(nonscalar_data_range) -
5189 std::get<0>(nonscalar_data_range))
5192 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5197 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5199 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5203 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5205 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5207 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5220 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5221 if (data_set_written[data_set] ==
false)
5223 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5224 <<
"LOOKUP_TABLE default" <<
'\n';
5225 std::copy(data_vectors[data_set].
begin(),
5226 data_vectors[data_set].
end(),
5227 std::ostream_iterator<double>(out,
" "));
5243 out <<
"<?xml version=\"1.0\" ?> \n";
5245 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5246 <<
"#This file was generated by the deal.II library";
5257 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"2.2\"";
5259 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5260 if (deal_ii_with_zlib &&
5262 out <<
" compressor=\"vtkZLibDataCompressor\"";
5263#ifdef DEAL_II_WORDS_BIGENDIAN
5264 out <<
" byte_order=\"BigEndian\"";
5266 out <<
" byte_order=\"LittleEndian\"";
5270 out <<
"<UnstructuredGrid>";
5280 out <<
" </UnstructuredGrid>\n";
5281 out <<
"</VTKFile>\n";
5286 template <
int dim,
int spacedim>
5290 const std::vector<std::string> &data_names,
5292 std::tuple<
unsigned int,
5296 &nonscalar_data_ranges,
5301 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5308 template <
int dim,
int spacedim>
5312 const std::vector<std::string> &data_names,
5314 std::tuple<
unsigned int,
5318 &nonscalar_data_ranges,
5331 unit.second.find(
'\"') == std::string::npos,
5333 "A physical unit you provided, <" + unit.second +
5334 ">, contained a quotation mark character. This is not allowed."));
5337#ifndef DEAL_II_WITH_MPI
5346 if (patches.empty())
5351 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5353 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5355 <<
" <PointData Scalars=\"scalars\">\n";
5356 std::vector<bool> data_set_written(data_names.size(),
false);
5357 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5360 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5361 i <= std::get<1>(nonscalar_data_range);
5363 data_set_written[i] =
true;
5367 out <<
" <DataArray type=\"Float32\" Name=\"";
5369 if (!std::get<2>(nonscalar_data_range).empty())
5370 out << std::get<2>(nonscalar_data_range);
5373 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5374 i < std::get<1>(nonscalar_data_range);
5376 out << data_names[i] <<
"__";
5377 out << data_names[std::get<1>(nonscalar_data_range)];
5380 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5383 for (
unsigned int data_set = 0; data_set < data_names.size();
5385 if (data_set_written[data_set] ==
false)
5387 out <<
" <DataArray type=\"Float32\" Name=\""
5388 << data_names[data_set] <<
"\"></DataArray>\n";
5391 out <<
" </PointData>\n";
5392 out <<
"</Piece>\n";
5406 const unsigned int n_metadata =
5408 (flags.
time != std::numeric_limits<double>::lowest() ? 1 : 0));
5410 out <<
"<FieldData>\n";
5415 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5416 << flags.
cycle <<
"</DataArray>\n";
5418 if (flags.
time != std::numeric_limits<double>::lowest())
5421 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5422 << flags.
time <<
"</DataArray>\n";
5426 out <<
"</FieldData>\n";
5430 const unsigned int n_data_sets = data_names.size();
5433 if (patches[0].points_are_available)
5442 const char *ascii_or_binary =
5443 (deal_ii_with_zlib &&
5450 unsigned int n_nodes;
5451 unsigned int n_cells;
5452 std::tie(n_nodes, n_cells, std::ignore) =
5460 const auto stringize_vertex_information = [&patches,
5464 ascii_or_binary]() {
5465 std::ostringstream o;
5467 o <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5468 << ascii_or_binary <<
"\">\n";
5469 const std::vector<Point<spacedim>> node_positions =
5474 std::vector<float> node_coordinates_3d;
5475 node_coordinates_3d.reserve(node_positions.size() * 3);
5476 for (
const auto &node_position : node_positions)
5478 for (
unsigned int d = 0; d < 3; ++d)
5480 node_coordinates_3d.emplace_back(node_position[d]);
5482 node_coordinates_3d.emplace_back(0.0f);
5484 vtu_stringize_array(node_coordinates_3d,
5489 o <<
" </DataArray>\n";
5490 o <<
" </Points>\n\n";
5499 const auto stringize_cell_to_vertex_information = [&patches,
5503 out.precision()]() {
5504 std::ostringstream o;
5507 o <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5508 << ascii_or_binary <<
"\">\n";
5510 std::vector<std::int32_t> cells;
5513 unsigned int first_vertex_of_patch = 0;
5515 std::vector<unsigned int> local_vertex_order;
5516 for (
const auto &patch : patches)
5518 local_vertex_order.clear();
5530 const unsigned int n_points = patch.
data.n_cols();
5531 Assert((dim == 2 && n_points == 6) ||
5532 (dim == 3 && n_points == 10),
5535 if (deal_ii_with_zlib &&
5539 for (
unsigned int i = 0; i < n_points; ++i)
5540 cells.push_back(first_vertex_of_patch + i);
5544 for (
unsigned int i = 0; i < n_points; ++i)
5545 o <<
'\t' << first_vertex_of_patch + i;
5549 first_vertex_of_patch += n_points;
5554 else if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
5558 const unsigned int n_points = patch.
data.n_cols();
5560 if (deal_ii_with_zlib &&
5564 for (
unsigned int i = 0; i < n_points; ++i)
5566 first_vertex_of_patch +
5571 for (
unsigned int i = 0; i < n_points; ++i)
5573 << (first_vertex_of_patch +
5578 first_vertex_of_patch += n_points;
5583 const unsigned int n_points_per_direction = n_subdivisions + 1;
5586 const auto flush_current_cell = [&flags,
5589 first_vertex_of_patch,
5590 &local_vertex_order]() {
5591 if (deal_ii_with_zlib &&
5595 for (
const auto &c : local_vertex_order)
5596 cells.push_back(first_vertex_of_patch + c);
5600 for (
const auto &c : local_vertex_order)
5601 o <<
'\t' << first_vertex_of_patch + c;
5605 local_vertex_order.clear();
5610 local_vertex_order.reserve(Utilities::fixed_power<dim>(2));
5616 local_vertex_order.emplace_back(0);
5617 flush_current_cell();
5623 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5625 const unsigned int starting_offset = i1;
5626 local_vertex_order.emplace_back(starting_offset);
5627 local_vertex_order.emplace_back(starting_offset +
5629 flush_current_cell();
5636 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5637 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5639 const unsigned int starting_offset =
5640 i2 * n_points_per_direction + i1;
5641 local_vertex_order.emplace_back(
5643 local_vertex_order.emplace_back(
5644 starting_offset + 1);
5645 local_vertex_order.emplace_back(
5646 starting_offset + n_points_per_direction + 1);
5647 local_vertex_order.emplace_back(
5648 starting_offset + n_points_per_direction);
5649 flush_current_cell();
5656 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5657 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5658 for (
unsigned int i1 = 0; i1 < n_subdivisions;
5661 const unsigned int starting_offset =
5662 i3 * n_points_per_direction *
5663 n_points_per_direction +
5664 i2 * n_points_per_direction + i1;
5665 local_vertex_order.emplace_back(
5667 local_vertex_order.emplace_back(
5668 starting_offset + 1);
5669 local_vertex_order.emplace_back(
5670 starting_offset + n_points_per_direction +
5672 local_vertex_order.emplace_back(
5673 starting_offset + n_points_per_direction);
5674 local_vertex_order.emplace_back(
5675 starting_offset + n_points_per_direction *
5676 n_points_per_direction);
5677 local_vertex_order.emplace_back(
5679 n_points_per_direction *
5680 n_points_per_direction +
5682 local_vertex_order.emplace_back(
5684 n_points_per_direction *
5685 n_points_per_direction +
5686 n_points_per_direction + 1);
5687 local_vertex_order.emplace_back(
5689 n_points_per_direction *
5690 n_points_per_direction +
5691 n_points_per_direction);
5692 flush_current_cell();
5703 local_vertex_order.resize(
5704 Utilities::fixed_power<dim>(n_points_per_direction));
5706 if constexpr (dim == 0)
5710 "Point-like cells should not be possible "
5711 "when writing higher-order cells."));
5713 else if constexpr (dim == 1)
5715 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
5717 const unsigned int local_index = i1;
5718 const unsigned int connectivity_index =
5720 .vtk_lexicographic_to_node_index(
5724 local_vertex_order[connectivity_index] = local_index;
5726 flush_current_cell();
5728 else if constexpr (dim == 2)
5730 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1; ++i2)
5731 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1; ++i1)
5733 const unsigned int local_index =
5734 i2 * n_points_per_direction + i1;
5735 const unsigned int connectivity_index =
5737 .vtk_lexicographic_to_node_index(
5739 {{n_subdivisions, n_subdivisions}},
5741 local_vertex_order[connectivity_index] =
5744 flush_current_cell();
5746 else if constexpr (dim == 3)
5748 for (
unsigned int i3 = 0; i3 < n_subdivisions + 1; ++i3)
5749 for (
unsigned int i2 = 0; i2 < n_subdivisions + 1; ++i2)
5750 for (
unsigned int i1 = 0; i1 < n_subdivisions + 1;
5753 const unsigned int local_index =
5754 i3 * n_points_per_direction *
5755 n_points_per_direction +
5756 i2 * n_points_per_direction + i1;
5757 const unsigned int connectivity_index =
5759 .vtk_lexicographic_to_node_index(
5765 local_vertex_order[connectivity_index] =
5769 flush_current_cell();
5777 first_vertex_of_patch +=
5786 vtu_stringize_array(cells,
5792 o <<
" </DataArray>\n";
5812 const auto stringize_cell_offset_and_type_information =
5817 output_precision = out.precision()]() {
5818 std::ostringstream o;
5820 o <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5821 << ascii_or_binary <<
"\">\n";
5823 std::vector<std::int32_t> offsets;
5824 offsets.reserve(n_cells);
5828 std::vector<unsigned int> cell_types;
5829 cell_types.reserve(n_cells);
5831 unsigned int first_vertex_of_patch = 0;
5833 for (
const auto &patch : patches)
5835 const auto vtk_cell_id =
5838 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5840 cell_types.push_back(vtk_cell_id[0]);
5841 first_vertex_of_patch += vtk_cell_id[2];
5842 offsets.push_back(first_vertex_of_patch);
5846 vtu_stringize_array(offsets,
5851 o <<
" </DataArray>\n";
5853 o <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5854 << ascii_or_binary <<
"\">\n";
5856 if (deal_ii_with_zlib &&
5859 std::vector<std::uint8_t> cell_types_uint8_t(cell_types.size());
5860 for (
unsigned int i = 0; i < cell_types.size(); ++i)
5861 cell_types_uint8_t[i] =
static_cast<std::uint8_t
>(cell_types[i]);
5863 vtu_stringize_array(cell_types_uint8_t,
5870 vtu_stringize_array(cell_types,
5877 o <<
" </DataArray>\n";
5887 const auto stringize_nonscalar_data_range =
5893 output_precision = out.precision()](
const Table<2, float> &data_vectors,
5894 const auto &range) {
5895 std::ostringstream o;
5897 const auto first_component = std::get<0>(range);
5898 const auto last_component = std::get<1>(range);
5899 const auto &name = std::get<2>(range);
5900 const bool is_tensor =
5901 (std::get<3>(range) ==
5903 const unsigned int n_components = (is_tensor ? 9 : 3);
5910 AssertThrow((last_component + 1 - first_component <= 9),
5912 "Can't declare a tensor with more than 9 components "
5913 "in VTK/VTU format."));
5917 AssertThrow((last_component + 1 - first_component <= 3),
5919 "Can't declare a vector with more than 3 components "
5920 "in VTK/VTU format."));
5925 o <<
" <DataArray type=\"Float32\" Name=\"";
5931 for (
unsigned int i = first_component; i < last_component; ++i)
5932 o << data_names[i] <<
"__";
5933 o << data_names[last_component];
5936 o <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5937 << ascii_or_binary <<
"\"";
5956 std::vector<float>
data;
5957 data.reserve(n_nodes * n_components);
5959 for (
unsigned int n = 0; n < n_nodes; ++n)
5963 switch (last_component - first_component)
5966 data.push_back(data_vectors(first_component, n));
5972 data.push_back(data_vectors(first_component, n));
5973 data.push_back(data_vectors(first_component + 1, n));
5978 data.push_back(data_vectors(first_component, n));
5979 data.push_back(data_vectors(first_component + 1, n));
5980 data.push_back(data_vectors(first_component + 2, n));
5993 const unsigned int size = last_component - first_component + 1;
5997 vtk_data[0][0] = data_vectors(first_component, n);
6002 for (
unsigned int c = 0; c <
size; ++c)
6006 vtk_data[ind[0]][ind[1]] =
6007 data_vectors(first_component + c, n);
6013 for (
unsigned int c = 0; c <
size; ++c)
6017 vtk_data[ind[0]][ind[1]] =
6018 data_vectors(first_component + c, n);
6029 for (
unsigned int i = 0; i < 3; ++i)
6030 for (
unsigned int j = 0; j < 3; ++j)
6031 data.push_back(vtk_data[i][j]);
6037 o <<
" </DataArray>\n";
6042 const auto stringize_scalar_data_set =
6046 output_precision = out.precision()](
const Table<2, float> &data_vectors,
6047 const unsigned int data_set) {
6048 std::ostringstream o;
6050 o <<
" <DataArray type=\"Float32\" Name=\"" << data_names[data_set]
6051 <<
"\" format=\"" << ascii_or_binary <<
"\"";
6055 o <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6060 const std::vector<float>
data(data_vectors[data_set].
begin(),
6061 data_vectors[data_set].
end());
6064 o <<
" </DataArray>\n";
6083 return create_global_data_table<dim, spacedim, float>(patches);
6097 std::move(*create_global_data_table_task.
return_value());
6103 std::vector<bool> data_set_handled(n_data_sets,
false);
6104 for (
const auto &range : nonscalar_data_ranges)
6107 const auto first_component = std::get<0>(range);
6108 const auto last_component = std::get<1>(range);
6109 for (
unsigned int i = first_component; i <= last_component; ++i)
6110 data_set_handled[i] =
true;
6113 return stringize_nonscalar_data_range(data_vectors, range);
6118 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6119 if (data_set_handled[data_set] ==
false)
6122 return stringize_scalar_data_set(data_vectors, data_set);
6128 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
6129 << n_cells <<
"\" >\n";
6130 for (
const auto &s : mesh_tasks.return_values())
6132 out <<
" <PointData Scalars=\"scalars\">\n";
6135 out <<
" </PointData>\n";
6136 out <<
" </Piece>\n";
6150 const std::vector<std::string> &piece_names,
6151 const std::vector<std::string> &data_names,
6153 std::tuple<
unsigned int,
6157 &nonscalar_data_ranges,
6169 unit.second.find(
'\"') == std::string::npos,
6171 "A physical unit you provided, <" + unit.second +
6172 ">, contained a quotation mark character. This is not allowed."));
6175 const unsigned int n_data_sets = data_names.size();
6177 out <<
"<?xml version=\"1.0\"?>\n";
6180 out <<
"#This file was generated by the deal.II library"
6185 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
6186 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
6194 const unsigned int n_metadata =
6196 (flags.
time != std::numeric_limits<double>::lowest() ? 1 : 0));
6198 out <<
" <FieldData>\n";
6203 <<
" <DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
6204 << flags.
cycle <<
"</DataArray>\n";
6206 if (flags.
time != std::numeric_limits<double>::lowest())
6209 <<
" <DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
6210 << flags.
time <<
"</DataArray>\n";
6214 out <<
" </FieldData>\n";
6217 out <<
" <PPointData Scalars=\"scalars\">\n";
6220 std::vector<bool> data_set_written(n_data_sets,
false);
6221 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
6223 const auto first_component = std::get<0>(nonscalar_data_range);
6224 const auto last_component = std::get<1>(nonscalar_data_range);
6225 const bool is_tensor =
6226 (std::get<3>(nonscalar_data_range) ==
6228 const unsigned int n_components = (is_tensor ? 9 : 3);
6235 AssertThrow((last_component + 1 - first_component <= 9),
6237 "Can't declare a tensor with more than 9 components "
6242 Assert((last_component + 1 - first_component <= 3),
6244 "Can't declare a vector with more than 3 components "
6249 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6250 i <= std::get<1>(nonscalar_data_range);
6252 data_set_written[i] =
true;
6256 out <<
" <PDataArray type=\"Float32\" Name=\"";
6258 const std::string &name = std::get<2>(nonscalar_data_range);
6263 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6264 i < std::get<1>(nonscalar_data_range);
6266 out << data_names[i] <<
"__";
6267 out << data_names[std::get<1>(nonscalar_data_range)];
6270 out <<
"\" NumberOfComponents=\"" << n_components
6271 <<
"\" format=\"ascii\"";
6283 data_names[std::get<1>(nonscalar_data_range)]) !=
6287 data_names[std::get<1>(nonscalar_data_range)])
6295 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6296 if (data_set_written[data_set] ==
false)
6298 out <<
" <PDataArray type=\"Float32\" Name=\""
6299 << data_names[data_set] <<
"\" format=\"ascii\"";
6303 out <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6309 out <<
" </PPointData>\n";
6311 out <<
" <PPoints>\n";
6312 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
6313 out <<
" </PPoints>\n";
6315 for (
const auto &piece_name : piece_names)
6316 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
6318 out <<
" </PUnstructuredGrid>\n";
6319 out <<
"</VTKFile>\n";
6332 const std::vector<std::pair<double, std::string>> ×_and_names)
6336 out <<
"<?xml version=\"1.0\"?>\n";
6339 out <<
"#This file was generated by the deal.II library"
6344 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
6345 out <<
" <Collection>\n";
6347 std::streamsize ss = out.precision();
6350 for (
const auto &time_and_name : times_and_names)
6351 out <<
" <DataSet timestep=\"" << time_and_name.first
6352 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
6355 out <<
" </Collection>\n";
6356 out <<
"</VTKFile>\n";
6368 const std::vector<std::string> &piece_names)
6370 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
6371 for (
const auto &piece_name : piece_names)
6372 out << piece_name <<
'\n';
6381 const std::vector<std::vector<std::string>> &piece_names)
6385 if (piece_names.empty())
6388 const double nblocks = piece_names[0].size();
6390 ExcMessage(
"piece_names should be a vector of nonempty vectors."));
6392 out <<
"!NBLOCKS " << nblocks <<
'\n';
6393 for (
const auto &domain : piece_names)
6395 Assert(domain.size() == nblocks,
6397 "piece_names should be a vector of equal sized vectors."));
6398 for (
const auto &subdomain : domain)
6399 out << subdomain <<
'\n';
6410 const std::vector<std::pair<
double, std::vector<std::string>>>
6411 ×_and_piece_names)
6415 if (times_and_piece_names.empty())
6418 const double nblocks = times_and_piece_names[0].second.size();
6422 "time_and_piece_names should contain nonempty vectors of filenames for every timestep."));
6424 for (
const auto &domain : times_and_piece_names)
6425 out <<
"!TIME " << domain.first <<
'\n';
6427 out <<
"!NBLOCKS " << nblocks <<
'\n';
6428 for (
const auto &domain : times_and_piece_names)
6430 Assert(domain.second.size() == nblocks,
6432 "piece_names should be a vector of equal sized vectors."));
6433 for (
const auto &subdomain : domain.second)
6434 out << subdomain <<
'\n';
6442 template <
int dim,
int spacedim>
6446 const std::vector<std::string> &,
6448 std::tuple<
unsigned int,
6458 template <
int spacedim>
6462 const std::vector<std::string> & ,
6464 std::tuple<
unsigned int,
6473 unsigned int width = flags.
width;
6476 unsigned int margin_in_percent = 0;
6478 margin_in_percent = 5;
6482 double x_dimension, y_dimension, z_dimension;
6484 const auto &first_patch = patches[0];
6486 unsigned int n_subdivisions = first_patch.n_subdivisions;
6487 unsigned int n = n_subdivisions + 1;
6488 const unsigned int d1 = 1;
6489 const unsigned int d2 = n;
6492 std::array<Point<spacedim>, 4> projected_points;
6495 std::array<Point<2>, 4> projection_decompositions;
6498 get_equispaced_location(first_patch, {0, 0}, n_subdivisions);
6500 if (first_patch.data.n_rows() != 0)
6505 double x_min = projected_point[0];
6506 double x_max = x_min;
6507 double y_min = projected_point[1];
6508 double y_max = y_min;
6509 double z_min = first_patch.data.n_rows() != 0 ?
6512 double z_max = z_min;
6515 for (
const auto &patch : patches)
6518 n = n_subdivisions + 1;
6520 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6522 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6524 projected_points[0] =
6525 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
6526 projected_points[1] =
6527 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
6528 projected_points[2] =
6529 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
6530 projected_points[3] = get_equispaced_location(patch,
6534 x_min =
std::min(x_min, projected_points[0][0]);
6535 x_min =
std::min(x_min, projected_points[1][0]);
6536 x_min =
std::min(x_min, projected_points[2][0]);
6537 x_min =
std::min(x_min, projected_points[3][0]);
6539 x_max =
std::max(x_max, projected_points[0][0]);
6540 x_max =
std::max(x_max, projected_points[1][0]);
6541 x_max =
std::max(x_max, projected_points[2][0]);
6542 x_max =
std::max(x_max, projected_points[3][0]);
6544 y_min =
std::min(y_min, projected_points[0][1]);
6545 y_min =
std::min(y_min, projected_points[1][1]);
6546 y_min =
std::min(y_min, projected_points[2][1]);
6547 y_min =
std::min(y_min, projected_points[3][1]);
6549 y_max =
std::max(y_max, projected_points[0][1]);
6550 y_max =
std::max(y_max, projected_points[1][1]);
6551 y_max =
std::max(y_max, projected_points[2][1]);
6552 y_max =
std::max(y_max, projected_points[3][1]);
6555 patch.
data.n_rows() == 0,
6558 patch.
data.n_rows()));
6560 z_min = std::min<double>(z_min,
6562 i1 * d1 + i2 * d2));
6563 z_min = std::min<double>(z_min,
6565 (i1 + 1) * d1 + i2 * d2));
6566 z_min = std::min<double>(z_min,
6568 i1 * d1 + (i2 + 1) * d2));
6570 std::min<double>(z_min,
6572 (i1 + 1) * d1 + (i2 + 1) * d2));
6574 z_max = std::max<double>(z_max,
6576 i1 * d1 + i2 * d2));
6577 z_max = std::max<double>(z_max,
6579 (i1 + 1) * d1 + i2 * d2));
6580 z_max = std::max<double>(z_max,
6582 i1 * d1 + (i2 + 1) * d2));
6584 std::max<double>(z_max,
6586 (i1 + 1) * d1 + (i2 + 1) * d2));
6591 x_dimension = x_max - x_min;
6592 y_dimension = y_max - y_min;
6593 z_dimension = z_max - z_min;
6600 float camera_focus = 0;
6603 camera_position[0] = 0.;
6604 camera_position[1] = 0.;
6605 camera_position[2] = z_min + 2. * z_dimension;
6607 camera_direction[0] = 0.;
6608 camera_direction[1] = 0.;
6609 camera_direction[2] = -1.;
6611 camera_horizontal[0] = 1.;
6612 camera_horizontal[1] = 0.;
6613 camera_horizontal[2] = 0.;
6615 camera_focus = .5 * z_dimension;
6621 const float angle_factor = 3.14159265f / 180.f;
6624 camera_position_temp[1] =
6627 camera_position_temp[2] =
6631 camera_direction_temp[1] =
6634 camera_direction_temp[2] =
6638 camera_horizontal_temp[1] =
6641 camera_horizontal_temp[2] =
6645 camera_position[1] = camera_position_temp[1];
6646 camera_position[2] = camera_position_temp[2];
6648 camera_direction[1] = camera_direction_temp[1];
6649 camera_direction[2] = camera_direction_temp[2];
6651 camera_horizontal[1] = camera_horizontal_temp[1];
6652 camera_horizontal[2] = camera_horizontal_temp[2];
6655 camera_position_temp[0] =
6658 camera_position_temp[1] =
6662 camera_direction_temp[0] =
6665 camera_direction_temp[1] =
6669 camera_horizontal_temp[0] =
6672 camera_horizontal_temp[1] =
6676 camera_position[0] = camera_position_temp[0];
6677 camera_position[1] = camera_position_temp[1];
6679 camera_direction[0] = camera_direction_temp[0];
6680 camera_direction[1] = camera_direction_temp[1];
6682 camera_horizontal[0] = camera_horizontal_temp[0];
6683 camera_horizontal[1] = camera_horizontal_temp[1];
6686 camera_position[0] = x_min + .5 * x_dimension;
6687 camera_position[1] = y_min + .5 * y_dimension;
6689 camera_position[0] += (z_min + 2. * z_dimension) *
6692 camera_position[1] -= (z_min + 2. * z_dimension) *
6698 double x_min_perspective, y_min_perspective;
6699 double x_max_perspective, y_max_perspective;
6700 double x_dimension_perspective, y_dimension_perspective;
6702 n_subdivisions = first_patch.n_subdivisions;
6703 n = n_subdivisions + 1;
6708 get_equispaced_location(first_patch, {0, 0}, n_subdivisions);
6710 if (first_patch.data.n_rows() != 0)
6715 point[0] = projected_point[0];
6716 point[1] = projected_point[1];
6717 point[2] = first_patch.data.n_rows() != 0 ?
6721 projection_decomposition = svg_project_point(point,
6727 x_min_perspective = projection_decomposition[0];
6728 x_max_perspective = projection_decomposition[0];
6729 y_min_perspective = projection_decomposition[1];
6730 y_max_perspective = projection_decomposition[1];
6733 for (
const auto &patch : patches)
6736 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6738 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6740 const std::array<Point<spacedim>, 4> projected_vertices{
6741 {get_equispaced_location(patch, {i1, i2}, n_subdivisions),
6742 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions),
6743 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions),
6744 get_equispaced_location(patch,
6749 patch.
data.n_rows() == 0,
6752 patch.
data.n_rows()));
6754 const std::array<Point<3>, 4> vertices = {
6755 {
Point<3>{projected_vertices[0][0],
6756 projected_vertices[0][1],
6757 patch.
data.n_rows() != 0 ?
6758 patch.
data(0, i1 * d1 + i2 * d2) :
6761 projected_vertices[1][1],
6762 patch.
data.n_rows() != 0 ?
6763 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6766 projected_vertices[2][1],
6767 patch.
data.n_rows() != 0 ?
6768 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6771 projected_vertices[3][1],
6772 patch.
data.n_rows() != 0 ?
6773 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6776 projection_decompositions = {
6777 {svg_project_point(vertices[0],
6782 svg_project_point(vertices[1],
6787 svg_project_point(vertices[2],
6792 svg_project_point(vertices[3],
6800 static_cast<double>(
6801 projection_decompositions[0][0]));
6804 static_cast<double>(
6805 projection_decompositions[1][0]));
6808 static_cast<double>(
6809 projection_decompositions[2][0]));
6812 static_cast<double>(
6813 projection_decompositions[3][0]));
6817 static_cast<double>(
6818 projection_decompositions[0][0]));
6821 static_cast<double>(
6822 projection_decompositions[1][0]));
6825 static_cast<double>(
6826 projection_decompositions[2][0]));
6829 static_cast<double>(
6830 projection_decompositions[3][0]));
6834 static_cast<double>(
6835 projection_decompositions[0][1]));
6838 static_cast<double>(
6839 projection_decompositions[1][1]));
6842 static_cast<double>(
6843 projection_decompositions[2][1]));
6846 static_cast<double>(
6847 projection_decompositions[3][1]));
6851 static_cast<double>(
6852 projection_decompositions[0][1]));
6855 static_cast<double>(
6856 projection_decompositions[1][1]));
6859 static_cast<double>(
6860 projection_decompositions[2][1]));
6863 static_cast<double>(
6864 projection_decompositions[3][1]));
6869 x_dimension_perspective = x_max_perspective - x_min_perspective;
6870 y_dimension_perspective = y_max_perspective - y_min_perspective;
6872 std::multiset<SvgCell> cells;
6875 for (
const auto &patch : patches)
6879 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6881 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6883 const std::array<Point<spacedim>, 4> projected_vertices = {
6884 {get_equispaced_location(patch, {i1, i2}, n_subdivisions),
6885 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions),
6886 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions),
6887 get_equispaced_location(patch,
6892 patch.
data.n_rows() == 0,
6895 patch.
data.n_rows()));
6899 cell.vertices[0][0] = projected_vertices[0][0];
6900 cell.vertices[0][1] = projected_vertices[0][1];
6901 cell.vertices[0][2] = patch.
data.n_rows() != 0 ?
6902 patch.
data(0, i1 * d1 + i2 * d2) :
6905 cell.vertices[1][0] = projected_vertices[1][0];
6906 cell.vertices[1][1] = projected_vertices[1][1];
6907 cell.vertices[1][2] = patch.
data.n_rows() != 0 ?
6908 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6911 cell.vertices[2][0] = projected_vertices[2][0];
6912 cell.vertices[2][1] = projected_vertices[2][1];
6913 cell.vertices[2][2] = patch.
data.n_rows() != 0 ?
6914 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6917 cell.vertices[3][0] = projected_vertices[3][0];
6918 cell.vertices[3][1] = projected_vertices[3][1];
6919 cell.vertices[3][2] =
6920 patch.
data.n_rows() != 0 ?
6921 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6924 cell.projected_vertices[0] =
6925 svg_project_point(cell.vertices[0],
6930 cell.projected_vertices[1] =
6931 svg_project_point(cell.vertices[1],
6936 cell.projected_vertices[2] =
6937 svg_project_point(cell.vertices[2],
6942 cell.projected_vertices[3] =
6943 svg_project_point(cell.vertices[3],
6949 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] +
6950 cell.vertices[2] + cell.vertices[3]);
6951 cell.projected_center = svg_project_point(cell.center,
6957 cell.depth = cell.center.distance(camera_position);
6967 width =
static_cast<unsigned int>(
6968 .5 +
height * (x_dimension_perspective / y_dimension_perspective));
6969 unsigned int additional_width = 0;
6972 additional_width =
static_cast<unsigned int>(
6976 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\""
6977 <<
height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
6979 <<
" <rect width=\"" << width + additional_width <<
"\" height=\""
6980 <<
height <<
"\" style=\"fill:white\"/>" <<
'\n'
6983 unsigned int triangle_counter = 0;
6986 for (
const auto &cell : cells)
6990 for (
unsigned int triangle_index = 0; triangle_index < 4;
6993 switch (triangle_index)
6996 points3d_triangle[0] = cell.vertices[0],
6997 points3d_triangle[1] = cell.vertices[1],
6998 points3d_triangle[2] = cell.center;
7001 points3d_triangle[0] = cell.vertices[1],
7002 points3d_triangle[1] = cell.vertices[3],
7003 points3d_triangle[2] = cell.center;
7006 points3d_triangle[0] = cell.vertices[3],
7007 points3d_triangle[1] = cell.vertices[2],
7008 points3d_triangle[2] = cell.center;
7011 points3d_triangle[0] = cell.vertices[2],
7012 points3d_triangle[1] = cell.vertices[0],
7013 points3d_triangle[2] = cell.center;
7020 svg_get_gradient_parameters(points3d_triangle);
7023 .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
7025 .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
7027 unsigned int start_r = 0;
7028 unsigned int start_g = 0;
7029 unsigned int start_b = 0;
7031 unsigned int stop_r = 0;
7032 unsigned int stop_g = 0;
7033 unsigned int stop_b = 0;
7035 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
7036 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
7038 double start_f = start_h * 6. - start_i;
7039 double start_q = 1. - start_f;
7041 double stop_f = stop_h * 6. - stop_i;
7042 double stop_q = 1. - stop_f;
7044 switch (start_i % 6)
7048 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
7051 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
7056 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
7059 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
7063 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7068 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7078 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7081 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7086 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7089 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7093 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7098 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7104 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
7106 gradient_start_point_3d[0] = gradient_param[0];
7107 gradient_start_point_3d[1] = gradient_param[1];
7108 gradient_start_point_3d[2] = gradient_param[4];
7110 gradient_stop_point_3d[0] = gradient_param[2];
7111 gradient_stop_point_3d[1] = gradient_param[3];
7112 gradient_stop_point_3d[2] = gradient_param[5];
7115 svg_project_point(gradient_start_point_3d,
7121 svg_project_point(gradient_stop_point_3d,
7128 out <<
" <linearGradient id=\"" << triangle_counter
7129 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7131 <<
static_cast<unsigned int>(
7133 ((gradient_start_point[0] - x_min_perspective) /
7134 x_dimension_perspective) *
7135 (width - (width / 100.) * 2. * margin_in_percent) +
7136 ((width / 100.) * margin_in_percent))
7139 <<
static_cast<unsigned int>(
7141 ((gradient_start_point[1] - y_min_perspective) /
7142 y_dimension_perspective) *
7146 <<
static_cast<unsigned int>(
7148 ((gradient_stop_point[0] - x_min_perspective) /
7149 x_dimension_perspective) *
7150 (width - (width / 100.) * 2. * margin_in_percent) +
7151 ((width / 100.) * margin_in_percent))
7154 <<
static_cast<unsigned int>(
7156 ((gradient_stop_point[1] - y_min_perspective) /
7157 y_dimension_perspective) *
7161 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7162 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7163 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7164 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7165 <<
" </linearGradient>" <<
'\n';
7168 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
7169 double x3 = cell.projected_center[0];
7170 double y3 = cell.projected_center[1];
7172 switch (triangle_index)
7175 x1 = cell.projected_vertices[0][0],
7176 y1 = cell.projected_vertices[0][1],
7177 x2 = cell.projected_vertices[1][0],
7178 y2 = cell.projected_vertices[1][1];
7181 x1 = cell.projected_vertices[1][0],
7182 y1 = cell.projected_vertices[1][1],
7183 x2 = cell.projected_vertices[3][0],
7184 y2 = cell.projected_vertices[3][1];
7187 x1 = cell.projected_vertices[3][0],
7188 y1 = cell.projected_vertices[3][1],
7189 x2 = cell.projected_vertices[2][0],
7190 y2 = cell.projected_vertices[2][1];
7193 x1 = cell.projected_vertices[2][0],
7194 y1 = cell.projected_vertices[2][1],
7195 x2 = cell.projected_vertices[0][0],
7196 y2 = cell.projected_vertices[0][1];
7202 out <<
" <path d=\"M "
7203 <<
static_cast<unsigned int>(
7205 ((x1 - x_min_perspective) / x_dimension_perspective) *
7206 (width - (width / 100.) * 2. * margin_in_percent) +
7207 ((width / 100.) * margin_in_percent))
7209 <<
static_cast<unsigned int>(
7211 ((y1 - y_min_perspective) / y_dimension_perspective) *
7214 <<
static_cast<unsigned int>(
7216 ((x2 - x_min_perspective) / x_dimension_perspective) *
7217 (width - (width / 100.) * 2. * margin_in_percent) +
7218 ((width / 100.) * margin_in_percent))
7220 <<
static_cast<unsigned int>(
7222 ((y2 - y_min_perspective) / y_dimension_perspective) *
7225 <<
static_cast<unsigned int>(
7227 ((x3 - x_min_perspective) / x_dimension_perspective) *
7228 (width - (width / 100.) * 2. * margin_in_percent) +
7229 ((width / 100.) * margin_in_percent))
7231 <<
static_cast<unsigned int>(
7233 ((y3 - y_min_perspective) / y_dimension_perspective) *
7236 <<
static_cast<unsigned int>(
7238 ((x1 - x_min_perspective) / x_dimension_perspective) *
7239 (width - (width / 100.) * 2. * margin_in_percent) +
7240 ((width / 100.) * margin_in_percent))
7242 <<
static_cast<unsigned int>(
7244 ((y1 - y_min_perspective) / y_dimension_perspective) *
7246 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter
7257 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
7259 unsigned int element_height =
static_cast<unsigned int>(
7260 ((
height / 100.) * (71. - 2. * margin_in_percent)) / 4);
7261 unsigned int element_width =
7262 static_cast<unsigned int>(.5 + (
height / 100.) * 2.5);
7264 additional_width = 0;
7267 static_cast<unsigned int>(.5 + (
height / 100.) * 2.5);
7269 for (
unsigned int index = 0; index < 4; ++index)
7271 double start_h = .667 - ((index + 1) / 4.) * .667;
7272 double stop_h = .667 - (index / 4.) * .667;
7274 unsigned int start_r = 0;
7275 unsigned int start_g = 0;
7276 unsigned int start_b = 0;
7278 unsigned int stop_r = 0;
7279 unsigned int stop_g = 0;
7280 unsigned int stop_b = 0;
7282 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
7283 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
7285 double start_f = start_h * 6. - start_i;
7286 double start_q = 1. - start_f;
7288 double stop_f = stop_h * 6. - stop_i;
7289 double stop_q = 1. - stop_f;
7291 switch (start_i % 6)
7295 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
7298 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
7303 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
7306 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
7310 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7315 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7325 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7328 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7333 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7336 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7340 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7345 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7352 out <<
" <linearGradient id=\"colorbar_" << index
7353 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7354 <<
"x1=\"" << width + additional_width <<
"\" "
7356 <<
static_cast<unsigned int>(.5 + (
height / 100.) *
7357 (margin_in_percent + 29)) +
7358 (3 - index) * element_height
7360 <<
"x2=\"" << width + additional_width <<
"\" "
7362 <<
static_cast<unsigned int>(.5 + (
height / 100.) *
7363 (margin_in_percent + 29)) +
7364 (4 - index) * element_height
7367 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7368 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7369 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7370 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7371 <<
" </linearGradient>" <<
'\n';
7376 <<
" x=\"" << width + additional_width <<
"\" y=\""
7377 <<
static_cast<unsigned int>(.5 + (
height / 100.) *
7378 (margin_in_percent + 29)) +
7379 (3 - index) * element_height
7380 <<
"\" width=\"" << element_width <<
"\" height=\""
7382 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_"
7383 << index <<
")\"/>" <<
'\n';
7386 for (
unsigned int index = 0; index < 5; ++index)
7390 << width + additional_width +
7391 static_cast<unsigned int>(1.5 * element_width)
7393 <<
static_cast<unsigned int>(
7394 .5 + (
height / 100.) * (margin_in_percent + 29) +
7395 (4. - index) * element_height + 30.)
7397 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
7399 if (index == 0 || index == 4)
7400 out <<
"; font-weight:bold";
7403 <<
static_cast<float>(
7404 (
static_cast<int>((z_min + index * (z_dimension / 4.)) *
7413 out <<
"</text>" <<
'\n';
7418 out <<
'\n' <<
"</svg>";
7424 template <
int dim,
int spacedim>
7428 const std::vector<std::string> &data_names,
7430 std::tuple<
unsigned int,
7434 &nonscalar_data_ranges,
7443 out << dim <<
' ' << spacedim <<
'\n';
7446 out <<
"[deal.II intermediate format graphics data]" <<
'\n'
7452 out << data_names.size() <<
'\n';
7453 for (
const auto &data_name : data_names)
7454 out << data_name <<
'\n';
7456 out << patches.size() <<
'\n';
7457 for (
unsigned int i = 0; i < patches.size(); ++i)
7458 out << patches[i] <<
'\n';
7460 out << nonscalar_data_ranges.size() <<
'\n';
7461 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
7462 out << std::get<0>(nonscalar_data_range) <<
' '
7463 << std::get<1>(nonscalar_data_range) <<
'\n'
7464 << std::get<2>(nonscalar_data_range) <<
'\n';
7472 template <
int dim,
int spacedim>
7476 const std::vector<std::string> &data_names,
7478 std::tuple<
unsigned int,
7482 &nonscalar_data_ranges,
7484 const std::string &filename,
7488#ifndef DEAL_II_WITH_MPI
7491 (void)nonscalar_data_ranges;
7498 ExcMessage(
"This functionality requires MPI to be enabled."));
7517 std::vector<char> my_buffer;
7519 boost::iostreams::filtering_ostream f;
7525# ifdef DEAL_II_WITH_ZLIB
7526 f.push(boost::iostreams::zlib_compressor(
7527 get_boost_zlib_compression_level(compression)));
7532 "Compression requires deal.II to be configured with ZLIB support."));
7535 boost::iostreams::back_insert_device<std::vector<char>> inserter(
7539 write_deal_II_intermediate<dim, spacedim>(
7540 patches, data_names, nonscalar_data_ranges, flags, f);
7542 const std::uint64_t my_size = my_buffer.size();
7548 const ParallelIntermediateHeader header{
7551 static_cast<std::uint64_t
>(compression),
7561 std::vector<std::uint64_t> chunk_sizes(n_ranks);
7562 int ierr = MPI_Gather(&my_size,
7564 Utilities::MPI::mpi_type_id_for_type<std::uint64_t>,
7565 static_cast<std::uint64_t *
>(chunk_sizes.data()),
7567 Utilities::MPI::mpi_type_id_for_type<std::uint64_t>,
7573 ierr = MPI_Info_create(&info);
7576 ierr = MPI_File_open(
7577 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7579 ierr = MPI_Info_free(&info);
7583 ierr = MPI_File_set_size(fh, 0);
7587 ierr = MPI_Barrier(
comm);
7594 fh, 0, &header,
sizeof(header), MPI_CHAR, MPI_STATUS_IGNORE);
7602 Utilities::MPI::mpi_type_id_for_type<std::uint64_t>,
7609 std::uint64_t prefix_sum = 0;
7610 ierr = MPI_Exscan(&my_size,
7613 Utilities::MPI::mpi_type_id_for_type<std::uint64_t>,
7619 const MPI_Offset offset =
static_cast<MPI_Offset
>(
sizeof(header)) +
7620 n_ranks *
sizeof(std::uint64_t) + prefix_sum;
7623 fh, offset, my_buffer.data(), my_size, MPI_CHAR, MPI_STATUS_IGNORE);
7632 ierr = MPI_File_sync(fh);
7635 ierr = MPI_File_close(&fh);
7642 std::pair<unsigned int, unsigned int>
7647 unsigned int dim, spacedim;
7648 input >> dim >> spacedim;
7650 return std::make_pair(dim, spacedim);
7659template <
int dim,
int spacedim>
7661 : default_subdivisions(1)
7667template <
int dim,
int spacedim>
7672 get_dataset_names(),
7673 get_nonscalar_data_ranges(),
7680template <
int dim,
int spacedim>
7685 get_dataset_names(),
7686 get_nonscalar_data_ranges(),
7693template <
int dim,
int spacedim>
7698 get_dataset_names(),
7699 get_nonscalar_data_ranges(),
7706template <
int dim,
int spacedim>
7711 get_dataset_names(),
7712 get_nonscalar_data_ranges(),
7719template <
int dim,
int spacedim>
7724 get_dataset_names(),
7725 get_nonscalar_data_ranges(),
7732template <
int dim,
int spacedim>
7737 get_dataset_names(),
7738 get_nonscalar_data_ranges(),
7745template <
int dim,
int spacedim>
7750 get_dataset_names(),
7751 get_nonscalar_data_ranges(),
7758template <
int dim,
int spacedim>
7763 get_dataset_names(),
7764 get_nonscalar_data_ranges(),
7769template <
int dim,
int spacedim>
7774 get_dataset_names(),
7775 get_nonscalar_data_ranges(),
7780template <
int dim,
int spacedim>
7785 get_dataset_names(),
7786 get_nonscalar_data_ranges(),
7792template <
int dim,
int spacedim>
7795 const std::string &filename,
7798#ifndef DEAL_II_WITH_MPI
7802 std::ofstream f(filename);
7810 int ierr = MPI_Info_create(&info);
7813 ierr = MPI_File_open(
7814 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7817 ierr = MPI_File_set_size(fh, 0);
7821 ierr = MPI_Barrier(
comm);
7823 ierr = MPI_Info_free(&info);
7827 unsigned int header_size;
7828 std::uint64_t footer_offset;
7833 std::stringstream ss;
7835 header_size = ss.str().size();
7838 fh, 0, ss.str().c_str(), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
7842 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0,
comm);
7846 const auto &patches = get_patches();
7855 std::stringstream ss;
7856 if (my_n_patches > 0 || (global_n_patches == 0 && myrank == 0))
7858 get_dataset_names(),
7859 get_nonscalar_data_ranges(),
7864 const std::uint64_t size_on_proc = ss.str().size();
7865 std::uint64_t prefix_sum = 0;
7866 ierr = MPI_Exscan(&size_on_proc,
7869 Utilities::MPI::mpi_type_id_for_type<std::uint64_t>,
7875 const MPI_Offset offset =
static_cast<MPI_Offset
>(header_size) + prefix_sum;
7885 if (myrank == n_ranks - 1)
7888 footer_offset = size_on_proc + offset;
7890 std::stringstream ss;
7892 const unsigned int footer_size = ss.str().size();
7910 ierr = MPI_File_sync(fh);
7913 ierr = MPI_File_close(&fh);
7920template <
int dim,
int spacedim>
7924 const std::vector<std::string> &piece_names)
const
7928 get_dataset_names(),
7929 get_nonscalar_data_ranges(),
7935template <
int dim,
int spacedim>
7938 const std::string &directory,
7939 const std::string &filename_without_extension,
7940 const unsigned int counter,
7942 const unsigned int n_digits_for_counter,
7943 const unsigned int n_groups)
const
7946 const unsigned int n_ranks =
7948 const unsigned int n_files_written =
7949 (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
7954 const unsigned int n_digits =
7957 const unsigned int color = rank % n_files_written;
7958 const std::string filename =
7959 directory + filename_without_extension +
"_" +
7963 if (n_groups == 0 || n_groups > n_ranks)
7966 std::ofstream output(filename);
7968 this->write_vtu(output);
7970 else if (n_groups == 1)
7973 this->write_vtu_in_parallel(filename, mpi_communicator);
7977#ifdef DEAL_II_WITH_MPI
7980 int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group);
7982 this->write_vtu_in_parallel(filename, comm_group);
7990 const std::string pvtu_filename =
7991 filename_without_extension +
"_" +
7996 std::vector<std::string> filename_vector;
7997 for (
unsigned int i = 0; i < n_files_written; ++i)
7999 const std::string filename =
8000 filename_without_extension +
"_" +
8004 filename_vector.emplace_back(filename);
8007 std::ofstream pvtu_output(directory + pvtu_filename);
8008 this->write_pvtu_record(pvtu_output, filename_vector);
8011 return pvtu_filename;
8016template <
int dim,
int spacedim>
8019 std::ostream &out)
const
8022 get_dataset_names(),
8023 get_nonscalar_data_ranges(),
8024 deal_II_intermediate_flags,
8030template <
int dim,
int spacedim>
8033 const std::string &filename,
8039 get_dataset_names(),
8040 get_nonscalar_data_ranges(),
8041 deal_II_intermediate_flags,
8049template <
int dim,
int spacedim>
8053 const std::string &h5_filename,
8054 const double cur_time,
8057 return create_xdmf_entry(
8058 data_filter, h5_filename, h5_filename, cur_time,
comm);
8063template <
int dim,
int spacedim>
8067 const std::string &h5_mesh_filename,
8068 const std::string &h5_solution_filename,
8069 const double cur_time,
8073 ExcMessage(
"XDMF only supports 2 or 3 space dimensions."));
8075#ifndef DEAL_II_WITH_HDF5
8079 (void)h5_mesh_filename;
8080 (void)h5_solution_filename;
8089 std::uint64_t local_node_cell_count[2], global_node_cell_count[2];
8091 local_node_cell_count[0] = data_filter.
n_nodes();
8092 local_node_cell_count[1] = data_filter.
n_cells();
8096 int ierr = MPI_Allreduce(local_node_cell_count,
8097 global_node_cell_count,
8099 Utilities::MPI::mpi_type_id_for_type<std::uint64_t>,
8111 const bool have_data = (data_filter.
n_nodes() > 0);
8114 const int key = myrank;
8115 const int color = (have_data ? 1 : 0);
8116 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8120 const bool am_i_first_rank_with_data =
8123 ierr = MPI_Comm_free(&split_comm);
8126 const int tag = 47381;
8129 if (am_i_first_rank_with_data)
8131 const auto &patches = get_patches();
8137 for (
const auto &patch : patches)
8143 h5_solution_filename,
8145 global_node_cell_count[0],
8146 global_node_cell_count[1],
8149 patches[0].reference_cell);
8150 const unsigned int n_data_sets = data_filter.
n_data_sets();
8154 for (
unsigned int i = 0; i < n_data_sets; ++i)
8164 ierr = MPI_Send(buffer.data(), buffer.size(), MPI_BYTE, 0, tag,
comm);
8173 if (myrank == 0 && !am_i_first_rank_with_data)
8178 int ierr = MPI_Probe(MPI_ANY_SOURCE, tag,
comm, &status);
8182 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
8185 std::vector<char> buffer(len);
8186 ierr = MPI_Recv(buffer.data(),
8195 return Utilities::unpack<XDMFEntry>(buffer,
false);
8203template <
int dim,
int spacedim>
8206 const std::vector<XDMFEntry> &entries,
8207 const std::string &filename,
8210#ifdef DEAL_II_WITH_MPI
8214 const int myrank = 0;
8220 std::ofstream xdmf_file(filename);
8222 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
8223 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
8224 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
8225 xdmf_file <<
" <Domain>\n";
8227 <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
8229 for (
const auto &entry : entries)
8231 xdmf_file << entry.get_xdmf_content(3);
8234 xdmf_file <<
" </Grid>\n";
8235 xdmf_file <<
" </Domain>\n";
8236 xdmf_file <<
"</Xdmf>\n";
8248template <
int dim,
int spacedim>
8254 get_dataset_names(),
8255 get_nonscalar_data_ranges(),
8262#if defined(DEAL_II_WITH_HDF5) || defined(DEAL_II_WITH_NETCDF)
8266 struct DistributedMeshSizes
8268 uint64_t n_nodes_local;
8269 uint64_t n_cells_local;
8270 uint64_t n_nodes_global;
8271 uint64_t n_cells_global;
8272 uint64_t offset_nodes;
8273 uint64_t offset_cells;
8281 DistributedMeshSizes
8282 compute_global_mesh_size(
const uint64_t n_nodes_local,
8283 const uint64_t n_cells_local,
8286 const uint64_t n_local[2] = {n_nodes_local, n_cells_local};
8287 uint64_t n_global[2];
8288 uint64_t offsets[2] = {0, 0};
8290# ifdef DEAL_II_WITH_MPI
8292 MPI_Allreduce(n_local,
8308 n_global[0] = n_local[0];
8309 n_global[1] = n_local[1];
8315 n_local[0], n_local[1], n_global[0], n_global[1], offsets[0], offsets[1]};
8320#ifdef DEAL_II_WITH_HDF5
8324 template <
int dim,
int spacedim>
8329 const bool write_mesh_file,
8330 const std::string &mesh_filename,
8331 const std::string &solution_filename,
8334 hid_t h5_mesh_file_id = -1, h5_solution_file_id, file_plist_id, plist_id;
8335 hid_t node_dataspace, node_dataset, node_file_dataspace,
8336 node_memory_dataspace, node_dataset_id;
8337 hid_t cell_dataspace, cell_dataset, cell_file_dataspace,
8338 cell_memory_dataspace;
8339 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace,
8340 pt_data_memory_dataspace;
8342 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
8343 std::vector<double> node_data_vec;
8344 std::vector<unsigned int> cell_data_vec;
8347 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
8350# ifdef DEAL_II_WITH_MPI
8351# ifdef H5_HAVE_PARALLEL
8353 status = H5Pset_fapl_mpio(file_plist_id,
comm, MPI_INFO_NULL);
8358# ifndef DEAL_II_WITH_ZLIB
8364 const DistributedMeshSizes mesh_sizes =
8365 compute_global_mesh_size(data_filter.
n_nodes(),
8370 plist_id = H5Pcreate(H5P_DATASET_XFER);
8372# ifdef DEAL_II_WITH_MPI
8373# ifdef H5_HAVE_PARALLEL
8374 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
8379 if (write_mesh_file)
8382 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(),
8390 node_ds_dim[0] = mesh_sizes.n_nodes_global;
8391 node_ds_dim[1] = (spacedim < 2) ? 2 : spacedim;
8392 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8395 cell_ds_dim[0] = mesh_sizes.n_cells_global;
8396 cell_ds_dim[1] = patches[0].reference_cell.n_vertices();
8397 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
8401# if H5Gcreate_vers == 1
8402 node_dataset = H5Dcreate(h5_mesh_file_id,
8408 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8409# ifdef DEAL_II_WITH_ZLIB
8410 H5Pset_deflate(node_dataset_id,
8412 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8414 node_dataset = H5Dcreate(h5_mesh_file_id,
8421 H5Pclose(node_dataset_id);
8424# if H5Gcreate_vers == 1
8425 cell_dataset = H5Dcreate(h5_mesh_file_id,
8431 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8432# ifdef DEAL_II_WITH_ZLIB
8433 H5Pset_deflate(node_dataset_id,
8435 H5Pset_chunk(node_dataset_id, 2, cell_ds_dim);
8437 cell_dataset = H5Dcreate(h5_mesh_file_id,
8444 H5Pclose(node_dataset_id);
8449 status = H5Sclose(node_dataspace);
8451 status = H5Sclose(cell_dataspace);
8456 count[0] = mesh_sizes.n_nodes_local;
8457 count[1] = (spacedim < 2) ? 2 : spacedim;
8459 offset[0] = mesh_sizes.offset_nodes;
8462 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8466 node_file_dataspace = H5Dget_space(node_dataset);
8468 status = H5Sselect_hyperslab(
8469 node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8473 count[0] = mesh_sizes.n_cells_local;
8474 count[1] = patches[0].reference_cell.n_vertices();
8475 offset[0] = mesh_sizes.offset_cells;
8477 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8480 cell_file_dataspace = H5Dget_space(cell_dataset);
8482 status = H5Sselect_hyperslab(
8483 cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8488 status = H5Dwrite(node_dataset,
8490 node_memory_dataspace,
8491 node_file_dataspace,
8493 node_data_vec.data());
8495 node_data_vec.clear();
8498 data_filter.
fill_cell_data(mesh_sizes.offset_nodes, cell_data_vec);
8499 status = H5Dwrite(cell_dataset,
8501 cell_memory_dataspace,
8502 cell_file_dataspace,
8504 cell_data_vec.data());
8506 cell_data_vec.clear();
8509 status = H5Sclose(node_file_dataspace);
8511 status = H5Sclose(cell_file_dataspace);
8515 status = H5Sclose(node_memory_dataspace);
8517 status = H5Sclose(cell_memory_dataspace);
8521 status = H5Dclose(node_dataset);
8523 status = H5Dclose(cell_dataset);
8527 if (mesh_filename != solution_filename)
8529 status = H5Fclose(h5_mesh_file_id);
8535 if (mesh_filename == solution_filename && write_mesh_file)
8537 h5_solution_file_id = h5_mesh_file_id;
8542 h5_solution_file_id = H5Fcreate(solution_filename.c_str(),
8552 std::string vector_name;
8561 node_ds_dim[0] = mesh_sizes.n_nodes_global;
8562 node_ds_dim[1] = pt_data_vector_dim;
8563 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8566# if H5Gcreate_vers == 1
8567 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8568 vector_name.c_str(),
8573 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8574# ifdef DEAL_II_WITH_ZLIB
8575 H5Pset_deflate(node_dataset_id,
8577 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8579 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8580 vector_name.c_str(),
8586 H5Pclose(node_dataset_id);
8591 count[0] = mesh_sizes.n_nodes_local;
8592 count[1] = pt_data_vector_dim;
8593 offset[0] = mesh_sizes.offset_nodes;
8595 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8599 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
8601 status = H5Sselect_hyperslab(pt_data_file_dataspace,
8610 status = H5Dwrite(pt_data_dataset,
8612 pt_data_memory_dataspace,
8613 pt_data_file_dataspace,
8619 status = H5Sclose(pt_data_dataspace);
8621 status = H5Sclose(pt_data_memory_dataspace);
8623 status = H5Sclose(pt_data_file_dataspace);
8626 status = H5Dclose(pt_data_dataset);
8631 status = H5Pclose(file_plist_id);
8635 status = H5Pclose(plist_id);
8639 status = H5Fclose(h5_solution_file_id);
8647template <
int dim,
int spacedim>
8651 const std::vector<std::string> &data_names,
8653 std::tuple<
unsigned int,
8657 &nonscalar_data_ranges,
8660 const unsigned int n_data_sets = data_names.size();
8662#ifndef DEAL_II_WITH_MPI
8669 Assert(patches.size() > 0, ExcNoPatches());
8671 if (patches.empty())
8675 unsigned int n_nodes;
8676 std::tie(n_nodes, std::ignore) = count_nodes_and_cells(patches);
8691 [&patches]() {
return create_global_data_table(patches); });
8699 std::move(*create_global_data_table_task.
return_value());
8703 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
8704 std::string vector_name;
8705 for (n_th_vector = 0, data_set = 0; data_set < n_data_sets;)
8708 while (n_th_vector < nonscalar_data_ranges.size() &&
8709 std::get<0>(nonscalar_data_ranges[n_th_vector]) < data_set)
8713 if (n_th_vector < nonscalar_data_ranges.size() &&
8714 std::get<0>(nonscalar_data_ranges[n_th_vector]) == data_set)
8717 pt_data_vector_dim = std::get<1>(nonscalar_data_ranges[n_th_vector]) -
8718 std::get<0>(nonscalar_data_ranges[n_th_vector]) +
8723 std::get<1>(nonscalar_data_ranges[n_th_vector]) >=
8724 std::get<0>(nonscalar_data_ranges[n_th_vector]),
8725 ExcLowerRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8726 std::get<0>(nonscalar_data_ranges[n_th_vector])));
8728 std::get<1>(nonscalar_data_ranges[n_th_vector]) < n_data_sets,
8729 ExcIndexRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8735 if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
8737 vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
8742 for (i = std::get<0>(nonscalar_data_ranges[n_th_vector]);
8743 i < std::get<1>(nonscalar_data_ranges[n_th_vector]);
8745 vector_name += data_names[i] +
"__";
8747 data_names[std::get<1>(nonscalar_data_ranges[n_th_vector])];
8753 pt_data_vector_dim = 1;
8754 vector_name = data_names[data_set];
8764 data_set += pt_data_vector_dim;
8770template <
int dim,
int spacedim>
8774 const std::string &filename,
8778 get_patches(), data_filter, hdf5_flags, filename,
comm);
8783template <
int dim,
int spacedim>
8787 const bool write_mesh_file,
8788 const std::string &mesh_filename,
8789 const std::string &solution_filename,
8803template <
int dim,
int spacedim>
8809 const std::string &filename,
8813 patches, data_filter, flags,
true, filename, filename,
comm);
8818template <
int dim,
int spacedim>
8824 const bool write_mesh_file,
8825 const std::string &mesh_filename,
8826 const std::string &solution_filename,
8832 "DataOutBase was asked to write HDF5 output for a space dimension of 1. "
8833 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
8835#ifndef DEAL_II_WITH_HDF5
8841 (void)write_mesh_file;
8842 (void)mesh_filename;
8843 (void)solution_filename;
8851# ifndef H5_HAVE_PARALLEL
8855 "Serial HDF5 output on multiple processes is not yet supported."));
8865 Assert((patches.size() > 0) || (n_ranks > 1), ExcNoPatches());
8872 const bool have_patches = (patches.size() > 0);
8876 const int color = (have_patches ? 1 : 0);
8877 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8883 do_write_hdf5<dim, spacedim>(patches,
8892 const int ierr = MPI_Comm_free(&split_comm);
8900#ifdef DEAL_II_WITH_NETCDF
8913 create(
const std::string &filename,
8914 const int open_mode,
8918 auto ncerr = nc_create_par(
8919 filename.c_str(), open_mode,
comm, MPI_INFO_NULL, &ncfile.ncid);
8930 open(
const std::string &filename,
const int open_mode,
const MPI_Comm comm)
8933 auto ncerr = nc_open_par(
8934 filename.c_str(), open_mode,
comm, MPI_INFO_NULL, &ncfile.ncid);
8944 operator int()
const
8958 int ncerr = nc_close(ncid);
8960 ExcIO(
"Unexpected error when closing a NetCDF file."));
8983 nc_put_att_var(
const int ncid,
8989 [&](
const auto &v) {
8990 using T = std::remove_cv_t<std::remove_reference_t<
decltype(v)>>;
8991 if constexpr (std::is_same_v<T, std::string>)
8993 return nc_put_att_text(ncid, varid, name, v.size(), v.c_str());
8995 else if constexpr (std::is_same_v<T, double>)
8997 return nc_put_att_double(ncid, varid, name, NC_DOUBLE, 1, &v);
8999 else if constexpr (std::is_same_v<T, int>)
9001 return nc_put_att_int(ncid, varid, name, NC_INT, 1, &v);
9016 template <
class AttrMap = std::initializer_list<
9017 std::pair<std::string, DataOutBase::CFFlags::AttributeValue>>>
9019 write_cf_attributes(
int ncid,
int varid,
const AttrMap &attrs)
9021 for (
const auto &[att_name, att_value] : attrs)
9023 ncerr = nc_put_att_var(ncid, varid, att_name.c_str(), att_value);
9034 write_cf_user_defined_attributes(
int ncid,
9036 const std::string &var_name,
9039 if (
auto it_atts = flags.
attributes.find(var_name);
9042 write_cf_attributes(ncid, varid, it_atts->second);
9051 template <
int spacedim>
9054 std::vector<double> &x,
9055 std::vector<double> &y)
9057 std::vector<double> coords;
9059 x.resize(data_filter.
n_nodes());
9060 y.resize(data_filter.
n_nodes());
9061 for (
unsigned int i = 0; i < data_filter.
n_nodes(); ++i)
9063 x[i] = coords[i * spacedim];
9064 y[i] = coords[i * spacedim + 1];
9073 template <
int dim,
int spacedim>
9078 const std::string &filename,
9079 const DistributedMeshSizes &mesh_sizes,
9085 NcFile::create(filename, NC_WRITE | NC_CLOBBER | NC_NETCDF4,
comm);
9088 write_cf_attributes(
9092 {
"Conventions",
"CF-1.12"},
9094 "Created by the deal.II finite element library (https://dealii.org)."},
9096 write_cf_user_defined_attributes(ncid, flags,
"global", NC_GLOBAL);
9101 Assert(patches.size() > 0,
9105 Assert(std::all_of(patches.begin(),
9107 [ref = patches[0].reference_cell](
const auto &patch) {
9108 return patch.reference_cell == ref;
9111 "Mixed meshes are currently not supported in CF output."));
9115 int dim_node, dim_cell, dim_cell_node;
9116 ncerr = nc_def_dim(ncid,
"node", mesh_sizes.n_nodes_global, &dim_node);
9118 ncerr = nc_def_dim(ncid,
"face", mesh_sizes.n_cells_global, &dim_cell);
9120 int n_nodes_per_cell = patches[0].reference_cell.n_vertices();
9121 ncerr = nc_def_dim(ncid,
"face_node", n_nodes_per_cell, &dim_cell_node);
9127 int var_mesh, var_cell, var_x, var_y;
9128 ncerr = nc_def_var(ncid,
"mesh", NC_INT, 0,
nullptr, &var_mesh);
9130 write_cf_attributes(ncid,
9133 {
"cf_role",
"mesh_topology"},
9134 {
"long_name",
"Topology of a 2-d unstructured mesh"},
9135 {
"topology_dimension", 2},
9136 {
"node_coordinates",
"mesh_node_x mesh_node_y"},
9137 {
"face_node_connectivity",
"mesh_face_nodes"},
9138 {
"face_dimension",
"face"},
9142 int dummy_mesh_value = 0;
9143 ncerr = nc_put_var_int(ncid, var_mesh, &dummy_mesh_value);
9147 const int dims_cells[2] = {dim_cell, dim_cell_node};
9149 nc_def_var(ncid,
"mesh_face_nodes", NC_INT, 2, dims_cells, &var_cell);
9151 write_cf_attributes(ncid,
9154 {
"cf_role",
"face_node_connectivity"},
9155 {
"long_name",
"Corner nodes that make up each face."},
9163 ncerr = nc_def_var(ncid,
"mesh_node_x", NC_DOUBLE, 1, &dim_node, &var_x);
9165 write_cf_attributes(ncid, var_x, {{
"axis",
"X"}});
9166 write_cf_user_defined_attributes(ncid, flags,
"x", var_x);
9167 ncerr = nc_def_var(ncid,
"mesh_node_y", NC_DOUBLE, 1, &dim_node, &var_y);
9169 write_cf_attributes(ncid, var_y, {{
"axis",
"Y"}});
9170 write_cf_user_defined_attributes(ncid, flags,
"y", var_y);
9173 int dim_time, var_time;
9174 if (flags.
time > -std::numeric_limits<double>::infinity())
9176 ncerr = nc_def_dim(ncid,
"time", NC_UNLIMITED, &dim_time);
9178 ncerr = nc_def_var(ncid,
"time", NC_DOUBLE, 1, &dim_time, &var_time);
9180 write_cf_attributes(ncid,
9183 {
"standard_name",
"time"},
9185 {
"long_name",
"Time dimension"},
9187 write_cf_user_defined_attributes(ncid, flags,
"time", var_time);
9191 std::vector<double> x, y;
9192 get_node_coordinates<spacedim>(data_filter, x, y);
9193 const size_t coord_write_start[1] = {(size_t)mesh_sizes.offset_nodes};
9194 const size_t coord_write_count[1] = {(size_t)data_filter.
n_nodes()};
9195 ncerr = nc_put_vara_double(
9196 ncid, var_x, coord_write_start, coord_write_count, x.data());
9198 ncerr = nc_put_vara_double(
9199 ncid, var_y, coord_write_start, coord_write_count, y.data());
9203 std::vector<unsigned int> ucells;
9205 const size_t cell_write_start[2] = {(size_t)mesh_sizes.offset_cells,
9207 const size_t cell_write_count[2] = {(size_t)data_filter.
n_cells(),
9208 (size_t)n_nodes_per_cell};
9209 ncerr = nc_put_vara_uint(
9210 ncid, var_cell, cell_write_start, cell_write_count, ucells.data());
9220 write_cf_time_point(
int ncid,
int dim_time,
int var_time,
double time)
9228 ncerr = nc_var_par_access(ncid, var_time, NC_COLLECTIVE);
9232 ncerr = nc_inq_dimlen(ncid, dim_time, &n_time);
9234 auto times = std::vector<double>(n_time);
9235 ncerr = nc_get_var_double(ncid, var_time, times.data());
9237 const auto it_lb = std::lower_bound(times.begin(), times.end(), time);
9238 index_t = std::distance(times.begin(), it_lb);
9239 const size_t count_t = 1;
9240 ncerr = nc_put_vara_double(ncid, var_time, &index_t, &count_t, &time);
9243 ncerr = nc_var_par_access(ncid, var_time, NC_INDEPENDENT);
9257 const std::string &filename,
9258 const DistributedMeshSizes &mesh_sizes,
9264 const auto ncid = NcFile::open(filename, NC_WRITE | NC_NETCDF4,
comm);
9268 ncerr = nc_inq_dimid(ncid,
"node", &dim_node);
9272 int dim_time = -1, var_time = -1;
9274 const bool has_time = flags.
time > -std::numeric_limits<double>::infinity();
9277 int inq_dim_time = nc_inq_dimid(ncid,
"time", &dim_time);
9278 int inq_var_time = nc_inq_varid(ncid,
"time", &var_time);
9281 const bool has_time_dimension = inq_dim_time != NC_EBADDIM;
9282 const bool has_time_variable = inq_var_time != NC_ENOTVAR;
9283 AssertThrow(has_time_dimension && has_time_variable,
9285 "You are trying to add a time point to an existing file "
9286 "that does not have a time dimension or variable. "
9287 "Check the options in DataOutBase::cf_flags."));
9292 index_t = write_cf_time_point(ncid, dim_time, var_time, flags.
time);
9296 for (
auto dataset_index = 0u; dataset_index < data_filter.
n_data_sets();
9301 "Can only write scalar data in CF files."));
9308 const int inq_var = nc_inq_varid(ncid, key.c_str(), &varid);
9309 if (inq_var == NC_ENOTVAR)
9312 const int var_dims[2] = {dim_time, dim_node};
9313 ncerr = nc_def_var(ncid,
9317 &var_dims[has_time ? 0 : 1],
9320 write_cf_attributes(
9325 {
"location",
"node"},
9327 std::numeric_limits<double>::quiet_NaN()},
9330 write_cf_user_defined_attributes(ncid, flags, key, varid);
9339 ncerr = nc_var_par_access(ncid, varid, NC_COLLECTIVE);
9341 const size_t var_write_start[2] = {index_t,
9342 (size_t)mesh_sizes.offset_nodes};
9343 const size_t var_write_count[2] = {1, (size_t)data_filter.
n_nodes()};
9344 ncerr = nc_put_vara_double(
9347 &var_write_start[has_time ? 0 : 1],
9348 &var_write_count[has_time ? 0 : 1],
9351 ncerr = nc_var_par_access(ncid, varid, NC_INDEPENDENT);
9361template <
int dim,
int spacedim>
9365 const std::string &filename,
9369 get_patches(), data_filter, cf_flags, filename,
comm);
9374template <
int dim,
int spacedim>
9379 const std::string &filename,
9386 "DataOutBase can only write CF output in 2 dimensions."));
9389 "Mesh must have codimension 0 for writing CF output."));
9391#ifndef DEAL_II_WITH_NETCDF
9404 int ierr = MPI_Barrier(
comm);
9416 Assert((patches.size() > 0) || (n_ranks > 1), ExcNoPatches());
9423 const bool have_patches = (patches.size() > 0);
9427 const int color = (have_patches ? 1 : 0);
9428 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
9431 ScopeExit cleanup_on_exit{[&split_comm] {
9432 int ierr = MPI_Comm_free(&split_comm);
9438 const DistributedMeshSizes mesh_sizes =
9439 compute_global_mesh_size(data_filter.
n_nodes(),
9447 mesh_sizes.n_nodes_global < uint64_t(std::numeric_limits<int>::max()),
9448 ExcMessage(
"The mesh has too many vertices to store in CF format."));
9454 patches, data_filter, flags, filename, mesh_sizes, split_comm);
9462 AssertThrow(std::filesystem::is_regular_file(filename),
9463 ExcIO(
"You are trying to write data to an existing file "
9464 "but no file of the given name exists. "
9465 "Create the file with a mesh by setting "
9466 "CFFlags::keep_existing_file = false."));
9471 write_cf_data(data_filter, flags, filename, mesh_sizes, split_comm);
9478template <
int dim,
int spacedim>
9486 output_format = default_fmt;
9488 switch (output_format)
9534 write_deal_II_intermediate(out);
9544template <
int dim,
int spacedim>
9553template <
int dim,
int spacedim>
9554template <
typename FlagType>
9558 if constexpr (std::is_same_v<FlagType, DataOutBase::DXFlags>)
9560 else if constexpr (std::is_same_v<FlagType, DataOutBase::UcdFlags>)
9562 else if constexpr (std::is_same_v<FlagType, DataOutBase::PovrayFlags>)
9563 povray_flags = flags;
9564 else if constexpr (std::is_same_v<FlagType, DataOutBase::EpsFlags>)
9566 else if constexpr (std::is_same_v<FlagType, DataOutBase::GmvFlags>)
9568 else if constexpr (std::is_same_v<FlagType, DataOutBase::Hdf5Flags>)
9570 else if constexpr (std::is_same_v<FlagType, DataOutBase::CFFlags>)
9572 else if constexpr (std::is_same_v<FlagType, DataOutBase::TecplotFlags>)
9573 tecplot_flags = flags;
9574 else if constexpr (std::is_same_v<FlagType, DataOutBase::VtkFlags>)
9576 else if constexpr (std::is_same_v<FlagType, DataOutBase::SvgFlags>)
9578 else if constexpr (std::is_same_v<FlagType, DataOutBase::GnuplotFlags>)
9579 gnuplot_flags = flags;
9580 else if constexpr (std::is_same_v<FlagType,
9582 deal_II_intermediate_flags = flags;
9589template <
int dim,
int spacedim>
9602template <
int dim,
int spacedim>
9609 "A name for the output format to be used");
9613 "Number of subdivisions of each mesh cell");
9659template <
int dim,
int spacedim>
9663 const std::string &output_name = prm.
get(
"Output format");
9665 default_subdivisions = prm.
get_integer(
"Subdivisions");
9668 dx_flags.parse_parameters(prm);
9672 ucd_flags.parse_parameters(prm);
9676 gnuplot_flags.parse_parameters(prm);
9680 povray_flags.parse_parameters(prm);
9684 eps_flags.parse_parameters(prm);
9688 gmv_flags.parse_parameters(prm);
9692 hdf5_flags.parse_parameters(prm);
9696 tecplot_flags.parse_parameters(prm);
9700 vtk_flags.parse_parameters(prm);
9704 deal_II_intermediate_flags.parse_parameters(prm);
9710template <
int dim,
int spacedim>
9714 return (
sizeof(default_fmt) +
9730template <
int dim,
int spacedim>
9732 std::tuple<
unsigned int,
9739 std::tuple<
unsigned int,
9746template <
int dim,
int spacedim>
9755 std::set<std::string> all_names;
9758 std::tuple<
unsigned int,
9762 ranges = this->get_nonscalar_data_ranges();
9763 const std::vector<std::string> data_names = this->get_dataset_names();
9764 const unsigned int n_data_sets = data_names.size();
9765 std::vector<bool> data_set_written(n_data_sets,
false);
9767 for (
const auto &range : ranges)
9769 const std::string &name = std::get<2>(range);
9772 Assert(all_names.find(name) == all_names.end(),
9774 "Error: names of fields in DataOut need to be unique, "
9776 name +
"' is used more than once."));
9777 all_names.insert(name);
9778 for (
unsigned int i = std::get<0>(range);
9779 i <= std::get<1>(range);
9781 data_set_written[i] =
true;
9785 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
9786 if (data_set_written[data_set] ==
false)
9788 const std::string &name = data_names[data_set];
9789 Assert(all_names.find(name) == all_names.end(),
9791 "Error: names of fields in DataOut need to be unique, "
9793 name +
"' is used more than once."));
9794 all_names.insert(name);
9804template <
int dim,
int spacedim>
9812 std::vector<typename ::DataOutBase::Patch<dim, spacedim>> tmp;
9816 std::vector<std::string> tmp;
9817 tmp.swap(dataset_names);
9821 std::tuple<
unsigned int,
9826 tmp.swap(nonscalar_data_ranges);
9833 std::pair<unsigned int, unsigned int> dimension_info =
9836 (dimension_info.second == spacedim),
9837 ExcIncompatibleDimensions(
9838 dimension_info.first, dim, dimension_info.second, spacedim));
9847 getline(in, header);
9849 std::ostringstream s;
9850 s <<
"[deal.II intermediate format graphics data]";
9852 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9856 getline(in, header);
9858 std::ostringstream s;
9862 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9866 getline(in, header);
9868 std::ostringstream s;
9872 Assert(header == s.str(),
9874 "Invalid or incompatible file format. Intermediate format "
9875 "files can only be read by the same deal.II version as they "
9876 "are written by."));
9880 unsigned int n_datasets;
9882 dataset_names.resize(n_datasets);
9883 for (
unsigned int i = 0; i < n_datasets; ++i)
9884 in >> dataset_names[i];
9886 unsigned int n_patches;
9888 patches.resize(n_patches);
9889 for (
unsigned int i = 0; i < n_patches; ++i)
9892 unsigned int n_nonscalar_data_ranges;
9893 in >> n_nonscalar_data_ranges;
9894 nonscalar_data_ranges.resize(n_nonscalar_data_ranges);
9895 for (
unsigned int i = 0; i < n_nonscalar_data_ranges; ++i)
9897 in >> std::get<0>(nonscalar_data_ranges[i]) >>
9898 std::get<1>(nonscalar_data_ranges[i]);
9907 std::get<2>(nonscalar_data_ranges[i]) = name;
9915template <
int dim,
int spacedim>
9921 ParallelIntermediateHeader header;
9922 in.read(
reinterpret_cast<char *
>(&header),
sizeof(header));
9924 header.magic == 0x00dea111,
9926 "Invalid header of parallel deal.II intermediate format encountered."));
9930 "Incorrect header version of parallel deal.II intermediate format."));
9932 std::vector<std::uint64_t> chunk_sizes(header.n_ranks);
9933 in.read(
reinterpret_cast<char *
>(chunk_sizes.data()),
9934 header.n_ranks *
sizeof(std::uint64_t));
9936 for (
unsigned int n = 0; n < header.n_ranks; ++n)
9940 std::vector<char> temp_buffer(chunk_sizes[n]);
9941 in.read(temp_buffer.data(), chunk_sizes[n]);
9944 header.compression) !=
9948 boost::iostreams::filtering_istreambuf f;
9951#ifdef DEAL_II_WITH_ZLIB
9952 f.push(boost::iostreams::zlib_decompressor());
9957 "Decompression requires deal.II to be configured with ZLIB support."));
9960 boost::iostreams::basic_array_source<char> source(temp_buffer.data(),
9961 temp_buffer.size());
9964 std::stringstream datastream;
9965 boost::iostreams::copy(f, datastream);
9975 temp_reader.
read(datastream);
9983template <
int dim,
int spacedim>
9987 using Patch = typename ::DataOutBase::Patch<dim, spacedim>;
9990 const std::vector<Patch> &source_patches = source.
get_patches();
9995 ExcIncompatibleDatasetNames());
10000 ExcMessage(
"Both sources need to declare the same components "
10002 for (
unsigned int i = 0; i < get_nonscalar_data_ranges().size(); ++i)
10004 Assert(std::get<0>(get_nonscalar_data_ranges()[i]) ==
10006 ExcMessage(
"Both sources need to declare the same components "
10008 Assert(std::get<1>(get_nonscalar_data_ranges()[i]) ==
10010 ExcMessage(
"Both sources need to declare the same components "
10012 Assert(std::get<2>(get_nonscalar_data_ranges()[i]) ==
10014 ExcMessage(
"Both sources need to declare the same components "
10019 Assert(patches[0].n_subdivisions == source_patches[0].n_subdivisions,
10020 ExcIncompatiblePatchLists());
10021 Assert(patches[0].
data.n_rows() == source_patches[0].data.n_rows(),
10022 ExcIncompatiblePatchLists());
10023 Assert(patches[0].
data.n_cols() == source_patches[0].data.n_cols(),
10024 ExcIncompatiblePatchLists());
10028 const unsigned int old_n_patches = patches.size();
10029 patches.insert(patches.end(), source_patches.begin(), source_patches.end());
10032 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
10033 patches[i].patch_index += old_n_patches;
10036 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
10038 if (patches[i].neighbors[n] !=
10040 patches[i].neighbors[n] += old_n_patches;
10045template <
int dim,
int spacedim>
10046const std::vector<typename ::DataOutBase::Patch<dim, spacedim>> &
10054template <
int dim,
int spacedim>
10055std::vector<std::string>
10058 return dataset_names;
10063template <
int dim,
int spacedim>
10065 std::tuple<
unsigned int,
10071 return nonscalar_data_ranges;
10080 , h5_sol_filename(
"")
10081 , h5_mesh_filename(
"")
10083 , num_nodes(
numbers::invalid_unsigned_int)
10084 , num_cells(
numbers::invalid_unsigned_int)
10085 , dimension(
numbers::invalid_unsigned_int)
10086 , space_dimension(
numbers::invalid_unsigned_int)
10088 , n_vertices_per_cell(
numbers::invalid_unsigned_int)
10096 const std::uint64_t nodes,
10097 const std::uint64_t cells,
10098 const unsigned int dim_,
10100 :
XDMFEntry(filename, filename, time, nodes, cells, dim_, dim, cell_type)
10109 const std::string &solution_filename,
10111 const std::uint64_t nodes,
10112 const std::uint64_t cells,
10113 const unsigned int dim_,
10139 if (cell_type == ReferenceCells::Invalid<dim>)
10140 return ReferenceCells::get_hypercube<dim>();
10150 const std::string &solution_filename,
10152 const std::uint64_t nodes,
10153 const std::uint64_t cells,
10154 const unsigned int dim_,
10155 const unsigned int spacedim,
10158 , h5_sol_filename(solution_filename)
10159 , h5_mesh_filename(mesh_filename)
10164 , space_dimension(spacedim)
10169 cell_type_hex_if_invalid<dim>(cell_type_);
10172 if constexpr (dim == 0)
10176 else if constexpr (dim == 1)
10180 else if constexpr (dim == 2)
10195 else if constexpr (dim == 3)
10218 const unsigned int dimension)
10231 indent(
const unsigned int indent_level)
10233 std::string res =
"";
10234 for (
unsigned int i = 0; i < indent_level; ++i)
10248 std::stringstream ss;
10250 ss << indent(indent_level + 0)
10251 <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
10252 ss << indent(indent_level + 1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
10253 ss << indent(indent_level + 1) <<
"<Geometry GeometryType=\""
10255 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
10257 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
10259 ss << indent(indent_level + 2) <<
"</DataItem>\n";
10260 ss << indent(indent_level + 1) <<
"</Geometry>\n";
10265 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\""
10268 ss <<
"\" NodesPerElement=\"1\">\n";
10270 ss <<
"\" NodesPerElement=\"2\">\n";
10275 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_cells
10277 <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
10280 ss << indent(indent_level + 2) <<
"</DataItem>\n";
10281 ss << indent(indent_level + 1) <<
"</Topology>\n";
10287 ss << indent(indent_level + 1)
10288 <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\""
10290 ss << indent(indent_level + 1) <<
"</Topology>\n";
10295 ss << indent(indent_level + 1) <<
"<Attribute Name=\""
10296 << attribute_dim.first <<
"\" AttributeType=\""
10297 << (attribute_dim.second > 1 ?
"Vector" :
"Scalar")
10298 <<
"\" Center=\"Node\">\n";
10300 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
10301 <<
" " << (attribute_dim.second > 1 ? 3 : 1)
10302 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
10304 << attribute_dim.first <<
'\n';
10305 ss << indent(indent_level + 2) <<
"</DataItem>\n";
10306 ss << indent(indent_level + 1) <<
"</Attribute>\n";
10309 ss << indent(indent_level + 0) <<
"</Grid>\n";
10318 template <
int dim,
int spacedim>
10323 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]"
10330 for (
const unsigned int i : patch.
reference_cell.vertex_indices())
10334 for (
const unsigned int i : patch.
reference_cell.face_indices())
10342 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
10343 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
10344 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
10345 out << patch.
data[i][j] <<
' ';
10354 template <
int dim,
int spacedim>
10363 std::string header;
10366 getline(in, header);
10367 while ((header.size() != 0) && (header.back() ==
' '))
10368 header.erase(header.size() - 1);
10370 while ((header.empty()) && in);
10372 std::ostringstream s;
10373 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
10375 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
10379 if constexpr (dim > 0)
10383 for (
const unsigned int i : patch.
reference_cell.vertex_indices())
10386 for (
const unsigned int i : patch.
reference_cell.face_indices())
10393 unsigned int n_subdivisions;
10394 in >> n_subdivisions;
10395 if constexpr (dim > 1)
10400 unsigned int n_rows, n_cols;
10401 in >> n_rows >> n_cols;
10402 patch.
data.reinit(n_rows, n_cols);
10403 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
10404 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
10405 in >> patch.
data[i][j];
10416#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
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)
void write_cell_single(const unsigned int index, const unsigned int start, const unsigned int n_points, const ReferenceCell< dim > &reference_cell)
unsigned int n_cells() const
DataOutBase::DataOutFilterFlags flags
Map3DPoint existing_points
unsigned int n_data_sets() const
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, const MPI_Comm comm) const
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const
void parse_parameters(ParameterHandler &prm)
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_cf_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm comm) const
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static void declare_parameters(ParameterHandler &prm)
void write_ucd(std::ostream &out) const
void write_povray(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, const MPI_Comm comm) const
std::size_t memory_consumption() const
void set_default_format(const DataOutBase::OutputFormat default_format)
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void write_gnuplot(std::ostream &out) const
void write_vtu(std::ostream &out) const
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm comm) const
void write_tecplot(std::ostream &out) const
void write_deal_II_intermediate_in_parallel(const std::string &filename, const MPI_Comm comm, const DataOutBase::CompressionLevel compression) const
void write_svg(std::ostream &out) const
void write_vtu_in_parallel(const std::string &filename, const MPI_Comm comm) const
void validate_dataset_names() const
void set_flags(const FlagType &flags)
void write_vtk(std::ostream &out) const
void write_gmv(std::ostream &out) const
std::string write_vtu_with_pvtu_record(const std::string &directory, const std::string &filename_without_extension, const unsigned int counter, const MPI_Comm mpi_communicator, const unsigned int n_digits_for_counter=numbers::invalid_unsigned_int, const unsigned int n_groups=0) const
void write_eps(std::ostream &out) const
void write_dx(std::ostream &out) const
void write_deal_II_intermediate(std::ostream &out) const
void merge(const DataOutReader< dim, spacedim > &other)
void read_whole_parallel_file(std::istream &in)
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const override
void read(std::istream &in)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
virtual std::vector< std::string > get_dataset_names() const override
void enter_subsection(const std::string &subsection, const bool create_path_if_needed=true)
long int get_integer(const std::string &entry_string) const
bool get_bool(const std::string &entry_name) const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
std::string get(const std::string &entry_string) const
double get_double(const std::string &entry_name) const
constexpr unsigned int n_vertices() 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()
unsigned int n_vertices_per_cell
std::string h5_sol_filename
std::string cell_type_name
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_PACKAGE_NAME
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
#define AssertThrowNC(code)
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcFileNotOpen(std::string arg1)
static ::ExceptionBase & ExcNotEnoughSpaceDimensionLabels()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNoPatches()
static ::ExceptionBase & ExcNeedsNetCDF()
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
#define AssertThrowMPI(error_code)
#define AssertNothrow(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNeedsHDF5()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Task< RT > new_task(const std::function< RT()> &function)
const unsigned int my_rank
std::vector< index_type > data
DataComponentInterpretation
@ component_is_part_of_tensor
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const EpsFlags &flags, std::ostream &out)
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
void write_nodes(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_deal_II_intermediate_in_parallel(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, const std::string &filename, const MPI_Comm comm, const CompressionLevel compression)
void write_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const UcdFlags &flags, std::ostream &out)
void write_cf_parallel(const std::vector< Patch< dim, spacedim > > &patches, const DataOutFilter &data_filter, const DataOutBase::CFFlags &flags, const std::string &filename, const MPI_Comm comm)
void write_dx(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const DXFlags &flags, std::ostream &out)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_gmv(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GmvFlags &flags, std::ostream &out)
void write_data(const std::vector< Patch< dim, spacedim > > &patches, unsigned int n_data_sets, const bool double_precision, StreamType &out)
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names)
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
void write_vtu_footer(std::ostream &out)
void write_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, DataOutFilter &filtered_data)
OutputFormat parse_output_format(const std::string &format_name)
std::vector< Point< spacedim > > get_node_positions(const std::vector< Patch< dim, spacedim > > &patches)
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim > > &patches, const DataOutFilter &data_filter, const DataOutBase::Hdf5Flags &flags, const std::string &filename, const MPI_Comm comm)
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
std::string get_output_format_names()
void write_svg(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const SvgFlags &flags, std::ostream &out)
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names)
void write_high_order_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out, const bool legacy_format)
std::string default_suffix(const OutputFormat output_format)
void write_povray(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const PovrayFlags &flags, std::ostream &out)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GnuplotFlags &flags, std::ostream &out)
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags)
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
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< 3 > Hexahedron
constexpr ReferenceCell< 2 > Quadrilateral
constexpr ReferenceCell< 1 > Line
constexpr ReferenceCell< 2 > Triangle
constexpr ReferenceCell< 3 > Tetrahedron
constexpr ReferenceCell< 3 > Pyramid
constexpr ReferenceCell< 3 > Wedge
constexpr ReferenceCell< 0 > Vertex
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 int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
unsigned int needed_digits(const unsigned int max_number)
constexpr T pow(const T base, const int iexp)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
constexpr types::global_dof_index invalid_size_type
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 > &)
CFFlags(const double time=-std::numeric_limits< double >::infinity(), const bool keep_existing_file=false, const std::map< std::string, std::vector< std::pair< std::string, AttributeValue > > > &attributes={})
std::map< std::string, std::vector< std::pair< std::string, AttributeValue > > > attributes
std::variant< int, double, std::string > AttributeValue
void parse_parameters(const ParameterHandler &prm)
DXFlags(const bool write_neighbors=false, const bool int_binary=false, const bool coordinates_binary=false, const bool data_binary=false)
static void declare_parameters(ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
void parse_parameters(const ParameterHandler &prm)
bool filter_duplicate_vertices
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
static void declare_parameters(ParameterHandler &prm)
static RgbValues default_color_function(const double value, const double min_value, const double max_value)
void parse_parameters(const ParameterHandler &prm)
ColorFunction color_function
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
EpsFlags(const unsigned int height_vector=0, const unsigned int color_vector=0, const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const double azimut_angle=60, const double turn_angle=30, const double z_scaling=1.0, const bool draw_mesh=true, const bool draw_cells=true, const bool shade_cells=true, const ColorFunction color_function=&default_color_function)
unsigned int color_vector
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
@ width
Scale to given width.
@ height
Scale to given height.
unsigned int height_vector
std::vector< std::string > space_dimension_labels
std::size_t memory_consumption() const
DataOutBase::CompressionLevel compression_level
Hdf5Flags(const CompressionLevel compression_level=CompressionLevel::best_speed)
static void declare_parameters(ParameterHandler &prm)
std::size_t memory_consumption() const
static const unsigned int no_neighbor
bool operator==(const Patch &patch) const
ReferenceCell< dim > reference_cell
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)
std::map< std::string, std::string > physical_units
bool write_higher_order_cells
DataOutBase::CompressionLevel compression_level
VtkFlags(const double time=std::numeric_limits< double >::lowest(), const unsigned int cycle=numbers::invalid_unsigned_int, 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={})
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)