57#ifdef DEAL_II_WITH_ZLIB
61#ifdef DEAL_II_WITH_HDF5
75 <<
"Unexpected input: expected line\n <" << arg1
76 <<
">\nbut got\n <" << arg2 <<
">");
82#ifdef DEAL_II_WITH_ZLIB
88 get_zlib_compression_level(
94 return Z_NO_COMPRESSION;
98 return Z_BEST_COMPRESSION;
100 return Z_DEFAULT_COMPRESSION;
103 return Z_NO_COMPRESSION;
111 template <
typename T>
113 write_compressed_block(
const std::vector<T> & data,
115 std::ostream & output_stream)
117 if (data.size() != 0)
120 auto compressed_data_length = compressBound(data.size() *
sizeof(
T));
121 std::vector<unsigned char> compressed_data(compressed_data_length);
124 compress2(&compressed_data[0],
125 &compressed_data_length,
126 reinterpret_cast<const Bytef *
>(data.data()),
127 data.size() *
sizeof(
T),
133 compressed_data.resize(compressed_data_length);
136 const uint32_t compression_header[4] = {
138 static_cast<uint32_t
>(data.size() *
sizeof(
T)),
139 static_cast<uint32_t
>(data.size() *
141 static_cast<uint32_t
>(
142 compressed_data_length)};
144 const auto header_start =
145 reinterpret_cast<const unsigned char *
>(&compression_header[0]);
148 {header_start, header_start + 4 *
sizeof(uint32_t)})
258 template <
int dim,
int spacedim,
typename Number =
double>
260 write_gmv_reorder_data_vectors(
261 const std::vector<Patch<dim, spacedim>> &patches,
265 if (patches.size() == 0)
275 const unsigned int n_data_sets = patches[0].points_are_available ?
276 (patches[0].data.n_rows() - spacedim) :
277 patches[0].data.n_rows();
282 unsigned int next_value = 0;
283 for (
const auto &patch : patches)
285 const unsigned int n_subdivisions = patch.n_subdivisions;
286 (void)n_subdivisions;
288 Assert((patch.data.n_rows() == n_data_sets &&
289 !patch.points_are_available) ||
290 (patch.data.n_rows() == n_data_sets + spacedim &&
291 patch.points_are_available),
293 (n_data_sets + spacedim) :
295 patch.data.n_rows()));
296 Assert(patch.reference_cell != ReferenceCells::get_hypercube<dim>() ||
297 (n_data_sets == 0) ||
298 (patch.data.n_cols() ==
299 Utilities::fixed_power<dim>(n_subdivisions + 1)),
301 n_subdivisions + 1));
303 for (
unsigned int i = 0; i < patch.data.n_cols(); ++i, ++next_value)
304 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
305 data_vectors[data_set][next_value] = patch.data(data_set, i);
308 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
338 for (
unsigned int d = 0;
d < dim; ++
d)
342 unsigned int internal_ind;
353 internal_ind = it->second;
363 const unsigned int pt_index)
382 node_data[
node_dim * existing_point.second +
d] =
383 existing_point.first(
d);
391 std::vector<unsigned int> &cell_data)
const
397 cell_data[filtered_cell.first] =
398 filtered_cell.second + local_node_offset;
467 const unsigned int start,
468 const unsigned int d1,
469 const unsigned int d2,
470 const unsigned int d3)
474 const unsigned int base_entry =
500 const unsigned int start,
501 const unsigned int n_points)
505 const unsigned int base_entry = index * n_points;
507 for (
unsigned int i = 0; i < n_points; ++i)
517 const unsigned int dimension,
518 const unsigned int set_num,
521 unsigned int new_dim;
540 for (
unsigned int d = 0;
d < new_dim; ++
d)
543 data_sets.back()[r * new_dim +
d] = data_vectors(set_num +
d, i);
559 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
561 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
563 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
565#ifdef DEAL_II_HAVE_TECPLOT
566 const unsigned int tecplot_binary_cell_type[4] = {0, 0, 1, 3};
571 enum vtk_linear_cell_type
583 enum vtk_quadratic_cell_type
585 VTK_QUADRATIC_EDGE = 21,
586 VTK_QUADRATIC_TRIANGLE = 22,
587 VTK_QUADRATIC_QUAD = 23,
588 VTK_QUADRATIC_TETRA = 24,
589 VTK_QUADRATIC_HEXAHEDRON = 25,
590 VTK_QUADRATIC_WEDGE = 26,
591 VTK_QUADRATIC_PYRAMID = 27
594 enum vtk_lagrange_cell_type
596 VTK_LAGRANGE_CURVE = 68,
597 VTK_LAGRANGE_TRIANGLE = 69,
598 VTK_LAGRANGE_QUADRILATERAL = 70,
599 VTK_LAGRANGE_TETRAHEDRON = 71,
600 VTK_LAGRANGE_HEXAHEDRON = 72,
601 VTK_LAGRANGE_WEDGE = 73,
602 VTK_LAGRANGE_PYRAMID = 74
609 template <
int dim,
int spacedim>
610 std::array<unsigned int, 3>
612 const bool write_higher_order_cells)
614 std::array<unsigned int, 3> vtk_cell_id{};
616 if (write_higher_order_cells)
620 const std::array<unsigned int, 4> cell_type_by_dim{
623 VTK_LAGRANGE_QUADRILATERAL,
624 VTK_LAGRANGE_HEXAHEDRON}};
625 vtk_cell_id[0] = cell_type_by_dim[dim];
630 vtk_cell_id[0] = VTK_LAGRANGE_TRIANGLE;
639 patch.
data.n_cols() == 3)
641 vtk_cell_id[0] = VTK_TRIANGLE;
645 patch.
data.n_cols() == 6)
647 vtk_cell_id[0] = VTK_QUADRATIC_TRIANGLE;
651 patch.
data.n_cols() == 4)
653 vtk_cell_id[0] = VTK_TETRA;
657 patch.
data.n_cols() == 10)
659 vtk_cell_id[0] = VTK_QUADRATIC_TETRA;
663 patch.
data.n_cols() == 6)
665 vtk_cell_id[0] = VTK_WEDGE;
669 patch.
data.n_cols() == 5)
671 vtk_cell_id[0] = VTK_PYRAMID;
674 else if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
676 const std::array<unsigned int, 4> cell_type_by_dim{
677 {VTK_VERTEX, VTK_LINE, VTK_QUAD, VTK_HEXAHEDRON}};
678 vtk_cell_id[0] = cell_type_by_dim[dim];
686 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>() ||
687 write_higher_order_cells)
688 vtk_cell_id[2] = patch.
data.n_cols();
701 template <
int dim,
int spacedim>
704 const unsigned int xstep,
705 const unsigned int ystep,
706 const unsigned int zstep,
707 const unsigned int n_subdivisions)
712 unsigned int point_no = 0;
717 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
721 point_no += (n_subdivisions + 1) * ystep;
734 for (
unsigned int d = 0;
d < spacedim; ++
d)
735 node[
d] = patch.
data(patch.
data.size(0) - spacedim +
d, point_no);
744 const double stepsize = 1. / n_subdivisions,
745 xfrac = xstep * stepsize;
751 const double yfrac = ystep * stepsize;
753 node += ((patch.
vertices[3] * xfrac) +
754 (patch.
vertices[2] * (1 - xfrac))) *
758 const double zfrac = zstep * stepsize;
760 node += (((patch.
vertices[5] * xfrac) +
761 (patch.
vertices[4] * (1 - xfrac))) *
764 (patch.
vertices[6] * (1 - xfrac))) *
777 template <
int dim,
int spacedim>
780 const unsigned int point_no)
786 for (
unsigned int d = 0;
d < spacedim; ++
d)
787 node[
d] = patch.
data(patch.
data.size(0) - spacedim +
d, point_no);
796 "Pyramids need different ordering of the vertices, which is not implemented yet here."));
812 vtk_point_index_from_ijk(
const unsigned i,
815 const std::array<unsigned, 2> &order)
817 const bool ibdy = (i == 0 || i == order[0]);
818 const bool jbdy = (j == 0 || j == order[1]);
820 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0);
824 return (i ? (j ? 2 : 1) : (j ? 3 : 0));
832 return (i - 1) + (j ? order[0] - 1 + order[1] - 1 : 0) + offset;
838 (i ? order[0] - 1 : 2 * (order[0] - 1) + order[1] - 1) +
843 offset += 2 * (order[0] - 1 + order[1] - 1);
845 return offset + (i - 1) + (order[0] - 1) * ((j - 1));
856 vtk_point_index_from_ijk(
const unsigned i,
859 const std::array<unsigned, 3> &order)
861 const bool ibdy = (i == 0 || i == order[0]);
862 const bool jbdy = (j == 0 || j == order[1]);
863 const bool kbdy = (k == 0 || k == order[2]);
865 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0) + (kbdy ? 1 : 0);
869 return (i ? (j ? 2 : 1) : (j ? 3 : 0)) + (k ? 4 : 0);
877 return (i - 1) + (j ? order[0] - 1 + order[1] - 1 : 0) +
878 (k ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
883 (i ? order[0] - 1 : 2 * (order[0] - 1) + order[1] - 1) +
884 (k ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
887 offset += 4 * (order[0] - 1) + 4 * (order[1] - 1);
888 return (k - 1) + (order[2] - 1) * (i ? (j ? 3 : 1) : (j ? 2 : 0)) +
892 offset += 4 * (order[0] - 1 + order[1] - 1 + order[2] - 1);
897 return (j - 1) + ((order[1] - 1) * (k - 1)) +
898 (i ? (order[1] - 1) * (order[2] - 1) : 0) + offset;
900 offset += 2 * (order[1] - 1) * (order[2] - 1);
903 return (i - 1) + ((order[0] - 1) * (k - 1)) +
904 (j ? (order[2] - 1) * (order[0] - 1) : 0) + offset;
906 offset += 2 * (order[2] - 1) * (order[0] - 1);
908 return (i - 1) + ((order[0] - 1) * (j - 1)) +
909 (k ? (order[0] - 1) * (order[1] - 1) : 0) + offset;
914 2 * ((order[1] - 1) * (order[2] - 1) + (order[2] - 1) * (order[0] - 1) +
915 (order[0] - 1) * (order[1] - 1));
916 return offset + (i - 1) +
917 (order[0] - 1) * ((j - 1) + (order[1] - 1) * ((k - 1)));
921 vtk_point_index_from_ijk(
const unsigned,
924 const std::array<unsigned, 0> &)
931 vtk_point_index_from_ijk(
const unsigned,
934 const std::array<unsigned, 1> &)
941 template <
int dim,
int spacedim>
944 unsigned int & n_nodes,
949 for (
const auto &patch : patches)
966 template <
int dim,
int spacedim>
969 const bool write_higher_order_cells,
970 unsigned int &n_nodes,
972 unsigned int &n_points_and_n_cells)
976 n_points_and_n_cells = 0;
978 for (
const auto &patch : patches)
985 if (write_higher_order_cells)
988 n_points_and_n_cells +=
994 n_points_and_n_cells +=
1001 n_nodes += patch.
data.n_cols();
1003 n_points_and_n_cells += patch.
data.n_cols() + 1;
1013 template <
typename FlagsType>
1020 StreamBase(std::ostream &stream,
const FlagsType &flags)
1032 write_point(
const unsigned int,
const Point<dim> &)
1035 ExcMessage(
"The derived class you are using needs to "
1036 "reimplement this function if you want to call "
1056 write_cell(
const unsigned int ,
1057 const unsigned int ,
1058 const unsigned int ,
1059 const unsigned int ,
1060 const unsigned int )
1063 ExcMessage(
"The derived class you are using needs to "
1064 "reimplement this function if you want to call "
1075 write_cell_single(
const unsigned int index,
1076 const unsigned int start,
1077 const unsigned int n_points)
1084 ExcMessage(
"The derived class you are using needs to "
1085 "reimplement this function if you want to call "
1103 template <
typename T>
1117 unsigned int selected_component;
1124 std::ostream &stream;
1129 const FlagsType flags;
1135 class DXStream :
public StreamBase<DataOutBase::DXFlags>
1142 write_point(
const unsigned int index,
const Point<dim> &);
1154 write_cell(
const unsigned int index,
1155 const unsigned int start,
1156 const unsigned int x_offset,
1157 const unsigned int y_offset,
1158 const unsigned int z_offset);
1166 template <
typename data>
1168 write_dataset(
const unsigned int index,
const std::vector<data> &
values);
1174 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
1181 write_point(
const unsigned int index,
const Point<dim> &);
1193 write_cell(
const unsigned int index,
1194 const unsigned int start,
1195 const unsigned int x_offset,
1196 const unsigned int y_offset,
1197 const unsigned int z_offset);
1203 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
1210 write_point(
const unsigned int index,
const Point<dim> &);
1222 write_cell(
const unsigned int index,
1223 const unsigned int start,
1224 const unsigned int x_offset,
1225 const unsigned int y_offset,
1226 const unsigned int z_offset);
1232 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1239 write_point(
const unsigned int index,
const Point<dim> &);
1253 write_cell(
const unsigned int index,
1254 const unsigned int start,
1255 const unsigned int x_offset,
1256 const unsigned int y_offset,
1257 const unsigned int z_offset);
1265 template <
typename data>
1267 write_dataset(
const unsigned int index,
const std::vector<data> &
values);
1273 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1280 write_point(
const unsigned int index,
const Point<dim> &);
1292 write_cell(
const unsigned int index,
1293 const unsigned int start,
1294 const unsigned int x_offset,
1295 const unsigned int y_offset,
1296 const unsigned int z_offset);
1302 write_cell_single(
const unsigned int index,
1303 const unsigned int start,
1304 const unsigned int n_points);
1315 write_high_order_cell(
const unsigned int index,
1316 const unsigned int start,
1317 const std::vector<unsigned> &connectivity);
1321 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
1328 write_point(
const unsigned int index,
const Point<dim> &);
1343 write_cell(
const unsigned int index,
1344 const unsigned int start,
1345 const unsigned int x_offset,
1346 const unsigned int y_offset,
1347 const unsigned int z_offset);
1353 write_cell_single(
const unsigned int index,
1354 const unsigned int start,
1355 const unsigned int n_points);
1366 write_high_order_cell(
const unsigned int index,
1367 const unsigned int start,
1368 const std::vector<unsigned> &connectivity);
1373 template <
typename T>
1384 template <
typename T>
1398 std::vector<int32_t> cells;
1411 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1413 if (flags.coordinates_binary)
1416 for (
unsigned int d = 0;
d < dim; ++
d)
1418 stream.write(
reinterpret_cast<const char *
>(data), dim *
sizeof(*data));
1422 for (
unsigned int d = 0;
d < dim; ++
d)
1423 stream << p(
d) <<
'\t';
1438 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell>
1439 set_node_numbers(
const unsigned int ,
1440 const unsigned int ,
1441 const unsigned int ,
1442 const unsigned int )
1451 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
1452 set_node_numbers<1>(
const unsigned int start,
1453 const unsigned int d1,
1454 const unsigned int ,
1455 const unsigned int )
1458 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
1460 nodes[1] = start + d1;
1467 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
1468 set_node_numbers<2>(
const unsigned int start,
1469 const unsigned int d1,
1470 const unsigned int d2,
1471 const unsigned int )
1474 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
1476 nodes[1] = start + d1;
1477 nodes[2] = start + d2;
1478 nodes[3] = start + d2 + d1;
1485 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
1486 set_node_numbers<3>(
const unsigned int start,
1487 const unsigned int d1,
1488 const unsigned int d2,
1489 const unsigned int d3)
1491 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
1493 nodes[1] = start + d1;
1494 nodes[2] = start + d2;
1495 nodes[3] = start + d2 + d1;
1496 nodes[4] = start + d3;
1497 nodes[5] = start + d3 + d1;
1498 nodes[6] = start + d3 + d2;
1499 nodes[7] = start + d3 + d2 + d1;
1508 DXStream::write_cell(
unsigned int,
1515 DataOutBaseImplementation::set_node_numbers<dim>(start, d1, d2, d3);
1517 if (flags.int_binary)
1519 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell> temp;
1520 for (
unsigned int i = 0; i < nodes.size(); ++i)
1522 stream.write(
reinterpret_cast<const char *
>(temp.data()),
1523 temp.size() *
sizeof(temp[0]));
1527 for (
unsigned int i = 0; i < nodes.size() - 1; ++i)
1529 stream << nodes[GeometryInfo<dim>::dx_to_deal[nodes.size() - 1]]
1536 template <
typename data>
1538 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &
values)
1540 if (flags.data_binary)
1542 stream.write(
reinterpret_cast<const char *
>(
values.data()),
1543 values.size() *
sizeof(data));
1547 for (
unsigned int i = 0; i <
values.size(); ++i)
1548 stream <<
'\t' <<
values[i];
1564 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1568 stream << p(selected_component) <<
' ';
1575 GmvStream::write_cell(
unsigned int,
1582 const unsigned int start = s + 1;
1583 stream << gmv_cell_type[dim] <<
'\n';
1588 stream <<
'\t' << start + d1;
1591 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1594 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1595 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1604 TecplotStream::TecplotStream(std::ostream & out,
1612 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1616 stream << p(selected_component) <<
'\n';
1623 TecplotStream::write_cell(
unsigned int,
1629 const unsigned int start = s + 1;
1634 stream <<
'\t' << start + d1;
1637 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1640 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1641 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1657 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1659 stream << index + 1 <<
" ";
1661 for (
unsigned int i = 0; i < dim; ++i)
1662 stream << p(i) <<
' ';
1664 for (
unsigned int i = dim; i < 3; ++i)
1673 UcdStream::write_cell(
unsigned int index,
1680 DataOutBaseImplementation::set_node_numbers<dim>(start, d1, d2, d3);
1683 stream << index + 1 <<
"\t0 " << ucd_cell_type[dim];
1684 for (
unsigned int i = 0; i < nodes.size(); ++i)
1691 template <
typename data>
1693 UcdStream::write_dataset(
const unsigned int index,
1694 const std::vector<data> &
values)
1696 stream << index + 1;
1697 for (
unsigned int i = 0; i <
values.size(); ++i)
1698 stream <<
'\t' <<
values[i];
1713 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1718 for (
unsigned int i = dim; i < 3; ++i)
1727 VtkStream::write_cell(
unsigned int,
1733 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' << start;
1736 stream <<
'\t' << start + d1;
1740 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1743 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1744 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1752 VtkStream::write_cell_single(
const unsigned int index,
1753 const unsigned int start,
1754 const unsigned int n_points)
1758 stream <<
'\t' << n_points;
1759 for (
unsigned int i = 0; i < n_points; ++i)
1760 stream <<
'\t' << start + i;
1766 VtkStream::write_high_order_cell(
const unsigned int,
1767 const unsigned int start,
1768 const std::vector<unsigned> &connectivity)
1770 stream << connectivity.size();
1771 for (
const auto &c : connectivity)
1772 stream <<
'\t' << start + c;
1783 VtuStream::write_point(
const unsigned int,
const Point<dim> &p)
1785#if !defined(DEAL_II_WITH_ZLIB)
1789 for (
unsigned int i = dim; i < 3; ++i)
1794 for (
unsigned int i = 0; i < dim; ++i)
1796 for (
unsigned int i = dim; i < 3; ++i)
1803 VtuStream::flush_points()
1805#ifdef DEAL_II_WITH_ZLIB
1816 VtuStream::write_cell(
unsigned int,
1822#if !defined(DEAL_II_WITH_ZLIB)
1826 stream <<
'\t' << start + d1;
1829 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1832 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1833 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1839 cells.push_back(start);
1842 cells.push_back(start + d1);
1845 cells.push_back(start + d2 + d1);
1846 cells.push_back(start + d2);
1849 cells.push_back(start + d3);
1850 cells.push_back(start + d3 + d1);
1851 cells.push_back(start + d3 + d2 + d1);
1852 cells.push_back(start + d3 + d2);
1860 VtuStream::write_cell_single(
const unsigned int index,
1861 const unsigned int start,
1862 const unsigned int n_points)
1866#if !defined(DEAL_II_WITH_ZLIB)
1867 for (
unsigned int i = 0; i < n_points; ++i)
1868 stream <<
'\t' << start + i;
1871 for (
unsigned int i = 0; i < n_points; ++i)
1872 cells.push_back(start + i);
1878 VtuStream::write_high_order_cell(
const unsigned int,
1879 const unsigned int start,
1880 const std::vector<unsigned> &connectivity)
1882#if !defined(DEAL_II_WITH_ZLIB)
1883 for (
const auto &c : connectivity)
1884 stream <<
'\t' << start + c;
1887 for (
const auto &c : connectivity)
1888 cells.push_back(start + c);
1893 VtuStream::flush_cells()
1895#ifdef DEAL_II_WITH_ZLIB
1898 *
this << cells <<
'\n';
1904 template <
typename T>
1908#ifdef DEAL_II_WITH_ZLIB
1911 write_compressed_block(data, flags, stream);
1913 for (
unsigned int i = 0; i < data.size(); ++i)
1914 stream << data[i] <<
' ';
1928 template <
int dim,
int spacedim>
1932 template <
int dim,
int spacedim>
1936 template <
int dim,
int spacedim>
1938 : patch_index(no_neighbor)
1940 , points_are_available(false)
1954 template <
int dim,
int spacedim>
1977 if (data.n_rows() != patch.
data.n_rows())
1980 if (data.n_cols() != patch.
data.n_cols())
1983 for (
unsigned int i = 0; i < data.n_rows(); ++i)
1984 for (
unsigned int j = 0; j < data.n_cols(); ++j)
1985 if (data[i][j] != patch.
data[i][j])
1993 template <
int dim,
int spacedim>
1999 sizeof(neighbors) /
sizeof(neighbors[0]) *
2009 template <
int dim,
int spacedim>
2017 data.swap(other_patch.
data);
2024 template <
int spacedim>
2028 template <
int spacedim>
2032 template <
int spacedim>
2036 template <
int spacedim>
2039 template <
int spacedim>
2041 : patch_index(no_neighbor)
2042 , points_are_available(false)
2050 template <
int spacedim>
2054 const unsigned int dim = 0;
2068 if (
data.n_rows() != patch.
data.n_rows())
2071 if (
data.n_cols() != patch.
data.n_cols())
2074 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
2075 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
2076 if (
data[i][j] != patch.
data[i][j])
2084 template <
int spacedim>
2096 template <
int spacedim>
2108 : write_preamble(write_preamble)
2123 : space_dimension_labels(labels)
2137 const bool bicubic_patch,
2138 const bool external_data)
2140 , bicubic_patch(bicubic_patch)
2141 , external_data(external_data)
2146 const bool xdmf_hdf5_output)
2147 : filter_duplicate_vertices(filter_duplicate_vertices)
2148 , xdmf_hdf5_output(xdmf_hdf5_output)
2156 "Filter duplicate vertices",
2159 "Whether to remove duplicate vertex values. deal.II duplicates "
2160 "vertices once for each adjacent cell so that it can output "
2161 "discontinuous quantities for which there may be more than one "
2162 "value for each vertex position. Setting this flag to "
2163 "'true' will merge all of these values by selecting a "
2164 "random one and outputting this as 'the' value for the vertex. "
2165 "As long as the data to be output corresponds to continuous "
2166 "fields, merging vertices has no effect. On the other hand, "
2167 "if the data to be output corresponds to discontinuous fields "
2168 "(either because you are using a discontinuous finite element, "
2169 "or because you are using a DataPostprocessor that yields "
2170 "discontinuous data, or because the data to be output has been "
2171 "produced by entirely different means), then the data in the "
2172 "output file no longer faithfully represents the underlying data "
2173 "because the discontinuous field has been replaced by a "
2174 "continuous one. Note also that the filtering can not occur "
2175 "on processor boundaries. Thus, a filtered discontinuous field "
2176 "looks like a continuous field inside of a subdomain, "
2177 "but like a discontinuous field at the subdomain boundary."
2179 "In any case, filtering results in drastically smaller output "
2180 "files (smaller by about a factor of 2^dim).");
2185 "Whether the data will be used in an XDMF/HDF5 combination.");
2200 const bool int_binary,
2201 const bool coordinates_binary,
2202 const bool data_binary)
2203 : write_neighbors(write_neighbors)
2204 , int_binary(int_binary)
2205 , coordinates_binary(coordinates_binary)
2206 , data_binary(data_binary)
2207 , data_double(false)
2217 "A boolean field indicating whether neighborship "
2218 "information between cells is to be written to the "
2219 "OpenDX output file");
2223 "Output format of integer numbers, which is "
2224 "either a text representation (ascii) or binary integer "
2225 "values of 32 or 64 bits length");
2229 "Output format of vertex coordinates, which is "
2230 "either a text representation (ascii) or binary "
2231 "floating point values of 32 or 64 bits length");
2235 "Output format of data values, which is "
2236 "either a text representation (ascii) or binary "
2237 "floating point values of 32 or 64 bits length");
2257 "A flag indicating whether a comment should be "
2258 "written to the beginning of the output file "
2259 "indicating date and time of creation as well "
2260 "as the creating program");
2274 const int azimuth_angle,
2275 const int polar_angle,
2276 const unsigned int line_thickness,
2278 const bool draw_colorbar)
2281 , height_vector(height_vector)
2282 , azimuth_angle(azimuth_angle)
2283 , polar_angle(polar_angle)
2284 , line_thickness(line_thickness)
2286 , draw_colorbar(draw_colorbar)
2297 "A flag indicating whether POVRAY should use smoothed "
2298 "triangles instead of the usual ones");
2302 "Whether POVRAY should use bicubic patches");
2306 "Whether camera and lighting information should "
2307 "be put into an external file \"data.inc\" or into "
2308 "the POVRAY input file");
2324 const unsigned int color_vector,
2326 const unsigned int size,
2327 const double line_width,
2328 const double azimut_angle,
2329 const double turn_angle,
2330 const double z_scaling,
2331 const bool draw_mesh,
2332 const bool draw_cells,
2333 const bool shade_cells,
2335 : height_vector(height_vector)
2336 , color_vector(color_vector)
2339 , line_width(line_width)
2340 , azimut_angle(azimut_angle)
2341 , turn_angle(turn_angle)
2342 , z_scaling(z_scaling)
2343 , draw_mesh(draw_mesh)
2344 , draw_cells(draw_cells)
2345 , shade_cells(shade_cells)
2346 , color_function(color_function)
2385 double sum = xmax + xmin;
2386 double sum13 = xmin + 3 * xmax;
2387 double sum22 = 2 * xmin + 2 * xmax;
2388 double sum31 = 3 * xmin + xmax;
2389 double dif = xmax - xmin;
2390 double rezdif = 1.0 / dif;
2394 if (x < (sum31) / 4)
2396 else if (x < (sum22) / 4)
2398 else if (x < (sum13) / 4)
2409 rgb_values.
green = 0;
2410 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2414 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2415 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2418 rgb_values.
red = (4 * x - 2 *
sum) * rezdif;
2419 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2420 rgb_values.
blue = 0;
2424 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2425 rgb_values.
blue = (4. * x - sum13) * rezdif;
2432 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2446 (x - xmin) / (xmax - xmin);
2459 1 - (x - xmin) / (xmax - xmin);
2471 "Number of the input vector that is to be used to "
2472 "generate height information");
2476 "Number of the input vector that is to be used to "
2477 "generate color information");
2481 "Whether width or height should be scaled to match "
2486 "The size (width or height) to which the eps output "
2487 "file is to be scaled");
2491 "The width in which the postscript renderer is to "
2496 "Angle of the viewing position against the vertical "
2501 "Angle of the viewing direction against the y-axis");
2505 "Scaling for the z-direction relative to the scaling "
2506 "used in x- and y-directions");
2510 "Whether the mesh lines, or only the surface should be "
2515 "Whether only the mesh lines, or also the interior of "
2516 "cells should be plotted. If this flag is false, then "
2517 "one can see through the mesh");
2521 "Whether the interior of cells shall be shaded");
2525 "default|grey scale|reverse grey scale"),
2526 "Name of a color function used to colorize mesh lines "
2527 "and/or cell interiors");
2537 if (prm.
get(
"Scale to width or height") ==
"width")
2549 if (prm.
get(
"Color function") ==
"default")
2551 else if (prm.
get(
"Color function") ==
"grey scale")
2553 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2564 : zone_name(zone_name)
2565 , solution_time(solution_time)
2578 VtkFlags::VtkFlags(
const double time,
2579 const unsigned int cycle,
2580 const bool print_date_and_time,
2582 const bool write_higher_order_cells)
2585 , print_date_and_time(print_date_and_time)
2586 , compression_level(compression_level)
2587 , write_higher_order_cells(write_higher_order_cells)
2595 if (format_name ==
"none")
2598 if (format_name ==
"dx")
2601 if (format_name ==
"ucd")
2604 if (format_name ==
"gnuplot")
2607 if (format_name ==
"povray")
2610 if (format_name ==
"eps")
2613 if (format_name ==
"gmv")
2616 if (format_name ==
"tecplot")
2619 if (format_name ==
"tecplot_binary")
2622 if (format_name ==
"vtk")
2625 if (format_name ==
"vtu")
2628 if (format_name ==
"deal.II intermediate")
2631 if (format_name ==
"hdf5")
2635 ExcMessage(
"The given file format name is not recognized: <" +
2636 format_name +
">"));
2647 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2655 switch (output_format)
2694 template <
int dim,
int spacedim,
typename StreamType>
2699 unsigned int count = 0;
2701 for (
const auto &patch : patches)
2704 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2706 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2708 out.write_point(count++, compute_arbitrary_node(patch, point_no));
2713 const unsigned int n = n_subdivisions + 1;
2716 const unsigned int n1 = (dim > 0) ? n : 1;
2717 const unsigned int n2 = (dim > 1) ? n : 1;
2718 const unsigned int n3 = (dim > 2) ? n : 1;
2720 for (
unsigned int i3 = 0; i3 < n3; ++i3)
2721 for (
unsigned int i2 = 0; i2 < n2; ++i2)
2722 for (
unsigned int i1 = 0; i1 < n1; ++i1)
2725 compute_hypercube_node(patch, i1, i2, i3, n_subdivisions));
2731 template <
int dim,
int spacedim,
typename StreamType>
2736 unsigned int count = 0;
2737 unsigned int first_vertex_of_patch = 0;
2738 for (
const auto &patch : patches)
2741 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2743 out.write_cell_single(count++,
2744 first_vertex_of_patch,
2745 patch.
data.n_cols());
2746 first_vertex_of_patch += patch.
data.n_cols();
2751 const unsigned int n = n_subdivisions + 1;
2753 const unsigned int n1 = (dim > 0) ? n_subdivisions : 1;
2754 const unsigned int n2 = (dim > 1) ? n_subdivisions : 1;
2755 const unsigned int n3 = (dim > 2) ? n_subdivisions : 1;
2757 const unsigned int d1 = 1;
2758 const unsigned int d2 = n;
2759 const unsigned int d3 = n * n;
2760 for (
unsigned int i3 = 0; i3 < n3; ++i3)
2761 for (
unsigned int i2 = 0; i2 < n2; ++i2)
2762 for (
unsigned int i1 = 0; i1 < n1; ++i1)
2764 const unsigned int offset =
2765 first_vertex_of_patch + i3 * d3 + i2 * d2 + i1 * d1;
2767 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2770 first_vertex_of_patch +=
2771 Utilities::fixed_power<dim>(n_subdivisions + 1);
2778 template <
int dim,
int spacedim,
typename StreamType>
2784 unsigned int first_vertex_of_patch = 0;
2785 unsigned int count = 0;
2787 std::vector<unsigned> connectivity;
2789 std::array<unsigned, dim> cell_order;
2791 for (
const auto &patch : patches)
2795 connectivity.resize(patch.
data.n_cols());
2797 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2798 connectivity[i] = i;
2800 out.template write_high_order_cell<dim>(count++,
2801 first_vertex_of_patch,
2804 first_vertex_of_patch += patch.
data.n_cols();
2809 const unsigned int n = n_subdivisions + 1;
2811 cell_order.fill(n_subdivisions);
2812 connectivity.resize(Utilities::fixed_power<dim>(n));
2815 const unsigned int n1 = (dim > 0) ? n_subdivisions : 0;
2816 const unsigned int n2 = (dim > 1) ? n_subdivisions : 0;
2817 const unsigned int n3 = (dim > 2) ? n_subdivisions : 0;
2819 const unsigned int d1 = 1;
2820 const unsigned int d2 = n;
2821 const unsigned int d3 = n * n;
2822 for (
unsigned int i3 = 0; i3 <= n3; ++i3)
2823 for (
unsigned int i2 = 0; i2 <= n2; ++i2)
2824 for (
unsigned int i1 = 0; i1 <= n1; ++i1)
2826 const unsigned int local_index =
2827 i3 * d3 + i2 * d2 + i1 * d1;
2828 const unsigned int connectivity_index =
2829 vtk_point_index_from_ijk(i1, i2, i3, cell_order);
2830 connectivity[connectivity_index] = local_index;
2833 out.template write_high_order_cell<dim>(count++,
2834 first_vertex_of_patch,
2838 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
2846 template <
int dim,
int spacedim,
class StreamType>
2849 unsigned int n_data_sets,
2850 const bool double_precision,
2854 unsigned int count = 0;
2856 for (
const auto &patch : patches)
2859 const unsigned int n = n_subdivisions + 1;
2861 Assert((patch.
data.n_rows() == n_data_sets &&
2863 (patch.
data.n_rows() == n_data_sets + spacedim &&
2866 (n_data_sets + spacedim) :
2868 patch.
data.n_rows()));
2869 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
2872 std::vector<float> floats(n_data_sets);
2873 std::vector<double> doubles(n_data_sets);
2876 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2878 if (double_precision)
2880 for (
unsigned int data_set = 0; data_set < n_data_sets;
2882 doubles[data_set] = patch.
data(data_set, i);
2883 out.write_dataset(count, doubles);
2887 for (
unsigned int data_set = 0; data_set < n_data_sets;
2889 floats[data_set] = patch.
data(data_set, i);
2890 out.write_dataset(count, floats);
2914 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
2915 camera_horizontal[2] * camera_direction[1];
2916 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
2917 camera_horizontal[0] * camera_direction[2];
2918 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
2919 camera_horizontal[1] * camera_direction[0];
2923 phi /= (
point[0] - camera_position[0]) * camera_direction[0] +
2924 (
point[1] - camera_position[1]) * camera_direction[1] +
2925 (
point[2] - camera_position[2]) * camera_direction[2];
2929 camera_position[0] + phi * (
point[0] - camera_position[0]);
2931 camera_position[1] + phi * (
point[1] - camera_position[1]);
2933 camera_position[2] + phi * (
point[2] - camera_position[2]);
2936 projection_decomposition[0] = (projection[0] - camera_position[0] -
2937 camera_focus * camera_direction[0]) *
2938 camera_horizontal[0];
2939 projection_decomposition[0] += (projection[1] - camera_position[1] -
2940 camera_focus * camera_direction[1]) *
2941 camera_horizontal[1];
2942 projection_decomposition[0] += (projection[2] - camera_position[2] -
2943 camera_focus * camera_direction[2]) *
2944 camera_horizontal[2];
2946 projection_decomposition[1] = (projection[0] - camera_position[0] -
2947 camera_focus * camera_direction[0]) *
2949 projection_decomposition[1] += (projection[1] - camera_position[1] -
2950 camera_focus * camera_direction[1]) *
2952 projection_decomposition[1] += (projection[2] - camera_position[2] -
2953 camera_focus * camera_direction[2]) *
2956 return projection_decomposition;
2970 for (
int i = 0; i < 2; ++i)
2972 for (
int j = 0; j < 2 - i; ++j)
2974 if (points[j][2] > points[j + 1][2])
2977 points[j] = points[j + 1];
2978 points[j + 1] = temp;
2985 v_inter = points[1];
2992 A[0][0] = v_max[0] - v_min[0];
2993 A[0][1] = v_inter[0] - v_min[0];
2994 A[1][0] = v_max[1] - v_min[1];
2995 A[1][1] = v_inter[1] - v_min[1];
3001 bool col_change =
false;
3010 double temp =
A[1][0];
3015 for (
unsigned int k = 0; k < 1; k++)
3017 for (
unsigned int i = k + 1; i < 2; i++)
3019 x =
A[i][k] /
A[k][k];
3021 for (
unsigned int j = k + 1; j < 2; j++)
3022 A[i][j] =
A[i][j] -
A[k][j] * x;
3024 b[i] =
b[i] -
b[k] * x;
3028 b[1] =
b[1] /
A[1][1];
3030 for (
int i = 0; i >= 0; i--)
3034 for (
unsigned int j = i + 1; j < 2; j++)
3037 b[i] =
sum /
A[i][i];
3047 double c =
b[0] * (v_max[2] - v_min[2]) +
b[1] * (v_inter[2] - v_min[2]) +
3051 A[0][0] = v_max[0] - v_min[0];
3052 A[0][1] = v_inter[0] - v_min[0];
3053 A[1][0] = v_max[1] - v_min[1];
3054 A[1][1] = v_inter[1] - v_min[1];
3056 b[0] = 1.0 - v_min[0];
3068 double temp =
A[1][0];
3073 for (
unsigned int k = 0; k < 1; k++)
3075 for (
unsigned int i = k + 1; i < 2; i++)
3077 x =
A[i][k] /
A[k][k];
3079 for (
unsigned int j = k + 1; j < 2; j++)
3080 A[i][j] =
A[i][j] -
A[k][j] * x;
3082 b[i] =
b[i] -
b[k] * x;
3086 b[1] =
b[1] /
A[1][1];
3088 for (
int i = 0; i >= 0; i--)
3092 for (
unsigned int j = i + 1; j < 2; j++)
3095 b[i] =
sum /
A[i][i];
3105 gradient[0] =
b[0] * (v_max[2] - v_min[2]) +
3106 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3109 A[0][0] = v_max[0] - v_min[0];
3110 A[0][1] = v_inter[0] - v_min[0];
3111 A[1][0] = v_max[1] - v_min[1];
3112 A[1][1] = v_inter[1] - v_min[1];
3115 b[1] = 1.0 - v_min[1];
3126 double temp =
A[1][0];
3131 for (
unsigned int k = 0; k < 1; k++)
3133 for (
unsigned int i = k + 1; i < 2; i++)
3135 x =
A[i][k] /
A[k][k];
3137 for (
unsigned int j = k + 1; j < 2; j++)
3138 A[i][j] =
A[i][j] -
A[k][j] * x;
3140 b[i] =
b[i] -
b[k] * x;
3144 b[1] =
b[1] /
A[1][1];
3146 for (
int i = 0; i >= 0; i--)
3150 for (
unsigned int j = i + 1; j < 2; j++)
3153 b[i] =
sum /
A[i][i];
3163 gradient[1] =
b[0] * (v_max[2] - v_min[2]) +
3164 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3167 double gradient_norm =
3173 gradient[1] * (v_min[1] - v_max[1]);
3177 gradient_parameters[0] = v_min[0];
3178 gradient_parameters[1] = v_min[1];
3183 gradient_parameters[4] = v_min[2];
3184 gradient_parameters[5] = v_max[2];
3186 return gradient_parameters;
3192 template <
int dim,
int spacedim>
3196 const std::vector<std::string> & data_names,
3198 std::tuple<
unsigned int,
3211#ifndef DEAL_II_WITH_MPI
3220 if (patches.size() == 0)
3224 const unsigned int n_data_sets = data_names.size();
3226 UcdStream ucd_out(out, flags);
3229 unsigned int n_nodes;
3231 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
3237 <<
"# This file was generated by the deal.II library." <<
'\n'
3241 <<
"# For a description of the UCD format see the AVS Developer's guide."
3247 out << n_nodes <<
' ' <<
n_cells <<
' ' << n_data_sets <<
' ' << 0
3260 if (n_data_sets != 0)
3262 out << n_data_sets <<
" ";
3263 for (
unsigned int i = 0; i < n_data_sets; ++i)
3268 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3269 out << data_names[data_set]
3273 write_data(patches, n_data_sets,
true, ucd_out);
3283 template <
int dim,
int spacedim>
3287 const std::vector<std::string> & data_names,
3289 std::tuple<
unsigned int,
3301#ifndef DEAL_II_WITH_MPI
3310 if (patches.size() == 0)
3314 DXStream dx_out(out, flags);
3317 unsigned int offset = 0;
3319 const unsigned int n_data_sets = data_names.size();
3322 unsigned int n_nodes;
3324 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
3326 out <<
"object \"vertices\" class array type float rank 1 shape "
3327 << spacedim <<
" items " << n_nodes;
3331 out <<
" lsb ieee data 0" <<
'\n';
3332 offset += n_nodes * spacedim *
sizeof(float);
3336 out <<
" data follows" <<
'\n';
3345 out <<
"object \"cells\" class array type int rank 1 shape "
3350 out <<
" lsb binary data " << offset <<
'\n';
3355 out <<
" data follows" <<
'\n';
3361 out <<
"attribute \"element type\" string \"";
3368 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3375 out <<
"object \"neighbors\" class array type int rank 1 shape "
3379 for (
const auto &patch : patches)
3382 const unsigned int n1 = (dim > 0) ? n : 1;
3383 const unsigned int n2 = (dim > 1) ? n : 1;
3384 const unsigned int n3 = (dim > 2) ? n : 1;
3385 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3386 unsigned int dx = 1;
3387 unsigned int dy = n;
3388 unsigned int dz = n * n;
3390 const unsigned int patch_start =
3393 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3394 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3395 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3397 const unsigned int nx = i1 *
dx;
3398 const unsigned int ny = i2 * dy;
3399 const unsigned int nz = i3 * dz;
3411 const unsigned int nn = patch.
neighbors[0];
3415 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3421 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3426 const unsigned int nn = patch.
neighbors[1];
3429 out << (nn * cells_per_patch + ny + nz);
3435 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3442 const unsigned int nn = patch.
neighbors[2];
3446 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3452 out <<
'\t' << patch_start + nx + ny - dy + nz;
3457 const unsigned int nn = patch.
neighbors[3];
3460 out << (nn * cells_per_patch + nx + nz);
3466 out <<
'\t' << patch_start + nx + ny + dy + nz;
3474 const unsigned int nn = patch.
neighbors[4];
3478 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3484 out <<
'\t' << patch_start + nx + ny + nz - dz;
3489 const unsigned int nn = patch.
neighbors[5];
3492 out << (nn * cells_per_patch + nx + ny);
3498 out <<
'\t' << patch_start + nx + ny + nz + dz;
3506 if (n_data_sets != 0)
3508 out <<
"object \"data\" class array type float rank 1 shape "
3509 << n_data_sets <<
" items " << n_nodes;
3513 out <<
" lsb ieee data " << offset <<
'\n';
3514 offset += n_data_sets * n_nodes *
3515 ((flags.
data_double) ?
sizeof(
double) :
sizeof(float));
3519 out <<
" data follows" <<
'\n';
3524 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3528 out <<
"object \"data\" class constantarray type float rank 0 items "
3529 << n_nodes <<
" data follows" <<
'\n'
3535 out <<
"object \"deal data\" class field" <<
'\n'
3536 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3537 <<
"component \"connections\" value \"cells\"" <<
'\n'
3538 <<
"component \"data\" value \"data\"" <<
'\n';
3541 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3548 out <<
"end" <<
'\n';
3566 template <
int dim,
int spacedim>
3570 const std::vector<std::string> & data_names,
3572 std::tuple<
unsigned int,
3581#ifndef DEAL_II_WITH_MPI
3591 if (patches.size() == 0)
3595 const unsigned int n_data_sets = data_names.size();
3599 out <<
"# This file was generated by the deal.II library." <<
'\n'
3603 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3609 GnuplotFlags::ExcNotEnoughSpaceDimensionLabels());
3610 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3615 for (
const auto &data_name : data_names)
3616 out <<
'<' << data_name <<
"> ";
3622 for (
const auto &patch : patches)
3625 const unsigned int n = n_subdivisions + 1;
3627 const unsigned int n1 = (dim > 0) ? n : 1;
3628 const unsigned int n2 = (dim > 1) ? n : 1;
3629 const unsigned int n3 = (dim > 2) ? n : 1;
3630 unsigned int d1 = 1;
3631 unsigned int d2 = n;
3632 unsigned int d3 = n * n;
3634 Assert((patch.
data.n_rows() == n_data_sets &&
3636 (patch.
data.n_rows() == n_data_sets + spacedim &&
3639 (n_data_sets + spacedim) :
3641 patch.
data.n_rows()));
3642 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
3648 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3650 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3653 out << compute_hypercube_node(
3654 patch, i1, i2, 0, n_subdivisions)
3657 for (
unsigned int data_set = 0; data_set < n_data_sets;
3659 out << patch.
data(data_set, i1 * d1 + i2 * d2) <<
' ';
3675 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3676 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3677 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3681 compute_hypercube_node(patch, i1, i2, i3, n_subdivisions);
3683 if (i1 < n_subdivisions)
3687 for (
unsigned int data_set = 0; data_set < n_data_sets;
3690 << patch.
data(data_set,
3691 i1 * d1 + i2 * d2 + i3 * d3);
3695 out << compute_hypercube_node(
3696 patch, i1 + 1, i2, i3, n_subdivisions);
3698 for (
unsigned int data_set = 0; data_set < n_data_sets;
3701 << patch.
data(data_set,
3702 (i1 + 1) * d1 + i2 * d2 + i3 * d3);
3706 out <<
'\n' <<
'\n';
3710 if (i2 < n_subdivisions)
3714 for (
unsigned int data_set = 0; data_set < n_data_sets;
3717 << patch.
data(data_set,
3718 i1 * d1 + i2 * d2 + i3 * d3);
3722 out << compute_hypercube_node(
3723 patch, i1, i2 + 1, i3, n_subdivisions);
3725 for (
unsigned int data_set = 0; data_set < n_data_sets;
3728 << patch.
data(data_set,
3729 i1 * d1 + (i2 + 1) * d2 + i3 * d3);
3733 out <<
'\n' <<
'\n';
3737 if (i3 < n_subdivisions)
3741 for (
unsigned int data_set = 0; data_set < n_data_sets;
3744 << patch.
data(data_set,
3745 i1 * d1 + i2 * d2 + i3 * d3);
3749 out << compute_hypercube_node(
3750 patch, i1, i2, i3 + 1, n_subdivisions);
3752 for (
unsigned int data_set = 0; data_set < n_data_sets;
3755 << patch.
data(data_set,
3756 i1 * d1 + i2 * d2 + (i3 + 1) * d3);
3759 out <<
'\n' <<
'\n';
3774 template <
int dim,
int spacedim>
3778 const std::vector<std::string> & data_names,
3780 std::tuple<
unsigned int,
3789#ifndef DEAL_II_WITH_MPI
3798 if (patches.size() == 0)
3805 const unsigned int n_data_sets = data_names.size();
3810 out <<
"/* This file was generated by the deal.II library." <<
'\n'
3814 <<
" For a description of the POVRAY format see the POVRAY manual."
3819 out <<
"#include \"colors.inc\" " <<
'\n'
3820 <<
"#include \"textures.inc\" " <<
'\n';
3825 out <<
"#include \"data.inc\" " <<
'\n';
3831 <<
"camera {" <<
'\n'
3832 <<
" location <1,4,-7>" <<
'\n'
3833 <<
" look_at <0,0,0>" <<
'\n'
3834 <<
" angle 30" <<
'\n'
3839 <<
"light_source {" <<
'\n'
3840 <<
" <1,4,-7>" <<
'\n'
3841 <<
" color Grey" <<
'\n'
3844 <<
"light_source {" <<
'\n'
3845 <<
" <0,20,0>" <<
'\n'
3846 <<
" color White" <<
'\n'
3853 double hmin = patches[0].data(0, 0);
3854 double hmax = patches[0].data(0, 0);
3856 for (
const auto &patch : patches)
3860 Assert((patch.
data.n_rows() == n_data_sets &&
3862 (patch.
data.n_rows() == n_data_sets + spacedim &&
3865 (n_data_sets + spacedim) :
3867 patch.
data.n_rows()));
3869 Utilities::fixed_power<dim>(n_subdivisions + 1),
3872 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
3873 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
3875 const int dl = i * (n_subdivisions + 1) + j;
3876 if (patch.
data(0, dl) < hmin)
3877 hmin = patch.
data(0, dl);
3878 if (patch.
data(0, dl) > hmax)
3879 hmax = patch.
data(0, dl);
3883 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
3884 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
3890 out <<
"#declare Tex=texture{" <<
'\n'
3891 <<
" pigment {" <<
'\n'
3892 <<
" gradient y" <<
'\n'
3893 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
3894 <<
" color_map {" <<
'\n'
3895 <<
" [0.00 color Light_Purple] " <<
'\n'
3896 <<
" [0.95 color Light_Purple] " <<
'\n'
3897 <<
" [1.00 color White] " <<
'\n'
3905 out <<
'\n' <<
"mesh {" <<
'\n';
3909 for (
const auto &patch : patches)
3912 const unsigned int n = n_subdivisions + 1;
3913 const unsigned int d1 = 1;
3914 const unsigned int d2 = n;
3916 Assert((patch.
data.n_rows() == n_data_sets &&
3918 (patch.
data.n_rows() == n_data_sets + spacedim &&
3921 (n_data_sets + spacedim) :
3923 patch.
data.n_rows()));
3924 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
3928 std::vector<Point<spacedim>> ver(n * n);
3930 for (
unsigned int i2 = 0; i2 < n; ++i2)
3931 for (
unsigned int i1 = 0; i1 < n; ++i1)
3934 ver[i1 * d1 + i2 * d2] =
3935 compute_hypercube_node(patch, i1, i2, 0, n_subdivisions);
3942 std::vector<Point<3>> nrml;
3952 for (
unsigned int i = 0; i < n; ++i)
3953 for (
unsigned int j = 0; j < n; ++j)
3955 const unsigned int il = (i == 0) ? i : (i - 1);
3956 const unsigned int ir =
3957 (i == n_subdivisions) ? i : (i + 1);
3958 const unsigned int jl = (j == 0) ? j : (j - 1);
3959 const unsigned int jr =
3960 (j == n_subdivisions) ? j : (j + 1);
3963 ver[ir * d1 + j * d2](0) - ver[il * d1 + j * d2](0);
3964 h1(1) = patch.
data(0, ir * d1 + j * d2) -
3965 patch.
data(0, il * d1 + j * d2);
3967 ver[ir * d1 + j * d2](1) - ver[il * d1 + j * d2](1);
3970 ver[i * d1 + jr * d2](0) - ver[i * d1 + jl * d2](0);
3971 h2(1) = patch.
data(0, i * d1 + jr * d2) -
3972 patch.
data(0, i * d1 + jl * d2);
3974 ver[i * d1 + jr * d2](1) - ver[i * d1 + jl * d2](1);
3976 nrml[i * d1 + j * d2](0) = h1(1) * h2(2) - h1(2) * h2(1);
3977 nrml[i * d1 + j * d2](1) = h1(2) * h2(0) - h1(0) * h2(2);
3978 nrml[i * d1 + j * d2](2) = h1(0) * h2(1) - h1(1) * h2(0);
3983 std::pow(nrml[i * d1 + j * d2](1), 2.) +
3984 std::pow(nrml[i * d1 + j * d2](2), 2.));
3986 if (nrml[i * d1 + j * d2](1) < 0)
3989 for (
unsigned int k = 0; k < 3; ++k)
3990 nrml[i * d1 + j * d2](k) /=
norm;
3995 for (
unsigned int i = 0; i < n_subdivisions; ++i)
3996 for (
unsigned int j = 0; j < n_subdivisions; ++j)
3999 const int dl = i * d1 + j * d2;
4005 out <<
"smooth_triangle {" <<
'\n'
4006 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4007 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0) <<
", "
4008 << nrml[dl](1) <<
", " << nrml[dl](2) <<
">," <<
'\n';
4009 out <<
" \t<" << ver[dl + d1](0) <<
","
4010 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
4011 <<
">, <" << nrml[dl + d1](0) <<
", "
4012 << nrml[dl + d1](1) <<
", " << nrml[dl + d1](2)
4014 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4015 << patch.
data(0, dl + d1 + d2) <<
","
4016 << ver[dl + d1 + d2](1) <<
">, <"
4017 << nrml[dl + d1 + d2](0) <<
", "
4018 << nrml[dl + d1 + d2](1) <<
", "
4019 << nrml[dl + d1 + d2](2) <<
">}" <<
'\n';
4022 out <<
"smooth_triangle {" <<
'\n'
4023 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4024 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0) <<
", "
4025 << nrml[dl](1) <<
", " << nrml[dl](2) <<
">," <<
'\n';
4026 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4027 << patch.
data(0, dl + d1 + d2) <<
","
4028 << ver[dl + d1 + d2](1) <<
">, <"
4029 << nrml[dl + d1 + d2](0) <<
", "
4030 << nrml[dl + d1 + d2](1) <<
", "
4031 << nrml[dl + d1 + d2](2) <<
">," <<
'\n';
4032 out <<
"\t<" << ver[dl + d2](0) <<
","
4033 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
4034 <<
">, <" << nrml[dl + d2](0) <<
", "
4035 << nrml[dl + d2](1) <<
", " << nrml[dl + d2](2)
4041 out <<
"triangle {" <<
'\n'
4042 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4043 <<
"," << ver[dl](1) <<
">," <<
'\n';
4044 out <<
"\t<" << ver[dl + d1](0) <<
","
4045 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
4047 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4048 << patch.
data(0, dl + d1 + d2) <<
","
4049 << ver[dl + d1 + d2](1) <<
">}" <<
'\n';
4052 out <<
"triangle {" <<
'\n'
4053 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4054 <<
"," << ver[dl](1) <<
">," <<
'\n';
4055 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4056 << patch.
data(0, dl + d1 + d2) <<
","
4057 << ver[dl + d1 + d2](1) <<
">," <<
'\n';
4058 out <<
"\t<" << ver[dl + d2](0) <<
","
4059 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
4067 Assert(n_subdivisions == 3,
4070 <<
"bicubic_patch {" <<
'\n'
4071 <<
" type 0" <<
'\n'
4072 <<
" flatness 0" <<
'\n'
4073 <<
" u_steps 0" <<
'\n'
4074 <<
" v_steps 0" <<
'\n';
4075 for (
int i = 0; i < 16; ++i)
4077 out <<
"\t<" << ver[i](0) <<
"," << patch.
data(0, i) <<
","
4078 << ver[i](1) <<
">";
4083 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4090 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4101 template <
int dim,
int spacedim>
4105 const std::vector<std::string> & ,
4107 std::tuple<
unsigned int,
4119 template <
int spacedim>
4123 const std::vector<std::string> & ,
4125 std::tuple<
unsigned int,
4134#ifndef DEAL_II_WITH_MPI
4143 if (patches.size() == 0)
4153 std::multiset<EpsCell2d> cells;
4162 double heights[4] = {0, 0, 0, 0};
4166 for (
const auto &patch : patches)
4169 const unsigned int n = n_subdivisions + 1;
4170 const unsigned int d1 = 1;
4171 const unsigned int d2 = n;
4173 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4174 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4178 compute_hypercube_node(patch, i1, i2, 0, n_subdivisions);
4180 compute_hypercube_node(patch, i1 + 1, i2, 0, n_subdivisions);
4182 compute_hypercube_node(patch, i1, i2 + 1, 0, n_subdivisions);
4183 points[3] = compute_hypercube_node(
4184 patch, i1 + 1, i2 + 1, 0, n_subdivisions);
4190 patch.
data.n_rows() == 0,
4193 patch.
data.n_rows()));
4195 patch.
data.n_rows() != 0 ?
4199 heights[1] = patch.
data.n_rows() != 0 ?
4201 (i1 + 1) * d1 + i2 * d2) *
4204 heights[2] = patch.
data.n_rows() != 0 ?
4206 i1 * d1 + (i2 + 1) * d2) *
4209 heights[3] = patch.
data.n_rows() != 0 ?
4211 (i1 + 1) * d1 + (i2 + 1) * d2) *
4218 for (
unsigned int i = 0; i < 4; ++i)
4219 heights[i] = points[i](2);
4244 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4246 const double x = points[vertex](0), y = points[vertex](1),
4247 z = -heights[vertex];
4249 eps_cell.vertices[vertex](0) = -cz * x + sz * y;
4250 eps_cell.vertices[vertex](1) =
4251 -cx * sz * x - cx * cz * y - sx * z;
4275 (points[0] + points[1] + points[2] + points[3]) / 4;
4276 const double center_height =
4277 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4280 eps_cell.depth = -sx * sz * center_point(0) -
4281 sx * cz * center_point(1) + cx * center_height;
4286 patch.
data.n_rows() == 0,
4289 patch.
data.n_rows()));
4290 const double color_values[4] = {
4291 patch.
data.n_rows() != 0 ?
4295 patch.
data.n_rows() != 0 ?
4299 patch.
data.n_rows() != 0 ?
4303 patch.
data.n_rows() != 0 ?
4305 (i1 + 1) * d1 + (i2 + 1) * d2) :
4309 eps_cell.color_value = (color_values[0] + color_values[1] +
4310 color_values[3] + color_values[2]) /
4315 std::min(min_color_value, eps_cell.color_value);
4317 std::max(max_color_value, eps_cell.color_value);
4321 cells.insert(eps_cell);
4327 double x_min = cells.begin()->vertices[0](0);
4328 double x_max = x_min;
4329 double y_min = cells.begin()->vertices[0](1);
4330 double y_max = y_min;
4332 for (
const auto &cell : cells)
4333 for (
const auto &vertex : cell.vertices)
4335 x_min =
std::min(x_min, vertex(0));
4336 x_max =
std::max(x_max, vertex(0));
4337 y_min =
std::min(y_min, vertex(1));
4338 y_max =
std::max(y_max, vertex(1));
4343 const double scale =
4345 (flags.
size_type == EpsFlags::width ? x_max - x_min : y_min - y_max));
4347 const Point<2> offset(x_min, y_min);
4352 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4353 <<
"%%Title: deal.II Output" <<
'\n'
4354 <<
"%%Creator: the deal.II library" <<
'\n'
4357 <<
"%%BoundingBox: "
4361 <<
static_cast<unsigned int>((x_max - x_min) *
scale + 0.5) <<
' '
4362 <<
static_cast<unsigned int>((y_max - y_min) *
scale + 0.5) <<
'\n';
4371 out <<
"/m {moveto} bind def" <<
'\n'
4372 <<
"/l {lineto} bind def" <<
'\n'
4373 <<
"/s {setrgbcolor} bind def" <<
'\n'
4374 <<
"/sg {setgray} bind def" <<
'\n'
4375 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4376 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4378 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4380 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4388 if (max_color_value == min_color_value)
4389 max_color_value = min_color_value + 1;
4393 for (
const auto &cell : cells)
4406 out << rgb_values.
red <<
" sg ";
4408 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4409 << rgb_values.
blue <<
" s ";
4414 out << (cell.vertices[0] - offset) *
scale <<
" m "
4415 << (cell.vertices[1] - offset) *
scale <<
" l "
4416 << (cell.vertices[3] - offset) *
scale <<
" l "
4417 << (cell.vertices[2] - offset) *
scale <<
" lf" <<
'\n';
4422 << (cell.vertices[0] - offset) *
scale <<
" m "
4423 << (cell.vertices[1] - offset) *
scale <<
" l "
4424 << (cell.vertices[3] - offset) *
scale <<
" l "
4425 << (cell.vertices[2] - offset) *
scale <<
" lx" <<
'\n';
4427 out <<
"showpage" <<
'\n';
4436 template <
int dim,
int spacedim>
4440 const std::vector<std::string> & data_names,
4442 std::tuple<
unsigned int,
4458#ifndef DEAL_II_WITH_MPI
4467 if (patches.size() == 0)
4471 GmvStream gmv_out(out, flags);
4472 const unsigned int n_data_sets = data_names.size();
4475 Assert((patches[0].data.n_rows() == n_data_sets &&
4476 !patches[0].points_are_available) ||
4477 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4478 patches[0].points_are_available),
4480 (n_data_sets + spacedim) :
4482 patches[0].data.n_rows()));
4486 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4489 unsigned int n_nodes;
4491 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4506 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4508 &write_gmv_reorder_data_vectors<dim, spacedim>;
4516 out <<
"nodes " << n_nodes <<
'\n';
4517 for (
unsigned int d = 0;
d < spacedim; ++
d)
4519 gmv_out.selected_component =
d;
4525 for (
unsigned int d = spacedim;
d < 3; ++
d)
4527 for (
unsigned int i = 0; i < n_nodes; ++i)
4534 out <<
"cells " <<
n_cells <<
'\n';
4539 out <<
"variable" <<
'\n';
4543 reorder_task.
join();
4547 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4549 out << data_names[data_set] <<
" 1" <<
'\n';
4551 data_vectors[data_set].
end(),
4552 std::ostream_iterator<double>(out,
" "));
4553 out <<
'\n' <<
'\n';
4559 out <<
"endvars" <<
'\n';
4562 out <<
"endgmv" <<
'\n';
4573 template <
int dim,
int spacedim>
4577 const std::vector<std::string> & data_names,
4579 std::tuple<
unsigned int,
4593#ifndef DEAL_II_WITH_MPI
4602 if (patches.size() == 0)
4606 TecplotStream tecplot_out(out, flags);
4608 const unsigned int n_data_sets = data_names.size();
4611 Assert((patches[0].data.n_rows() == n_data_sets &&
4612 !patches[0].points_are_available) ||
4613 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4614 patches[0].points_are_available),
4616 (n_data_sets + spacedim) :
4618 patches[0].data.n_rows()));
4621 unsigned int n_nodes;
4623 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4629 <<
"# This file was generated by the deal.II library." <<
'\n'
4633 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4638 out <<
"Variables=";
4646 out <<
"\"x\", \"y\"";
4649 out <<
"\"x\", \"y\", \"z\"";
4655 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4656 out <<
", \"" << data_names[data_set] <<
"\"";
4662 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4665 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4667 out <<
"f=feblock, n=" << n_nodes <<
", e=" <<
n_cells
4668 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4687 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4689 &write_gmv_reorder_data_vectors<dim, spacedim>;
4697 for (
unsigned int d = 0;
d < spacedim; ++
d)
4699 tecplot_out.selected_component =
d;
4710 reorder_task.
join();
4713 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4716 data_vectors[data_set].
end(),
4717 std::ostream_iterator<double>(out,
"\n"));
4735#ifdef DEAL_II_HAVE_TECPLOT
4742 TecplotMacros(
const unsigned int n_nodes = 0,
4743 const unsigned int n_vars = 0,
4744 const unsigned int n_cells = 0,
4745 const unsigned int n_vert = 0);
4748 nd(
const unsigned int i,
const unsigned int j);
4750 cd(
const unsigned int i,
const unsigned int j);
4751 std::vector<float> nodalData;
4752 std::vector<int> connData;
4755 unsigned int n_nodes;
4756 unsigned int n_vars;
4758 unsigned int n_vert;
4762 inline TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
4763 const unsigned int n_vars,
4765 const unsigned int n_vert)
4771 nodalData.resize(n_nodes * n_vars);
4772 connData.resize(
n_cells * n_vert);
4777 inline TecplotMacros::~TecplotMacros()
4783 TecplotMacros::nd(
const unsigned int i,
const unsigned int j)
4785 return nodalData[i * n_nodes + j];
4791 TecplotMacros::cd(
const unsigned int i,
const unsigned int j)
4793 return connData[i + j * n_vert];
4804 template <
int dim,
int spacedim>
4808 const std::vector<std::string> & data_names,
4810 std::tuple<
unsigned int,
4814 & nonscalar_data_ranges,
4823#ifndef DEAL_II_HAVE_TECPLOT
4826 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
4834 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
4841 char *file_name = (
char *)flags.tecplot_binary_file_name;
4843 if (file_name ==
nullptr)
4848 ExcMessage(
"Specify the name of the tecplot_binary"
4849 " file through the TecplotFlags interface."));
4850 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
4857# ifndef DEAL_II_WITH_MPI
4866 if (patches.size() == 0)
4870 const unsigned int n_data_sets = data_names.size();
4873 Assert((patches[0].data.n_rows() == n_data_sets &&
4874 !patches[0].points_are_available) ||
4875 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4876 patches[0].points_are_available),
4878 (n_data_sets + spacedim) :
4880 patches[0].data.n_rows()));
4883 unsigned int n_nodes;
4885 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4887 const unsigned int vars_per_node = (spacedim + n_data_sets),
4890 TecplotMacros tm(n_nodes, vars_per_node,
n_cells, nodes_per_cell);
4892 int is_double = 0, tec_debug = 0, cell_type = tecplot_binary_cell_type[dim];
4894 std::string tec_var_names;
4898 tec_var_names =
"x y";
4901 tec_var_names =
"x y z";
4907 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4909 tec_var_names +=
" ";
4910 tec_var_names += data_names[data_set];
4926 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4928 &write_gmv_reorder_data_vectors<dim, spacedim>;
4934 for (
unsigned int d = 1;
d <= spacedim; ++
d)
4936 unsigned int entry = 0;
4938 for (
const auto &patch : patches)
4946 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4947 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4949 const double x_frac = i * 1. / n_subdivisions,
4950 y_frac = j * 1. / n_subdivisions;
4952 tm.nd((
d - 1), entry) =
static_cast<float>(
4954 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
4957 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
4966 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4967 for (
unsigned int k = 0; k < n_subdivisions + 1; ++k)
4968 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4970 const double x_frac = i * 1. / n_subdivisions,
4971 y_frac = k * 1. / n_subdivisions,
4972 z_frac = j * 1. / n_subdivisions;
4975 tm.nd((
d - 1), entry) =
static_cast<float>(
4976 ((((patch.
vertices[1](
d - 1) * x_frac) +
4977 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
4980 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
4984 (patch.
vertices[4](
d - 1) * (1 - x_frac))) *
4987 (patch.
vertices[6](
d - 1) * (1 - x_frac))) *
5005 reorder_task.
join();
5008 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5009 for (
unsigned int entry = 0; entry < data_vectors[data_set].size();
5011 tm.nd((spacedim + data_set), entry) =
5012 static_cast<float>(data_vectors[data_set][entry]);
5018 unsigned int first_vertex_of_patch = 0;
5019 unsigned int elem = 0;
5021 for (
const auto &patch : patches)
5024 const unsigned int n = n_subdivisions + 1;
5025 const unsigned int d1 = 1;
5026 const unsigned int d2 = n;
5027 const unsigned int d3 = n * n;
5033 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5034 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5037 first_vertex_of_patch + (i1)*d1 + (i2)*d2 + 1;
5039 first_vertex_of_patch + (i1 + 1) * d1 + (i2)*d2 + 1;
5040 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5043 first_vertex_of_patch + (i1)*d1 + (i2 + 1) * d2 + 1;
5052 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5053 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5054 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5059 tm.cd(0, elem) = first_vertex_of_patch + (i1)*d1 +
5060 (i2)*d2 + (i3)*d3 + 1;
5061 tm.cd(1, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5062 (i2)*d2 + (i3)*d3 + 1;
5063 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5064 (i2 + 1) * d2 + (i3)*d3 + 1;
5065 tm.cd(3, elem) = first_vertex_of_patch + (i1)*d1 +
5066 (i2 + 1) * d2 + (i3)*d3 + 1;
5067 tm.cd(4, elem) = first_vertex_of_patch + (i1)*d1 +
5068 (i2)*d2 + (i3 + 1) * d3 + 1;
5069 tm.cd(5, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5070 (i2)*d2 + (i3 + 1) * d3 + 1;
5071 tm.cd(6, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5072 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
5073 tm.cd(7, elem) = first_vertex_of_patch + (i1)*d1 +
5074 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
5087 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
5092 int ierr = 0, num_nodes =
static_cast<int>(n_nodes),
5093 num_cells =
static_cast<int>(
n_cells);
5095 char dot[2] = {
'.', 0};
5099 char *var_names =
const_cast<char *
>(tec_var_names.c_str());
5100 ierr = TECINI(
nullptr, var_names, file_name, dot, &tec_debug, &is_double);
5104 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K', 0};
5106 TECZNE(
nullptr, &num_nodes, &num_cells, &cell_type, FEBLOCK,
nullptr);
5110 int total = (vars_per_node * num_nodes);
5112 ierr = TECDAT(&total, tm.nodalData.data(), &is_double);
5116 ierr = TECNOD(tm.connData.data());
5129 template <
int dim,
int spacedim>
5133 const std::vector<std::string> & data_names,
5135 std::tuple<
unsigned int,
5139 & nonscalar_data_ranges,
5145#ifndef DEAL_II_WITH_MPI
5154 if (patches.size() == 0)
5158 VtkStream vtk_out(out, flags);
5160 const unsigned int n_data_sets = data_names.size();
5162 if (patches[0].points_are_available)
5174 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5175 <<
"#This file was generated by the deal.II library";
5183 out <<
'\n' <<
"ASCII" <<
'\n';
5185 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
5192 const unsigned int n_metadata =
5197 out <<
"FIELD FieldData " << n_metadata <<
"\n";
5201 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
"\n";
5205 out <<
"TIME 1 1 double\n" << flags.
time <<
"\n";
5211 unsigned int n_nodes,
n_cells, n_points_and_n_cells;
5212 compute_sizes(patches,
5216 n_points_and_n_cells);
5232 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5234 &write_gmv_reorder_data_vectors<dim, spacedim>;
5242 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5247 out <<
"CELLS " <<
n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5255 out <<
"CELL_TYPES " <<
n_cells <<
'\n';
5259 for (
const auto &patch : patches)
5261 const auto vtk_cell_id =
5264 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5265 out <<
' ' << vtk_cell_id[0];
5274 reorder_task.
join();
5279 out <<
"POINT_DATA " << n_nodes <<
'\n';
5283 std::vector<bool> data_set_written(n_data_sets,
false);
5284 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5291 std::get<0>(nonscalar_data_range),
5293 std::get<0>(nonscalar_data_range)));
5294 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5298 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5299 std::get<0>(nonscalar_data_range) <=
5302 "Can't declare a vector with more than 3 components "
5306 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5307 i <= std::get<1>(nonscalar_data_range);
5309 data_set_written[i] =
true;
5315 if (!std::get<2>(nonscalar_data_range).empty())
5316 out << std::get<2>(nonscalar_data_range);
5319 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5320 i < std::get<1>(nonscalar_data_range);
5322 out << data_names[i] <<
"__";
5323 out << data_names[std::get<1>(nonscalar_data_range)];
5326 out <<
" double" <<
'\n';
5329 for (
unsigned int n = 0; n < n_nodes; ++n)
5331 switch (std::get<1>(nonscalar_data_range) -
5332 std::get<0>(nonscalar_data_range))
5335 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5340 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5342 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5346 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5348 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5350 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5363 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5364 if (data_set_written[data_set] ==
false)
5366 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5367 <<
"LOOKUP_TABLE default" <<
'\n';
5369 data_vectors[data_set].
end(),
5370 std::ostream_iterator<double>(out,
" "));
5386 out <<
"<?xml version=\"1.0\" ?> \n";
5388 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5389 <<
"#This file was generated by the deal.II library";
5398 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5399#ifdef DEAL_II_WITH_ZLIB
5400 out <<
" compressor=\"vtkZLibDataCompressor\"";
5402#ifdef DEAL_II_WORDS_BIGENDIAN
5403 out <<
" byte_order=\"BigEndian\"";
5405 out <<
" byte_order=\"LittleEndian\"";
5409 out <<
"<UnstructuredGrid>";
5419 out <<
" </UnstructuredGrid>\n";
5420 out <<
"</VTKFile>\n";
5425 template <
int dim,
int spacedim>
5429 const std::vector<std::string> & data_names,
5431 std::tuple<
unsigned int,
5435 & nonscalar_data_ranges,
5440 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5447 template <
int dim,
int spacedim>
5451 const std::vector<std::string> & data_names,
5453 std::tuple<
unsigned int,
5457 & nonscalar_data_ranges,
5463#ifndef DEAL_II_WITH_MPI
5472 if (patches.size() == 0)
5477 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5479 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5481 <<
" <PointData Scalars=\"scalars\">\n";
5482 std::vector<bool> data_set_written(data_names.size(),
false);
5483 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5486 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5487 i <= std::get<1>(nonscalar_data_range);
5489 data_set_written[i] =
true;
5493 out <<
" <DataArray type=\"Float32\" Name=\"";
5495 if (!std::get<2>(nonscalar_data_range).empty())
5496 out << std::get<2>(nonscalar_data_range);
5499 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5500 i < std::get<1>(nonscalar_data_range);
5502 out << data_names[i] <<
"__";
5503 out << data_names[std::get<1>(nonscalar_data_range)];
5506 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5509 for (
unsigned int data_set = 0; data_set < data_names.size();
5511 if (data_set_written[data_set] ==
false)
5513 out <<
" <DataArray type=\"Float32\" Name=\""
5514 << data_names[data_set] <<
"\"></DataArray>\n";
5517 out <<
" </PointData>\n";
5518 out <<
"</Piece>\n";
5532 const unsigned int n_metadata =
5536 out <<
"<FieldData>\n";
5541 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5542 << flags.
cycle <<
"</DataArray>\n";
5547 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5548 << flags.
time <<
"</DataArray>\n";
5552 out <<
"</FieldData>\n";
5556 VtuStream vtu_out(out, flags);
5558 const unsigned int n_data_sets = data_names.size();
5561 if (patches[0].points_are_available)
5570#ifdef DEAL_II_WITH_ZLIB
5571 const char *ascii_or_binary =
"binary";
5573 const char * ascii_or_binary =
"ascii";
5578 unsigned int n_nodes,
n_cells, n_points_and_n_cells;
5579 compute_sizes(patches,
5583 n_points_and_n_cells);
5599 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5601 &write_gmv_reorder_data_vectors<dim, spacedim, float>;
5610 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
5612 out <<
" <Points>\n";
5613 out <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5614 << ascii_or_binary <<
"\">\n";
5616 out <<
" </DataArray>\n";
5617 out <<
" </Points>\n\n";
5620 out <<
" <Cells>\n";
5621 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5622 << ascii_or_binary <<
"\">\n";
5627 out <<
" </DataArray>\n";
5631 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5632 << ascii_or_binary <<
"\">\n";
5634 std::vector<int32_t> offsets;
5639#ifdef DEAL_II_WITH_ZLIB
5640 std::vector<uint8_t> cell_types;
5642 std::vector<unsigned int> cell_types;
5646 unsigned int first_vertex_of_patch = 0;
5648 for (
const auto &patch : patches)
5650 const auto vtk_cell_id =
5653 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5655 cell_types.push_back(vtk_cell_id[0]);
5656 first_vertex_of_patch += vtk_cell_id[2];
5657 offsets.push_back(first_vertex_of_patch);
5663 out <<
" </DataArray>\n";
5667 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5668 << ascii_or_binary <<
"\">\n";
5671 vtu_out << cell_types;
5673 out <<
" </DataArray>\n";
5674 out <<
" </Cells>\n";
5682 reorder_task.
join();
5687 out <<
" <PointData Scalars=\"scalars\">\n";
5691 std::vector<bool> data_set_written(n_data_sets,
false);
5692 for (
const auto &range : nonscalar_data_ranges)
5694 const auto first_component = std::get<0>(range);
5695 const auto last_component = std::get<1>(range);
5696 const auto &name = std::get<2>(range);
5697 const bool is_tensor =
5698 (std::get<3>(range) ==
5700 const unsigned int n_components = (is_tensor ? 9 : 3);
5707 AssertThrow((last_component + 1 - first_component <= 9),
5709 "Can't declare a tensor with more than 9 components "
5714 AssertThrow((last_component + 1 - first_component <= 3),
5716 "Can't declare a vector with more than 3 components "
5721 for (
unsigned int i = first_component; i <= last_component; ++i)
5722 data_set_written[i] =
true;
5726 out <<
" <DataArray type=\"Float32\" Name=\"";
5732 for (
unsigned int i = first_component; i < last_component; ++i)
5733 out << data_names[i] <<
"__";
5734 out << data_names[last_component];
5737 out <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
5738 << ascii_or_binary <<
"\">\n";
5741 std::vector<float> data;
5742 data.reserve(n_nodes * n_components);
5744 for (
unsigned int n = 0; n < n_nodes; ++n)
5748 switch (last_component - first_component)
5751 data.push_back(data_vectors(first_component, n));
5757 data.push_back(data_vectors(first_component, n));
5758 data.push_back(data_vectors(first_component + 1, n));
5763 data.push_back(data_vectors(first_component, n));
5764 data.push_back(data_vectors(first_component + 1, n));
5765 data.push_back(data_vectors(first_component + 2, n));
5778 const unsigned int size = last_component - first_component + 1;
5782 vtk_data[0][0] = data_vectors(first_component, n);
5787 for (
unsigned int c = 0; c < size; ++c)
5791 vtk_data[ind[0]][ind[1]] =
5792 data_vectors(first_component + c, n);
5798 for (
unsigned int c = 0; c < size; ++c)
5802 vtk_data[ind[0]][ind[1]] =
5803 data_vectors(first_component + c, n);
5814 for (
unsigned int i = 0; i < 3; ++i)
5815 for (
unsigned int j = 0; j < 3; ++j)
5816 data.push_back(vtk_data[i][j]);
5821 out <<
" </DataArray>\n";
5826 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5827 if (data_set_written[data_set] ==
false)
5829 out <<
" <DataArray type=\"Float32\" Name=\""
5830 << data_names[data_set] <<
"\" format=\"" << ascii_or_binary
5833 std::vector<float> data(data_vectors[data_set].
begin(),
5834 data_vectors[data_set].
end());
5836 out <<
" </DataArray>\n";
5839 out <<
" </PointData>\n";
5842 out <<
" </Piece>\n";
5856 const std::vector<std::string> &piece_names,
5857 const std::vector<std::string> &data_names,
5859 std::tuple<
unsigned int,
5863 &nonscalar_data_ranges)
5867 const unsigned int n_data_sets = data_names.size();
5869 out <<
"<?xml version=\"1.0\"?>\n";
5872 out <<
"#This file was generated by the deal.II library"
5877 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
5878 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
5879 out <<
" <PPointData Scalars=\"scalars\">\n";
5882 std::vector<bool> data_set_written(n_data_sets,
false);
5883 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5885 const auto first_component = std::get<0>(nonscalar_data_range);
5886 const auto last_component = std::get<1>(nonscalar_data_range);
5887 const bool is_tensor =
5888 (std::get<3>(nonscalar_data_range) ==
5890 const unsigned int n_components = (is_tensor ? 9 : 3);
5897 AssertThrow((last_component + 1 - first_component <= 9),
5899 "Can't declare a tensor with more than 9 components "
5904 Assert((last_component + 1 - first_component <= 3),
5906 "Can't declare a vector with more than 3 components "
5911 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5912 i <= std::get<1>(nonscalar_data_range);
5914 data_set_written[i] =
true;
5918 out <<
" <PDataArray type=\"Float32\" Name=\"";
5920 if (!std::get<2>(nonscalar_data_range).empty())
5921 out << std::get<2>(nonscalar_data_range);
5924 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5925 i < std::get<1>(nonscalar_data_range);
5927 out << data_names[i] <<
"__";
5928 out << data_names[std::get<1>(nonscalar_data_range)];
5931 out <<
"\" NumberOfComponents=\"" << n_components
5932 <<
"\" format=\"ascii\"/>\n";
5935 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5936 if (data_set_written[data_set] ==
false)
5938 out <<
" <PDataArray type=\"Float32\" Name=\""
5939 << data_names[data_set] <<
"\" format=\"ascii\"/>\n";
5942 out <<
" </PPointData>\n";
5944 out <<
" <PPoints>\n";
5945 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
5946 out <<
" </PPoints>\n";
5948 for (
const auto &piece_name : piece_names)
5949 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
5951 out <<
" </PUnstructuredGrid>\n";
5952 out <<
"</VTKFile>\n";
5965 const std::vector<std::pair<double, std::string>> ×_and_names)
5969 out <<
"<?xml version=\"1.0\"?>\n";
5972 out <<
"#This file was generated by the deal.II library"
5977 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
5978 out <<
" <Collection>\n";
5980 std::streamsize ss = out.precision();
5983 for (
const auto &time_and_name : times_and_names)
5984 out <<
" <DataSet timestep=\"" << time_and_name.first
5985 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
5988 out <<
" </Collection>\n";
5989 out <<
"</VTKFile>\n";
6001 const std::vector<std::string> &piece_names)
6003 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
6004 for (
const auto &piece_name : piece_names)
6005 out << piece_name <<
'\n';
6014 const std::vector<std::vector<std::string>> &piece_names)
6018 if (piece_names.size() == 0)
6021 const double nblocks = piece_names[0].size();
6023 ExcMessage(
"piece_names should be a vector of nonempty vectors."));
6025 out <<
"!NBLOCKS " << nblocks <<
'\n';
6026 for (
const auto &domain : piece_names)
6028 Assert(domain.size() == nblocks,
6030 "piece_names should be a vector of equal sized vectors."));
6031 for (
const auto &subdomain : domain)
6032 out << subdomain <<
'\n';
6043 const std::vector<std::pair<
double, std::vector<std::string>>>
6044 ×_and_piece_names)
6048 if (times_and_piece_names.size() == 0)
6051 const double nblocks = times_and_piece_names[0].second.size();
6055 "time_and_piece_names should contain nonempty vectors of filenames for every timestep."));
6057 for (
const auto &domain : times_and_piece_names)
6058 out <<
"!TIME " << domain.first <<
'\n';
6060 out <<
"!NBLOCKS " << nblocks <<
'\n';
6061 for (
const auto &domain : times_and_piece_names)
6063 Assert(domain.second.size() == nblocks,
6065 "piece_names should be a vector of equal sized vectors."));
6066 for (
const auto &subdomain : domain.second)
6067 out << subdomain <<
'\n';
6075 template <
int dim,
int spacedim>
6079 const std::vector<std::string> &,
6081 std::tuple<
unsigned int,
6091 template <
int spacedim>
6095 const std::vector<std::string> & ,
6097 std::tuple<
unsigned int,
6105 const unsigned int height = flags.
height;
6106 unsigned int width = flags.
width;
6109 unsigned int margin_in_percent = 0;
6111 margin_in_percent = 5;
6115 double x_dimension, y_dimension, z_dimension;
6117 const auto &first_patch = patches[0];
6119 unsigned int n_subdivisions = first_patch.n_subdivisions;
6120 unsigned int n = n_subdivisions + 1;
6121 const unsigned int d1 = 1;
6122 const unsigned int d2 = n;
6125 std::array<Point<spacedim>, 4> projected_points;
6128 std::array<Point<2>, 4> projection_decompositions;
6131 compute_hypercube_node(first_patch, 0, 0, 0, n_subdivisions);
6133 if (first_patch.data.n_rows() != 0)
6138 double x_min = projected_point[0];
6139 double x_max = x_min;
6140 double y_min = projected_point[1];
6141 double y_max = y_min;
6142 double z_min = first_patch.data.n_rows() != 0 ?
6145 double z_max = z_min;
6148 for (
const auto &patch : patches)
6151 n = n_subdivisions + 1;
6153 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6155 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6157 projected_points[0] =
6158 compute_hypercube_node(patch, i1, i2, 0, n_subdivisions);
6159 projected_points[1] =
6160 compute_hypercube_node(patch, i1 + 1, i2, 0, n_subdivisions);
6161 projected_points[2] =
6162 compute_hypercube_node(patch, i1, i2 + 1, 0, n_subdivisions);
6163 projected_points[3] = compute_hypercube_node(
6164 patch, i1 + 1, i2 + 1, 0, n_subdivisions);
6166 x_min =
std::min(x_min, projected_points[0][0]);
6167 x_min =
std::min(x_min, projected_points[1][0]);
6168 x_min =
std::min(x_min, projected_points[2][0]);
6169 x_min =
std::min(x_min, projected_points[3][0]);
6171 x_max =
std::max(x_max, projected_points[0][0]);
6172 x_max =
std::max(x_max, projected_points[1][0]);
6173 x_max =
std::max(x_max, projected_points[2][0]);
6174 x_max =
std::max(x_max, projected_points[3][0]);
6176 y_min =
std::min(y_min, projected_points[0][1]);
6177 y_min =
std::min(y_min, projected_points[1][1]);
6178 y_min =
std::min(y_min, projected_points[2][1]);
6179 y_min =
std::min(y_min, projected_points[3][1]);
6181 y_max =
std::max(y_max, projected_points[0][1]);
6182 y_max =
std::max(y_max, projected_points[1][1]);
6183 y_max =
std::max(y_max, projected_points[2][1]);
6184 y_max =
std::max(y_max, projected_points[3][1]);
6187 patch.
data.n_rows() == 0,
6190 patch.
data.n_rows()));
6192 z_min = std::min<double>(z_min,
6194 i1 * d1 + i2 * d2));
6195 z_min = std::min<double>(z_min,
6197 (i1 + 1) * d1 + i2 * d2));
6198 z_min = std::min<double>(z_min,
6200 i1 * d1 + (i2 + 1) * d2));
6202 std::min<double>(z_min,
6204 (i1 + 1) * d1 + (i2 + 1) * d2));
6206 z_max = std::max<double>(z_max,
6208 i1 * d1 + i2 * d2));
6209 z_max = std::max<double>(z_max,
6211 (i1 + 1) * d1 + i2 * d2));
6212 z_max = std::max<double>(z_max,
6214 i1 * d1 + (i2 + 1) * d2));
6216 std::max<double>(z_max,
6218 (i1 + 1) * d1 + (i2 + 1) * d2));
6223 x_dimension = x_max - x_min;
6224 y_dimension = y_max - y_min;
6225 z_dimension = z_max - z_min;
6232 float camera_focus = 0;
6235 camera_position[0] = 0.;
6236 camera_position[1] = 0.;
6237 camera_position[2] = z_min + 2. * z_dimension;
6239 camera_direction[0] = 0.;
6240 camera_direction[1] = 0.;
6241 camera_direction[2] = -1.;
6243 camera_horizontal[0] = 1.;
6244 camera_horizontal[1] = 0.;
6245 camera_horizontal[2] = 0.;
6247 camera_focus = .5 * z_dimension;
6253 const float angle_factor = 3.14159265f / 180.f;
6256 camera_position_temp[1] =
6259 camera_position_temp[2] =
6263 camera_direction_temp[1] =
6266 camera_direction_temp[2] =
6270 camera_horizontal_temp[1] =
6273 camera_horizontal_temp[2] =
6277 camera_position[1] = camera_position_temp[1];
6278 camera_position[2] = camera_position_temp[2];
6280 camera_direction[1] = camera_direction_temp[1];
6281 camera_direction[2] = camera_direction_temp[2];
6283 camera_horizontal[1] = camera_horizontal_temp[1];
6284 camera_horizontal[2] = camera_horizontal_temp[2];
6287 camera_position_temp[0] =
6290 camera_position_temp[1] =
6294 camera_direction_temp[0] =
6297 camera_direction_temp[1] =
6301 camera_horizontal_temp[0] =
6304 camera_horizontal_temp[1] =
6308 camera_position[0] = camera_position_temp[0];
6309 camera_position[1] = camera_position_temp[1];
6311 camera_direction[0] = camera_direction_temp[0];
6312 camera_direction[1] = camera_direction_temp[1];
6314 camera_horizontal[0] = camera_horizontal_temp[0];
6315 camera_horizontal[1] = camera_horizontal_temp[1];
6318 camera_position[0] = x_min + .5 * x_dimension;
6319 camera_position[1] = y_min + .5 * y_dimension;
6321 camera_position[0] += (z_min + 2. * z_dimension) *
6324 camera_position[1] -= (z_min + 2. * z_dimension) *
6330 double x_min_perspective, y_min_perspective;
6331 double x_max_perspective, y_max_perspective;
6332 double x_dimension_perspective, y_dimension_perspective;
6334 n_subdivisions = first_patch.n_subdivisions;
6335 n = n_subdivisions + 1;
6340 compute_hypercube_node(first_patch, 0, 0, 0, n_subdivisions);
6342 if (first_patch.data.n_rows() != 0)
6347 point[0] = projected_point[0];
6348 point[1] = projected_point[1];
6349 point[2] = first_patch.data.n_rows() != 0 ?
6353 projection_decomposition = svg_project_point(
point,
6359 x_min_perspective = projection_decomposition[0];
6360 x_max_perspective = projection_decomposition[0];
6361 y_min_perspective = projection_decomposition[1];
6362 y_max_perspective = projection_decomposition[1];
6365 for (
const auto &patch : patches)
6368 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6370 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6373 {compute_hypercube_node(patch, i1, i2, 0, n_subdivisions),
6374 compute_hypercube_node(patch, i1 + 1, i2, 0, n_subdivisions),
6375 compute_hypercube_node(patch, i1, i2 + 1, 0, n_subdivisions),
6376 compute_hypercube_node(
6377 patch, i1 + 1, i2 + 1, 0, n_subdivisions)}};
6380 patch.
data.n_rows() == 0,
6383 patch.
data.n_rows()));
6385 const std::array<Point<3>, 4>
vertices = {
6388 patch.
data.n_rows() != 0 ?
6389 patch.
data(0, i1 * d1 + i2 * d2) :
6393 patch.
data.n_rows() != 0 ?
6394 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6398 patch.
data.n_rows() != 0 ?
6399 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6403 patch.
data.n_rows() != 0 ?
6404 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6407 projection_decompositions = {
6431 static_cast<double>(
6432 projection_decompositions[0][0]));
6435 static_cast<double>(
6436 projection_decompositions[1][0]));
6439 static_cast<double>(
6440 projection_decompositions[2][0]));
6443 static_cast<double>(
6444 projection_decompositions[3][0]));
6448 static_cast<double>(
6449 projection_decompositions[0][0]));
6452 static_cast<double>(
6453 projection_decompositions[1][0]));
6456 static_cast<double>(
6457 projection_decompositions[2][0]));
6460 static_cast<double>(
6461 projection_decompositions[3][0]));
6465 static_cast<double>(
6466 projection_decompositions[0][1]));
6469 static_cast<double>(
6470 projection_decompositions[1][1]));
6473 static_cast<double>(
6474 projection_decompositions[2][1]));
6477 static_cast<double>(
6478 projection_decompositions[3][1]));
6482 static_cast<double>(
6483 projection_decompositions[0][1]));
6486 static_cast<double>(
6487 projection_decompositions[1][1]));
6490 static_cast<double>(
6491 projection_decompositions[2][1]));
6494 static_cast<double>(
6495 projection_decompositions[3][1]));
6500 x_dimension_perspective = x_max_perspective - x_min_perspective;
6501 y_dimension_perspective = y_max_perspective - y_min_perspective;
6503 std::multiset<SvgCell> cells;
6506 for (
const auto &patch : patches)
6510 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6512 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6515 {compute_hypercube_node(patch, i1, i2, 0, n_subdivisions),
6516 compute_hypercube_node(patch, i1 + 1, i2, 0, n_subdivisions),
6517 compute_hypercube_node(patch, i1, i2 + 1, 0, n_subdivisions),
6518 compute_hypercube_node(
6519 patch, i1 + 1, i2 + 1, 0, n_subdivisions)}};
6522 patch.
data.n_rows() == 0,
6525 patch.
data.n_rows()));
6531 cell.vertices[0][2] = patch.
data.n_rows() != 0 ?
6532 patch.
data(0, i1 * d1 + i2 * d2) :
6537 cell.vertices[1][2] = patch.
data.n_rows() != 0 ?
6538 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6543 cell.vertices[2][2] = patch.
data.n_rows() != 0 ?
6544 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6549 cell.vertices[3][2] =
6550 patch.
data.n_rows() != 0 ?
6551 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6554 cell.projected_vertices[0] =
6555 svg_project_point(cell.vertices[0],
6560 cell.projected_vertices[1] =
6561 svg_project_point(cell.vertices[1],
6566 cell.projected_vertices[2] =
6567 svg_project_point(cell.vertices[2],
6572 cell.projected_vertices[3] =
6573 svg_project_point(cell.vertices[3],
6579 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] +
6580 cell.vertices[2] + cell.vertices[3]);
6581 cell.projected_center = svg_project_point(cell.center,
6587 cell.depth = cell.center.distance(camera_position);
6597 width =
static_cast<unsigned int>(
6598 .5 + height * (x_dimension_perspective / y_dimension_perspective));
6599 unsigned int additional_width = 0;
6602 additional_width =
static_cast<unsigned int>(
6606 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\""
6607 << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
6609 <<
" <rect width=\"" << width + additional_width <<
"\" height=\""
6610 << height <<
"\" style=\"fill:white\"/>" <<
'\n'
6613 unsigned int triangle_counter = 0;
6616 for (
const auto &cell : cells)
6620 for (
unsigned int triangle_index = 0; triangle_index < 4;
6623 switch (triangle_index)
6626 points3d_triangle[0] = cell.vertices[0],
6627 points3d_triangle[1] = cell.vertices[1],
6628 points3d_triangle[2] = cell.center;
6631 points3d_triangle[0] = cell.vertices[1],
6632 points3d_triangle[1] = cell.vertices[3],
6633 points3d_triangle[2] = cell.center;
6636 points3d_triangle[0] = cell.vertices[3],
6637 points3d_triangle[1] = cell.vertices[2],
6638 points3d_triangle[2] = cell.center;
6641 points3d_triangle[0] = cell.vertices[2],
6642 points3d_triangle[1] = cell.vertices[0],
6643 points3d_triangle[2] = cell.center;
6650 svg_get_gradient_parameters(points3d_triangle);
6653 .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
6655 .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
6657 unsigned int start_r = 0;
6658 unsigned int start_g = 0;
6659 unsigned int start_b = 0;
6661 unsigned int stop_r = 0;
6662 unsigned int stop_g = 0;
6663 unsigned int stop_b = 0;
6665 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6666 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6668 double start_f = start_h * 6. - start_i;
6669 double start_q = 1. - start_f;
6671 double stop_f = stop_h * 6. - stop_i;
6672 double stop_q = 1. - stop_f;
6674 switch (start_i % 6)
6678 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6681 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
6686 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6689 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
6693 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
6698 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6708 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6711 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
6716 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6719 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
6723 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
6728 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6734 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
6736 gradient_start_point_3d[0] = gradient_param[0];
6737 gradient_start_point_3d[1] = gradient_param[1];
6738 gradient_start_point_3d[2] = gradient_param[4];
6740 gradient_stop_point_3d[0] = gradient_param[2];
6741 gradient_stop_point_3d[1] = gradient_param[3];
6742 gradient_stop_point_3d[2] = gradient_param[5];
6745 svg_project_point(gradient_start_point_3d,
6751 svg_project_point(gradient_stop_point_3d,
6758 out <<
" <linearGradient id=\"" << triangle_counter
6759 <<
"\" gradientUnits=\"userSpaceOnUse\" "
6761 <<
static_cast<unsigned int>(
6763 ((gradient_start_point[0] - x_min_perspective) /
6764 x_dimension_perspective) *
6765 (width - (width / 100.) * 2. * margin_in_percent) +
6766 ((width / 100.) * margin_in_percent))
6769 <<
static_cast<unsigned int>(
6770 .5 + height - (height / 100.) * margin_in_percent -
6771 ((gradient_start_point[1] - y_min_perspective) /
6772 y_dimension_perspective) *
6773 (height - (height / 100.) * 2. * margin_in_percent))
6776 <<
static_cast<unsigned int>(
6778 ((gradient_stop_point[0] - x_min_perspective) /
6779 x_dimension_perspective) *
6780 (width - (width / 100.) * 2. * margin_in_percent) +
6781 ((width / 100.) * margin_in_percent))
6784 <<
static_cast<unsigned int>(
6785 .5 + height - (height / 100.) * margin_in_percent -
6786 ((gradient_stop_point[1] - y_min_perspective) /
6787 y_dimension_perspective) *
6788 (height - (height / 100.) * 2. * margin_in_percent))
6791 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
6792 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
6793 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
6794 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
6795 <<
" </linearGradient>" <<
'\n';
6798 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
6799 double x3 = cell.projected_center[0];
6800 double y3 = cell.projected_center[1];
6802 switch (triangle_index)
6805 x1 = cell.projected_vertices[0][0],
6806 y1 = cell.projected_vertices[0][1],
6807 x2 = cell.projected_vertices[1][0],
6808 y2 = cell.projected_vertices[1][1];
6811 x1 = cell.projected_vertices[1][0],
6812 y1 = cell.projected_vertices[1][1],
6813 x2 = cell.projected_vertices[3][0],
6814 y2 = cell.projected_vertices[3][1];
6817 x1 = cell.projected_vertices[3][0],
6818 y1 = cell.projected_vertices[3][1],
6819 x2 = cell.projected_vertices[2][0],
6820 y2 = cell.projected_vertices[2][1];
6823 x1 = cell.projected_vertices[2][0],
6824 y1 = cell.projected_vertices[2][1],
6825 x2 = cell.projected_vertices[0][0],
6826 y2 = cell.projected_vertices[0][1];
6832 out <<
" <path d=\"M "
6833 <<
static_cast<unsigned int>(
6835 ((x1 - x_min_perspective) / x_dimension_perspective) *
6836 (width - (width / 100.) * 2. * margin_in_percent) +
6837 ((width / 100.) * margin_in_percent))
6839 <<
static_cast<unsigned int>(
6840 .5 + height - (height / 100.) * margin_in_percent -
6841 ((y1 - y_min_perspective) / y_dimension_perspective) *
6842 (height - (height / 100.) * 2. * margin_in_percent))
6844 <<
static_cast<unsigned int>(
6846 ((x2 - x_min_perspective) / x_dimension_perspective) *
6847 (width - (width / 100.) * 2. * margin_in_percent) +
6848 ((width / 100.) * margin_in_percent))
6850 <<
static_cast<unsigned int>(
6851 .5 + height - (height / 100.) * margin_in_percent -
6852 ((y2 - y_min_perspective) / y_dimension_perspective) *
6853 (height - (height / 100.) * 2. * margin_in_percent))
6855 <<
static_cast<unsigned int>(
6857 ((x3 - x_min_perspective) / x_dimension_perspective) *
6858 (width - (width / 100.) * 2. * margin_in_percent) +
6859 ((width / 100.) * margin_in_percent))
6861 <<
static_cast<unsigned int>(
6862 .5 + height - (height / 100.) * margin_in_percent -
6863 ((y3 - y_min_perspective) / y_dimension_perspective) *
6864 (height - (height / 100.) * 2. * margin_in_percent))
6866 <<
static_cast<unsigned int>(
6868 ((x1 - x_min_perspective) / x_dimension_perspective) *
6869 (width - (width / 100.) * 2. * margin_in_percent) +
6870 ((width / 100.) * margin_in_percent))
6872 <<
static_cast<unsigned int>(
6873 .5 + height - (height / 100.) * margin_in_percent -
6874 ((y1 - y_min_perspective) / y_dimension_perspective) *
6875 (height - (height / 100.) * 2. * margin_in_percent))
6876 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter
6887 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
6889 unsigned int element_height =
static_cast<unsigned int>(
6890 ((height / 100.) * (71. - 2. * margin_in_percent)) / 4);
6891 unsigned int element_width =
6892 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
6894 additional_width = 0;
6897 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
6899 for (
unsigned int index = 0; index < 4; index++)
6901 double start_h = .667 - ((index + 1) / 4.) * .667;
6902 double stop_h = .667 - (index / 4.) * .667;
6904 unsigned int start_r = 0;
6905 unsigned int start_g = 0;
6906 unsigned int start_b = 0;
6908 unsigned int stop_r = 0;
6909 unsigned int stop_g = 0;
6910 unsigned int stop_b = 0;
6912 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6913 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6915 double start_f = start_h * 6. - start_i;
6916 double start_q = 1. - start_f;
6918 double stop_f = stop_h * 6. - stop_i;
6919 double stop_q = 1. - stop_f;
6921 switch (start_i % 6)
6925 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6928 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
6933 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6936 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
6940 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
6945 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6955 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6958 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
6963 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6966 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
6970 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
6975 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6982 out <<
" <linearGradient id=\"colorbar_" << index
6983 <<
"\" gradientUnits=\"userSpaceOnUse\" "
6984 <<
"x1=\"" << width + additional_width <<
"\" "
6986 <<
static_cast<unsigned int>(.5 + (height / 100.) *
6987 (margin_in_percent + 29)) +
6988 (3 - index) * element_height
6990 <<
"x2=\"" << width + additional_width <<
"\" "
6992 <<
static_cast<unsigned int>(.5 + (height / 100.) *
6993 (margin_in_percent + 29)) +
6994 (4 - index) * element_height
6997 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
6998 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
6999 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
7000 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
7001 <<
" </linearGradient>" <<
'\n';
7006 <<
" x=\"" << width + additional_width <<
"\" y=\""
7007 <<
static_cast<unsigned int>(.5 + (height / 100.) *
7008 (margin_in_percent + 29)) +
7009 (3 - index) * element_height
7010 <<
"\" width=\"" << element_width <<
"\" height=\""
7012 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_"
7013 << index <<
")\"/>" <<
'\n';
7016 for (
unsigned int index = 0; index < 5; index++)
7020 << width + additional_width +
7021 static_cast<unsigned int>(1.5 * element_width)
7023 <<
static_cast<unsigned int>(
7024 .5 + (height / 100.) * (margin_in_percent + 29) +
7025 (4. - index) * element_height + 30.)
7027 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
7029 if (index == 0 || index == 4)
7030 out <<
"; font-weight:bold";
7033 <<
static_cast<float>(
7034 (
static_cast<int>((z_min + index * (z_dimension / 4.)) *
7043 out <<
"</text>" <<
'\n';
7048 out <<
'\n' <<
"</svg>";
7054 template <
int dim,
int spacedim>
7058 const std::vector<std::string> & data_names,
7060 std::tuple<
unsigned int,
7064 &nonscalar_data_ranges,
7073 out << dim <<
' ' << spacedim <<
'\n';
7076 out <<
"[deal.II intermediate format graphics data]" <<
'\n'
7079 <<
"[Version: " << Deal_II_IntermediateFlags::format_version <<
"]"
7082 out << data_names.size() <<
'\n';
7083 for (
const auto &data_name : data_names)
7084 out << data_name <<
'\n';
7086 out << patches.size() <<
'\n';
7087 for (
unsigned int i = 0; i < patches.size(); ++i)
7088 out << patches[i] <<
'\n';
7090 out << nonscalar_data_ranges.size() <<
'\n';
7091 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
7092 out << std::get<0>(nonscalar_data_range) <<
' '
7093 << std::get<1>(nonscalar_data_range) <<
'\n'
7094 << std::get<2>(nonscalar_data_range) <<
'\n';
7103 std::pair<unsigned int, unsigned int>
7108 unsigned int dim, spacedim;
7109 input >> dim >> spacedim;
7111 return std::make_pair(dim, spacedim);
7120template <
int dim,
int spacedim>
7122 : default_subdivisions(1)
7128template <
int dim,
int spacedim>
7133 get_dataset_names(),
7134 get_nonscalar_data_ranges(),
7141template <
int dim,
int spacedim>
7146 get_dataset_names(),
7147 get_nonscalar_data_ranges(),
7154template <
int dim,
int spacedim>
7159 get_dataset_names(),
7160 get_nonscalar_data_ranges(),
7167template <
int dim,
int spacedim>
7172 get_dataset_names(),
7173 get_nonscalar_data_ranges(),
7180template <
int dim,
int spacedim>
7185 get_dataset_names(),
7186 get_nonscalar_data_ranges(),
7193template <
int dim,
int spacedim>
7198 get_dataset_names(),
7199 get_nonscalar_data_ranges(),
7206template <
int dim,
int spacedim>
7211 get_dataset_names(),
7212 get_nonscalar_data_ranges(),
7219template <
int dim,
int spacedim>
7224 get_dataset_names(),
7225 get_nonscalar_data_ranges(),
7230template <
int dim,
int spacedim>
7235 get_dataset_names(),
7236 get_nonscalar_data_ranges(),
7241template <
int dim,
int spacedim>
7246 get_dataset_names(),
7247 get_nonscalar_data_ranges(),
7252template <
int dim,
int spacedim>
7255 const std::string &filename,
7258#ifndef DEAL_II_WITH_MPI
7262 std::ofstream f(filename);
7270 int ierr = MPI_Info_create(&info);
7273 ierr = MPI_File_open(
comm,
7275 MPI_MODE_CREATE | MPI_MODE_WRONLY,
7280 ierr = MPI_File_set_size(fh, 0);
7284 ierr = MPI_Barrier(
comm);
7286 ierr = MPI_Info_free(&info);
7289 unsigned int header_size;
7294 std::stringstream ss;
7296 header_size = ss.str().size();
7297 ierr = MPI_File_write(fh,
7305 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0,
comm);
7308 ierr = MPI_File_seek_shared(fh, header_size, MPI_SEEK_SET);
7311 const auto &patches = get_patches();
7320 std::stringstream ss;
7321 if (my_n_patches > 0 || (global_n_patches == 0 && myrank == 0))
7323 get_dataset_names(),
7324 get_nonscalar_data_ranges(),
7328 ierr = MPI_File_write_ordered(fh,
7339 std::stringstream ss;
7341 unsigned int footer_size = ss.str().size();
7342 ierr = MPI_File_write_shared(fh,
7349 ierr = MPI_File_close(&fh);
7355template <
int dim,
int spacedim>
7359 const std::vector<std::string> &piece_names)
const
7363 get_dataset_names(),
7364 get_nonscalar_data_ranges());
7368template <
int dim,
int spacedim>
7371 const std::string &directory,
7372 const std::string &filename_without_extension,
7373 const unsigned int counter,
7375 const unsigned int n_digits_for_counter,
7376 const unsigned int n_groups)
const
7379 const unsigned int n_ranks =
7381 const unsigned int n_files_written =
7382 (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
7387 const unsigned int n_digits =
7390 const unsigned int color = rank % n_files_written;
7391 const std::string filename =
7392 directory + filename_without_extension +
"_" +
7396 if (n_groups == 0 || n_groups > n_ranks)
7399 std::ofstream output(filename.c_str());
7403 else if (n_groups == 1)
7406 this->write_vtu_in_parallel(filename.c_str(), mpi_communicator);
7410#ifdef DEAL_II_WITH_MPI
7413 int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group);
7415 this->write_vtu_in_parallel(filename.c_str(), comm_group);
7416 ierr = MPI_Comm_free(&comm_group);
7424 const std::string pvtu_filename =
7425 filename_without_extension +
"_" +
7430 std::vector<std::string> filename_vector;
7431 for (
unsigned int i = 0; i < n_files_written; ++i)
7433 const std::string filename =
7434 filename_without_extension +
"_" +
7438 filename_vector.emplace_back(filename);
7441 std::ofstream pvtu_output((directory + pvtu_filename).c_str());
7445 return pvtu_filename;
7450template <
int dim,
int spacedim>
7453 std::ostream &out)
const
7456 get_dataset_names(),
7457 get_nonscalar_data_ranges(),
7458 deal_II_intermediate_flags,
7463template <
int dim,
int spacedim>
7467 const std::string & h5_filename,
7468 const double cur_time,
7471 return create_xdmf_entry(
7472 data_filter, h5_filename, h5_filename, cur_time,
comm);
7477template <
int dim,
int spacedim>
7481 const std::string & h5_mesh_filename,
7482 const std::string & h5_solution_filename,
7483 const double cur_time,
7486 unsigned int local_node_cell_count[2], global_node_cell_count[2];
7488#ifndef DEAL_II_WITH_HDF5
7492 (void)h5_mesh_filename;
7493 (void)h5_solution_filename;
7499 ExcMessage(
"XDMF only supports 2 or 3 space dimensions."));
7501 local_node_cell_count[0] = data_filter.
n_nodes();
7502 local_node_cell_count[1] = data_filter.
n_cells();
7505#ifdef DEAL_II_WITH_MPI
7507 int ierr = MPI_Allreduce(local_node_cell_count,
7508 global_node_cell_count,
7516 const int myrank = 0;
7517 global_node_cell_count[0] = local_node_cell_count[0];
7518 global_node_cell_count[1] = local_node_cell_count[1];
7525 h5_solution_filename,
7527 global_node_cell_count[0],
7528 global_node_cell_count[1],
7531 unsigned int n_data_sets = data_filter.
n_data_sets();
7536 for (i = 0; i < n_data_sets; ++i)
7550template <
int dim,
int spacedim>
7553 const std::vector<XDMFEntry> &entries,
7554 const std::string & filename,
7557#ifdef DEAL_II_WITH_MPI
7561 const int myrank = 0;
7567 std::ofstream xdmf_file(filename.c_str());
7568 std::vector<XDMFEntry>::const_iterator it;
7570 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
7571 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
7572 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
7573 xdmf_file <<
" <Domain>\n";
7575 <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
7578 const auto &patches = get_patches();
7581 for (it = entries.begin(); it != entries.end(); ++it)
7586 xdmf_file <<
" </Grid>\n";
7587 xdmf_file <<
" </Domain>\n";
7588 xdmf_file <<
"</Xdmf>\n";
7600template <
int dim,
int spacedim>
7606 get_dataset_names(),
7607 get_nonscalar_data_ranges(),
7613template <
int dim,
int spacedim>
7617 const std::vector<std::string> & data_names,
7619 std::tuple<
unsigned int,
7623 & nonscalar_data_ranges,
7626 const unsigned int n_data_sets = data_names.size();
7627 unsigned int n_node, n_cell;
7631#ifndef DEAL_II_WITH_MPI
7640 if (patches.size() == 0)
7644 compute_sizes<dim, spacedim>(patches, n_node, n_cell);
7647 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
7649 &DataOutBase::template write_gmv_reorder_data_vectors<dim, spacedim>;
7657 reorder_task.
join();
7661 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
7662 std::string vector_name;
7663 for (n_th_vector = 0, data_set = 0; data_set < n_data_sets;)
7666 while (n_th_vector < nonscalar_data_ranges.size() &&
7667 std::get<0>(nonscalar_data_ranges[n_th_vector]) < data_set)
7671 if (n_th_vector < nonscalar_data_ranges.size() &&
7672 std::get<0>(nonscalar_data_ranges[n_th_vector]) == data_set)
7675 pt_data_vector_dim = std::get<1>(nonscalar_data_ranges[n_th_vector]) -
7676 std::get<0>(nonscalar_data_ranges[n_th_vector]) +
7681 std::get<1>(nonscalar_data_ranges[n_th_vector]) >=
7682 std::get<0>(nonscalar_data_ranges[n_th_vector]),
7683 ExcLowerRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
7684 std::get<0>(nonscalar_data_ranges[n_th_vector])));
7686 std::get<1>(nonscalar_data_ranges[n_th_vector]) < n_data_sets,
7687 ExcIndexRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
7693 if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
7695 vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
7700 for (i = std::get<0>(nonscalar_data_ranges[n_th_vector]);
7701 i < std::get<1>(nonscalar_data_ranges[n_th_vector]);
7703 vector_name += data_names[i] +
"__";
7705 data_names[std::get<1>(nonscalar_data_ranges[n_th_vector])];
7711 pt_data_vector_dim = 1;
7712 vector_name = data_names[data_set];
7722 data_set += pt_data_vector_dim;
7728template <
int dim,
int spacedim>
7732 const std::string & filename,
7740template <
int dim,
int spacedim>
7744 const bool write_mesh_file,
7745 const std::string & mesh_filename,
7746 const std::string & solution_filename,
7759template <
int dim,
int spacedim>
7764 const std::string & filename,
7772template <
int dim,
int spacedim>
7777 const bool write_mesh_file,
7778 const std::string & mesh_filename,
7779 const std::string & solution_filename,
7785 "DataOutBase was asked to write HDF5 output for a space dimension of 1. "
7786 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
7790#ifndef DEAL_II_WITH_HDF5
7795 (void)write_mesh_file;
7796 (void)mesh_filename;
7797 (void)solution_filename;
7801# ifndef DEAL_II_WITH_MPI
7813 hid_t h5_mesh_file_id = -1, h5_solution_file_id, file_plist_id, plist_id;
7814 hid_t node_dataspace, node_dataset, node_file_dataspace,
7815 node_memory_dataspace;
7816 hid_t cell_dataspace, cell_dataset, cell_file_dataspace,
7817 cell_memory_dataspace;
7818 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace,
7819 pt_data_memory_dataspace;
7821 unsigned int local_node_cell_count[2];
7822 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
7823 std::vector<double> node_data_vec;
7824 std::vector<unsigned int> cell_data_vec;
7827# ifndef H5_HAVE_PARALLEL
7828# ifdef DEAL_II_WITH_MPI
7833 "Serial HDF5 output on multiple processes is not yet supported."));
7837 local_node_cell_count[0] = data_filter.
n_nodes();
7838 local_node_cell_count[1] = data_filter.
n_cells();
7841 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
7844# ifdef DEAL_II_WITH_MPI
7845# ifdef H5_HAVE_PARALLEL
7847 status = H5Pset_fapl_mpio(file_plist_id,
comm, MPI_INFO_NULL);
7855 unsigned int global_node_cell_count[2] = {0, 0};
7856 unsigned int global_node_cell_offsets[2] = {0, 0};
7858# ifdef DEAL_II_WITH_MPI
7859 ierr = MPI_Allreduce(local_node_cell_count,
7860 global_node_cell_count,
7866 ierr = MPI_Exscan(local_node_cell_count,
7867 global_node_cell_offsets,
7874 global_node_cell_count[0] = local_node_cell_count[0];
7875 global_node_cell_count[1] = local_node_cell_count[1];
7876 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
7880 plist_id = H5Pcreate(H5P_DATASET_XFER);
7882# ifdef DEAL_II_WITH_MPI
7883# ifdef H5_HAVE_PARALLEL
7884 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
7889 if (write_mesh_file)
7892 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(),
7900 node_ds_dim[0] = global_node_cell_count[0];
7901 node_ds_dim[1] = (spacedim < 2) ? 2 : spacedim;
7902 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
7905 cell_ds_dim[0] = global_node_cell_count[1];
7906 cell_ds_dim[1] = patches[0].reference_cell.n_vertices();
7907 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
7911# if H5Gcreate_vers == 1
7912 node_dataset = H5Dcreate(h5_mesh_file_id,
7918 node_dataset = H5Dcreate(h5_mesh_file_id,
7927# if H5Gcreate_vers == 1
7928 cell_dataset = H5Dcreate(
7929 h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
7931 cell_dataset = H5Dcreate(h5_mesh_file_id,
7942 status = H5Sclose(node_dataspace);
7944 status = H5Sclose(cell_dataspace);
7949 count[0] = local_node_cell_count[0];
7950 count[1] = (spacedim < 2) ? 2 : spacedim;
7952 offset[0] = global_node_cell_offsets[0];
7955 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7959 node_file_dataspace = H5Dget_space(node_dataset);
7961 status = H5Sselect_hyperslab(
7962 node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7966 count[0] = local_node_cell_count[1];
7967 count[1] = patches[0].reference_cell.n_vertices();
7968 offset[0] = global_node_cell_offsets[1];
7970 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7973 cell_file_dataspace = H5Dget_space(cell_dataset);
7975 status = H5Sselect_hyperslab(
7976 cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7981 status = H5Dwrite(node_dataset,
7983 node_memory_dataspace,
7984 node_file_dataspace,
7986 node_data_vec.data());
7988 node_data_vec.clear();
7991 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
7992 status = H5Dwrite(cell_dataset,
7994 cell_memory_dataspace,
7995 cell_file_dataspace,
7997 cell_data_vec.data());
7999 cell_data_vec.clear();
8002 status = H5Sclose(node_file_dataspace);
8004 status = H5Sclose(cell_file_dataspace);
8008 status = H5Sclose(node_memory_dataspace);
8010 status = H5Sclose(cell_memory_dataspace);
8014 status = H5Dclose(node_dataset);
8016 status = H5Dclose(cell_dataset);
8020 if (mesh_filename != solution_filename)
8022 status = H5Fclose(h5_mesh_file_id);
8028 if (mesh_filename == solution_filename && write_mesh_file)
8030 h5_solution_file_id = h5_mesh_file_id;
8035 h5_solution_file_id = H5Fcreate(solution_filename.c_str(),
8045 std::string vector_name;
8054 node_ds_dim[0] = global_node_cell_count[0];
8055 node_ds_dim[1] = pt_data_vector_dim;
8056 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
8059# if H5Gcreate_vers == 1
8060 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8061 vector_name.c_str(),
8066 pt_data_dataset = H5Dcreate(h5_solution_file_id,
8067 vector_name.c_str(),
8077 count[0] = local_node_cell_count[0];
8078 count[1] = pt_data_vector_dim;
8079 offset[0] = global_node_cell_offsets[0];
8081 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
8085 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
8087 status = H5Sselect_hyperslab(pt_data_file_dataspace,
8096 status = H5Dwrite(pt_data_dataset,
8098 pt_data_memory_dataspace,
8099 pt_data_file_dataspace,
8105 status = H5Sclose(pt_data_dataspace);
8107 status = H5Sclose(pt_data_memory_dataspace);
8109 status = H5Sclose(pt_data_file_dataspace);
8112 status = H5Dclose(pt_data_dataset);
8117 status = H5Pclose(file_plist_id);
8121 status = H5Pclose(plist_id);
8125 status = H5Fclose(h5_solution_file_id);
8132template <
int dim,
int spacedim>
8140 output_format = default_fmt;
8142 switch (output_format)
8198template <
int dim,
int spacedim>
8207template <
int dim,
int spacedim>
8208template <
typename FlagType>
8214 if (
typeid(flags) ==
typeid(dx_flags))
8216 else if (
typeid(flags) ==
typeid(ucd_flags))
8218 else if (
typeid(flags) ==
typeid(povray_flags))
8220 else if (
typeid(flags) ==
typeid(eps_flags))
8222 else if (
typeid(flags) ==
typeid(gmv_flags))
8224 else if (
typeid(flags) ==
typeid(tecplot_flags))
8227 else if (
typeid(flags) ==
typeid(vtk_flags))
8229 else if (
typeid(flags) ==
typeid(svg_flags))
8231 else if (
typeid(flags) ==
typeid(gnuplot_flags))
8234 else if (
typeid(flags) ==
typeid(deal_II_intermediate_flags))
8235 deal_II_intermediate_flags =
8243template <
int dim,
int spacedim>
8256template <
int dim,
int spacedim>
8263 "A name for the output format to be used");
8267 "Number of subdivisions of each mesh cell");
8309template <
int dim,
int spacedim>
8313 const std::string &output_name = prm.
get(
"Output format");
8315 default_subdivisions = prm.
get_integer(
"Subdivisions");
8318 dx_flags.parse_parameters(prm);
8322 ucd_flags.parse_parameters(prm);
8326 gnuplot_flags.parse_parameters(prm);
8330 povray_flags.parse_parameters(prm);
8334 eps_flags.parse_parameters(prm);
8338 gmv_flags.parse_parameters(prm);
8342 tecplot_flags.parse_parameters(prm);
8346 vtk_flags.parse_parameters(prm);
8350 deal_II_intermediate_flags.parse_parameters(prm);
8356template <
int dim,
int spacedim>
8360 return (
sizeof(default_fmt) +
8375template <
int dim,
int spacedim>
8377 std::tuple<
unsigned int,
8384 std::tuple<
unsigned int,
8391template <
int dim,
int spacedim>
8399 std::set<std::string> all_names;
8402 std::tuple<
unsigned int,
8406 ranges = this->get_nonscalar_data_ranges();
8407 const std::vector<std::string> data_names = this->get_dataset_names();
8408 const unsigned int n_data_sets = data_names.size();
8409 std::vector<bool> data_set_written(n_data_sets,
false);
8411 for (
const auto &range : ranges)
8413 const std::string &name = std::get<2>(range);
8416 Assert(all_names.find(name) == all_names.end(),
8418 "Error: names of fields in DataOut need to be unique, "
8420 name +
"' is used more than once."));
8421 all_names.insert(name);
8422 for (
unsigned int i = std::get<0>(range); i <= std::get<1>(range);
8424 data_set_written[i] =
true;
8428 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
8429 if (data_set_written[data_set] ==
false)
8431 const std::string &name = data_names[data_set];
8432 Assert(all_names.find(name) == all_names.end(),
8434 "Error: names of fields in DataOut need to be unique, "
8436 name +
"' is used more than once."));
8437 all_names.insert(name);
8447template <
int dim,
int spacedim>
8455 std::vector<typename ::DataOutBase::Patch<dim, spacedim>> tmp;
8459 std::vector<std::string> tmp;
8460 tmp.swap(dataset_names);
8464 std::tuple<
unsigned int,
8469 tmp.swap(nonscalar_data_ranges);
8476 std::pair<unsigned int, unsigned int> dimension_info =
8479 (dimension_info.second == spacedim),
8480 ExcIncompatibleDimensions(
8481 dimension_info.first, dim, dimension_info.second, spacedim));
8490 getline(in, header);
8492 std::ostringstream s;
8493 s <<
"[deal.II intermediate format graphics data]";
8495 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
8499 getline(in, header);
8501 std::ostringstream s;
8505 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
8509 getline(in, header);
8511 std::ostringstream s;
8515 Assert(header == s.str(),
8517 "Invalid or incompatible file format. Intermediate format "
8518 "files can only be read by the same deal.II version as they "
8519 "are written by."));
8523 unsigned int n_datasets;
8525 dataset_names.resize(n_datasets);
8526 for (
unsigned int i = 0; i < n_datasets; ++i)
8527 in >> dataset_names[i];
8529 unsigned int n_patches;
8531 patches.resize(n_patches);
8532 for (
unsigned int i = 0; i < n_patches; ++i)
8535 unsigned int n_nonscalar_data_ranges;
8536 in >> n_nonscalar_data_ranges;
8537 nonscalar_data_ranges.resize(n_nonscalar_data_ranges);
8538 for (
unsigned int i = 0; i < n_nonscalar_data_ranges; ++i)
8540 in >> std::get<0>(nonscalar_data_ranges[i]) >>
8541 std::get<1>(nonscalar_data_ranges[i]);
8550 std::get<2>(nonscalar_data_ranges[i]) = name;
8558template <
int dim,
int spacedim>
8562 using Patch = typename ::DataOutBase::Patch<dim, spacedim>;
8565 const std::vector<Patch> &source_patches = source.
get_patches();
8573 Assert(get_nonscalar_data_ranges().size() ==
8575 ExcMessage(
"Both sources need to declare the same components "
8577 for (
unsigned int i = 0; i < get_nonscalar_data_ranges().size(); ++i)
8579 Assert(std::get<0>(get_nonscalar_data_ranges()[i]) ==
8581 ExcMessage(
"Both sources need to declare the same components "
8583 Assert(std::get<1>(get_nonscalar_data_ranges()[i]) ==
8585 ExcMessage(
"Both sources need to declare the same components "
8587 Assert(std::get<2>(get_nonscalar_data_ranges()[i]) ==
8589 ExcMessage(
"Both sources need to declare the same components "
8594 Assert(patches[0].n_subdivisions == source_patches[0].n_subdivisions,
8596 Assert(patches[0].data.n_rows() == source_patches[0].data.n_rows(),
8598 Assert(patches[0].data.n_cols() == source_patches[0].data.n_cols(),
8603 const unsigned int old_n_patches = patches.size();
8604 patches.insert(patches.end(), source_patches.begin(), source_patches.end());
8607 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
8608 patches[i].patch_index += old_n_patches;
8611 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
8613 if (patches[i].neighbors[n] !=
8615 patches[i].neighbors[n] += old_n_patches;
8620template <
int dim,
int spacedim>
8621const std::vector<typename ::DataOutBase::Patch<dim, spacedim>> &
8629template <
int dim,
int spacedim>
8630std::vector<std::string>
8633 return dataset_names;
8638template <
int dim,
int spacedim>
8640 std::tuple<
unsigned int,
8646 return nonscalar_data_ranges;
8655 , h5_sol_filename(
"")
8656 , h5_mesh_filename(
"")
8668 const unsigned int nodes,
8669 const unsigned int cells,
8670 const unsigned int dim)
8671 :
XDMFEntry(filename, filename, time, nodes, cells, dim, dim)
8677 const std::string &solution_filename,
8679 const unsigned int nodes,
8680 const unsigned int cells,
8681 const unsigned int dim)
8682 :
XDMFEntry(mesh_filename, solution_filename, time, nodes, cells, dim, dim)
8688 const std::string &solution_filename,
8690 const unsigned int nodes,
8691 const unsigned int cells,
8692 const unsigned int dim,
8693 const unsigned int spacedim)
8695 , h5_sol_filename(solution_filename)
8696 , h5_mesh_filename(mesh_filename)
8701 , space_dimension(spacedim)
8708 const unsigned int dimension)
8721 indent(
const unsigned int indent_level)
8723 std::string res =
"";
8724 for (
unsigned int i = 0; i < indent_level; ++i)
8739 ReferenceCells::get_hypercube<0>());
8742 ReferenceCells::get_hypercube<1>());
8745 ReferenceCells::get_hypercube<2>());
8748 ReferenceCells::get_hypercube<3>());
8765 std::stringstream ss;
8766 ss << indent(indent_level + 0)
8767 <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
8768 ss << indent(indent_level + 1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
8769 ss << indent(indent_level + 1) <<
"<Geometry GeometryType=\""
8771 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
8773 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
8775 ss << indent(indent_level + 2) <<
"</DataItem>\n";
8776 ss << indent(indent_level + 1) <<
"</Geometry>\n";
8781 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\"";
8799 ss <<
"Quadrilateral";
8818 ss <<
"Tetrahedron";
8822 ss <<
"\" NumberOfElements=\"" <<
num_cells;
8824 ss <<
"\" NodesPerElement=\"1\">\n";
8826 ss <<
"\" NodesPerElement=\"2\">\n";
8831 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_cells
8833 <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
8836 ss << indent(indent_level + 2) <<
"</DataItem>\n";
8837 ss << indent(indent_level + 1) <<
"</Topology>\n";
8843 ss << indent(indent_level + 1)
8844 <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\""
8846 ss << indent(indent_level + 1) <<
"</Topology>\n";
8851 ss << indent(indent_level + 1) <<
"<Attribute Name=\""
8852 << attribute_dim.first <<
"\" AttributeType=\""
8853 << (attribute_dim.second > 1 ?
"Vector" :
"Scalar")
8854 <<
"\" Center=\"Node\">\n";
8856 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
8857 <<
" " << (attribute_dim.second > 1 ? 3 : 1)
8858 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
8860 << attribute_dim.first <<
"\n";
8861 ss << indent(indent_level + 2) <<
"</DataItem>\n";
8862 ss << indent(indent_level + 1) <<
"</Attribute>\n";
8865 ss << indent(indent_level + 0) <<
"</Grid>\n";
8874 template <
int dim,
int spacedim>
8879 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]"
8895 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
8896 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
8897 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
8898 out << patch.
data[i][j] <<
' ';
8906 template <
int dim,
int spacedim>
8918 getline(in, header);
8919 while ((header.size() != 0) && (header[header.size() - 1] ==
' '))
8920 header.erase(header.size() - 1);
8922 while ((header.empty()) && in);
8924 std::ostringstream s;
8925 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
8927 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
8942 unsigned int n_rows, n_cols;
8943 in >> n_rows >> n_cols;
8944 patch.
data.reinit(n_rows, n_cols);
8945 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
8946 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
8947 in >> patch.
data[i][j];
8958#include "data_out_base.inst"
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
void enter_subsection(const std::string &subsection)
unsigned int n_vertices() const
SymmetricTensor< rank, dim, Number > sum(const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm &mpi_communicator)
static constexpr TableIndices< rank_ > unrolled_to_component_indices(const unsigned int i)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_PACKAGE_VERSION
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_FALLTHROUGH
#define DEAL_II_PACKAGE_NAME
Point< 2 > projected_vertices[4]
Point< 2 > projected_center
std::size_t memory_consumption() const
static void declare_parameters(ParameterHandler &prm)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const
const double * get_data_set(const unsigned int set_num) const
static void declare_parameters(ParameterHandler &prm)
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
static void declare_parameters(ParameterHandler &prm)
void parse_parameters(ParameterHandler &prm)
static ::ExceptionBase & ExcIncompatiblePatchLists()
static RgbValues default_color_function(const double value, const double min_value, const double max_value)
std::map< unsigned int, unsigned int > filtered_points
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
std::vector< std::string > space_dimension_labels
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static void declare_parameters(ParameterHandler &prm)
static ::ExceptionBase & ExcIO()
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm &comm) const
void parse_parameters(const ParameterHandler &prm)
ColorFunction color_function
std::string get_data_set_name(const unsigned int set_num) const
void write_ucd(std::ostream &out) const
void merge(const DataOutReader< dim, spacedim > &other)
static ::ExceptionBase & ExcFileNotOpen(std::string arg1)
ReferenceCell reference_cell
void write_povray(std::ostream &out) const
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
void internal_add_cell(const unsigned int cell_index, const unsigned int pt_index)
static void declare_parameters(ParameterHandler &prm)
void write_cell(const unsigned int index, const unsigned int start, const unsigned int d1, const unsigned int d2, const unsigned int d3)
ZlibCompressionLevel compression_level
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, const MPI_Comm &comm) const
static const unsigned int format_version
static const unsigned int no_neighbor
PovrayFlags(const bool smooth=false, const bool bicubic_patch=false, const bool external_data=false)
static ::ExceptionBase & ExcNotImplemented()
void write_vtu_in_parallel(const std::string &filename, const MPI_Comm &comm) const
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const override
unsigned int height_vector
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
void write_cell_single(const unsigned int index, const unsigned int start, const unsigned int n_points)
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)
static ::ExceptionBase & ExcIncompatibleDatasetNames()
void parse_parameters(const ParameterHandler &prm)
std::vector< unsigned int > data_set_dims
std::size_t memory_consumption() const
void set_default_format(const DataOutBase::OutputFormat default_format)
Point< spacedim > vertices[1]
unsigned int n_nodes() const
#define Assert(cond, exc)
void parse_parameters(const ParameterHandler &prm)
unsigned int color_vector
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
static void declare_parameters(ParameterHandler &prm)
void fill_node_data(std::vector< double > &node_data) const
std::vector< std::vector< double > > data_sets
bool operator==(const Patch &patch) const
std::string h5_sol_filename
unsigned int get_data_set_dim(const unsigned int set_num) const
void write_gnuplot(std::ostream &out) const
static ::ExceptionBase & ExcNoPatches()
static ::ExceptionBase & ExcTecplotAPIError()
void read(std::istream &in)
#define DeclException2(Exception2, type1, type2, outsequence)
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)
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
void write_vtu(std::ostream &out) const
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
#define AssertThrowMPI(error_code)
static const unsigned int space_dim
void write_tecplot(std::ostream &out) const
TecplotFlags(const char *zone_name=nullptr, const double solution_time=-1.0)
void write_data_set(const std::string &name, const unsigned int dimension, const unsigned int set_num, const Table< 2, double > &data_vectors)
void parse_parameters(const ParameterHandler &prm)
std::string h5_mesh_filename
static unsigned int n_subdivisions
std::string get_xdmf_content(const unsigned int indent_level) const
bool write_higher_order_cells
std::map< unsigned int, unsigned int > filtered_cells
bool points_are_available
void add_attribute(const std::string &attr_name, const unsigned int dimension)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
std::map< std::string, unsigned int > attribute_dims
#define AssertIndexRange(index, range)
virtual std::vector< std::string > get_dataset_names() const override
void write_svg(std::ostream &out) const
static ::ExceptionBase & ExcInternalError()
unsigned int height_vector
unsigned int n_subdivisions
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, const MPI_Comm &comm) const
void validate_dataset_names() const
void set_flags(const FlagType &flags)
std::vector< std::string > data_set_names
void write_vtk(std::ostream &out) const
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcNotInitialized()
unsigned int line_thickness
void swap(Patch< dim, spacedim > &other_patch)
void fill_cell_data(const unsigned int local_node_offset, std::vector< unsigned int > &cell_data) const
bool filter_duplicate_vertices
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
void write_point(const unsigned int index, const Point< dim > &p)
bool points_are_available
UcdFlags(const bool write_preamble=false)
static ::ExceptionBase & ExcErrorOpeningTecplotFile(char *arg1)
std::size_t memory_consumption() const
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)
std::array< unsigned int, GeometryInfo< dim >::faces_per_cell > neighbors
void write_gmv(std::ostream &out) const
void write_eps(std::ostream &out) const
unsigned int n_cells() const
unsigned int space_dimension
static ::ExceptionBase & ExcMessage(std::string arg1)
static void declare_parameters(ParameterHandler &prm)
DataOutBase::DataOutFilterFlags flags
Map3DPoint existing_points
void write_dx(std::ostream &out) const
#define AssertThrow(cond, exc)
unsigned int n_data_sets() const
void write_deal_II_intermediate(std::ostream &out) const
@ width
Scale to given width.
@ height
Scale to given height.
Task< RT > new_task(const std::function< RT()> &function)
#define DEAL_II_MPI_CONST_CAST(expr)
OutputOperator< VectorType > & operator<<(OutputOperator< VectorType > &out, unsigned int step)
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)
void write_nodes(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_high_order_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim > > &patches, const DataOutFilter &data_filter, const std::string &filename, const MPI_Comm &comm)
void write_tecplot_binary(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_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const UcdFlags &flags, std::ostream &out)
void write_dx(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const DXFlags &flags, std::ostream &out)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_gmv(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GmvFlags &flags, std::ostream &out)
void write_data(const std::vector< Patch< dim, spacedim > > &patches, unsigned int n_data_sets, const bool double_precision, StreamType &out)
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names)
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
void write_vtu_footer(std::ostream &out)
void write_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &out)
void write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, DataOutFilter &filtered_data)
OutputFormat parse_output_format(const std::string &format_name)
void write_svg(const std::vector< Patch< dim, spacedim > > &, const std::vector< std::string > &, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &, const SvgFlags &, std::ostream &)
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)
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)
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 reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell &reference_cell)
@ valid
Iterator points to a valid object.
types::global_dof_index size_type
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void swap(MemorySpaceData< Number, MemorySpace > &, MemorySpaceData< Number, MemorySpace > &)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > epsilon(const Tensor< 2, dim, Number > &Grad_u)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell & get_hypercube()
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
unsigned int this_mpi_process(const MPI_Comm &mpi_communicator)
T sum(const T &t, const MPI_Comm &mpi_communicator)
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
constexpr T pow(const T base, const int iexp)
std::string encode_base64(const std::vector< unsigned char > &binary_input)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
unsigned int needed_digits(const unsigned int max_number)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
void copy(const T *begin, const T *end, U *dest)
static constexpr double PI
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
*braid_SplitCommworld & comm
bool operator<(const SynchronousIterators< Iterators > &a, const SynchronousIterators< Iterators > &b)