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;
239 ExcMessage(
"This function can only be called if cmake found "
240 "a working libz installation."));
254 template <
typename T>
256 vtu_stringize_array(
const std::vector<T> &data,
259 std::ostringstream &output)
261 if (deal_ii_with_zlib &&
265 compress_array(data, compression_level, output);
269 const auto old_precision = output.precision(precision);
270 for (
const T &el : data)
272 output.precision(old_precision);
285 struct ParallelIntermediateHeader
288 std::uint64_t version;
289 std::uint64_t compression;
292 std::uint64_t n_ranks;
293 std::uint64_t n_patches;
319 Point<3> vertices[4];
330 Point<2> projected_vertices[4];
333 Point<2> projected_center;
343 SvgCell::operator<(
const SvgCell &e)
const
346 return depth >
e.depth;
384 EpsCell2d::operator<(
const EpsCell2d &e)
const
387 return depth > e.depth;
403 template <
int dim,
int spacedim,
typename Number =
double>
404 std::unique_ptr<Table<2, Number>>
405 create_global_data_table(
const std::vector<Patch<dim, spacedim>> &patches)
409 return std::make_unique<Table<2, Number>>();
418 const unsigned int n_data_sets = patches[0].points_are_available ?
419 (patches[0].data.n_rows() - spacedim) :
420 patches[0].data.n_rows();
421 const unsigned int n_data_points =
422 std::accumulate(patches.begin(),
425 [](
const unsigned int count,
426 const Patch<dim, spacedim> &patch) {
427 return count + patch.data.n_cols();
430 std::unique_ptr<Table<2, Number>> global_data_table =
431 std::make_unique<Table<2, Number>>(n_data_sets, n_data_points);
434 unsigned int next_value = 0;
435 for (
const auto &patch : patches)
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()));
449 (n_data_sets == 0) ||
450 (patch.data.n_cols() ==
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;
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)
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)
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,
1124 const ReferenceCell<dim> &reference_cell)
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>
1186 DXStream(std::ostream &stream,
const DataOutBase::DXFlags &flags);
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>
1223 GmvStream(std::ostream &stream,
const DataOutBase::GmvFlags &flags);
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>
1250 TecplotStream(std::ostream &stream,
const DataOutBase::TecplotFlags &flags);
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>
1277 UcdStream(std::ostream &stream,
const DataOutBase::UcdFlags &flags);
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>
1316 VtkStream(std::ostream &stream,
const DataOutBase::VtkFlags &flags);
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,
1344 const ReferenceCell<dim> &reference_cell);
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()),
1493 values.size() *
sizeof(data));
1497 for (
unsigned int i = 0; i <
values.size(); ++i)
1498 stream <<
'\t' << values[i];
1507 GmvStream::GmvStream(std::ostream &out,
const DataOutBase::GmvFlags &f)
1508 : StreamBase<DataOutBase::
GmvFlags>(out, f)
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,
1581 const DataOutBase::TecplotFlags &f)
1582 : StreamBase<DataOutBase::TecplotFlags>(out, f)
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;
1652 UcdStream::UcdStream(std::ostream &out,
const DataOutBase::UcdFlags &f)
1653 : StreamBase<DataOutBase::UcdFlags>(out, f)
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];
1706 VtkStream::VtkStream(std::ostream &out,
const DataOutBase::VtkFlags &f)
1707 : StreamBase<DataOutBase::VtkFlags>(out, f)
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 index,
1783 const unsigned int start,
1784 const unsigned int n_points,
1785 const ReferenceCell<dim> &reference_cell)
1789 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1791 stream <<
'\t' << n_points;
1792 for (
unsigned int i = 0; i < n_points; ++i)
1803 VtkStream::write_high_order_cell(
const unsigned int start,
1804 const std::vector<unsigned> &connectivity)
1806 stream << connectivity.size();
1807 for (
const auto &c : connectivity)
1808 stream <<
'\t' << start + c;
1815namespace DataOutBase
1817 const unsigned int Deal_II_IntermediateFlags::format_version = 4;
1820 template <
int dim,
int spacedim>
1824 template <
int dim,
int spacedim>
1828 template <
int dim,
int spacedim>
1846 template <
int dim,
int spacedim>
1854 const double epsilon = 3e-16;
1872 if (
data.n_rows() != patch.
data.n_rows())
1875 if (
data.n_cols() != patch.
data.n_cols())
1878 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1879 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1880 if (
data[i][j] != patch.
data[i][j])
1888 template <
int dim,
int spacedim>
1905 template <
int dim,
int spacedim>
1909 std::swap(
vertices, other_patch.vertices);
1910 std::swap(
neighbors, other_patch.neighbors);
1913 data.swap(other_patch.data);
1920 template <
int spacedim>
1924 template <
int spacedim>
1928 template <
int spacedim>
1932 template <
int spacedim>
1935 template <
int spacedim>
1939 template <
int spacedim>
1949 template <
int spacedim>
1953 const unsigned int dim = 0;
1956 const double epsilon = 3e-16;
1967 if (
data.n_rows() != patch.
data.n_rows())
1970 if (
data.n_cols() != patch.
data.n_cols())
1973 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1974 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1975 if (
data[i][j] != patch.
data[i][j])
1983 template <
int spacedim>
1995 template <
int spacedim>
1999 std::swap(
vertices, other_patch.vertices);
2001 data.swap(other_patch.data);
2056 "Filter duplicate vertices",
2059 "Whether to remove duplicate vertex values. deal.II duplicates "
2060 "vertices once for each adjacent cell so that it can output "
2061 "discontinuous quantities for which there may be more than one "
2062 "value for each vertex position. Setting this flag to "
2063 "'true' will merge all of these values by selecting a "
2064 "random one and outputting this as 'the' value for the vertex. "
2065 "As long as the data to be output corresponds to continuous "
2066 "fields, merging vertices has no effect. On the other hand, "
2067 "if the data to be output corresponds to discontinuous fields "
2068 "(either because you are using a discontinuous finite element, "
2069 "or because you are using a DataPostprocessor that yields "
2070 "discontinuous data, or because the data to be output has been "
2071 "produced by entirely different means), then the data in the "
2072 "output file no longer faithfully represents the underlying data "
2073 "because the discontinuous field has been replaced by a "
2074 "continuous one. Note also that the filtering can not occur "
2075 "on processor boundaries. Thus, a filtered discontinuous field "
2076 "looks like a continuous field inside of a subdomain, "
2077 "but like a discontinuous field at the subdomain boundary."
2079 "In any case, filtering results in drastically smaller output "
2080 "files (smaller by about a factor of 2^dim).");
2085 "Whether the data will be used in an XDMF/HDF5 combination.");
2117 "A boolean field indicating whether neighborship "
2118 "information between cells is to be written to the "
2119 "OpenDX output file");
2123 "Output format of integer numbers, which is "
2124 "either a text representation (ascii) or binary integer "
2125 "values of 32 or 64 bits length");
2129 "Output format of vertex coordinates, which is "
2130 "either a text representation (ascii) or binary "
2131 "floating point values of 32 or 64 bits length");
2135 "Output format of data values, which is "
2136 "either a text representation (ascii) or binary "
2137 "floating point values of 32 or 64 bits length");
2157 "A flag indicating whether a comment should be "
2158 "written to the beginning of the output file "
2159 "indicating date and time of creation as well "
2160 "as the creating program");
2197 "A flag indicating whether POVRAY should use smoothed "
2198 "triangles instead of the usual ones");
2202 "Whether POVRAY should use bicubic patches");
2206 "Whether camera and lighting information should "
2207 "be put into an external file \"data.inc\" or into "
2208 "the POVRAY input file");
2226 const unsigned int size,
2285 double sum = xmax + xmin;
2286 double sum13 = xmin + 3 * xmax;
2287 double sum22 = 2 * xmin + 2 * xmax;
2288 double sum31 = 3 * xmin + xmax;
2289 double dif = xmax - xmin;
2290 double rezdif = 1.0 / dif;
2294 if (x < (sum31) / 4)
2296 else if (x < (sum22) / 4)
2298 else if (x < (sum13) / 4)
2309 rgb_values.
green = 0;
2310 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2314 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2315 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2318 rgb_values.
red = (4 * x - 2 * sum) * rezdif;
2319 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2320 rgb_values.
blue = 0;
2324 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2325 rgb_values.
blue = (4. * x - sum13) * rezdif;
2332 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2346 (x - xmin) / (xmax - xmin);
2359 1 - (x - xmin) / (xmax - xmin);
2371 "Number of the input vector that is to be used to "
2372 "generate height information");
2376 "Number of the input vector that is to be used to "
2377 "generate color information");
2381 "Whether width or height should be scaled to match "
2386 "The size (width or height) to which the eps output "
2387 "file is to be scaled");
2391 "The width in which the postscript renderer is to "
2396 "Angle of the viewing position against the vertical "
2401 "Angle of the viewing direction against the y-axis");
2405 "Scaling for the z-direction relative to the scaling "
2406 "used in x- and y-directions");
2410 "Whether the mesh lines, or only the surface should be "
2415 "Whether only the mesh lines, or also the interior of "
2416 "cells should be plotted. If this flag is false, then "
2417 "one can see through the mesh");
2421 "Whether the interior of cells shall be shaded");
2425 "default|grey scale|reverse grey scale"),
2426 "Name of a color function used to colorize mesh lines "
2427 "and/or cell interiors");
2437 if (prm.
get(
"Scale to width or height") ==
"width")
2449 if (prm.
get(
"Color function") ==
"default")
2451 else if (prm.
get(
"Color function") ==
"grey scale")
2453 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2464 const std::map<std::string,
2465 std::vector<std::pair<std::string, AttributeValue>>>
2493 const unsigned int cycle,
2511 if (format_name ==
"none")
2514 if (format_name ==
"dx")
2517 if (format_name ==
"ucd")
2520 if (format_name ==
"gnuplot")
2523 if (format_name ==
"povray")
2526 if (format_name ==
"eps")
2529 if (format_name ==
"gmv")
2532 if (format_name ==
"tecplot")
2535 if (format_name ==
"vtk")
2538 if (format_name ==
"vtu")
2541 if (format_name ==
"deal.II intermediate")
2544 if (format_name ==
"hdf5")
2548 ExcMessage(
"The given file format name is not recognized: <" +
2549 format_name +
">"));
2560 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|vtk|vtu|hdf5|svg|deal.II intermediate";
2568 switch (output_format)
2610 template <
int dim,
int spacedim>
2611 std::vector<Point<spacedim>>
2615 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
2617 std::vector<Point<spacedim>> node_positions;
2618 std::size_t n_nodes = 0;
2619 for (
const auto &patch : patches)
2622 n_nodes += patch.
data.n_cols();
2626 node_positions.reserve(n_nodes);
2628 for (
const auto &patch : patches)
2633 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2635 node_positions.emplace_back(get_node_location(
2649 node_positions.emplace_back(
2653 for (
unsigned int i1 = 0; i1 < n; ++i1)
2654 node_positions.emplace_back(
2658 for (
unsigned int i2 = 0; i2 < n; ++i2)
2659 for (
unsigned int i1 = 0; i1 < n; ++i1)
2660 node_positions.emplace_back(get_equispaced_location(
2664 for (
unsigned int i3 = 0; i3 < n; ++i3)
2665 for (
unsigned int i2 = 0; i2 < n; ++i2)
2666 for (
unsigned int i1 = 0; i1 < n; ++i1)
2667 node_positions.emplace_back(get_equispaced_location(
2677 return node_positions;
2681 template <
int dim,
int spacedim,
typename StreamType>
2687 const std::vector<Point<spacedim>> node_positions =
2691 for (
const auto &node : node_positions)
2692 out.write_point(count++, node);
2698 template <
int dim,
int spacedim,
typename StreamType>
2703 unsigned int count = 0;
2704 unsigned int first_vertex_of_patch = 0;
2705 for (
const auto &patch : patches)
2710 out.write_cell_single(count++,
2711 first_vertex_of_patch,
2712 patch.
data.n_cols(),
2714 first_vertex_of_patch += patch.
data.n_cols();
2725 const unsigned int offset = first_vertex_of_patch;
2726 out.template write_cell<0>(count++, offset, {});
2732 constexpr unsigned int d1 = 1;
2736 const unsigned int offset =
2737 first_vertex_of_patch + i1 * d1;
2738 out.template write_cell<1>(count++, offset, {{d1}});
2746 constexpr unsigned int d1 = 1;
2747 const unsigned int d2 = n;
2752 const unsigned int offset =
2753 first_vertex_of_patch + i2 * d2 + i1 * d1;
2754 out.template write_cell<2>(count++,
2764 constexpr unsigned int d1 = 1;
2765 const unsigned int d2 = n;
2766 const unsigned int d3 = n * n;
2772 const unsigned int offset = first_vertex_of_patch +
2775 out.template write_cell<3>(count++,
2787 first_vertex_of_patch +=
2797 template <
int dim,
int spacedim,
typename StreamType>
2801 const bool legacy_format)
2805 (void)legacy_format;
2807 unsigned int first_vertex_of_patch = 0;
2809 std::vector<unsigned> connectivity;
2811 for (
const auto &patch : patches)
2815 connectivity.resize(patch.
data.n_cols());
2817 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2818 connectivity[i] = i;
2820 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2823 first_vertex_of_patch += patch.
data.n_cols();
2832 if constexpr (dim == 0)
2835 ExcMessage(
"Point-like cells should not be possible "
2836 "when writing higher-order cells."));
2838 else if constexpr (dim == 1)
2842 const unsigned int local_index = i1;
2843 const unsigned int connectivity_index =
2846 connectivity[connectivity_index] = local_index;
2849 else if constexpr (dim == 2)
2854 const unsigned int local_index = i2 * n + i1;
2855 const unsigned int connectivity_index =
2860 connectivity[connectivity_index] = local_index;
2863 else if constexpr (dim == 3)
2869 const unsigned int local_index =
2870 i3 * n * n + i2 * n + i1;
2871 const unsigned int connectivity_index =
2876 connectivity[connectivity_index] = local_index;
2884 out.template write_high_order_cell<dim>(first_vertex_of_patch,
2896 template <
int dim,
int spacedim,
typename StreamType>
2899 unsigned int n_data_sets,
2900 const bool double_precision,
2904 unsigned int count = 0;
2906 for (
const auto &patch : patches)
2911 Assert((patch.
data.n_rows() == n_data_sets &&
2913 (patch.
data.n_rows() == n_data_sets + spacedim &&
2916 (n_data_sets + spacedim) :
2918 patch.
data.n_rows()));
2922 std::vector<float> floats(n_data_sets);
2923 std::vector<double> doubles(n_data_sets);
2926 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2928 if (double_precision)
2930 for (
unsigned int data_set = 0; data_set < n_data_sets;
2932 doubles[data_set] = patch.
data(data_set, i);
2933 out.write_dataset(count, doubles);
2937 for (
unsigned int data_set = 0; data_set < n_data_sets;
2939 floats[data_set] = patch.
data(data_set, i);
2940 out.write_dataset(count, floats);
2965 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
2966 camera_horizontal[2] * camera_direction[1];
2967 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
2968 camera_horizontal[0] * camera_direction[2];
2969 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
2970 camera_horizontal[1] * camera_direction[0];
2974 phi /= (point[0] - camera_position[0]) * camera_direction[0] +
2975 (point[1] - camera_position[1]) * camera_direction[1] +
2976 (point[2] - camera_position[2]) * camera_direction[2];
2980 camera_position[0] + phi * (point[0] - camera_position[0]);
2982 camera_position[1] + phi * (point[1] - camera_position[1]);
2984 camera_position[2] + phi * (point[2] - camera_position[2]);
2987 projection_decomposition[0] = (projection[0] - camera_position[0] -
2988 camera_focus * camera_direction[0]) *
2989 camera_horizontal[0];
2990 projection_decomposition[0] += (projection[1] - camera_position[1] -
2991 camera_focus * camera_direction[1]) *
2992 camera_horizontal[1];
2993 projection_decomposition[0] += (projection[2] - camera_position[2] -
2994 camera_focus * camera_direction[2]) *
2995 camera_horizontal[2];
2997 projection_decomposition[1] = (projection[0] - camera_position[0] -
2998 camera_focus * camera_direction[0]) *
3000 projection_decomposition[1] += (projection[1] - camera_position[1] -
3001 camera_focus * camera_direction[1]) *
3003 projection_decomposition[1] += (projection[2] - camera_position[2] -
3004 camera_focus * camera_direction[2]) *
3007 return projection_decomposition;
3016 svg_get_gradient_parameters(
Point<3> points[])
3022 for (
int i = 0; i < 2; ++i)
3024 for (
int j = 0; j < 2 - i; ++j)
3026 if (points[j][2] > points[j + 1][2])
3029 points[j] = points[j + 1];
3030 points[j + 1] = temp;
3037 v_inter = points[1];
3044 A[0][0] = v_max[0] - v_min[0];
3045 A[0][1] = v_inter[0] - v_min[0];
3046 A[1][0] = v_max[1] - v_min[1];
3047 A[1][1] = v_inter[1] - v_min[1];
3053 bool col_change =
false;
3062 double temp = A[1][0];
3067 for (
unsigned int k = 0; k < 1; ++k)
3069 for (
unsigned int i = k + 1; i < 2; ++i)
3071 x = A[i][k] / A[k][k];
3073 for (
unsigned int j = k + 1; j < 2; ++j)
3074 A[i][j] = A[i][j] - A[k][j] * x;
3076 b[i] = b[i] - b[k] * x;
3080 b[1] =
b[1] /
A[1][1];
3082 for (
int i = 0; i >= 0; i--)
3086 for (
unsigned int j = i + 1; j < 2; ++j)
3087 sum = sum - A[i][j] * b[j];
3089 b[i] =
sum /
A[i][i];
3099 double c =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) +
3103 A[0][0] = v_max[0] - v_min[0];
3104 A[0][1] = v_inter[0] - v_min[0];
3105 A[1][0] = v_max[1] - v_min[1];
3106 A[1][1] = v_inter[1] - v_min[1];
3108 b[0] = 1.0 - v_min[0];
3120 double temp =
A[1][0];
3125 for (
unsigned int k = 0; k < 1; ++k)
3127 for (
unsigned int i = k + 1; i < 2; ++i)
3129 x = A[i][k] / A[k][k];
3131 for (
unsigned int j = k + 1; j < 2; ++j)
3132 A[i][j] = A[i][j] - A[k][j] * x;
3134 b[i] = b[i] - b[k] * x;
3138 b[1] =
b[1] /
A[1][1];
3140 for (
int i = 0; i >= 0; i--)
3144 for (
unsigned int j = i + 1; j < 2; ++j)
3145 sum = sum - A[i][j] * b[j];
3147 b[i] = sum / A[i][i];
3157 gradient[0] = b[0] * (v_max[2] - v_min[2]) +
3158 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3161 A[0][0] = v_max[0] - v_min[0];
3162 A[0][1] = v_inter[0] - v_min[0];
3163 A[1][0] = v_max[1] - v_min[1];
3164 A[1][1] = v_inter[1] - v_min[1];
3167 b[1] = 1.0 - v_min[1];
3178 double temp = A[1][0];
3183 for (
unsigned int k = 0; k < 1; ++k)
3185 for (
unsigned int i = k + 1; i < 2; ++i)
3187 x = A[i][k] / A[k][k];
3189 for (
unsigned int j = k + 1; j < 2; ++j)
3190 A[i][j] = A[i][j] - A[k][j] * x;
3192 b[i] = b[i] - b[k] * x;
3196 b[1] =
b[1] /
A[1][1];
3198 for (
int i = 0; i >= 0; i--)
3202 for (
unsigned int j = i + 1; j < 2; ++j)
3203 sum = sum - A[i][j] * b[j];
3205 b[i] = sum / A[i][i];
3215 gradient[1] = b[0] * (v_max[2] - v_min[2]) +
3216 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3219 gradient /= gradient.norm();
3221 const double lambda = -gradient[0] * (v_min[0] - v_max[0]) -
3222 gradient[1] * (v_min[1] - v_max[1]);
3226 gradient_parameters[0] = v_min[0];
3227 gradient_parameters[1] = v_min[1];
3229 gradient_parameters[2] = v_min[0] + lambda * gradient[0];
3230 gradient_parameters[3] = v_min[1] + lambda * gradient[1];
3232 gradient_parameters[4] = v_min[2];
3233 gradient_parameters[5] = v_max[2];
3235 return gradient_parameters;
3241 template <
int dim,
int spacedim>
3245 const std::vector<std::string> &data_names,
3247 std::tuple<
unsigned int,
3260#ifndef DEAL_II_WITH_MPI
3269 if (patches.empty())
3273 const unsigned int n_data_sets = data_names.size();
3275 UcdStream ucd_out(out, flags);
3279 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
3285 <<
"# This file was generated by the deal.II library." <<
'\n'
3289 <<
"# For a description of the UCD format see the AVS Developer's guide."
3295 out << n_nodes <<
' ' << n_cells <<
' ' << n_data_sets <<
' ' << 0
3308 if (n_data_sets != 0)
3310 out << n_data_sets <<
" ";
3311 for (
unsigned int i = 0; i < n_data_sets; ++i)
3316 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3317 out << data_names[data_set]
3321 write_data(patches, n_data_sets,
true, ucd_out);
3331 template <
int dim,
int spacedim>
3335 const std::vector<std::string> &data_names,
3337 std::tuple<
unsigned int,
3349#ifndef DEAL_II_WITH_MPI
3358 if (patches.empty())
3362 DXStream dx_out(out, flags);
3365 unsigned int offset = 0;
3367 const unsigned int n_data_sets = data_names.size();
3371 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
3374 out <<
"object \"vertices\" class array type float rank 1 shape "
3375 << spacedim <<
" items " << n_nodes;
3379 out <<
" lsb ieee data 0" <<
'\n';
3380 offset += n_nodes * spacedim *
sizeof(float);
3384 out <<
" data follows" <<
'\n';
3393 out <<
"object \"cells\" class array type int rank 1 shape "
3398 out <<
" lsb binary data " << offset <<
'\n';
3399 offset += n_cells *
sizeof(
int);
3403 out <<
" data follows" <<
'\n';
3409 out <<
"attribute \"element type\" string \"";
3410 if constexpr (dim == 1)
3412 else if constexpr (dim == 2)
3414 else if constexpr (dim == 3)
3416 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3423 out <<
"object \"neighbors\" class array type int rank 1 shape "
3427 for (
const auto &patch : patches)
3430 const unsigned int n1 = (dim > 0) ? n : 1;
3431 const unsigned int n2 = (dim > 1) ? n : 1;
3432 const unsigned int n3 = (dim > 2) ? n : 1;
3433 const unsigned int x_minus = (dim > 0) ? 0 : 0;
3434 const unsigned int x_plus = (dim > 0) ? 1 : 0;
3435 const unsigned int y_minus = (dim > 1) ? 2 : 0;
3436 const unsigned int y_plus = (dim > 1) ? 3 : 0;
3437 const unsigned int z_minus = (dim > 2) ? 4 : 0;
3438 const unsigned int z_plus = (dim > 2) ? 5 : 0;
3440 unsigned int dx = 1;
3441 unsigned int dy = n;
3442 unsigned int dz = n * n;
3444 const unsigned int patch_start =
3447 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3448 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3449 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3451 const unsigned int nx = i1 *
dx;
3452 const unsigned int ny = i2 * dy;
3453 const unsigned int nz = i3 * dz;
3465 const unsigned int nn = patch.
neighbors[x_minus];
3469 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3475 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3480 const unsigned int nn = patch.
neighbors[x_plus];
3483 out << (nn * cells_per_patch + ny + nz);
3489 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3496 const unsigned int nn = patch.
neighbors[y_minus];
3500 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3506 out <<
'\t' << patch_start + nx + ny - dy + nz;
3511 const unsigned int nn = patch.
neighbors[y_plus];
3514 out << (nn * cells_per_patch + nx + nz);
3520 out <<
'\t' << patch_start + nx + ny + dy + nz;
3528 const unsigned int nn = patch.
neighbors[z_minus];
3532 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3538 out <<
'\t' << patch_start + nx + ny + nz - dz;
3543 const unsigned int nn = patch.
neighbors[z_plus];
3546 out << (nn * cells_per_patch + nx + ny);
3552 out <<
'\t' << patch_start + nx + ny + nz + dz;
3560 if (n_data_sets != 0)
3562 out <<
"object \"data\" class array type float rank 1 shape "
3563 << n_data_sets <<
" items " << n_nodes;
3567 out <<
" lsb ieee data " << offset <<
'\n';
3568 offset += n_data_sets * n_nodes *
3569 ((flags.
data_double) ?
sizeof(double) :
sizeof(float));
3573 out <<
" data follows" <<
'\n';
3578 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3582 out <<
"object \"data\" class constantarray type float rank 0 items "
3583 << n_nodes <<
" data follows" <<
'\n'
3589 out <<
"object \"deal data\" class field" <<
'\n'
3590 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3591 <<
"component \"connections\" value \"cells\"" <<
'\n'
3592 <<
"component \"data\" value \"data\"" <<
'\n';
3595 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3602 out <<
"end" <<
'\n';
3620 template <
int dim,
int spacedim>
3624 const std::vector<std::string> &data_names,
3626 std::tuple<
unsigned int,
3635#ifndef DEAL_II_WITH_MPI
3645 if (patches.empty())
3649 const unsigned int n_data_sets = data_names.size();
3653 out <<
"# This file was generated by the deal.II library." <<
'\n'
3657 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3664 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3669 for (
const auto &data_name : data_names)
3670 out <<
'<' << data_name <<
"> ";
3676 for (
const auto &patch : patches)
3681 Assert((patch.
data.n_rows() == n_data_sets &&
3683 (patch.
data.n_rows() == n_data_sets + spacedim &&
3686 (n_data_sets + spacedim) :
3688 patch.
data.n_rows()));
3690 auto output_point_data =
3691 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3692 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3693 out << patch.data(data_set, point_index) <<
' ';
3702 Assert(patch.data.n_cols() == 1,
3710 output_point_data(0);
3720 Assert(patch.data.n_cols() ==
3725 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3731 output_point_data(i1);
3745 n_points_per_direction),
3749 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3751 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3755 out << get_equispaced_location(patch,
3760 output_point_data(i1 + i2 * n_points_per_direction);
3785 out << get_node_location(patch, 0) <<
' ';
3786 output_point_data(0);
3789 out << get_node_location(patch, 1) <<
' ';
3790 output_point_data(1);
3794 out << get_node_location(patch, 2) <<
' ';
3795 output_point_data(2);
3798 out << get_node_location(patch, 2) <<
' ';
3799 output_point_data(2);
3820 n_points_per_direction),
3827 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3828 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3830 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3835 get_equispaced_location(patch,
3842 out << this_point <<
' ';
3843 output_point_data(i1 +
3844 i2 * n_points_per_direction +
3845 i3 * n_points_per_direction *
3846 n_points_per_direction);
3850 out << get_equispaced_location(patch,
3855 output_point_data((i1 + 1) +
3856 i2 * n_points_per_direction +
3857 i3 * n_points_per_direction *
3858 n_points_per_direction);
3862 out <<
'\n' <<
'\n';
3869 out << this_point <<
' ';
3870 output_point_data(i1 +
3871 i2 * n_points_per_direction +
3872 i3 * n_points_per_direction *
3873 n_points_per_direction);
3877 out << get_equispaced_location(patch,
3883 i1 + (i2 + 1) * n_points_per_direction +
3884 i3 * n_points_per_direction *
3885 n_points_per_direction);
3889 out <<
'\n' <<
'\n';
3896 out << this_point <<
' ';
3897 output_point_data(i1 +
3898 i2 * n_points_per_direction +
3899 i3 * n_points_per_direction *
3900 n_points_per_direction);
3904 out << get_equispaced_location(patch,
3910 i1 + i2 * n_points_per_direction +
3911 (i3 + 1) * n_points_per_direction *
3912 n_points_per_direction);
3915 out <<
'\n' <<
'\n';
3924 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3926 out << get_node_location(patch, v) <<
' ';
3927 output_point_data(v);
3932 for (
const unsigned int v : {3, 1})
3934 out << get_node_location(patch, v) <<
' ';
3935 output_point_data(v);
3945 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
3947 out << get_node_location(patch, v) <<
' ';
3948 output_point_data(v);
3953 for (
const unsigned int v : {2, 4, 3})
3955 out << get_node_location(patch, v) <<
' ';
3956 output_point_data(v);
3970 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
3972 out << get_node_location(patch, v) <<
' ';
3973 output_point_data(v);
3978 for (
const unsigned int v : {1, 4})
3980 out << get_node_location(patch, v) <<
' ';
3981 output_point_data(v);
3986 for (
const unsigned int v : {2, 5})
3988 out << get_node_location(patch, v) <<
' ';
3989 output_point_data(v);
4014 template <
int dim,
int spacedim>
4016 do_write_povray(
const std::vector<Patch<dim, spacedim>> &,
4017 const std::vector<std::string> &,
4018 const PovrayFlags &,
4022 ExcMessage(
"Writing files in POVRAY format is only supported "
4023 "for two-dimensional meshes."));
4029 do_write_povray(
const std::vector<
Patch<2, 2>> &patches,
4030 const std::vector<std::string> &data_names,
4036#ifndef DEAL_II_WITH_MPI
4045 if (patches.empty())
4048 constexpr int dim = 2;
4050 constexpr int spacedim = 2;
4052 const unsigned int n_data_sets = data_names.size();
4058 <<
"/* This file was generated by the deal.II library." <<
'\n'
4062 <<
" For a description of the POVRAY format see the POVRAY manual."
4067 out <<
"#include \"colors.inc\" " <<
'\n'
4068 <<
"#include \"textures.inc\" " <<
'\n';
4072 if (flags.external_data)
4073 out <<
"#include \"data.inc\" " <<
'\n';
4079 <<
"camera {" <<
'\n'
4080 <<
" location <1,4,-7>" <<
'\n'
4081 <<
" look_at <0,0,0>" <<
'\n'
4082 <<
" angle 30" <<
'\n'
4087 <<
"light_source {" <<
'\n'
4088 <<
" <1,4,-7>" <<
'\n'
4089 <<
" color Grey" <<
'\n'
4092 <<
"light_source {" <<
'\n'
4093 <<
" <0,20,0>" <<
'\n'
4094 <<
" color White" <<
'\n'
4101 double hmin = patches[0].data(0, 0);
4102 double hmax = patches[0].data(0, 0);
4104 for (
const auto &patch : patches)
4108 Assert((patch.
data.n_rows() == n_data_sets &&
4110 (patch.
data.n_rows() == n_data_sets + spacedim &&
4113 (n_data_sets + spacedim) :
4115 patch.
data.n_rows()));
4125 if (patch.
data(0, dl) < hmin)
4126 hmin = patch.
data(0, dl);
4127 if (patch.
data(0, dl) > hmax)
4128 hmax = patch.
data(0, dl);
4132 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
4133 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
4136 if (!flags.external_data)
4139 out <<
"#declare Tex=texture{" <<
'\n'
4140 <<
" pigment {" <<
'\n'
4141 <<
" gradient y" <<
'\n'
4142 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
4143 <<
" color_map {" <<
'\n'
4144 <<
" [0.00 color Light_Purple] " <<
'\n'
4145 <<
" [0.95 color Light_Purple] " <<
'\n'
4146 <<
" [1.00 color White] " <<
'\n'
4151 if (!flags.bicubic_patch)
4154 out <<
'\n' <<
"mesh {" <<
'\n';
4158 for (
const auto &patch : patches)
4162 const unsigned int d1 = 1;
4163 const unsigned int d2 = n;
4165 Assert((patch.
data.n_rows() == n_data_sets &&
4167 (patch.
data.n_rows() == n_data_sets + spacedim &&
4170 (n_data_sets + spacedim) :
4172 patch.
data.n_rows()));
4178 std::vector<Point<spacedim>> ver(n * n);
4180 for (
unsigned int i2 = 0; i2 < n; ++i2)
4181 for (
unsigned int i1 = 0; i1 < n; ++i1)
4184 ver[i1 * d1 + i2 * d2] =
4189 if (!flags.bicubic_patch)
4192 std::vector<Point<3>> nrml;
4202 for (
unsigned int i = 0; i < n; ++i)
4203 for (
unsigned int j = 0; j < n; ++j)
4205 const unsigned int il = (i == 0) ? i : (i - 1);
4206 const unsigned int ir =
4208 const unsigned int jl = (j == 0) ? j : (j - 1);
4209 const unsigned int jr =
4213 ver[ir * d1 + j * d2][0] - ver[il * d1 + j * d2][0];
4214 h1[1] = patch.
data(0, ir * d1 + j * d2) -
4215 patch.
data(0, il * d1 + j * d2);
4217 ver[ir * d1 + j * d2][1] - ver[il * d1 + j * d2][1];
4220 ver[i * d1 + jr * d2][0] - ver[i * d1 + jl * d2][0];
4221 h2[1] = patch.
data(0, i * d1 + jr * d2) -
4222 patch.
data(0, i * d1 + jl * d2);
4224 ver[i * d1 + jr * d2][1] - ver[i * d1 + jl * d2][1];
4226 nrml[i * d1 + j * d2][0] =
4227 h1[1] * h2[2] - h1[2] * h2[1];
4228 nrml[i * d1 + j * d2][1] =
4229 h1[2] * h2[0] - h1[0] * h2[2];
4230 nrml[i * d1 + j * d2][2] =
4231 h1[0] * h2[1] - h1[1] * h2[0];
4234 double norm = std::hypot(nrml[i * d1 + j * d2][0],
4235 nrml[i * d1 + j * d2][1],
4236 nrml[i * d1 + j * d2][2]);
4238 if (nrml[i * d1 + j * d2][1] < 0)
4241 for (
unsigned int k = 0; k < 3; ++k)
4242 nrml[i * d1 + j * d2][k] /=
norm;
4251 const int dl = i * d1 + j * d2;
4257 out <<
"smooth_triangle {" <<
'\n'
4258 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4259 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4260 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4262 out <<
" \t<" << ver[dl + d1][0] <<
","
4263 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4264 <<
">, <" << nrml[dl + d1][0] <<
", "
4265 << nrml[dl + d1][1] <<
", " << nrml[dl + d1][2]
4267 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4268 << patch.
data(0, dl + d1 + d2) <<
","
4269 << ver[dl + d1 + d2][1] <<
">, <"
4270 << nrml[dl + d1 + d2][0] <<
", "
4271 << nrml[dl + d1 + d2][1] <<
", "
4272 << nrml[dl + d1 + d2][2] <<
">}" <<
'\n';
4275 out <<
"smooth_triangle {" <<
'\n'
4276 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4277 <<
"," << ver[dl][1] <<
">, <" << nrml[dl][0]
4278 <<
", " << nrml[dl][1] <<
", " << nrml[dl][2]
4280 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4281 << patch.
data(0, dl + d1 + d2) <<
","
4282 << ver[dl + d1 + d2][1] <<
">, <"
4283 << nrml[dl + d1 + d2][0] <<
", "
4284 << nrml[dl + d1 + d2][1] <<
", "
4285 << nrml[dl + d1 + d2][2] <<
">," <<
'\n';
4286 out <<
"\t<" << ver[dl + d2][0] <<
","
4287 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4288 <<
">, <" << nrml[dl + d2][0] <<
", "
4289 << nrml[dl + d2][1] <<
", " << nrml[dl + d2][2]
4295 out <<
"triangle {" <<
'\n'
4296 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4297 <<
"," << ver[dl][1] <<
">," <<
'\n';
4298 out <<
"\t<" << ver[dl + d1][0] <<
","
4299 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1][1]
4301 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4302 << patch.
data(0, dl + d1 + d2) <<
","
4303 << ver[dl + d1 + d2][1] <<
">}" <<
'\n';
4306 out <<
"triangle {" <<
'\n'
4307 <<
"\t<" << ver[dl][0] <<
"," << patch.
data(0, dl)
4308 <<
"," << ver[dl][1] <<
">," <<
'\n';
4309 out <<
"\t<" << ver[dl + d1 + d2][0] <<
","
4310 << patch.
data(0, dl + d1 + d2) <<
","
4311 << ver[dl + d1 + d2][1] <<
">," <<
'\n';
4312 out <<
"\t<" << ver[dl + d2][0] <<
","
4313 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2][1]
4324 <<
"bicubic_patch {" <<
'\n'
4325 <<
" type 0" <<
'\n'
4326 <<
" flatness 0" <<
'\n'
4327 <<
" u_steps 0" <<
'\n'
4328 <<
" v_steps 0" <<
'\n';
4329 for (
int i = 0; i < 16; ++i)
4331 out <<
"\t<" << ver[i][0] <<
"," << patch.
data(0, i) <<
","
4332 << ver[i][1] <<
">";
4337 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4341 if (!flags.bicubic_patch)
4344 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4356 template <
int dim,
int spacedim>
4360 const std::vector<std::string> &data_names,
4362 std::tuple<
unsigned int,
4369 do_write_povray(patches, data_names, flags, out);
4374 template <
int dim,
int spacedim>
4378 const std::vector<std::string> & ,
4380 std::tuple<
unsigned int,
4392 template <
int spacedim>
4396 const std::vector<std::string> & ,
4398 std::tuple<
unsigned int,
4407#ifndef DEAL_II_WITH_MPI
4416 if (patches.empty())
4426 std::multiset<EpsCell2d> cells;
4430 float min_color_value = std::numeric_limits<float>::max();
4431 float max_color_value = std::numeric_limits<float>::min();
4435 double heights[4] = {0, 0, 0, 0};
4439 for (
const auto &patch : patches)
4443 const unsigned int d1 = 1;
4444 const unsigned int d2 = n;
4456 points[3] = get_equispaced_location(patch,
4464 patch.
data.n_rows() == 0,
4467 patch.
data.n_rows()));
4469 patch.
data.n_rows() != 0 ?
4473 heights[1] = patch.
data.n_rows() != 0 ?
4475 (i1 + 1) * d1 + i2 * d2) *
4478 heights[2] = patch.
data.n_rows() != 0 ?
4480 i1 * d1 + (i2 + 1) * d2) *
4483 heights[3] = patch.
data.n_rows() != 0 ?
4485 (i1 + 1) * d1 + (i2 + 1) * d2) *
4492 for (
unsigned int i = 0; i < 4; ++i)
4493 heights[i] = points[i][2];
4518 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4520 const double x = points[vertex][0], y = points[vertex][1],
4521 z = -heights[vertex];
4523 eps_cell.vertices[vertex][0] = -cz * x + sz * y;
4524 eps_cell.vertices[vertex][1] =
4525 -cx * sz * x - cx * cz * y - sx * z;
4549 (points[0] + points[1] + points[2] + points[3]) / 4;
4550 const double center_height =
4551 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4554 eps_cell.depth = -sx * sz * center_point[0] -
4555 sx * cz * center_point[1] + cx * center_height;
4560 patch.
data.n_rows() == 0,
4563 patch.
data.n_rows()));
4564 const double color_values[4] = {
4565 patch.
data.n_rows() != 0 ?
4569 patch.
data.n_rows() != 0 ?
4573 patch.
data.n_rows() != 0 ?
4577 patch.
data.n_rows() != 0 ?
4579 (i1 + 1) * d1 + (i2 + 1) * d2) :
4583 eps_cell.color_value = (color_values[0] + color_values[1] +
4584 color_values[3] + color_values[2]) /
4589 std::min(min_color_value, eps_cell.color_value);
4591 std::max(max_color_value, eps_cell.color_value);
4595 cells.insert(eps_cell);
4601 double x_min = cells.begin()->vertices[0][0];
4602 double x_max = x_min;
4603 double y_min = cells.begin()->vertices[0][1];
4604 double y_max = y_min;
4606 for (
const auto &cell : cells)
4607 for (
const auto &vertex : cell.vertices)
4609 x_min =
std::min(x_min, vertex[0]);
4610 x_max =
std::max(x_max, vertex[0]);
4611 y_min =
std::min(y_min, vertex[1]);
4612 y_max =
std::max(y_max, vertex[1]);
4617 const double scale =
4621 const Point<2> offset(x_min, y_min);
4626 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4627 <<
"%%Title: deal.II Output" <<
'\n'
4628 <<
"%%Creator: the deal.II library" <<
'\n'
4631 <<
"%%BoundingBox: "
4635 <<
static_cast<unsigned int>((x_max - x_min) * scale + 0.5) <<
' '
4636 <<
static_cast<unsigned int>((y_max - y_min) * scale + 0.5) <<
'\n';
4645 out <<
"/m {moveto} bind def" <<
'\n'
4646 <<
"/l {lineto} bind def" <<
'\n'
4647 <<
"/s {setrgbcolor} bind def" <<
'\n'
4648 <<
"/sg {setgray} bind def" <<
'\n'
4649 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4650 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4652 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4654 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4662 if (max_color_value == min_color_value)
4663 max_color_value = min_color_value + 1;
4667 for (
const auto &cell : cells)
4680 out << rgb_values.
red <<
" sg ";
4682 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4683 << rgb_values.
blue <<
" s ";
4688 out << (cell.vertices[0] - offset) * scale <<
" m "
4689 << (cell.vertices[1] - offset) * scale <<
" l "
4690 << (cell.vertices[3] - offset) * scale <<
" l "
4691 << (cell.vertices[2] - offset) * scale <<
" lf" <<
'\n';
4696 << (cell.vertices[0] - offset) * scale <<
" m "
4697 << (cell.vertices[1] - offset) * scale <<
" l "
4698 << (cell.vertices[3] - offset) * scale <<
" l "
4699 << (cell.vertices[2] - offset) * scale <<
" lx" <<
'\n';
4701 out <<
"showpage" <<
'\n';
4710 template <
int dim,
int spacedim>
4714 const std::vector<std::string> &data_names,
4716 std::tuple<
unsigned int,
4732#ifndef DEAL_II_WITH_MPI
4741 if (patches.empty())
4745 GmvStream gmv_out(out, flags);
4746 const unsigned int n_data_sets = data_names.size();
4749 Assert((patches[0].data.n_rows() == n_data_sets &&
4750 !patches[0].points_are_available) ||
4751 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4752 patches[0].points_are_available),
4754 (n_data_sets + spacedim) :
4756 patches[0].data.n_rows()));
4760 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4764 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
4779 [&patches]() {
return create_global_data_table(patches); });
4785 out <<
"nodes " << n_nodes <<
'\n';
4786 for (
unsigned int d = 0; d < spacedim; ++d)
4788 gmv_out.selected_component = d;
4794 for (
unsigned int d = spacedim; d < 3; ++d)
4796 for (
unsigned int i = 0; i < n_nodes; ++i)
4803 out <<
"cells " << n_cells <<
'\n';
4808 out <<
"variable" <<
'\n';
4812 std::move(*create_global_data_table_task.
return_value());
4816 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4818 out << data_names[data_set] <<
" 1" <<
'\n';
4819 std::copy(data_vectors[data_set].
begin(),
4820 data_vectors[data_set].
end(),
4821 std::ostream_iterator<double>(out,
" "));
4822 out <<
'\n' <<
'\n';
4828 out <<
"endvars" <<
'\n';
4831 out <<
"endgmv" <<
'\n';
4842 template <
int dim,
int spacedim>
4846 const std::vector<std::string> &data_names,
4848 std::tuple<
unsigned int,
4862#ifndef DEAL_II_WITH_MPI
4871 if (patches.empty())
4875 TecplotStream tecplot_out(out, flags);
4877 const unsigned int n_data_sets = data_names.size();
4880 Assert((patches[0].data.n_rows() == n_data_sets &&
4881 !patches[0].points_are_available) ||
4882 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4883 patches[0].points_are_available),
4885 (n_data_sets + spacedim) :
4887 patches[0].data.n_rows()));
4891 auto [n_nodes, n_cells] = count_nodes_and_cells(patches);
4897 <<
"# This file was generated by the deal.II library." <<
'\n'
4901 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4906 out <<
"Variables=";
4914 out <<
"\"x\", \"y\"";
4917 out <<
"\"x\", \"y\", \"z\"";
4923 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4924 out <<
", \"" << data_names[data_set] <<
"\"";
4930 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4933 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4935 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4936 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4953 [&patches]() {
return create_global_data_table(patches); });
4959 for (
unsigned int d = 0; d < spacedim; ++d)
4961 tecplot_out.selected_component = d;
4972 std::move(*create_global_data_table_task.
return_value());
4975 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4977 std::copy(data_vectors[data_set].
begin(),
4978 data_vectors[data_set].
end(),
4979 std::ostream_iterator<double>(out,
"\n"));
4994 template <
int dim,
int spacedim>
4998 const std::vector<std::string> &data_names,
5000 std::tuple<
unsigned int,
5004 &nonscalar_data_ranges,
5010#ifndef DEAL_II_WITH_MPI
5019 if (patches.empty())
5023 VtkStream vtk_out(out, flags);
5025 const unsigned int n_data_sets = data_names.size();
5027 if (patches[0].points_are_available)
5039 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5040 <<
"#This file was generated by the deal.II library";
5048 out <<
'\n' <<
"ASCII" <<
'\n';
5050 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
5057 const unsigned int n_metadata =
5059 (flags.
time != std::numeric_limits<double>::lowest() ? 1 : 0));
5062 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5066 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5068 if (flags.
time != std::numeric_limits<double>::lowest())
5070 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5076 unsigned int n_nodes;
5077 unsigned int n_cells;
5078 unsigned int n_points_and_n_cells;
5079 std::tie(n_nodes, n_cells, n_points_and_n_cells) =
5095 [&patches]() {
return create_global_data_table(patches); });
5101 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5106 out <<
"CELLS " << n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5114 out <<
"CELL_TYPES " << n_cells <<
'\n';
5118 for (
const auto &patch : patches)
5120 const auto vtk_cell_id =
5123 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5124 out <<
' ' << vtk_cell_id[0];
5133 std::move(*create_global_data_table_task.
return_value());
5138 out <<
"POINT_DATA " << n_nodes <<
'\n';
5142 std::vector<bool> data_set_written(n_data_sets,
false);
5143 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5148 "The VTK writer does not currently support outputting "
5149 "tensor data. Use the VTU writer instead."));
5152 std::get<0>(nonscalar_data_range),
5154 std::get<0>(nonscalar_data_range)));
5155 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5159 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5160 std::get<0>(nonscalar_data_range) <=
5163 "Can't declare a vector with more than 3 components "
5167 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5168 i <= std::get<1>(nonscalar_data_range);
5170 data_set_written[i] =
true;
5176 if (!std::get<2>(nonscalar_data_range).empty())
5177 out << std::get<2>(nonscalar_data_range);
5180 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5181 i < std::get<1>(nonscalar_data_range);
5183 out << data_names[i] <<
"__";
5184 out << data_names[std::get<1>(nonscalar_data_range)];
5187 out <<
" double" <<
'\n';
5190 for (
unsigned int n = 0; n < n_nodes; ++n)
5192 switch (std::get<1>(nonscalar_data_range) -
5193 std::get<0>(nonscalar_data_range))
5196 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5201 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5203 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5207 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5209 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5211 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5224 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5225 if (data_set_written[data_set] ==
false)
5227 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5228 <<
"LOOKUP_TABLE default" <<
'\n';
5229 std::copy(data_vectors[data_set].
begin(),
5230 data_vectors[data_set].
end(),
5231 std::ostream_iterator<double>(out,
" "));
5247 out <<
"<?xml version=\"1.0\" ?> \n";
5249 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5250 <<
"#This file was generated by the deal.II library";
5261 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"2.2\"";
5263 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5264 if (deal_ii_with_zlib &&
5266 out <<
" compressor=\"vtkZLibDataCompressor\"";
5267#ifdef DEAL_II_WORDS_BIGENDIAN
5268 out <<
" byte_order=\"BigEndian\"";
5270 out <<
" byte_order=\"LittleEndian\"";
5274 out <<
"<UnstructuredGrid>";
5284 out <<
" </UnstructuredGrid>\n";
5285 out <<
"</VTKFile>\n";
5290 template <
int dim,
int spacedim>
5294 const std::vector<std::string> &data_names,
5296 std::tuple<
unsigned int,
5300 &nonscalar_data_ranges,
5305 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5312 template <
int dim,
int spacedim>
5316 const std::vector<std::string> &data_names,
5318 std::tuple<
unsigned int,
5322 &nonscalar_data_ranges,
5336 unit.second.find(
'\"') == std::string::npos,
5338 "A physical unit you provided, <" + unit.second +
5339 ">, contained a quotation mark character. This is not allowed."));
5342#ifndef DEAL_II_WITH_MPI
5351 if (patches.empty())
5356 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5358 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5360 <<
" <PointData Scalars=\"scalars\">\n";
5361 std::vector<bool> data_set_written(data_names.size(),
false);
5362 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5365 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5366 i <= std::get<1>(nonscalar_data_range);
5368 data_set_written[i] =
true;
5372 out <<
" <DataArray type=\"Float32\" Name=\"";
5374 if (!std::get<2>(nonscalar_data_range).empty())
5375 out << std::get<2>(nonscalar_data_range);
5378 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5379 i < std::get<1>(nonscalar_data_range);
5381 out << data_names[i] <<
"__";
5382 out << data_names[std::get<1>(nonscalar_data_range)];
5385 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5388 for (
unsigned int data_set = 0; data_set < data_names.size();
5390 if (data_set_written[data_set] ==
false)
5392 out <<
" <DataArray type=\"Float32\" Name=\""
5393 << data_names[data_set] <<
"\"></DataArray>\n";
5396 out <<
" </PointData>\n";
5397 out <<
"</Piece>\n";
5411 const unsigned int n_metadata =
5413 (flags.
time != std::numeric_limits<double>::lowest() ? 1 : 0));
5415 out <<
"<FieldData>\n";
5420 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5421 << flags.
cycle <<
"</DataArray>\n";
5423 if (flags.
time != std::numeric_limits<double>::lowest())
5426 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5427 << flags.
time <<
"</DataArray>\n";
5431 out <<
"</FieldData>\n";
5435 const unsigned int n_data_sets = data_names.size();
5438 if (patches[0].points_are_available)
5447 const char *ascii_or_binary =
5448 (deal_ii_with_zlib &&
5455 unsigned int n_nodes;
5456 unsigned int n_cells;
5457 std::tie(n_nodes, n_cells, std::ignore) =
5465 const auto stringize_vertex_information = [&patches,
5469 ascii_or_binary]() {
5470 std::ostringstream o;
5472 o <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5473 << ascii_or_binary <<
"\">\n";
5474 const std::vector<Point<spacedim>> node_positions =
5479 std::vector<float> node_coordinates_3d;
5480 node_coordinates_3d.reserve(node_positions.size() * 3);
5481 for (
const auto &node_position : node_positions)
5483 for (
unsigned int d = 0; d < 3; ++d)
5485 node_coordinates_3d.emplace_back(node_position[d]);
5487 node_coordinates_3d.emplace_back(0.0f);
5489 vtu_stringize_array(node_coordinates_3d,
5494 o <<
" </DataArray>\n";
5495 o <<
" </Points>\n\n";
5504 const auto stringize_cell_to_vertex_information = [&patches,
5508 out.precision()]() {
5509 std::ostringstream o;
5512 o <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5513 << ascii_or_binary <<
"\">\n";
5515 std::vector<std::int32_t> cells;
5518 unsigned int first_vertex_of_patch = 0;
5520 std::vector<unsigned int> local_vertex_order;
5521 for (
const auto &patch : patches)
5523 local_vertex_order.clear();
5535 const unsigned int n_points = patch.
data.n_cols();
5536 Assert((dim == 2 && n_points == 6) ||
5537 (dim == 3 && n_points == 10),
5540 if (deal_ii_with_zlib &&
5544 for (
unsigned int i = 0; i < n_points; ++i)
5545 cells.push_back(first_vertex_of_patch + i);
5549 for (
unsigned int i = 0; i < n_points; ++i)
5550 o <<
'\t' << first_vertex_of_patch + i;
5554 first_vertex_of_patch += n_points;
5563 const unsigned int n_points = patch.
data.n_cols();
5565 if (deal_ii_with_zlib &&
5569 for (
unsigned int i = 0; i < n_points; ++i)
5571 first_vertex_of_patch +
5576 for (
unsigned int i = 0; i < n_points; ++i)
5578 << (first_vertex_of_patch +
5583 first_vertex_of_patch += n_points;
5591 const auto flush_current_cell = [&flags,
5594 first_vertex_of_patch,
5595 &local_vertex_order]() {
5596 if (deal_ii_with_zlib &&
5600 for (
const auto &c : local_vertex_order)
5601 cells.push_back(first_vertex_of_patch + c);
5605 for (
const auto &c : local_vertex_order)
5606 o <<
'\t' << first_vertex_of_patch + c;
5610 local_vertex_order.clear();
5621 local_vertex_order.emplace_back(0);
5622 flush_current_cell();
5630 const unsigned int starting_offset = i1;
5631 local_vertex_order.emplace_back(starting_offset);
5632 local_vertex_order.emplace_back(starting_offset +
5634 flush_current_cell();
5644 const unsigned int starting_offset =
5645 i2 * n_points_per_direction + i1;
5646 local_vertex_order.emplace_back(
5648 local_vertex_order.emplace_back(
5649 starting_offset + 1);
5650 local_vertex_order.emplace_back(
5651 starting_offset + n_points_per_direction + 1);
5652 local_vertex_order.emplace_back(
5653 starting_offset + n_points_per_direction);
5654 flush_current_cell();
5666 const unsigned int starting_offset =
5667 i3 * n_points_per_direction *
5668 n_points_per_direction +
5669 i2 * n_points_per_direction + i1;
5670 local_vertex_order.emplace_back(
5672 local_vertex_order.emplace_back(
5673 starting_offset + 1);
5674 local_vertex_order.emplace_back(
5675 starting_offset + n_points_per_direction +
5677 local_vertex_order.emplace_back(
5678 starting_offset + n_points_per_direction);
5679 local_vertex_order.emplace_back(
5680 starting_offset + n_points_per_direction *
5681 n_points_per_direction);
5682 local_vertex_order.emplace_back(
5684 n_points_per_direction *
5685 n_points_per_direction +
5687 local_vertex_order.emplace_back(
5689 n_points_per_direction *
5690 n_points_per_direction +
5691 n_points_per_direction + 1);
5692 local_vertex_order.emplace_back(
5694 n_points_per_direction *
5695 n_points_per_direction +
5696 n_points_per_direction);
5697 flush_current_cell();
5708 local_vertex_order.resize(
5711 if constexpr (dim == 0)
5715 "Point-like cells should not be possible "
5716 "when writing higher-order cells."));
5718 else if constexpr (dim == 1)
5722 const unsigned int local_index = i1;
5723 const unsigned int connectivity_index =
5725 .vtk_lexicographic_to_node_index(
5729 local_vertex_order[connectivity_index] = local_index;
5731 flush_current_cell();
5733 else if constexpr (dim == 2)
5738 const unsigned int local_index =
5739 i2 * n_points_per_direction + i1;
5740 const unsigned int connectivity_index =
5742 .vtk_lexicographic_to_node_index(
5746 local_vertex_order[connectivity_index] =
5749 flush_current_cell();
5751 else if constexpr (dim == 3)
5758 const unsigned int local_index =
5759 i3 * n_points_per_direction *
5760 n_points_per_direction +
5761 i2 * n_points_per_direction + i1;
5762 const unsigned int connectivity_index =
5764 .vtk_lexicographic_to_node_index(
5770 local_vertex_order[connectivity_index] =
5774 flush_current_cell();
5782 first_vertex_of_patch +=
5791 vtu_stringize_array(cells,
5797 o <<
" </DataArray>\n";
5817 const auto stringize_cell_offset_and_type_information =
5822 output_precision = out.precision()]() {
5823 std::ostringstream o;
5825 o <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5826 << ascii_or_binary <<
"\">\n";
5828 std::vector<std::int32_t> offsets;
5829 offsets.reserve(n_cells);
5833 std::vector<unsigned int> cell_types;
5834 cell_types.reserve(n_cells);
5836 unsigned int first_vertex_of_patch = 0;
5838 for (
const auto &patch : patches)
5840 const auto vtk_cell_id =
5843 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5845 cell_types.push_back(vtk_cell_id[0]);
5846 first_vertex_of_patch += vtk_cell_id[2];
5847 offsets.push_back(first_vertex_of_patch);
5851 vtu_stringize_array(offsets,
5856 o <<
" </DataArray>\n";
5858 o <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5859 << ascii_or_binary <<
"\">\n";
5861 if (deal_ii_with_zlib &&
5864 std::vector<std::uint8_t> cell_types_uint8_t(cell_types.size());
5865 for (
unsigned int i = 0; i < cell_types.size(); ++i)
5866 cell_types_uint8_t[i] =
static_cast<std::uint8_t
>(cell_types[i]);
5868 vtu_stringize_array(cell_types_uint8_t,
5875 vtu_stringize_array(cell_types,
5882 o <<
" </DataArray>\n";
5892 const auto stringize_nonscalar_data_range =
5898 output_precision = out.precision()](
const Table<2, float> &data_vectors,
5899 const auto &range) {
5900 std::ostringstream o;
5902 const auto first_component = std::get<0>(range);
5903 const auto last_component = std::get<1>(range);
5904 const auto &name = std::get<2>(range);
5905 const bool is_tensor =
5906 (std::get<3>(range) ==
5908 const unsigned int n_components = (is_tensor ? 9 : 3);
5915 AssertThrow((last_component + 1 - first_component <= 9),
5917 "Can't declare a tensor with more than 9 components "
5918 "in VTK/VTU format."));
5922 AssertThrow((last_component + 1 - first_component <= 3),
5924 "Can't declare a vector with more than 3 components "
5925 "in VTK/VTU format."));
5930 o <<
" <DataArray type=\"Float32\" Name=\"";
5936 for (
unsigned int i = first_component; i < last_component; ++i)
5937 o << data_names[i] <<
"__";
5938 o << data_names[last_component];
5941 o <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5942 << ascii_or_binary <<
"\"";
5961 std::vector<float> data;
5962 data.reserve(n_nodes * n_components);
5964 for (
unsigned int n = 0; n < n_nodes; ++n)
5968 switch (last_component - first_component)
5971 data.push_back(data_vectors(first_component, n));
5977 data.push_back(data_vectors(first_component, n));
5978 data.push_back(data_vectors(first_component + 1, n));
5983 data.push_back(data_vectors(first_component, n));
5984 data.push_back(data_vectors(first_component + 1, n));
5985 data.push_back(data_vectors(first_component + 2, n));
5998 const unsigned int size = last_component - first_component + 1;
6002 vtk_data[0][0] = data_vectors(first_component, n);
6007 for (
unsigned int c = 0; c < size; ++c)
6011 vtk_data[ind[0]][ind[1]] =
6012 data_vectors(first_component + c, n);
6018 for (
unsigned int c = 0; c < size; ++c)
6022 vtk_data[ind[0]][ind[1]] =
6023 data_vectors(first_component + c, n);
6034 for (
unsigned int i = 0; i < 3; ++i)
6035 for (
unsigned int j = 0; j < 3; ++j)
6036 data.push_back(vtk_data[i][j]);
6042 o <<
" </DataArray>\n";
6047 const auto stringize_scalar_data_set =
6051 output_precision = out.precision()](
const Table<2, float> &data_vectors,
6052 const unsigned int data_set) {
6053 std::ostringstream o;
6055 o <<
" <DataArray type=\"Float32\" Name=\"" << data_names[data_set]
6056 <<
"\" format=\"" << ascii_or_binary <<
"\"";
6060 o <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6065 const std::vector<float> data(data_vectors[data_set].
begin(),
6066 data_vectors[data_set].
end());
6069 o <<
" </DataArray>\n";
6088 return create_global_data_table<dim, spacedim, float>(patches);
6102 std::move(*create_global_data_table_task.
return_value());
6108 std::vector<bool> data_set_handled(n_data_sets,
false);
6109 for (
const auto &range : nonscalar_data_ranges)
6112 const auto first_component = std::get<0>(range);
6113 const auto last_component = std::get<1>(range);
6114 for (
unsigned int i = first_component; i <= last_component; ++i)
6115 data_set_handled[i] =
true;
6118 return stringize_nonscalar_data_range(data_vectors, range);
6123 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6124 if (data_set_handled[data_set] ==
false)
6127 return stringize_scalar_data_set(data_vectors, data_set);
6133 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
6134 << n_cells <<
"\" >\n";
6135 for (
const auto &s : mesh_tasks.return_values())
6137 out <<
" <PointData Scalars=\"scalars\">\n";
6140 out <<
" </PointData>\n";
6141 out <<
" </Piece>\n";
6155 const std::vector<std::string> &piece_names,
6156 const std::vector<std::string> &data_names,
6158 std::tuple<
unsigned int,
6162 &nonscalar_data_ranges,
6175 unit.second.find(
'\"') == std::string::npos,
6177 "A physical unit you provided, <" + unit.second +
6178 ">, contained a quotation mark character. This is not allowed."));
6181 const unsigned int n_data_sets = data_names.size();
6183 out <<
"<?xml version=\"1.0\"?>\n";
6186 out <<
"#This file was generated by the deal.II library"
6191 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
6192 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
6200 const unsigned int n_metadata =
6202 (flags.
time != std::numeric_limits<double>::lowest() ? 1 : 0));
6204 out <<
" <FieldData>\n";
6209 <<
" <DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
6210 << flags.
cycle <<
"</DataArray>\n";
6212 if (flags.
time != std::numeric_limits<double>::lowest())
6215 <<
" <DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
6216 << flags.
time <<
"</DataArray>\n";
6220 out <<
" </FieldData>\n";
6223 out <<
" <PPointData Scalars=\"scalars\">\n";
6226 std::vector<bool> data_set_written(n_data_sets,
false);
6227 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
6229 const auto first_component = std::get<0>(nonscalar_data_range);
6230 const auto last_component = std::get<1>(nonscalar_data_range);
6231 const bool is_tensor =
6232 (std::get<3>(nonscalar_data_range) ==
6234 const unsigned int n_components = (is_tensor ? 9 : 3);
6241 AssertThrow((last_component + 1 - first_component <= 9),
6243 "Can't declare a tensor with more than 9 components "
6248 Assert((last_component + 1 - first_component <= 3),
6250 "Can't declare a vector with more than 3 components "
6255 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6256 i <= std::get<1>(nonscalar_data_range);
6258 data_set_written[i] =
true;
6262 out <<
" <PDataArray type=\"Float32\" Name=\"";
6264 const std::string &name = std::get<2>(nonscalar_data_range);
6269 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6270 i < std::get<1>(nonscalar_data_range);
6272 out << data_names[i] <<
"__";
6273 out << data_names[std::get<1>(nonscalar_data_range)];
6276 out <<
"\" NumberOfComponents=\"" << n_components
6277 <<
"\" format=\"ascii\"";
6289 data_names[std::get<1>(nonscalar_data_range)]) !=
6293 data_names[std::get<1>(nonscalar_data_range)])
6301 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6302 if (data_set_written[data_set] ==
false)
6304 out <<
" <PDataArray type=\"Float32\" Name=\""
6305 << data_names[data_set] <<
"\" format=\"ascii\"";
6309 out <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6315 out <<
" </PPointData>\n";
6317 out <<
" <PPoints>\n";
6318 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
6319 out <<
" </PPoints>\n";
6321 for (
const auto &piece_name : piece_names)
6322 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
6324 out <<
" </PUnstructuredGrid>\n";
6325 out <<
"</VTKFile>\n";
6338 const std::vector<std::pair<double, std::string>> ×_and_names)
6342 out <<
"<?xml version=\"1.0\"?>\n";
6345 out <<
"#This file was generated by the deal.II library"
6350 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
6351 out <<
" <Collection>\n";
6353 std::streamsize ss = out.precision();
6356 for (
const auto &time_and_name : times_and_names)
6357 out <<
" <DataSet timestep=\"" << time_and_name.first
6358 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
6361 out <<
" </Collection>\n";
6362 out <<
"</VTKFile>\n";
6374 const std::vector<std::string> &piece_names)
6376 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
6377 for (
const auto &piece_name : piece_names)
6378 out << piece_name <<
'\n';
6387 const std::vector<std::vector<std::string>> &piece_names)
6391 if (piece_names.empty())
6394 const double nblocks = piece_names[0].size();
6396 ExcMessage(
"piece_names should be a vector of nonempty vectors."));
6398 out <<
"!NBLOCKS " << nblocks <<
'\n';
6399 for (
const auto &domain : piece_names)
6401 Assert(domain.size() == nblocks,
6403 "piece_names should be a vector of equal sized vectors."));
6404 for (
const auto &subdomain : domain)
6405 out << subdomain <<
'\n';
6416 const std::vector<std::pair<
double, std::vector<std::string>>>
6417 ×_and_piece_names)
6421 if (times_and_piece_names.empty())
6424 const double nblocks = times_and_piece_names[0].second.size();
6428 "time_and_piece_names should contain nonempty vectors of filenames for every timestep."));
6430 for (
const auto &domain : times_and_piece_names)
6431 out <<
"!TIME " << domain.first <<
'\n';
6433 out <<
"!NBLOCKS " << nblocks <<
'\n';
6434 for (
const auto &domain : times_and_piece_names)
6436 Assert(domain.second.size() == nblocks,
6438 "piece_names should be a vector of equal sized vectors."));
6439 for (
const auto &subdomain : domain.second)
6440 out << subdomain <<
'\n';
6448 template <
int dim,
int spacedim>
6452 const std::vector<std::string> &,
6454 std::tuple<
unsigned int,
6464 template <
int spacedim>
6468 const std::vector<std::string> & ,
6470 std::tuple<
unsigned int,
6479 unsigned int width = flags.
width;
6482 unsigned int margin_in_percent = 0;
6484 margin_in_percent = 5;
6488 double x_dimension, y_dimension, z_dimension;
6490 const auto &first_patch = patches[0];
6494 const unsigned int d1 = 1;
6495 const unsigned int d2 = n;
6498 std::array<Point<spacedim>, 4> projected_points;
6501 std::array<Point<2>, 4> projection_decompositions;
6506 if (first_patch.data.n_rows() != 0)
6511 double x_min = projected_point[0];
6512 double x_max = x_min;
6513 double y_min = projected_point[1];
6514 double y_max = y_min;
6515 double z_min = first_patch.data.n_rows() != 0 ?
6518 double z_max = z_min;
6521 for (
const auto &patch : patches)
6530 projected_points[0] =
6532 projected_points[1] =
6534 projected_points[2] =
6536 projected_points[3] = get_equispaced_location(patch,
6540 x_min =
std::min(x_min, projected_points[0][0]);
6541 x_min =
std::min(x_min, projected_points[1][0]);
6542 x_min =
std::min(x_min, projected_points[2][0]);
6543 x_min =
std::min(x_min, projected_points[3][0]);
6545 x_max =
std::max(x_max, projected_points[0][0]);
6546 x_max =
std::max(x_max, projected_points[1][0]);
6547 x_max =
std::max(x_max, projected_points[2][0]);
6548 x_max =
std::max(x_max, projected_points[3][0]);
6550 y_min =
std::min(y_min, projected_points[0][1]);
6551 y_min =
std::min(y_min, projected_points[1][1]);
6552 y_min =
std::min(y_min, projected_points[2][1]);
6553 y_min =
std::min(y_min, projected_points[3][1]);
6555 y_max =
std::max(y_max, projected_points[0][1]);
6556 y_max =
std::max(y_max, projected_points[1][1]);
6557 y_max =
std::max(y_max, projected_points[2][1]);
6558 y_max =
std::max(y_max, projected_points[3][1]);
6561 patch.
data.n_rows() == 0,
6564 patch.
data.n_rows()));
6568 i1 * d1 + i2 * d2));
6571 (i1 + 1) * d1 + i2 * d2));
6574 i1 * d1 + (i2 + 1) * d2));
6578 (i1 + 1) * d1 + (i2 + 1) * d2));
6582 i1 * d1 + i2 * d2));
6585 (i1 + 1) * d1 + i2 * d2));
6588 i1 * d1 + (i2 + 1) * d2));
6592 (i1 + 1) * d1 + (i2 + 1) * d2));
6597 x_dimension = x_max - x_min;
6598 y_dimension = y_max - y_min;
6599 z_dimension = z_max - z_min;
6606 float camera_focus = 0;
6609 camera_position[0] = 0.;
6610 camera_position[1] = 0.;
6611 camera_position[2] = z_min + 2. * z_dimension;
6613 camera_direction[0] = 0.;
6614 camera_direction[1] = 0.;
6615 camera_direction[2] = -1.;
6617 camera_horizontal[0] = 1.;
6618 camera_horizontal[1] = 0.;
6619 camera_horizontal[2] = 0.;
6621 camera_focus = .5 * z_dimension;
6627 const float angle_factor = 3.14159265f / 180.f;
6630 camera_position_temp[1] =
6633 camera_position_temp[2] =
6637 camera_direction_temp[1] =
6640 camera_direction_temp[2] =
6644 camera_horizontal_temp[1] =
6647 camera_horizontal_temp[2] =
6651 camera_position[1] = camera_position_temp[1];
6652 camera_position[2] = camera_position_temp[2];
6654 camera_direction[1] = camera_direction_temp[1];
6655 camera_direction[2] = camera_direction_temp[2];
6657 camera_horizontal[1] = camera_horizontal_temp[1];
6658 camera_horizontal[2] = camera_horizontal_temp[2];
6661 camera_position_temp[0] =
6664 camera_position_temp[1] =
6668 camera_direction_temp[0] =
6671 camera_direction_temp[1] =
6675 camera_horizontal_temp[0] =
6678 camera_horizontal_temp[1] =
6682 camera_position[0] = camera_position_temp[0];
6683 camera_position[1] = camera_position_temp[1];
6685 camera_direction[0] = camera_direction_temp[0];
6686 camera_direction[1] = camera_direction_temp[1];
6688 camera_horizontal[0] = camera_horizontal_temp[0];
6689 camera_horizontal[1] = camera_horizontal_temp[1];
6692 camera_position[0] = x_min + .5 * x_dimension;
6693 camera_position[1] = y_min + .5 * y_dimension;
6695 camera_position[0] += (z_min + 2. * z_dimension) *
6698 camera_position[1] -= (z_min + 2. * z_dimension) *
6704 double x_min_perspective, y_min_perspective;
6705 double x_max_perspective, y_max_perspective;
6706 double x_dimension_perspective, y_dimension_perspective;
6716 if (first_patch.data.n_rows() != 0)
6721 point[0] = projected_point[0];
6722 point[1] = projected_point[1];
6723 point[2] = first_patch.data.n_rows() != 0 ?
6727 projection_decomposition = svg_project_point(point,
6733 x_min_perspective = projection_decomposition[0];
6734 x_max_perspective = projection_decomposition[0];
6735 y_min_perspective = projection_decomposition[1];
6736 y_max_perspective = projection_decomposition[1];
6739 for (
const auto &patch : patches)
6746 const std::array<Point<spacedim>, 4> projected_vertices{
6750 get_equispaced_location(patch,
6755 patch.
data.n_rows() == 0,
6758 patch.
data.n_rows()));
6760 const std::array<Point<3>, 4> vertices = {
6761 {
Point<3>{projected_vertices[0][0],
6762 projected_vertices[0][1],
6763 patch.
data.n_rows() != 0 ?
6764 patch.
data(0, i1 * d1 + i2 * d2) :
6767 projected_vertices[1][1],
6768 patch.
data.n_rows() != 0 ?
6769 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6772 projected_vertices[2][1],
6773 patch.
data.n_rows() != 0 ?
6774 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6777 projected_vertices[3][1],
6778 patch.
data.n_rows() != 0 ?
6779 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6782 projection_decompositions = {
6783 {svg_project_point(vertices[0],
6788 svg_project_point(vertices[1],
6793 svg_project_point(vertices[2],
6798 svg_project_point(vertices[3],
6806 static_cast<double>(
6807 projection_decompositions[0][0]));
6810 static_cast<double>(
6811 projection_decompositions[1][0]));
6814 static_cast<double>(
6815 projection_decompositions[2][0]));
6818 static_cast<double>(
6819 projection_decompositions[3][0]));
6823 static_cast<double>(
6824 projection_decompositions[0][0]));
6827 static_cast<double>(
6828 projection_decompositions[1][0]));
6831 static_cast<double>(
6832 projection_decompositions[2][0]));
6835 static_cast<double>(
6836 projection_decompositions[3][0]));
6840 static_cast<double>(
6841 projection_decompositions[0][1]));
6844 static_cast<double>(
6845 projection_decompositions[1][1]));
6848 static_cast<double>(
6849 projection_decompositions[2][1]));
6852 static_cast<double>(
6853 projection_decompositions[3][1]));
6857 static_cast<double>(
6858 projection_decompositions[0][1]));
6861 static_cast<double>(
6862 projection_decompositions[1][1]));
6865 static_cast<double>(
6866 projection_decompositions[2][1]));
6869 static_cast<double>(
6870 projection_decompositions[3][1]));
6875 x_dimension_perspective = x_max_perspective - x_min_perspective;
6876 y_dimension_perspective = y_max_perspective - y_min_perspective;
6878 std::multiset<SvgCell> cells;
6881 for (
const auto &patch : patches)
6889 const std::array<Point<spacedim>, 4> projected_vertices = {
6893 get_equispaced_location(patch,
6898 patch.
data.n_rows() == 0,
6901 patch.
data.n_rows()));
6905 cell.vertices[0][0] = projected_vertices[0][0];
6906 cell.vertices[0][1] = projected_vertices[0][1];
6907 cell.vertices[0][2] = patch.
data.n_rows() != 0 ?
6908 patch.
data(0, i1 * d1 + i2 * d2) :
6911 cell.vertices[1][0] = projected_vertices[1][0];
6912 cell.vertices[1][1] = projected_vertices[1][1];
6913 cell.vertices[1][2] = patch.
data.n_rows() != 0 ?
6914 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6917 cell.vertices[2][0] = projected_vertices[2][0];
6918 cell.vertices[2][1] = projected_vertices[2][1];
6919 cell.vertices[2][2] = patch.
data.n_rows() != 0 ?
6920 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6923 cell.vertices[3][0] = projected_vertices[3][0];
6924 cell.vertices[3][1] = projected_vertices[3][1];
6925 cell.vertices[3][2] =
6926 patch.
data.n_rows() != 0 ?
6927 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6930 cell.projected_vertices[0] =
6931 svg_project_point(cell.vertices[0],
6936 cell.projected_vertices[1] =
6937 svg_project_point(cell.vertices[1],
6942 cell.projected_vertices[2] =
6943 svg_project_point(cell.vertices[2],
6948 cell.projected_vertices[3] =
6949 svg_project_point(cell.vertices[3],
6955 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] +
6956 cell.vertices[2] + cell.vertices[3]);
6957 cell.projected_center = svg_project_point(cell.center,
6963 cell.depth = cell.center.distance(camera_position);
6973 width =
static_cast<unsigned int>(
6974 .5 +
height * (x_dimension_perspective / y_dimension_perspective));
6975 unsigned int additional_width = 0;
6978 additional_width =
static_cast<unsigned int>(
6982 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\""
6983 <<
height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
6985 <<
" <rect width=\"" << width + additional_width <<
"\" height=\""
6986 <<
height <<
"\" style=\"fill:white\"/>" <<
'\n'
6989 unsigned int triangle_counter = 0;
6992 for (
const auto &cell : cells)
6996 for (
unsigned int triangle_index = 0; triangle_index < 4;
6999 switch (triangle_index)
7002 points3d_triangle[0] = cell.vertices[0],
7003 points3d_triangle[1] = cell.vertices[1],
7004 points3d_triangle[2] = cell.center;
7007 points3d_triangle[0] = cell.vertices[1],
7008 points3d_triangle[1] = cell.vertices[3],
7009 points3d_triangle[2] = cell.center;
7012 points3d_triangle[0] = cell.vertices[3],
7013 points3d_triangle[1] = cell.vertices[2],
7014 points3d_triangle[2] = cell.center;
7017 points3d_triangle[0] = cell.vertices[2],
7018 points3d_triangle[1] = cell.vertices[0],
7019 points3d_triangle[2] = cell.center;
7026 svg_get_gradient_parameters(points3d_triangle);
7029 .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
7031 .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
7033 unsigned int start_r = 0;
7034 unsigned int start_g = 0;
7035 unsigned int start_b = 0;
7037 unsigned int stop_r = 0;
7038 unsigned int stop_g = 0;
7039 unsigned int stop_b = 0;
7041 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
7042 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
7044 double start_f = start_h * 6. - start_i;
7045 double start_q = 1. - start_f;
7047 double stop_f = stop_h * 6. - stop_i;
7048 double stop_q = 1. - stop_f;
7050 switch (start_i % 6)
7054 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
7057 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
7062 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
7065 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
7069 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7074 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7084 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7087 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7092 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7095 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7099 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7104 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7110 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
7112 gradient_start_point_3d[0] = gradient_param[0];
7113 gradient_start_point_3d[1] = gradient_param[1];
7114 gradient_start_point_3d[2] = gradient_param[4];
7116 gradient_stop_point_3d[0] = gradient_param[2];
7117 gradient_stop_point_3d[1] = gradient_param[3];
7118 gradient_stop_point_3d[2] = gradient_param[5];
7121 svg_project_point(gradient_start_point_3d,
7127 svg_project_point(gradient_stop_point_3d,
7134 out <<
" <linearGradient id=\"" << triangle_counter
7135 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7137 <<
static_cast<unsigned int>(
7139 ((gradient_start_point[0] - x_min_perspective) /
7140 x_dimension_perspective) *
7141 (width - (width / 100.) * 2. * margin_in_percent) +
7142 ((width / 100.) * margin_in_percent))
7145 <<
static_cast<unsigned int>(
7147 ((gradient_start_point[1] - y_min_perspective) /
7148 y_dimension_perspective) *
7152 <<
static_cast<unsigned int>(
7154 ((gradient_stop_point[0] - x_min_perspective) /
7155 x_dimension_perspective) *
7156 (width - (width / 100.) * 2. * margin_in_percent) +
7157 ((width / 100.) * margin_in_percent))
7160 <<
static_cast<unsigned int>(
7162 ((gradient_stop_point[1] - y_min_perspective) /
7163 y_dimension_perspective) *
7167 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7168 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7169 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7170 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7171 <<
" </linearGradient>" <<
'\n';
7174 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
7175 double x3 = cell.projected_center[0];
7176 double y3 = cell.projected_center[1];
7178 switch (triangle_index)
7181 x1 = cell.projected_vertices[0][0],
7182 y1 = cell.projected_vertices[0][1],
7183 x2 = cell.projected_vertices[1][0],
7184 y2 = cell.projected_vertices[1][1];
7187 x1 = cell.projected_vertices[1][0],
7188 y1 = cell.projected_vertices[1][1],
7189 x2 = cell.projected_vertices[3][0],
7190 y2 = cell.projected_vertices[3][1];
7193 x1 = cell.projected_vertices[3][0],
7194 y1 = cell.projected_vertices[3][1],
7195 x2 = cell.projected_vertices[2][0],
7196 y2 = cell.projected_vertices[2][1];
7199 x1 = cell.projected_vertices[2][0],
7200 y1 = cell.projected_vertices[2][1],
7201 x2 = cell.projected_vertices[0][0],
7202 y2 = cell.projected_vertices[0][1];
7208 out <<
" <path d=\"M "
7209 <<
static_cast<unsigned int>(
7211 ((x1 - x_min_perspective) / x_dimension_perspective) *
7212 (width - (width / 100.) * 2. * margin_in_percent) +
7213 ((width / 100.) * margin_in_percent))
7215 <<
static_cast<unsigned int>(
7217 ((y1 - y_min_perspective) / y_dimension_perspective) *
7220 <<
static_cast<unsigned int>(
7222 ((x2 - x_min_perspective) / x_dimension_perspective) *
7223 (width - (width / 100.) * 2. * margin_in_percent) +
7224 ((width / 100.) * margin_in_percent))
7226 <<
static_cast<unsigned int>(
7228 ((y2 - y_min_perspective) / y_dimension_perspective) *
7231 <<
static_cast<unsigned int>(
7233 ((x3 - x_min_perspective) / x_dimension_perspective) *
7234 (width - (width / 100.) * 2. * margin_in_percent) +
7235 ((width / 100.) * margin_in_percent))
7237 <<
static_cast<unsigned int>(
7239 ((y3 - y_min_perspective) / y_dimension_perspective) *
7242 <<
static_cast<unsigned int>(
7244 ((x1 - x_min_perspective) / x_dimension_perspective) *
7245 (width - (width / 100.) * 2. * margin_in_percent) +
7246 ((width / 100.) * margin_in_percent))
7248 <<
static_cast<unsigned int>(
7250 ((y1 - y_min_perspective) / y_dimension_perspective) *
7252 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter
7263 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
7265 unsigned int element_height =
static_cast<unsigned int>(
7266 ((
height / 100.) * (71. - 2. * margin_in_percent)) / 4);
7267 unsigned int element_width =
7268 static_cast<unsigned int>(.5 + (
height / 100.) * 2.5);
7270 additional_width = 0;
7273 static_cast<unsigned int>(.5 + (
height / 100.) * 2.5);
7275 for (
unsigned int index = 0; index < 4; ++index)
7277 double start_h = .667 - ((index + 1) / 4.) * .667;
7278 double stop_h = .667 - (index / 4.) * .667;
7280 unsigned int start_r = 0;
7281 unsigned int start_g = 0;
7282 unsigned int start_b = 0;
7284 unsigned int stop_r = 0;
7285 unsigned int stop_g = 0;
7286 unsigned int stop_b = 0;
7288 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
7289 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
7291 double start_f = start_h * 6. - start_i;
7292 double start_q = 1. - start_f;
7294 double stop_f = stop_h * 6. - stop_i;
7295 double stop_q = 1. - stop_f;
7297 switch (start_i % 6)
7301 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
7304 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
7309 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
7312 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
7316 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
7321 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
7331 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
7334 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
7339 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
7342 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
7346 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
7351 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
7358 out <<
" <linearGradient id=\"colorbar_" << index
7359 <<
"\" gradientUnits=\"userSpaceOnUse\" "
7360 <<
"x1=\"" << width + additional_width <<
"\" "
7362 <<
static_cast<unsigned int>(.5 + (
height / 100.) *
7363 (margin_in_percent + 29)) +
7364 (3 - index) * element_height
7366 <<
"x2=\"" << width + additional_width <<
"\" "
7368 <<
static_cast<unsigned int>(.5 + (
height / 100.) *
7369 (margin_in_percent + 29)) +
7370 (4 - index) * element_height
7373 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
7374 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
7375 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7376 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7377 <<
" </linearGradient>" <<
'\n';
7382 <<
" x=\"" << width + additional_width <<
"\" y=\""
7383 <<
static_cast<unsigned int>(.5 + (
height / 100.) *
7384 (margin_in_percent + 29)) +
7385 (3 - index) * element_height
7386 <<
"\" width=\"" << element_width <<
"\" height=\""
7388 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_"
7389 << index <<
")\"/>" <<
'\n';
7392 for (
unsigned int index = 0; index < 5; ++index)
7396 << width + additional_width +
7397 static_cast<unsigned int>(1.5 * element_width)
7399 <<
static_cast<unsigned int>(
7400 .5 + (
height / 100.) * (margin_in_percent + 29) +
7401 (4. - index) * element_height + 30.)
7403 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
7405 if (index == 0 || index == 4)
7406 out <<
"; font-weight:bold";
7409 <<
static_cast<float>(
7410 (
static_cast<int>((z_min + index * (z_dimension / 4.)) *
7419 out <<
"</text>" <<
'\n';
7424 out <<
'\n' <<
"</svg>";
7430 template <
int dim,
int spacedim>
7434 const std::vector<std::string> &data_names,
7436 std::tuple<
unsigned int,
7440 &nonscalar_data_ranges,
7449 out << dim <<
' ' << spacedim <<
'\n';
7452 out <<
"[deal.II intermediate format graphics data]" <<
'\n'
7458 out << data_names.size() <<
'\n';
7459 for (
const auto &data_name : data_names)
7460 out << data_name <<
'\n';
7462 out << patches.size() <<
'\n';
7463 for (
unsigned int i = 0; i < patches.size(); ++i)
7464 out << patches[i] <<
'\n';
7466 out << nonscalar_data_ranges.size() <<
'\n';
7467 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
7468 out << std::get<0>(nonscalar_data_range) <<
' '
7469 << std::get<1>(nonscalar_data_range) <<
'\n'
7470 << std::get<2>(nonscalar_data_range) <<
'\n';
7478 template <
int dim,
int spacedim>
7482 const std::vector<std::string> &data_names,
7484 std::tuple<
unsigned int,
7488 &nonscalar_data_ranges,
7490 const std::string &filename,
7494#ifndef DEAL_II_WITH_MPI
7497 (void)nonscalar_data_ranges;
7504 ExcMessage(
"This functionality requires MPI to be enabled."));
7523 std::vector<char> my_buffer;
7525 boost::iostreams::filtering_ostream f;
7531# ifdef DEAL_II_WITH_ZLIB
7532 f.push(boost::iostreams::zlib_compressor(
7533 get_boost_zlib_compression_level(compression)));
7538 "Compression requires deal.II to be configured with ZLIB support."));
7541 boost::iostreams::back_insert_device<std::vector<char>> inserter(
7546 patches, data_names, nonscalar_data_ranges, flags, f);
7548 const std::uint64_t my_size = my_buffer.size();
7554 const ParallelIntermediateHeader header{
7557 static_cast<std::uint64_t
>(compression),
7567 std::vector<std::uint64_t> chunk_sizes(n_ranks);
7568 int ierr = MPI_Gather(&my_size,
7571 static_cast<std::uint64_t *
>(chunk_sizes.data()),
7579 ierr = MPI_Info_create(&info);
7582 ierr = MPI_File_open(
7583 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7585 ierr = MPI_Info_free(&info);
7589 ierr = MPI_File_set_size(fh, 0);
7593 ierr = MPI_Barrier(
comm);
7600 fh, 0, &header,
sizeof(header), MPI_CHAR, MPI_STATUS_IGNORE);
7615 std::uint64_t prefix_sum = 0;
7616 ierr = MPI_Exscan(&my_size,
7625 const MPI_Offset offset =
static_cast<MPI_Offset
>(
sizeof(header)) +
7626 n_ranks *
sizeof(std::uint64_t) + prefix_sum;
7629 fh, offset, my_buffer.data(), my_size, MPI_CHAR, MPI_STATUS_IGNORE);
7638 ierr = MPI_File_sync(fh);
7641 ierr = MPI_File_close(&fh);
7648 std::pair<unsigned int, unsigned int>
7653 unsigned int dim, spacedim;
7654 input >> dim >> spacedim;
7656 return std::make_pair(dim, spacedim);
7665template <
int dim,
int spacedim>
7673template <
int dim,
int spacedim>
7686template <
int dim,
int spacedim>
7699template <
int dim,
int spacedim>
7712template <
int dim,
int spacedim>
7725template <
int dim,
int spacedim>
7738template <
int dim,
int spacedim>
7751template <
int dim,
int spacedim>
7764template <
int dim,
int spacedim>
7775template <
int dim,
int spacedim>
7786template <
int dim,
int spacedim>
7798template <
int dim,
int spacedim>
7801 const std::string &filename,
7804#ifndef DEAL_II_WITH_MPI
7808 std::ofstream f(filename);
7816 int ierr = MPI_Info_create(&info);
7819 ierr = MPI_File_open(
7820 comm, filename.c_str(), MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
7823 ierr = MPI_File_set_size(fh, 0);
7827 ierr = MPI_Barrier(
comm);
7829 ierr = MPI_Info_free(&info);
7833 unsigned int header_size;
7834 std::uint64_t footer_offset;
7839 std::stringstream ss;
7841 header_size = ss.str().size();
7844 fh, 0, ss.str().c_str(), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
7848 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0,
comm);
7861 std::stringstream ss;
7862 if (my_n_patches > 0 || (global_n_patches == 0 && myrank == 0))
7870 const std::uint64_t size_on_proc = ss.str().size();
7871 std::uint64_t prefix_sum = 0;
7872 ierr = MPI_Exscan(&size_on_proc,
7881 const MPI_Offset offset =
static_cast<MPI_Offset
>(header_size) + prefix_sum;
7891 if (myrank == n_ranks - 1)
7894 footer_offset = size_on_proc + offset;
7896 std::stringstream ss;
7898 const unsigned int footer_size = ss.str().size();
7916 ierr = MPI_File_sync(fh);
7919 ierr = MPI_File_close(&fh);
7926template <
int dim,
int spacedim>
7930 const std::vector<std::string> &piece_names)
const
7941template <
int dim,
int spacedim>
7944 const std::string &directory,
7945 const std::string &filename_without_extension,
7946 const unsigned int counter,
7948 const unsigned int n_digits_for_counter,
7949 const unsigned int n_groups)
const
7952 const unsigned int n_ranks =
7954 const unsigned int n_files_written =
7955 (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
7960 const unsigned int n_digits =
7963 const unsigned int color = rank % n_files_written;
7964 const std::string filename =
7965 directory + filename_without_extension +
"_" +
7969 if (n_groups == 0 || n_groups > n_ranks)
7972 std::ofstream output(filename);
7976 else if (n_groups == 1)
7983#ifdef DEAL_II_WITH_MPI
7986 int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group);
7996 const std::string pvtu_filename =
7997 filename_without_extension +
"_" +
8002 std::vector<std::string> filename_vector;
8003 for (
unsigned int i = 0; i < n_files_written; ++i)
8005 const std::string filename =
8006 filename_without_extension +
"_" +
8010 filename_vector.emplace_back(filename);
8013 std::ofstream pvtu_output(directory + pvtu_filename);
8017 return pvtu_filename;
8022template <
int dim,
int spacedim>
8025 std::ostream &out)
const
8036template <
int dim,
int spacedim>
8039 const std::string &filename,
8055template <
int dim,
int spacedim>
8059 const std::string &h5_filename,
8060 const double cur_time,
8064 data_filter, h5_filename, h5_filename, cur_time,
comm);
8069template <
int dim,
int spacedim>
8073 const std::string &h5_mesh_filename,
8074 const std::string &h5_solution_filename,
8075 const double cur_time,
8079 ExcMessage(
"XDMF only supports 2 or 3 space dimensions."));
8081#ifndef DEAL_II_WITH_HDF5
8085 (void)h5_mesh_filename;
8086 (void)h5_solution_filename;
8095 std::uint64_t local_node_cell_count[2], global_node_cell_count[2];
8097 local_node_cell_count[0] = data_filter.
n_nodes();
8098 local_node_cell_count[1] = data_filter.
n_cells();
8102 int ierr = MPI_Allreduce(local_node_cell_count,
8103 global_node_cell_count,
8117 const bool have_data = (data_filter.
n_nodes() > 0);
8120 const int key = myrank;
8121 const int color = (have_data ? 1 : 0);
8122 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8126 const bool am_i_first_rank_with_data =
8129 ierr = MPI_Comm_free(&split_comm);
8132 const int tag = 47381;
8135 if (am_i_first_rank_with_data)
8143 for (
const auto &patch : patches)
8149 h5_solution_filename,
8151 global_node_cell_count[0],
8152 global_node_cell_count[1],
8155 patches[0].reference_cell);
8156 const unsigned int n_data_sets = data_filter.
n_data_sets();
8160 for (
unsigned int i = 0; i < n_data_sets; ++i)
8170 ierr = MPI_Send(buffer.data(), buffer.size(), MPI_BYTE, 0, tag,
comm);
8179 if (myrank == 0 && !am_i_first_rank_with_data)
8184 int ierr = MPI_Probe(MPI_ANY_SOURCE, tag,
comm, &status);
8188 ierr = MPI_Get_count(&status, MPI_BYTE, &len);
8191 std::vector<char> buffer(len);
8192 ierr = MPI_Recv(buffer.data(),
8209template <
int dim,
int spacedim>
8212 const std::vector<XDMFEntry> &entries,
8213 const std::string &filename,
8216#ifdef DEAL_II_WITH_MPI
8220 const int myrank = 0;
8226 std::ofstream xdmf_file(filename);
8228 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
8229 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
8230 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
8231 xdmf_file <<
" <Domain>\n";
8233 <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
8235 for (
const auto &entry : entries)
8237 xdmf_file << entry.get_xdmf_content(3);
8240 xdmf_file <<
" </Grid>\n";
8241 xdmf_file <<
" </Domain>\n";
8242 xdmf_file <<
"</Xdmf>\n";
8254template <
int dim,
int spacedim>
8268#if defined(DEAL_II_WITH_HDF5) || defined(DEAL_II_WITH_NETCDF)
8272 struct DistributedMeshSizes
8274 uint64_t n_nodes_local;
8275 uint64_t n_cells_local;
8276 uint64_t n_nodes_global;
8277 uint64_t n_cells_global;
8278 uint64_t offset_nodes;
8279 uint64_t offset_cells;
8287 DistributedMeshSizes
8288 compute_global_mesh_size(
const uint64_t n_nodes_local,
8289 const uint64_t n_cells_local,
8292 const uint64_t n_local[2] = {n_nodes_local, n_cells_local};
8293 uint64_t n_global[2];
8294 uint64_t offsets[2] = {0, 0};
8296# ifdef DEAL_II_WITH_MPI
8298 MPI_Allreduce(n_local,
8314 n_global[0] = n_local[0];
8315 n_global[1] = n_local[1];
8321 n_local[0], n_local[1], n_global[0], n_global[1], offsets[0], offsets[1]};
8326#ifdef DEAL_II_WITH_HDF5
8330 template <
int dim,
int spacedim>
8335 const bool write_mesh_file,
8336 const std::string &mesh_filename,
8337 const std::string &solution_filename,
8340 hid_t h5_mesh_file_id = -1, h5_solution_file_id, file_plist_id, plist_id;
8341 hid_t node_dataspace, node_dataset, node_file_dataspace,
8342 node_memory_dataspace, node_dataset_id;
8343 hid_t cell_dataspace, cell_dataset, cell_file_dataspace,
8344 cell_memory_dataspace;
8345 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace,
8346 pt_data_memory_dataspace;
8348 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
8349 std::vector<double> node_data_vec;
8350 std::vector<unsigned int> cell_data_vec;
8353 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
8356# ifdef DEAL_II_WITH_MPI
8357# ifdef H5_HAVE_PARALLEL
8359 status = H5Pset_fapl_mpio(file_plist_id,
comm, MPI_INFO_NULL);
8364# ifndef DEAL_II_WITH_ZLIB
8370 const DistributedMeshSizes mesh_sizes =
8371 compute_global_mesh_size(data_filter.
n_nodes(),
8376 plist_id = H5Pcreate(H5P_DATASET_XFER);
8378# ifdef DEAL_II_WITH_MPI
8379# ifdef H5_HAVE_PARALLEL
8380 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
8385 if (write_mesh_file)
8388 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(),
8396 node_ds_dim[0] = mesh_sizes.n_nodes_global;
8397 node_ds_dim[1] = (spacedim < 2) ? 2 : spacedim;
8398 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8401 cell_ds_dim[0] = mesh_sizes.n_cells_global;
8402 cell_ds_dim[1] = patches[0].reference_cell.n_vertices();
8403 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
8407# if H5Gcreate_vers == 1
8408 node_dataset = H5Dcreate(h5_mesh_file_id,
8414 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8415# ifdef DEAL_II_WITH_ZLIB
8416 H5Pset_deflate(node_dataset_id,
8418 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8420 node_dataset = H5Dcreate(h5_mesh_file_id,
8427 H5Pclose(node_dataset_id);
8430# if H5Gcreate_vers == 1
8431 cell_dataset = H5Dcreate(h5_mesh_file_id,
8437 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8438# ifdef DEAL_II_WITH_ZLIB
8439 H5Pset_deflate(node_dataset_id,
8441 H5Pset_chunk(node_dataset_id, 2, cell_ds_dim);
8443 cell_dataset = H5Dcreate(h5_mesh_file_id,
8450 H5Pclose(node_dataset_id);
8455 status = H5Sclose(node_dataspace);
8457 status = H5Sclose(cell_dataspace);
8462 count[0] = mesh_sizes.n_nodes_local;
8463 count[1] = (spacedim < 2) ? 2 : spacedim;
8465 offset[0] = mesh_sizes.offset_nodes;
8468 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8472 node_file_dataspace = H5Dget_space(node_dataset);
8474 status = H5Sselect_hyperslab(
8475 node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8479 count[0] = mesh_sizes.n_cells_local;
8480 count[1] = patches[0].reference_cell.n_vertices();
8481 offset[0] = mesh_sizes.offset_cells;
8483 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8486 cell_file_dataspace = H5Dget_space(cell_dataset);
8488 status = H5Sselect_hyperslab(
8489 cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
8494 status = H5Dwrite(node_dataset,
8496 node_memory_dataspace,
8497 node_file_dataspace,
8499 node_data_vec.data());
8501 node_data_vec.clear();
8504 data_filter.
fill_cell_data(mesh_sizes.offset_nodes, cell_data_vec);
8505 status = H5Dwrite(cell_dataset,
8507 cell_memory_dataspace,
8508 cell_file_dataspace,
8510 cell_data_vec.data());
8512 cell_data_vec.clear();
8515 status = H5Sclose(node_file_dataspace);
8517 status = H5Sclose(cell_file_dataspace);
8521 status = H5Sclose(node_memory_dataspace);
8523 status = H5Sclose(cell_memory_dataspace);
8527 status = H5Dclose(node_dataset);
8529 status = H5Dclose(cell_dataset);
8533 if (mesh_filename != solution_filename)
8535 status = H5Fclose(h5_mesh_file_id);
8541 if (mesh_filename == solution_filename && write_mesh_file)
8543 h5_solution_file_id = h5_mesh_file_id;
8548 h5_solution_file_id = H5Fcreate(solution_filename.c_str(),
8558 std::string vector_name;
8567 node_ds_dim[0] = mesh_sizes.n_nodes_global;
8568 node_ds_dim[1] = pt_data_vector_dim;
8569 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8572# if H5Gcreate_vers == 1
8573 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8574 vector_name.c_str(),
8579 node_dataset_id = H5Pcreate(H5P_DATASET_CREATE);
8580# ifdef DEAL_II_WITH_ZLIB
8581 H5Pset_deflate(node_dataset_id,
8583 H5Pset_chunk(node_dataset_id, 2, node_ds_dim);
8585 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8586 vector_name.c_str(),
8592 H5Pclose(node_dataset_id);
8597 count[0] = mesh_sizes.n_nodes_local;
8598 count[1] = pt_data_vector_dim;
8599 offset[0] = mesh_sizes.offset_nodes;
8601 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8605 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
8607 status = H5Sselect_hyperslab(pt_data_file_dataspace,
8616 status = H5Dwrite(pt_data_dataset,
8618 pt_data_memory_dataspace,
8619 pt_data_file_dataspace,
8625 status = H5Sclose(pt_data_dataspace);
8627 status = H5Sclose(pt_data_memory_dataspace);
8629 status = H5Sclose(pt_data_file_dataspace);
8632 status = H5Dclose(pt_data_dataset);
8637 status = H5Pclose(file_plist_id);
8641 status = H5Pclose(plist_id);
8645 status = H5Fclose(h5_solution_file_id);
8653template <
int dim,
int spacedim>
8657 const std::vector<std::string> &data_names,
8659 std::tuple<
unsigned int,
8663 &nonscalar_data_ranges,
8666 const unsigned int n_data_sets = data_names.size();
8668#ifndef DEAL_II_WITH_MPI
8677 if (patches.empty())
8681 unsigned int n_nodes;
8682 std::tie(n_nodes, std::ignore) = count_nodes_and_cells(patches);
8697 [&patches]() {
return create_global_data_table(patches); });
8705 std::move(*create_global_data_table_task.
return_value());
8709 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
8710 std::string vector_name;
8711 for (n_th_vector = 0, data_set = 0; data_set < n_data_sets;)
8714 while (n_th_vector < nonscalar_data_ranges.size() &&
8715 std::get<0>(nonscalar_data_ranges[n_th_vector]) < data_set)
8719 if (n_th_vector < nonscalar_data_ranges.size() &&
8720 std::get<0>(nonscalar_data_ranges[n_th_vector]) == data_set)
8723 pt_data_vector_dim = std::get<1>(nonscalar_data_ranges[n_th_vector]) -
8724 std::get<0>(nonscalar_data_ranges[n_th_vector]) +
8729 std::get<1>(nonscalar_data_ranges[n_th_vector]) >=
8730 std::get<0>(nonscalar_data_ranges[n_th_vector]),
8731 ExcLowerRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8732 std::get<0>(nonscalar_data_ranges[n_th_vector])));
8734 std::get<1>(nonscalar_data_ranges[n_th_vector]) < n_data_sets,
8735 ExcIndexRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
8741 if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
8743 vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
8748 for (i = std::get<0>(nonscalar_data_ranges[n_th_vector]);
8749 i < std::get<1>(nonscalar_data_ranges[n_th_vector]);
8751 vector_name += data_names[i] +
"__";
8753 data_names[std::get<1>(nonscalar_data_ranges[n_th_vector])];
8759 pt_data_vector_dim = 1;
8760 vector_name = data_names[data_set];
8770 data_set += pt_data_vector_dim;
8776template <
int dim,
int spacedim>
8780 const std::string &filename,
8789template <
int dim,
int spacedim>
8793 const bool write_mesh_file,
8794 const std::string &mesh_filename,
8795 const std::string &solution_filename,
8809template <
int dim,
int spacedim>
8815 const std::string &filename,
8819 patches, data_filter, flags,
true, filename, filename,
comm);
8824template <
int dim,
int spacedim>
8830 const bool write_mesh_file,
8831 const std::string &mesh_filename,
8832 const std::string &solution_filename,
8838 "DataOutBase was asked to write HDF5 output for a space dimension of 1. "
8839 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
8841#ifndef DEAL_II_WITH_HDF5
8847 (void)write_mesh_file;
8848 (void)mesh_filename;
8849 (void)solution_filename;
8858# ifndef H5_HAVE_PARALLEL
8862 "Serial HDF5 output on multiple processes is not yet supported."));
8879 const bool have_patches = (patches.size() > 0);
8883 const int color = (have_patches ? 1 : 0);
8884 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
8890 do_write_hdf5<dim, spacedim>(patches,
8899 const int ierr = MPI_Comm_free(&split_comm);
8907#ifdef DEAL_II_WITH_NETCDF
8920 create(
const std::string &filename,
8921 const int open_mode,
8925 auto ncerr = nc_create_par(
8926 filename.c_str(), open_mode,
comm, MPI_INFO_NULL, &ncfile.ncid);
8937 open(
const std::string &filename,
const int open_mode,
const MPI_Comm
comm)
8940 auto ncerr = nc_open_par(
8941 filename.c_str(), open_mode,
comm, MPI_INFO_NULL, &ncfile.ncid);
8951 operator int()
const
8965 int ncerr = nc_close(ncid);
8967 ExcIO(
"Unexpected error when closing a NetCDF file."));
8990 nc_put_att_var(
const int ncid,
8996 [&](
const auto &v) {
8997 using T = std::remove_cv_t<std::remove_reference_t<
decltype(v)>>;
8998 if constexpr (std::is_same_v<T, std::string>)
9000 return nc_put_att_text(ncid, varid, name, v.size(), v.c_str());
9002 else if constexpr (std::is_same_v<T, double>)
9004 return nc_put_att_double(ncid, varid, name, NC_DOUBLE, 1, &v);
9006 else if constexpr (std::is_same_v<T, int>)
9008 return nc_put_att_int(ncid, varid, name, NC_INT, 1, &v);
9023 template <
class AttrMap = std::initializer_list<
9024 std::pair<std::string, DataOutBase::CFFlags::AttributeValue>>>
9026 write_cf_attributes(
int ncid,
int varid,
const AttrMap &attrs)
9028 for (
const auto &[att_name, att_value] : attrs)
9030 ncerr = nc_put_att_var(ncid, varid, att_name.c_str(), att_value);
9041 write_cf_user_defined_attributes(
int ncid,
9043 const std::string &var_name,
9046 if (
auto it_atts = flags.
attributes.find(var_name);
9049 write_cf_attributes(ncid, varid, it_atts->second);
9058 template <
int spacedim>
9061 std::vector<double> &x,
9062 std::vector<double> &y)
9064 std::vector<double> coords;
9066 x.resize(data_filter.
n_nodes());
9067 y.resize(data_filter.
n_nodes());
9068 for (
unsigned int i = 0; i < data_filter.
n_nodes(); ++i)
9070 x[i] = coords[i * spacedim];
9071 y[i] = coords[i * spacedim + 1];
9080 template <
int dim,
int spacedim>
9085 const std::string &filename,
9086 const DistributedMeshSizes &mesh_sizes,
9092 NcFile::create(filename, NC_WRITE | NC_CLOBBER | NC_NETCDF4,
comm);
9095 write_cf_attributes(
9099 {
"Conventions",
"CF-1.12"},
9101 "Created by the deal.II finite element library (https://dealii.org)."},
9103 write_cf_user_defined_attributes(ncid, flags,
"global", NC_GLOBAL);
9108 Assert(patches.size() > 0,
9112 Assert(std::all_of(patches.begin(),
9114 [ref = patches[0].reference_cell](
const auto &patch) {
9115 return patch.reference_cell == ref;
9118 "Mixed meshes are currently not supported in CF output."));
9122 int dim_node, dim_cell, dim_cell_node;
9123 ncerr = nc_def_dim(ncid,
"node", mesh_sizes.n_nodes_global, &dim_node);
9125 ncerr = nc_def_dim(ncid,
"face", mesh_sizes.n_cells_global, &dim_cell);
9127 int n_nodes_per_cell = patches[0].reference_cell.n_vertices();
9128 ncerr = nc_def_dim(ncid,
"face_node", n_nodes_per_cell, &dim_cell_node);
9134 int var_mesh, var_cell, var_x, var_y;
9135 ncerr = nc_def_var(ncid,
"mesh", NC_INT, 0,
nullptr, &var_mesh);
9137 write_cf_attributes(ncid,
9140 {
"cf_role",
"mesh_topology"},
9141 {
"long_name",
"Topology of a 2-d unstructured mesh"},
9142 {
"topology_dimension", 2},
9143 {
"node_coordinates",
"mesh_node_x mesh_node_y"},
9144 {
"face_node_connectivity",
"mesh_face_nodes"},
9145 {
"face_dimension",
"face"},
9149 int dummy_mesh_value = 0;
9150 ncerr = nc_put_var_int(ncid, var_mesh, &dummy_mesh_value);
9154 const int dims_cells[2] = {dim_cell, dim_cell_node};
9156 nc_def_var(ncid,
"mesh_face_nodes", NC_INT, 2, dims_cells, &var_cell);
9158 write_cf_attributes(ncid,
9161 {
"cf_role",
"face_node_connectivity"},
9162 {
"long_name",
"Corner nodes that make up each face."},
9170 ncerr = nc_def_var(ncid,
"mesh_node_x", NC_DOUBLE, 1, &dim_node, &var_x);
9172 write_cf_attributes(ncid, var_x, {{
"axis",
"X"}});
9173 write_cf_user_defined_attributes(ncid, flags,
"x", var_x);
9174 ncerr = nc_def_var(ncid,
"mesh_node_y", NC_DOUBLE, 1, &dim_node, &var_y);
9176 write_cf_attributes(ncid, var_y, {{
"axis",
"Y"}});
9177 write_cf_user_defined_attributes(ncid, flags,
"y", var_y);
9180 int dim_time, var_time;
9181 if (flags.
time > -std::numeric_limits<double>::infinity())
9183 ncerr = nc_def_dim(ncid,
"time", NC_UNLIMITED, &dim_time);
9185 ncerr = nc_def_var(ncid,
"time", NC_DOUBLE, 1, &dim_time, &var_time);
9187 write_cf_attributes(ncid,
9190 {
"standard_name",
"time"},
9192 {
"long_name",
"Time dimension"},
9194 write_cf_user_defined_attributes(ncid, flags,
"time", var_time);
9198 std::vector<double> x, y;
9199 get_node_coordinates<spacedim>(data_filter, x, y);
9200 const size_t coord_write_start[1] = {(size_t)mesh_sizes.offset_nodes};
9201 const size_t coord_write_count[1] = {(size_t)data_filter.
n_nodes()};
9202 ncerr = nc_put_vara_double(
9203 ncid, var_x, coord_write_start, coord_write_count, x.data());
9205 ncerr = nc_put_vara_double(
9206 ncid, var_y, coord_write_start, coord_write_count, y.data());
9210 std::vector<unsigned int> ucells;
9212 const size_t cell_write_start[2] = {(size_t)mesh_sizes.offset_cells,
9214 const size_t cell_write_count[2] = {(size_t)data_filter.
n_cells(),
9215 (size_t)n_nodes_per_cell};
9216 ncerr = nc_put_vara_uint(
9217 ncid, var_cell, cell_write_start, cell_write_count, ucells.data());
9227 write_cf_time_point(
int ncid,
int dim_time,
int var_time,
double time)
9235 ncerr = nc_var_par_access(ncid, var_time, NC_COLLECTIVE);
9239 ncerr = nc_inq_dimlen(ncid, dim_time, &n_time);
9241 auto times = std::vector<double>(n_time);
9242 ncerr = nc_get_var_double(ncid, var_time, times.data());
9244 const auto it_lb = std::lower_bound(times.begin(), times.end(), time);
9245 index_t = std::distance(times.begin(), it_lb);
9246 const size_t count_t = 1;
9247 ncerr = nc_put_vara_double(ncid, var_time, &index_t, &count_t, &time);
9250 ncerr = nc_var_par_access(ncid, var_time, NC_INDEPENDENT);
9264 const std::string &filename,
9265 const DistributedMeshSizes &mesh_sizes,
9271 const auto ncid = NcFile::open(filename, NC_WRITE | NC_NETCDF4,
comm);
9275 ncerr = nc_inq_dimid(ncid,
"node", &dim_node);
9279 int dim_time = -1, var_time = -1;
9281 const bool has_time = flags.
time > -std::numeric_limits<double>::infinity();
9284 int inq_dim_time = nc_inq_dimid(ncid,
"time", &dim_time);
9285 int inq_var_time = nc_inq_varid(ncid,
"time", &var_time);
9288 const bool has_time_dimension = inq_dim_time != NC_EBADDIM;
9289 const bool has_time_variable = inq_var_time != NC_ENOTVAR;
9290 AssertThrow(has_time_dimension && has_time_variable,
9292 "You are trying to add a time point to an existing file "
9293 "that does not have a time dimension or variable. "
9294 "Check the options in DataOutBase::cf_flags."));
9299 index_t = write_cf_time_point(ncid, dim_time, var_time, flags.
time);
9303 for (
auto dataset_index = 0u; dataset_index < data_filter.
n_data_sets();
9308 "Can only write scalar data in CF files."));
9311 const double *values = data_filter.
get_data_set(dataset_index);
9315 const int inq_var = nc_inq_varid(ncid, key.c_str(), &varid);
9316 if (inq_var == NC_ENOTVAR)
9319 const int var_dims[2] = {dim_time, dim_node};
9320 ncerr = nc_def_var(ncid,
9324 &var_dims[has_time ? 0 : 1],
9327 write_cf_attributes(
9332 {
"location",
"node"},
9334 std::numeric_limits<double>::quiet_NaN()},
9337 write_cf_user_defined_attributes(ncid, flags, key, varid);
9346 ncerr = nc_var_par_access(ncid, varid, NC_COLLECTIVE);
9348 const size_t var_write_start[2] = {index_t,
9349 (size_t)mesh_sizes.offset_nodes};
9350 const size_t var_write_count[2] = {1, (size_t)data_filter.
n_nodes()};
9351 ncerr = nc_put_vara_double(
9354 &var_write_start[has_time ? 0 : 1],
9355 &var_write_count[has_time ? 0 : 1],
9358 ncerr = nc_var_par_access(ncid, varid, NC_INDEPENDENT);
9368template <
int dim,
int spacedim>
9372 const std::string &filename,
9381template <
int dim,
int spacedim>
9386 const std::string &filename,
9393 "DataOutBase can only write CF output in 2 dimensions."));
9396 "Mesh must have codimension 0 for writing CF output."));
9398#ifndef DEAL_II_WITH_NETCDF
9411 int ierr = MPI_Barrier(
comm);
9430 const bool have_patches = (patches.size() > 0);
9434 const int color = (have_patches ? 1 : 0);
9435 const int ierr = MPI_Comm_split(
comm, color, key, &split_comm);
9438 ScopeExit cleanup_on_exit{[&split_comm] {
9439 int ierr = MPI_Comm_free(&split_comm);
9445 const DistributedMeshSizes mesh_sizes =
9446 compute_global_mesh_size(data_filter.
n_nodes(),
9454 mesh_sizes.n_nodes_global < uint64_t(std::numeric_limits<int>::max()),
9455 ExcMessage(
"The mesh has too many vertices to store in CF format."));
9461 patches, data_filter, flags, filename, mesh_sizes, split_comm);
9469 AssertThrow(std::filesystem::is_regular_file(filename),
9470 ExcIO(
"You are trying to write data to an existing file "
9471 "but no file of the given name exists. "
9472 "Create the file with a mesh by setting "
9473 "CFFlags::keep_existing_file = false."));
9478 write_cf_data(data_filter, flags, filename, mesh_sizes, split_comm);
9485template <
int dim,
int spacedim>
9495 switch (output_format)
9551template <
int dim,
int spacedim>
9560template <
int dim,
int spacedim>
9561template <
typename FlagType>
9565 if constexpr (std::is_same_v<FlagType, DataOutBase::DXFlags>)
9567 else if constexpr (std::is_same_v<FlagType, DataOutBase::UcdFlags>)
9569 else if constexpr (std::is_same_v<FlagType, DataOutBase::PovrayFlags>)
9571 else if constexpr (std::is_same_v<FlagType, DataOutBase::EpsFlags>)
9573 else if constexpr (std::is_same_v<FlagType, DataOutBase::GmvFlags>)
9575 else if constexpr (std::is_same_v<FlagType, DataOutBase::Hdf5Flags>)
9577 else if constexpr (std::is_same_v<FlagType, DataOutBase::CFFlags>)
9579 else if constexpr (std::is_same_v<FlagType, DataOutBase::TecplotFlags>)
9581 else if constexpr (std::is_same_v<FlagType, DataOutBase::VtkFlags>)
9583 else if constexpr (std::is_same_v<FlagType, DataOutBase::SvgFlags>)
9585 else if constexpr (std::is_same_v<FlagType, DataOutBase::GnuplotFlags>)
9587 else if constexpr (std::is_same_v<FlagType,
9596template <
int dim,
int spacedim>
9609template <
int dim,
int spacedim>
9616 "A name for the output format to be used");
9620 "Number of subdivisions of each mesh cell");
9666template <
int dim,
int spacedim>
9670 const std::string &output_name = prm.
get(
"Output format");
9717template <
int dim,
int spacedim>
9737template <
int dim,
int spacedim>
9739 std::tuple<
unsigned int,
9746 std::tuple<
unsigned int,
9753template <
int dim,
int spacedim>
9762 std::set<std::string> all_names;
9765 std::tuple<
unsigned int,
9771 const unsigned int n_data_sets = data_names.size();
9772 std::vector<bool> data_set_written(n_data_sets,
false);
9774 for (
const auto &range : ranges)
9776 const std::string &name = std::get<2>(range);
9779 Assert(all_names.find(name) == all_names.end(),
9781 "Error: names of fields in DataOut need to be unique, "
9783 name +
"' is used more than once."));
9784 all_names.insert(name);
9785 for (
unsigned int i = std::get<0>(range);
9786 i <= std::get<1>(range);
9788 data_set_written[i] =
true;
9792 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
9793 if (data_set_written[data_set] ==
false)
9795 const std::string &name = data_names[data_set];
9796 Assert(all_names.find(name) == all_names.end(),
9798 "Error: names of fields in DataOut need to be unique, "
9800 name +
"' is used more than once."));
9801 all_names.insert(name);
9811template <
int dim,
int spacedim>
9819 std::vector<typename ::DataOutBase::Patch<dim, spacedim>> tmp;
9823 std::vector<std::string> tmp;
9828 std::tuple<
unsigned int,
9840 std::pair<unsigned int, unsigned int> dimension_info =
9843 (dimension_info.second == spacedim),
9845 dimension_info.first, dim, dimension_info.second, spacedim));
9854 getline(in, header);
9856 std::ostringstream s;
9857 s <<
"[deal.II intermediate format graphics data]";
9859 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9863 getline(in, header);
9865 std::ostringstream s;
9869 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
9873 getline(in, header);
9875 std::ostringstream s;
9879 Assert(header == s.str(),
9881 "Invalid or incompatible file format. Intermediate format "
9882 "files can only be read by the same deal.II version as they "
9883 "are written by."));
9887 unsigned int n_datasets;
9890 for (
unsigned int i = 0; i < n_datasets; ++i)
9893 unsigned int n_patches;
9896 for (
unsigned int i = 0; i < n_patches; ++i)
9899 unsigned int n_nonscalar_data_ranges;
9900 in >> n_nonscalar_data_ranges;
9902 for (
unsigned int i = 0; i < n_nonscalar_data_ranges; ++i)
9922template <
int dim,
int spacedim>
9928 ParallelIntermediateHeader header;
9929 in.read(
reinterpret_cast<char *
>(&header),
sizeof(header));
9931 header.magic == 0x00dea111,
9933 "Invalid header of parallel deal.II intermediate format encountered."));
9937 "Incorrect header version of parallel deal.II intermediate format."));
9939 std::vector<std::uint64_t> chunk_sizes(header.n_ranks);
9940 in.read(
reinterpret_cast<char *
>(chunk_sizes.data()),
9941 header.n_ranks *
sizeof(std::uint64_t));
9943 for (
unsigned int n = 0; n < header.n_ranks; ++n)
9947 std::vector<char> temp_buffer(chunk_sizes[n]);
9948 in.read(temp_buffer.data(), chunk_sizes[n]);
9951 header.compression) !=
9955 boost::iostreams::filtering_istreambuf f;
9958#ifdef DEAL_II_WITH_ZLIB
9959 f.push(boost::iostreams::zlib_decompressor());
9964 "Decompression requires deal.II to be configured with ZLIB support."));
9967 boost::iostreams::basic_array_source<char> source(temp_buffer.data(),
9968 temp_buffer.size());
9971 std::stringstream datastream;
9972 boost::iostreams::copy(f, datastream);
9982 temp_reader.
read(datastream);
9990template <
int dim,
int spacedim>
9994 using Patch = typename ::DataOutBase::Patch<dim, spacedim>;
9997 const std::vector<Patch> &source_patches = source.
get_patches();
10007 ExcMessage(
"Both sources need to declare the same components "
10013 ExcMessage(
"Both sources need to declare the same components "
10017 ExcMessage(
"Both sources need to declare the same components "
10021 ExcMessage(
"Both sources need to declare the same components "
10026 Assert(
patches[0].n_subdivisions == source_patches[0].n_subdivisions,
10028 Assert(
patches[0].data.n_rows() == source_patches[0].data.n_rows(),
10030 Assert(
patches[0].data.n_cols() == source_patches[0].data.n_cols(),
10035 const unsigned int old_n_patches =
patches.size();
10036 patches.insert(
patches.end(), source_patches.begin(), source_patches.end());
10039 for (
unsigned int i = old_n_patches; i <
patches.size(); ++i)
10040 patches[i].patch_index += old_n_patches;
10043 for (
unsigned int i = old_n_patches; i <
patches.size(); ++i)
10045 if (
patches[i].neighbors[n] !=
10047 patches[i].neighbors[n] += old_n_patches;
10052template <
int dim,
int spacedim>
10053const std::vector<typename ::DataOutBase::Patch<dim, spacedim>> &
10061template <
int dim,
int spacedim>
10062std::vector<std::string>
10070template <
int dim,
int spacedim>
10072 std::tuple<
unsigned int,
10103 const std::uint64_t nodes,
10104 const std::uint64_t cells,
10105 const unsigned int dim_,
10107 :
XDMFEntry(filename, filename, time, nodes, cells, dim_, dim, cell_type)
10116 const std::string &solution_filename,
10118 const std::uint64_t nodes,
10119 const std::uint64_t cells,
10120 const unsigned int dim_,
10157 const std::string &solution_filename,
10159 const std::uint64_t nodes,
10160 const std::uint64_t cells,
10161 const unsigned int dim_,
10162 const unsigned int spacedim,
10176 cell_type_hex_if_invalid<dim>(cell_type_);
10179 if constexpr (dim == 0)
10183 else if constexpr (dim == 1)
10187 else if constexpr (dim == 2)
10202 else if constexpr (dim == 3)
10238 indent(
const unsigned int indent_level)
10240 std::string res =
"";
10241 for (
unsigned int i = 0; i < indent_level; ++i)
10255 std::stringstream ss;
10257 ss << indent(indent_level + 0)
10258 <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
10259 ss << indent(indent_level + 1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
10260 ss << indent(indent_level + 1) <<
"<Geometry GeometryType=\""
10262 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
10264 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
10266 ss << indent(indent_level + 2) <<
"</DataItem>\n";
10267 ss << indent(indent_level + 1) <<
"</Geometry>\n";
10272 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\""
10275 ss <<
"\" NodesPerElement=\"1\">\n";
10277 ss <<
"\" NodesPerElement=\"2\">\n";
10282 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_cells
10284 <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
10287 ss << indent(indent_level + 2) <<
"</DataItem>\n";
10288 ss << indent(indent_level + 1) <<
"</Topology>\n";
10294 ss << indent(indent_level + 1)
10295 <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\""
10297 ss << indent(indent_level + 1) <<
"</Topology>\n";
10302 ss << indent(indent_level + 1) <<
"<Attribute Name=\""
10303 << attribute_dim.first <<
"\" AttributeType=\""
10304 << (attribute_dim.second > 1 ?
"Vector" :
"Scalar")
10305 <<
"\" Center=\"Node\">\n";
10307 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
10308 <<
" " << (attribute_dim.second > 1 ? 3 : 1)
10309 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
10311 << attribute_dim.first <<
'\n';
10312 ss << indent(indent_level + 2) <<
"</DataItem>\n";
10313 ss << indent(indent_level + 1) <<
"</Attribute>\n";
10316 ss << indent(indent_level + 0) <<
"</Grid>\n";
10325 template <
int dim,
int spacedim>
10330 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]"
10337 for (
const unsigned int i : patch.
reference_cell.vertex_indices())
10341 for (
const unsigned int i : patch.
reference_cell.face_indices())
10349 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
10350 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
10351 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
10352 out << patch.
data[i][j] <<
' ';
10361 template <
int dim,
int spacedim>
10370 std::string header;
10373 getline(in, header);
10374 while ((header.size() != 0) && (header.back() ==
' '))
10375 header.erase(header.size() - 1);
10377 while ((header.empty()) && in);
10379 std::ostringstream s;
10380 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
10382 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
10386 if constexpr (dim > 0)
10390 for (
const unsigned int i : patch.
reference_cell.vertex_indices())
10393 for (
const unsigned int i : patch.
reference_cell.face_indices())
10402 if constexpr (dim > 1)
10407 unsigned int n_rows, n_cols;
10408 in >> n_rows >> n_cols;
10409 patch.
data.reinit(n_rows, n_cols);
10410 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
10411 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
10412 in >> patch.
data[i][j];
10423#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
unsigned int default_subdivisions
void parse_parameters(ParameterHandler &prm)
DataOutBase::Deal_II_IntermediateFlags deal_II_intermediate_flags
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_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)
virtual std::vector< std::string > get_dataset_names() const =0
DataOutBase::TecplotFlags tecplot_flags
void write_ucd(std::ostream &out) const
void write_povray(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, const MPI_Comm comm) const
DataOutBase::GmvFlags gmv_flags
std::size_t memory_consumption() const
void set_default_format(const DataOutBase::OutputFormat default_format)
DataOutBase::Hdf5Flags hdf5_flags
DataOutBase::PovrayFlags povray_flags
DataOutBase::UcdFlags ucd_flags
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
DataOutBase::OutputFormat default_fmt
DataOutBase::GnuplotFlags gnuplot_flags
void write_gnuplot(std::ostream &out) const
DataOutBase::CFFlags cf_flags
void write_vtu(std::ostream &out) const
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm comm) const
void write_tecplot(std::ostream &out) const
void write_deal_II_intermediate_in_parallel(const std::string &filename, const MPI_Comm comm, const DataOutBase::CompressionLevel compression) const
void write_svg(std::ostream &out) const
void write_vtu_in_parallel(const std::string &filename, const MPI_Comm comm) const
DataOutBase::SvgFlags svg_flags
void validate_dataset_names() const
void set_flags(const FlagType &flags)
void write_vtk(std::ostream &out) const
virtual const std::vector< DataOutBase::Patch< dim, spacedim > > & get_patches() const =0
DataOutBase::VtkFlags vtk_flags
void write_gmv(std::ostream &out) const
std::string write_vtu_with_pvtu_record(const std::string &directory, const std::string &filename_without_extension, const unsigned int counter, const MPI_Comm mpi_communicator, const unsigned int n_digits_for_counter=numbers::invalid_unsigned_int, const unsigned int n_groups=0) const
DataOutBase::EpsFlags eps_flags
void write_eps(std::ostream &out) const
DataOutBase::DXFlags dx_flags
void write_dx(std::ostream &out) const
void write_deal_II_intermediate(std::ostream &out) const
void merge(const DataOutReader< dim, spacedim > &other)
void read_whole_parallel_file(std::istream &in)
std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > nonscalar_data_ranges
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const override
void read(std::istream &in)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
virtual std::vector< std::string > get_dataset_names() const override
std::vector< std::string > dataset_names
std::vector<::DataOutBase::Patch< dim, spacedim > > patches
void enter_subsection(const std::string &subsection, const bool create_path_if_needed=true)
long int get_integer(const std::string &entry_string) const
bool get_bool(const std::string &entry_name) const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
std::string get(const std::string &entry_string) const
double get_double(const std::string &entry_name) const
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_FALLTHROUGH
#define DEAL_II_PACKAGE_NAME
const unsigned int DoFAccessor< structdim, dim, spacedim, level_dof_access >::space_dimension
const unsigned int DoFAccessor< structdim, dim, spacedim, level_dof_access >::dimension
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
#define AssertThrowNC(code)
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcIncompatiblePatchLists()
static ::ExceptionBase & ExcFileNotOpen(std::string arg1)
static ::ExceptionBase & ExcNotEnoughSpaceDimensionLabels()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNoPatches()
static ::ExceptionBase & ExcNeedsNetCDF()
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
#define AssertThrowMPI(error_code)
static ::ExceptionBase & ExcIncompatibleDimensions(int arg1, int arg2, int arg3, int arg4)
#define 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 & ExcIncompatibleDatasetNames()
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
const bool IsBlockVector< VectorType >::value
Task< RT > new_task(const std::function< RT()> &function)
DataComponentInterpretation
@ component_is_part_of_tensor
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const EpsFlags &flags, std::ostream &out)
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
void write_nodes(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_deal_II_intermediate_in_parallel(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, const std::string &filename, const MPI_Comm comm, const CompressionLevel compression)
void write_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const UcdFlags &flags, std::ostream &out)
void write_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)
const unsigned int Patch< 0, spacedim >::n_subdivisions
void write_data(const std::vector< Patch< dim, spacedim > > &patches, unsigned int n_data_sets, const bool double_precision, StreamType &out)
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
const ReferenceCell< 0 > Patch< 0, spacedim >::reference_cell
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names)
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
void write_vtu_footer(std::ostream &out)
void write_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, DataOutFilter &filtered_data)
OutputFormat parse_output_format(const std::string &format_name)
std::vector< Point< spacedim > > get_node_positions(const std::vector< Patch< dim, spacedim > > &patches)
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim > > &patches, const DataOutFilter &data_filter, const DataOutBase::Hdf5Flags &flags, const std::string &filename, const MPI_Comm comm)
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
std::string get_output_format_names()
void write_svg(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const SvgFlags &flags, std::ostream &out)
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names)
void write_high_order_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out, const bool legacy_format)
std::string default_suffix(const OutputFormat output_format)
void write_povray(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const PovrayFlags &flags, std::ostream &out)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GnuplotFlags &flags, std::ostream &out)
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags)
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
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)
*Â *Â if(update_pressure &update_flags) *Â compute_pressure(constitutive_request
constexpr ReferenceCell< 3 > Hexahedron
constexpr ReferenceCell< 2 > Quadrilateral
constexpr ReferenceCell< 1 > Line
constexpr ReferenceCell< 2 > Triangle
constexpr ReferenceCell< 3 > Tetrahedron
constexpr const ReferenceCell< dim > & get_simplex()
constexpr ReferenceCell< dim > Invalid
constexpr ReferenceCell< 3 > Pyramid
constexpr const ReferenceCell< dim > & get_hypercube()
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)
constexpr T fixed_power(const T t)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
unsigned int needed_digits(const unsigned int max_number)
constexpr T pow(const T base, const int iexp)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
constexpr 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 > &)
unsigned int global_dof_index
*braid_SplitCommworld & comm
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)
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
void parse_parameters(const ParameterHandler &prm)
ColorFunction color_function
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
EpsFlags(const unsigned int height_vector=0, const unsigned int color_vector=0, const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const double azimut_angle=60, const double turn_angle=30, const double z_scaling=1.0, const bool draw_mesh=true, const bool draw_cells=true, const bool shade_cells=true, const ColorFunction color_function=&default_color_function)
unsigned int color_vector
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
@ width
Scale to given width.
@ height
Scale to given height.
unsigned int height_vector
std::vector< std::string > space_dimension_labels
std::size_t memory_consumption() const
DataOutBase::CompressionLevel compression_level
Hdf5Flags(const CompressionLevel compression_level=CompressionLevel::best_speed)
static void declare_parameters(ParameterHandler &prm)
Point< spacedim > vertices[1]
bool points_are_available
static const unsigned int no_neighbor
std::size_t memory_consumption() const
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 constexpr unsigned int vertices_per_cell
static constexpr std::array< unsigned int, vertices_per_cell > ucd_to_deal
static constexpr unsigned int faces_per_cell
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static constexpr std::array< unsigned int, vertices_per_cell > dx_to_deal
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)