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,
506 const unsigned int base_entry = index * n_points;
508 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
510 for (
unsigned int i = 0; i < n_points; ++i)
521 const unsigned int dimension,
522 const unsigned int set_num,
525 unsigned int new_dim;
544 for (
unsigned int d = 0;
d < new_dim; ++
d)
547 data_sets.back()[r * new_dim +
d] = data_vectors(set_num +
d, i);
563 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
565 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
567 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
569 #ifdef DEAL_II_HAVE_TECPLOT
570 const unsigned int tecplot_binary_cell_type[4] = {0, 0, 1, 3};
575 enum vtk_linear_cell_type
587 enum vtk_quadratic_cell_type
589 VTK_QUADRATIC_EDGE = 21,
590 VTK_QUADRATIC_TRIANGLE = 22,
591 VTK_QUADRATIC_QUAD = 23,
592 VTK_QUADRATIC_TETRA = 24,
593 VTK_QUADRATIC_HEXAHEDRON = 25,
594 VTK_QUADRATIC_WEDGE = 26,
595 VTK_QUADRATIC_PYRAMID = 27
598 enum vtk_lagrange_cell_type
600 VTK_LAGRANGE_CURVE = 68,
601 VTK_LAGRANGE_TRIANGLE = 69,
602 VTK_LAGRANGE_QUADRILATERAL = 70,
603 VTK_LAGRANGE_TETRAHEDRON = 71,
604 VTK_LAGRANGE_HEXAHEDRON = 72,
605 VTK_LAGRANGE_WEDGE = 73,
606 VTK_LAGRANGE_PYRAMID = 74
613 template <
int dim,
int spacedim>
614 std::array<unsigned int, 3>
616 const bool write_higher_order_cells)
618 std::array<unsigned int, 3> vtk_cell_id{};
620 if (write_higher_order_cells)
624 const std::array<unsigned int, 4> cell_type_by_dim{
627 VTK_LAGRANGE_QUADRILATERAL,
628 VTK_LAGRANGE_HEXAHEDRON}};
629 vtk_cell_id[0] = cell_type_by_dim[dim];
634 vtk_cell_id[0] = VTK_LAGRANGE_TRIANGLE;
643 patch.
data.n_cols() == 3)
645 vtk_cell_id[0] = VTK_TRIANGLE;
649 patch.
data.n_cols() == 6)
651 vtk_cell_id[0] = VTK_QUADRATIC_TRIANGLE;
655 patch.
data.n_cols() == 4)
657 vtk_cell_id[0] = VTK_TETRA;
661 patch.
data.n_cols() == 10)
663 vtk_cell_id[0] = VTK_QUADRATIC_TETRA;
667 patch.
data.n_cols() == 6)
669 vtk_cell_id[0] = VTK_WEDGE;
673 patch.
data.n_cols() == 5)
675 vtk_cell_id[0] = VTK_PYRAMID;
678 else if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
680 const std::array<unsigned int, 4> cell_type_by_dim{
681 {VTK_VERTEX, VTK_LINE, VTK_QUAD, VTK_HEXAHEDRON}};
682 vtk_cell_id[0] = cell_type_by_dim[dim];
690 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>() ||
691 write_higher_order_cells)
692 vtk_cell_id[2] = patch.
data.n_cols();
708 template <
int dim,
int spacedim>
710 get_equispaced_location(
712 const std::initializer_list<unsigned int> &lattice_location,
713 const unsigned int n_subdivisions)
721 const unsigned int xstep = (dim > 0 ? *(lattice_location.begin() + 0) : 0);
722 const unsigned int ystep = (dim > 1 ? *(lattice_location.begin() + 1) : 0);
723 const unsigned int zstep = (dim > 2 ? *(lattice_location.begin() + 2) : 0);
731 unsigned int point_no = 0;
736 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
740 point_no += (n_subdivisions + 1) * ystep;
754 for (
unsigned int d = 0;
d < spacedim; ++
d)
755 node[
d] = patch.
data(patch.
data.size(0) - spacedim +
d, point_no);
767 const double stepsize = 1. / n_subdivisions;
768 const double xfrac = xstep * stepsize;
774 const double yfrac = ystep * stepsize;
776 node += ((patch.
vertices[3] * xfrac) +
777 (patch.
vertices[2] * (1 - xfrac))) *
781 const double zfrac = zstep * stepsize;
783 node += (((patch.
vertices[5] * xfrac) +
784 (patch.
vertices[4] * (1 - xfrac))) *
787 (patch.
vertices[6] * (1 - xfrac))) *
800 template <
int dim,
int spacedim>
803 const unsigned int node_index)
808 unsigned int point_no_actual = node_index;
813 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
814 point_no_actual = table[node_index];
822 for (
unsigned int d = 0;
d < spacedim; ++
d)
824 patch.
data(patch.
data.size(0) - spacedim +
d, point_no_actual);
837 return patch.
vertices[point_no_actual];
851 vtk_point_index_from_ijk(
const unsigned i,
854 const std::array<unsigned, 2> &order)
856 const bool ibdy = (i == 0 || i == order[0]);
857 const bool jbdy = (j == 0 || j == order[1]);
859 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0);
863 return (i != 0u ? (j != 0u ? 2 : 1) : (j != 0u ? 3 : 0));
871 return (i - 1) + (j != 0u ? order[0] - 1 + order[1] - 1 : 0) +
878 (i != 0u ? order[0] - 1 :
879 2 * (order[0] - 1) + order[1] - 1) +
884 offset += 2 * (order[0] - 1 + order[1] - 1);
886 return offset + (i - 1) + (order[0] - 1) * ((j - 1));
899 vtk_point_index_from_ijk(
const unsigned i,
902 const std::array<unsigned, 3> &order)
904 const bool ibdy = (i == 0 || i == order[0]);
905 const bool jbdy = (j == 0 || j == order[1]);
906 const bool kbdy = (k == 0 || k == order[2]);
908 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0) + (kbdy ? 1 : 0);
912 return (i != 0u ? (j != 0u ? 2 : 1) : (j != 0u ? 3 : 0)) +
921 return (i - 1) + (j != 0u ? order[0] - 1 + order[1] - 1 : 0) +
922 (k != 0u ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
927 (i != 0u ? order[0] - 1 :
928 2 * (order[0] - 1) + order[1] - 1) +
929 (k != 0u ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
932 offset += 4 * (order[0] - 1) + 4 * (order[1] - 1);
935 (i != 0u ? (j != 0u ? 3 : 1) : (j != 0u ? 2 : 0)) +
939 offset += 4 * (order[0] - 1 + order[1] - 1 + order[2] - 1);
944 return (j - 1) + ((order[1] - 1) * (k - 1)) +
945 (i != 0u ? (order[1] - 1) * (order[2] - 1) : 0) + offset;
947 offset += 2 * (order[1] - 1) * (order[2] - 1);
950 return (i - 1) + ((order[0] - 1) * (k - 1)) +
951 (j != 0u ? (order[2] - 1) * (order[0] - 1) : 0) + offset;
953 offset += 2 * (order[2] - 1) * (order[0] - 1);
955 return (i - 1) + ((order[0] - 1) * (j - 1)) +
956 (k != 0u ? (order[0] - 1) * (order[1] - 1) : 0) + offset;
961 2 * ((order[1] - 1) * (order[2] - 1) + (order[2] - 1) * (order[0] - 1) +
962 (order[0] - 1) * (order[1] - 1));
963 return offset + (i - 1) +
964 (order[0] - 1) * ((j - 1) + (order[1] - 1) * ((k - 1)));
970 vtk_point_index_from_ijk(
const unsigned,
973 const std::array<unsigned, 0> &)
982 vtk_point_index_from_ijk(
const unsigned,
985 const std::array<unsigned, 1> &)
993 template <
int dim,
int spacedim>
996 unsigned int & n_nodes,
1001 for (
const auto &patch : patches)
1005 "The reference cell for this patch is set to 'Invalid', "
1006 "but that is clearly not a valid choice. Did you forget "
1007 "to set the reference cell for the patch?"));
1010 if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
1012 n_nodes += Utilities::fixed_power<dim>(patch.
n_subdivisions + 1);
1026 template <
int dim,
int spacedim>
1029 const bool write_higher_order_cells,
1030 unsigned int &n_nodes,
1032 unsigned int &n_points_and_n_cells)
1036 n_points_and_n_cells = 0;
1038 for (
const auto &patch : patches)
1041 if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
1043 n_nodes += Utilities::fixed_power<dim>(patch.
n_subdivisions + 1);
1045 if (write_higher_order_cells)
1048 n_points_and_n_cells +=
1054 n_points_and_n_cells +=
1061 n_nodes += patch.
data.n_cols();
1063 n_points_and_n_cells += patch.
data.n_cols() + 1;
1073 template <
typename FlagsType>
1080 StreamBase(std::ostream &stream,
const FlagsType &flags)
1092 write_point(
const unsigned int,
const Point<dim> &)
1095 ExcMessage(
"The derived class you are using needs to "
1096 "reimplement this function if you want to call "
1116 write_cell(
const unsigned int ,
1117 const unsigned int ,
1118 const unsigned int ,
1119 const unsigned int ,
1120 const unsigned int )
1123 ExcMessage(
"The derived class you are using needs to "
1124 "reimplement this function if you want to call "
1135 write_cell_single(
const unsigned int index,
1136 const unsigned int start,
1137 const unsigned int n_points,
1146 ExcMessage(
"The derived class you are using needs to "
1147 "reimplement this function if you want to call "
1165 template <
typename T>
1179 unsigned int selected_component;
1186 std::ostream &stream;
1191 const FlagsType flags;
1197 class DXStream :
public StreamBase<DataOutBase::DXFlags>
1204 write_point(
const unsigned int index,
const Point<dim> &);
1216 write_cell(
const unsigned int index,
1217 const unsigned int start,
1218 const unsigned int x_offset,
1219 const unsigned int y_offset,
1220 const unsigned int z_offset);
1228 template <
typename data>
1230 write_dataset(
const unsigned int index,
const std::vector<data> &
values);
1236 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
1243 write_point(
const unsigned int index,
const Point<dim> &);
1255 write_cell(
const unsigned int index,
1256 const unsigned int start,
1257 const unsigned int x_offset,
1258 const unsigned int y_offset,
1259 const unsigned int z_offset);
1265 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
1272 write_point(
const unsigned int index,
const Point<dim> &);
1284 write_cell(
const unsigned int index,
1285 const unsigned int start,
1286 const unsigned int x_offset,
1287 const unsigned int y_offset,
1288 const unsigned int z_offset);
1294 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1301 write_point(
const unsigned int index,
const Point<dim> &);
1315 write_cell(
const unsigned int index,
1316 const unsigned int start,
1317 const unsigned int x_offset,
1318 const unsigned int y_offset,
1319 const unsigned int z_offset);
1327 template <
typename data>
1329 write_dataset(
const unsigned int index,
const std::vector<data> &
values);
1335 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1342 write_point(
const unsigned int index,
const Point<dim> &);
1354 write_cell(
const unsigned int index,
1355 const unsigned int start,
1356 const unsigned int x_offset,
1357 const unsigned int y_offset,
1358 const unsigned int z_offset);
1364 write_cell_single(
const unsigned int index,
1365 const unsigned int start,
1366 const unsigned int n_points,
1378 write_high_order_cell(
const unsigned int index,
1379 const unsigned int start,
1380 const std::vector<unsigned> &connectivity);
1384 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
1391 write_point(
const unsigned int index,
const Point<dim> &);
1406 write_cell(
const unsigned int index,
1407 const unsigned int start,
1408 const unsigned int x_offset,
1409 const unsigned int y_offset,
1410 const unsigned int z_offset);
1416 write_cell_single(
const unsigned int index,
1417 const unsigned int start,
1418 const unsigned int n_points,
1430 write_high_order_cell(
const unsigned int index,
1431 const unsigned int start,
1432 const std::vector<unsigned> &connectivity);
1437 template <
typename T>
1448 template <
typename T>
1462 std::vector<int32_t> cells;
1475 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1477 if (flags.coordinates_binary)
1480 for (
unsigned int d = 0;
d < dim; ++
d)
1482 stream.write(
reinterpret_cast<const char *
>(data), dim *
sizeof(*data));
1486 for (
unsigned int d = 0;
d < dim; ++
d)
1487 stream << p(
d) <<
'\t';
1502 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell>
1503 set_node_numbers(
const unsigned int ,
1504 const unsigned int ,
1505 const unsigned int ,
1506 const unsigned int )
1515 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
1516 set_node_numbers<1>(
const unsigned int start,
1517 const unsigned int d1,
1518 const unsigned int ,
1519 const unsigned int )
1522 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
1524 nodes[1] = start + d1;
1531 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
1532 set_node_numbers<2>(
const unsigned int start,
1533 const unsigned int d1,
1534 const unsigned int d2,
1535 const unsigned int )
1538 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
1540 nodes[1] = start + d1;
1541 nodes[2] = start + d2;
1542 nodes[3] = start + d2 + d1;
1549 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
1550 set_node_numbers<3>(
const unsigned int start,
1551 const unsigned int d1,
1552 const unsigned int d2,
1553 const unsigned int d3)
1555 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
1557 nodes[1] = start + d1;
1558 nodes[2] = start + d2;
1559 nodes[3] = start + d2 + d1;
1560 nodes[4] = start + d3;
1561 nodes[5] = start + d3 + d1;
1562 nodes[6] = start + d3 + d2;
1563 nodes[7] = start + d3 + d2 + d1;
1572 DXStream::write_cell(
unsigned int,
1579 DataOutBaseImplementation::set_node_numbers<dim>(start, d1, d2, d3);
1581 if (flags.int_binary)
1583 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell> temp;
1584 for (
unsigned int i = 0; i < nodes.size(); ++i)
1586 stream.write(
reinterpret_cast<const char *
>(temp.data()),
1587 temp.size() *
sizeof(temp[0]));
1591 for (
unsigned int i = 0; i < nodes.size() - 1; ++i)
1593 stream << nodes[GeometryInfo<dim>::dx_to_deal[nodes.size() - 1]]
1600 template <
typename data>
1602 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &
values)
1604 if (flags.data_binary)
1606 stream.write(
reinterpret_cast<const char *
>(
values.data()),
1607 values.size() *
sizeof(data));
1611 for (
unsigned int i = 0; i <
values.size(); ++i)
1612 stream <<
'\t' <<
values[i];
1628 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1632 stream << p(selected_component) <<
' ';
1639 GmvStream::write_cell(
unsigned int,
1646 const unsigned int start = s + 1;
1647 stream << gmv_cell_type[dim] <<
'\n';
1652 stream <<
'\t' << start + d1;
1655 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1658 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1659 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1668 TecplotStream::TecplotStream(std::ostream & out,
1676 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1680 stream << p(selected_component) <<
'\n';
1687 TecplotStream::write_cell(
unsigned int,
1693 const unsigned int start = s + 1;
1698 stream <<
'\t' << start + d1;
1701 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1704 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1705 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1721 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1723 stream <<
index + 1 <<
" ";
1725 for (
unsigned int i = 0; i < dim; ++i)
1726 stream << p(i) <<
' ';
1728 for (
unsigned int i = dim; i < 3; ++i)
1737 UcdStream::write_cell(
unsigned int index,
1744 DataOutBaseImplementation::set_node_numbers<dim>(start, d1, d2, d3);
1747 stream <<
index + 1 <<
"\t0 " << ucd_cell_type[dim];
1748 for (
unsigned int i = 0; i < nodes.size(); ++i)
1755 template <
typename data>
1757 UcdStream::write_dataset(
const unsigned int index,
1758 const std::vector<data> &
values)
1760 stream <<
index + 1;
1761 for (
unsigned int i = 0; i <
values.size(); ++i)
1762 stream <<
'\t' <<
values[i];
1777 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1782 for (
unsigned int i = dim; i < 3; ++i)
1791 VtkStream::write_cell(
unsigned int,
1797 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' << start;
1800 stream <<
'\t' << start + d1;
1804 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1807 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1808 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1816 VtkStream::write_cell_single(
const unsigned int index,
1817 const unsigned int start,
1818 const unsigned int n_points,
1823 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1825 stream <<
'\t' << n_points;
1826 for (
unsigned int i = 0; i < n_points; ++i)
1835 VtkStream::write_high_order_cell(
const unsigned int,
1836 const unsigned int start,
1837 const std::vector<unsigned> &connectivity)
1839 stream << connectivity.size();
1840 for (
const auto &c : connectivity)
1841 stream <<
'\t' << start + c;
1852 VtuStream::write_point(
const unsigned int,
const Point<dim> &p)
1854 #if !defined(DEAL_II_WITH_ZLIB)
1858 for (
unsigned int i = dim; i < 3; ++i)
1863 for (
unsigned int i = 0; i < dim; ++i)
1865 for (
unsigned int i = dim; i < 3; ++i)
1872 VtuStream::flush_points()
1874 #ifdef DEAL_II_WITH_ZLIB
1885 VtuStream::write_cell(
unsigned int,
1891 #if !defined(DEAL_II_WITH_ZLIB)
1895 stream <<
'\t' << start + d1;
1898 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1901 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1902 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1908 cells.push_back(start);
1911 cells.push_back(start + d1);
1914 cells.push_back(start + d2 + d1);
1915 cells.push_back(start + d2);
1918 cells.push_back(start + d3);
1919 cells.push_back(start + d3 + d1);
1920 cells.push_back(start + d3 + d2 + d1);
1921 cells.push_back(start + d3 + d2);
1929 VtuStream::write_cell_single(
const unsigned int index,
1930 const unsigned int start,
1931 const unsigned int n_points,
1936 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1938 #if !defined(DEAL_II_WITH_ZLIB)
1939 for (
unsigned int i = 0; i < n_points; ++i)
1945 for (
unsigned int i = 0; i < n_points; ++i)
1953 VtuStream::write_high_order_cell(
const unsigned int,
1954 const unsigned int start,
1955 const std::vector<unsigned> &connectivity)
1957 #if !defined(DEAL_II_WITH_ZLIB)
1958 for (
const auto &c : connectivity)
1959 stream <<
'\t' << start + c;
1962 for (
const auto &c : connectivity)
1963 cells.push_back(start + c);
1968 VtuStream::flush_cells()
1970 #ifdef DEAL_II_WITH_ZLIB
1973 *
this << cells <<
'\n';
1979 template <
typename T>
1983 #ifdef DEAL_II_WITH_ZLIB
1986 write_compressed_block(data, flags, stream);
1988 for (
unsigned int i = 0; i < data.size(); ++i)
1989 stream << data[i] <<
' ';
2003 template <
int dim,
int spacedim>
2007 template <
int dim,
int spacedim>
2011 template <
int dim,
int spacedim>
2013 : patch_index(no_neighbor)
2015 , points_are_available(false)
2029 template <
int dim,
int spacedim>
2055 if (data.n_rows() != patch.
data.n_rows())
2058 if (data.n_cols() != patch.
data.n_cols())
2061 for (
unsigned int i = 0; i < data.n_rows(); ++i)
2062 for (
unsigned int j = 0; j < data.n_cols(); ++j)
2063 if (data[i][j] != patch.
data[i][j])
2071 template <
int dim,
int spacedim>
2077 sizeof(neighbors) /
sizeof(neighbors[0]) *
2088 template <
int dim,
int spacedim>
2096 data.swap(other_patch.
data);
2103 template <
int spacedim>
2107 template <
int spacedim>
2111 template <
int spacedim>
2115 template <
int spacedim>
2118 template <
int spacedim>
2122 template <
int spacedim>
2124 : patch_index(no_neighbor)
2125 , points_are_available(false)
2132 template <
int spacedim>
2136 const unsigned int dim = 0;
2150 if (
data.n_rows() != patch.
data.n_rows())
2153 if (
data.n_cols() != patch.
data.n_cols())
2156 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
2157 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
2158 if (
data[i][j] != patch.
data[i][j])
2166 template <
int spacedim>
2178 template <
int spacedim>
2191 : write_preamble(write_preamble)
2206 : space_dimension_labels(labels)
2220 const bool bicubic_patch,
2221 const bool external_data)
2223 , bicubic_patch(bicubic_patch)
2224 , external_data(external_data)
2229 const bool xdmf_hdf5_output)
2230 : filter_duplicate_vertices(filter_duplicate_vertices)
2231 , xdmf_hdf5_output(xdmf_hdf5_output)
2239 "Filter duplicate vertices",
2242 "Whether to remove duplicate vertex values. deal.II duplicates "
2243 "vertices once for each adjacent cell so that it can output "
2244 "discontinuous quantities for which there may be more than one "
2245 "value for each vertex position. Setting this flag to "
2246 "'true' will merge all of these values by selecting a "
2247 "random one and outputting this as 'the' value for the vertex. "
2248 "As long as the data to be output corresponds to continuous "
2249 "fields, merging vertices has no effect. On the other hand, "
2250 "if the data to be output corresponds to discontinuous fields "
2251 "(either because you are using a discontinuous finite element, "
2252 "or because you are using a DataPostprocessor that yields "
2253 "discontinuous data, or because the data to be output has been "
2254 "produced by entirely different means), then the data in the "
2255 "output file no longer faithfully represents the underlying data "
2256 "because the discontinuous field has been replaced by a "
2257 "continuous one. Note also that the filtering can not occur "
2258 "on processor boundaries. Thus, a filtered discontinuous field "
2259 "looks like a continuous field inside of a subdomain, "
2260 "but like a discontinuous field at the subdomain boundary."
2262 "In any case, filtering results in drastically smaller output "
2263 "files (smaller by about a factor of 2^dim).");
2268 "Whether the data will be used in an XDMF/HDF5 combination.");
2283 const bool int_binary,
2284 const bool coordinates_binary,
2285 const bool data_binary)
2286 : write_neighbors(write_neighbors)
2287 , int_binary(int_binary)
2288 , coordinates_binary(coordinates_binary)
2289 , data_binary(data_binary)
2290 , data_double(false)
2300 "A boolean field indicating whether neighborship "
2301 "information between cells is to be written to the "
2302 "OpenDX output file");
2306 "Output format of integer numbers, which is "
2307 "either a text representation (ascii) or binary integer "
2308 "values of 32 or 64 bits length");
2312 "Output format of vertex coordinates, which is "
2313 "either a text representation (ascii) or binary "
2314 "floating point values of 32 or 64 bits length");
2318 "Output format of data values, which is "
2319 "either a text representation (ascii) or binary "
2320 "floating point values of 32 or 64 bits length");
2340 "A flag indicating whether a comment should be "
2341 "written to the beginning of the output file "
2342 "indicating date and time of creation as well "
2343 "as the creating program");
2357 const int azimuth_angle,
2358 const int polar_angle,
2359 const unsigned int line_thickness,
2361 const bool draw_colorbar)
2364 , height_vector(height_vector)
2365 , azimuth_angle(azimuth_angle)
2366 , polar_angle(polar_angle)
2367 , line_thickness(line_thickness)
2369 , draw_colorbar(draw_colorbar)
2380 "A flag indicating whether POVRAY should use smoothed "
2381 "triangles instead of the usual ones");
2385 "Whether POVRAY should use bicubic patches");
2389 "Whether camera and lighting information should "
2390 "be put into an external file \"data.inc\" or into "
2391 "the POVRAY input file");
2407 const unsigned int color_vector,
2409 const unsigned int size,
2410 const double line_width,
2411 const double azimut_angle,
2412 const double turn_angle,
2413 const double z_scaling,
2414 const bool draw_mesh,
2415 const bool draw_cells,
2416 const bool shade_cells,
2418 : height_vector(height_vector)
2419 , color_vector(color_vector)
2422 , line_width(line_width)
2423 , azimut_angle(azimut_angle)
2424 , turn_angle(turn_angle)
2425 , z_scaling(z_scaling)
2426 , draw_mesh(draw_mesh)
2427 , draw_cells(draw_cells)
2428 , shade_cells(shade_cells)
2429 , color_function(color_function)
2468 double sum = xmax + xmin;
2469 double sum13 = xmin + 3 * xmax;
2470 double sum22 = 2 * xmin + 2 * xmax;
2471 double sum31 = 3 * xmin + xmax;
2472 double dif = xmax - xmin;
2473 double rezdif = 1.0 / dif;
2477 if (x < (sum31) / 4)
2479 else if (x < (sum22) / 4)
2481 else if (x < (sum13) / 4)
2492 rgb_values.
green = 0;
2493 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2497 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2498 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2501 rgb_values.
red = (4 * x - 2 *
sum) * rezdif;
2502 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2503 rgb_values.
blue = 0;
2507 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2508 rgb_values.
blue = (4. * x - sum13) * rezdif;
2515 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2529 (x - xmin) / (xmax - xmin);
2542 1 - (x - xmin) / (xmax - xmin);
2554 "Number of the input vector that is to be used to "
2555 "generate height information");
2559 "Number of the input vector that is to be used to "
2560 "generate color information");
2564 "Whether width or height should be scaled to match "
2569 "The size (width or height) to which the eps output "
2570 "file is to be scaled");
2574 "The width in which the postscript renderer is to "
2579 "Angle of the viewing position against the vertical "
2584 "Angle of the viewing direction against the y-axis");
2588 "Scaling for the z-direction relative to the scaling "
2589 "used in x- and y-directions");
2593 "Whether the mesh lines, or only the surface should be "
2598 "Whether only the mesh lines, or also the interior of "
2599 "cells should be plotted. If this flag is false, then "
2600 "one can see through the mesh");
2604 "Whether the interior of cells shall be shaded");
2608 "default|grey scale|reverse grey scale"),
2609 "Name of a color function used to colorize mesh lines "
2610 "and/or cell interiors");
2620 if (prm.
get(
"Scale to width or height") ==
"width")
2632 if (prm.
get(
"Color function") ==
"default")
2634 else if (prm.
get(
"Color function") ==
"grey scale")
2636 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2647 : zone_name(zone_name)
2648 , solution_time(solution_time)
2662 const unsigned int cycle,
2663 const bool print_date_and_time,
2665 const bool write_higher_order_cells,
2666 const std::map<std::string, std::string> &physical_units)
2669 , print_date_and_time(print_date_and_time)
2670 , compression_level(compression_level)
2671 , write_higher_order_cells(write_higher_order_cells)
2672 , physical_units(physical_units)
2680 if (format_name ==
"none")
2683 if (format_name ==
"dx")
2686 if (format_name ==
"ucd")
2689 if (format_name ==
"gnuplot")
2692 if (format_name ==
"povray")
2695 if (format_name ==
"eps")
2698 if (format_name ==
"gmv")
2701 if (format_name ==
"tecplot")
2704 if (format_name ==
"tecplot_binary")
2707 if (format_name ==
"vtk")
2710 if (format_name ==
"vtu")
2713 if (format_name ==
"deal.II intermediate")
2716 if (format_name ==
"hdf5")
2720 ExcMessage(
"The given file format name is not recognized: <" +
2721 format_name +
">"));
2732 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2740 switch (output_format)
2779 template <
int dim,
int spacedim,
typename StreamType>
2784 unsigned int count = 0;
2786 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
2788 for (
const auto &patch : patches)
2791 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2793 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2795 out.write_point(count++,
2796 get_node_location(patch,
2805 const unsigned int n = n_subdivisions + 1;
2810 out.write_point(count++,
2811 get_equispaced_location(patch,
2816 for (
unsigned int i1 = 0; i1 < n; ++i1)
2817 out.write_point(count++,
2818 get_equispaced_location(patch,
2823 for (
unsigned int i2 = 0; i2 < n; ++i2)
2824 for (
unsigned int i1 = 0; i1 < n; ++i1)
2825 out.write_point(count++,
2826 get_equispaced_location(patch,
2831 for (
unsigned int i3 = 0; i3 < n; ++i3)
2832 for (
unsigned int i2 = 0; i2 < n; ++i2)
2833 for (
unsigned int i1 = 0; i1 < n; ++i1)
2834 out.write_point(count++,
2835 get_equispaced_location(
2836 patch, {i1, i2, i3}, n_subdivisions));
2847 template <
int dim,
int spacedim,
typename StreamType>
2852 unsigned int count = 0;
2853 unsigned int first_vertex_of_patch = 0;
2854 for (
const auto &patch : patches)
2857 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2859 out.write_cell_single(count++,
2860 first_vertex_of_patch,
2861 patch.
data.n_cols(),
2863 first_vertex_of_patch += patch.
data.n_cols();
2868 const unsigned int n = n_subdivisions + 1;
2870 const unsigned int n1 = (dim > 0) ? n_subdivisions : 1;
2871 const unsigned int n2 = (dim > 1) ? n_subdivisions : 1;
2872 const unsigned int n3 = (dim > 2) ? n_subdivisions : 1;
2874 const unsigned int d1 = 1;
2875 const unsigned int d2 = n;
2876 const unsigned int d3 = n * n;
2877 for (
unsigned int i3 = 0; i3 < n3; ++i3)
2878 for (
unsigned int i2 = 0; i2 < n2; ++i2)
2879 for (
unsigned int i1 = 0; i1 < n1; ++i1)
2881 const unsigned int offset =
2882 first_vertex_of_patch + i3 * d3 + i2 * d2 + i1 * d1;
2884 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2887 first_vertex_of_patch +=
2888 Utilities::fixed_power<dim>(n_subdivisions + 1);
2895 template <
int dim,
int spacedim,
typename StreamType>
2901 unsigned int first_vertex_of_patch = 0;
2902 unsigned int count = 0;
2904 std::vector<unsigned> connectivity;
2906 std::array<unsigned, dim> cell_order;
2908 for (
const auto &patch : patches)
2910 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2912 connectivity.resize(patch.
data.n_cols());
2914 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2915 connectivity[i] = i;
2917 out.template write_high_order_cell<dim>(count++,
2918 first_vertex_of_patch,
2921 first_vertex_of_patch += patch.
data.n_cols();
2926 const unsigned int n = n_subdivisions + 1;
2928 cell_order.fill(n_subdivisions);
2929 connectivity.resize(Utilities::fixed_power<dim>(n));
2932 const unsigned int n1 = (dim > 0) ? n_subdivisions : 0;
2933 const unsigned int n2 = (dim > 1) ? n_subdivisions : 0;
2934 const unsigned int n3 = (dim > 2) ? n_subdivisions : 0;
2936 const unsigned int d1 = 1;
2937 const unsigned int d2 = n;
2938 const unsigned int d3 = n * n;
2939 for (
unsigned int i3 = 0; i3 <= n3; ++i3)
2940 for (
unsigned int i2 = 0; i2 <= n2; ++i2)
2941 for (
unsigned int i1 = 0; i1 <= n1; ++i1)
2943 const unsigned int local_index =
2944 i3 * d3 + i2 * d2 + i1 * d1;
2945 const unsigned int connectivity_index =
2946 vtk_point_index_from_ijk(i1, i2, i3, cell_order);
2947 connectivity[connectivity_index] = local_index;
2950 out.template write_high_order_cell<dim>(count++,
2951 first_vertex_of_patch,
2955 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
2963 template <
int dim,
int spacedim,
class StreamType>
2966 unsigned int n_data_sets,
2967 const bool double_precision,
2971 unsigned int count = 0;
2973 for (
const auto &patch : patches)
2976 const unsigned int n = n_subdivisions + 1;
2978 Assert((patch.
data.n_rows() == n_data_sets &&
2980 (patch.
data.n_rows() == n_data_sets + spacedim &&
2983 (n_data_sets + spacedim) :
2985 patch.
data.n_rows()));
2986 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
2989 std::vector<float> floats(n_data_sets);
2990 std::vector<double> doubles(n_data_sets);
2993 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2995 if (double_precision)
2997 for (
unsigned int data_set = 0; data_set < n_data_sets;
2999 doubles[data_set] = patch.
data(data_set, i);
3000 out.write_dataset(count, doubles);
3004 for (
unsigned int data_set = 0; data_set < n_data_sets;
3006 floats[data_set] = patch.
data(data_set, i);
3007 out.write_dataset(count, floats);
3032 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
3033 camera_horizontal[2] * camera_direction[1];
3034 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
3035 camera_horizontal[0] * camera_direction[2];
3036 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
3037 camera_horizontal[1] * camera_direction[0];
3041 phi /= (
point[0] - camera_position[0]) * camera_direction[0] +
3042 (
point[1] - camera_position[1]) * camera_direction[1] +
3043 (
point[2] - camera_position[2]) * camera_direction[2];
3047 camera_position[0] + phi * (
point[0] - camera_position[0]);
3049 camera_position[1] + phi * (
point[1] - camera_position[1]);
3051 camera_position[2] + phi * (
point[2] - camera_position[2]);
3054 projection_decomposition[0] = (projection[0] - camera_position[0] -
3055 camera_focus * camera_direction[0]) *
3056 camera_horizontal[0];
3057 projection_decomposition[0] += (projection[1] - camera_position[1] -
3058 camera_focus * camera_direction[1]) *
3059 camera_horizontal[1];
3060 projection_decomposition[0] += (projection[2] - camera_position[2] -
3061 camera_focus * camera_direction[2]) *
3062 camera_horizontal[2];
3064 projection_decomposition[1] = (projection[0] - camera_position[0] -
3065 camera_focus * camera_direction[0]) *
3067 projection_decomposition[1] += (projection[1] - camera_position[1] -
3068 camera_focus * camera_direction[1]) *
3070 projection_decomposition[1] += (projection[2] - camera_position[2] -
3071 camera_focus * camera_direction[2]) *
3074 return projection_decomposition;
3083 svg_get_gradient_parameters(
Point<3> points[])
3089 for (
int i = 0; i < 2; ++i)
3091 for (
int j = 0; j < 2 - i; ++j)
3093 if (points[j][2] > points[j + 1][2])
3096 points[j] = points[j + 1];
3097 points[j + 1] = temp;
3104 v_inter = points[1];
3111 A[0][0] = v_max[0] - v_min[0];
3112 A[0][1] = v_inter[0] - v_min[0];
3113 A[1][0] = v_max[1] - v_min[1];
3114 A[1][1] = v_inter[1] - v_min[1];
3120 bool col_change =
false;
3129 double temp =
A[1][0];
3134 for (
unsigned int k = 0; k < 1; ++k)
3136 for (
unsigned int i = k + 1; i < 2; ++i)
3138 x =
A[i][k] /
A[k][k];
3140 for (
unsigned int j = k + 1; j < 2; ++j)
3141 A[i][j] =
A[i][j] -
A[k][j] * x;
3143 b[i] =
b[i] -
b[k] * x;
3147 b[1] =
b[1] /
A[1][1];
3149 for (
int i = 0; i >= 0; i--)
3153 for (
unsigned int j = i + 1; j < 2; ++j)
3156 b[i] =
sum /
A[i][i];
3166 double c =
b[0] * (v_max[2] - v_min[2]) +
b[1] * (v_inter[2] - v_min[2]) +
3170 A[0][0] = v_max[0] - v_min[0];
3171 A[0][1] = v_inter[0] - v_min[0];
3172 A[1][0] = v_max[1] - v_min[1];
3173 A[1][1] = v_inter[1] - v_min[1];
3175 b[0] = 1.0 - v_min[0];
3187 double temp =
A[1][0];
3192 for (
unsigned int k = 0; k < 1; ++k)
3194 for (
unsigned int i = k + 1; i < 2; ++i)
3196 x =
A[i][k] /
A[k][k];
3198 for (
unsigned int j = k + 1; j < 2; ++j)
3199 A[i][j] =
A[i][j] -
A[k][j] * x;
3201 b[i] =
b[i] -
b[k] * x;
3205 b[1] =
b[1] /
A[1][1];
3207 for (
int i = 0; i >= 0; i--)
3211 for (
unsigned int j = i + 1; j < 2; ++j)
3214 b[i] =
sum /
A[i][i];
3224 gradient[0] =
b[0] * (v_max[2] - v_min[2]) +
3225 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3228 A[0][0] = v_max[0] - v_min[0];
3229 A[0][1] = v_inter[0] - v_min[0];
3230 A[1][0] = v_max[1] - v_min[1];
3231 A[1][1] = v_inter[1] - v_min[1];
3234 b[1] = 1.0 - v_min[1];
3245 double temp =
A[1][0];
3250 for (
unsigned int k = 0; k < 1; ++k)
3252 for (
unsigned int i = k + 1; i < 2; ++i)
3254 x =
A[i][k] /
A[k][k];
3256 for (
unsigned int j = k + 1; j < 2; ++j)
3257 A[i][j] =
A[i][j] -
A[k][j] * x;
3259 b[i] =
b[i] -
b[k] * x;
3263 b[1] =
b[1] /
A[1][1];
3265 for (
int i = 0; i >= 0; i--)
3269 for (
unsigned int j = i + 1; j < 2; ++j)
3272 b[i] =
sum /
A[i][i];
3282 gradient[1] =
b[0] * (v_max[2] - v_min[2]) +
3283 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3289 gradient[1] * (v_min[1] - v_max[1]);
3293 gradient_parameters[0] = v_min[0];
3294 gradient_parameters[1] = v_min[1];
3299 gradient_parameters[4] = v_min[2];
3300 gradient_parameters[5] = v_max[2];
3302 return gradient_parameters;
3308 template <
int dim,
int spacedim>
3312 const std::vector<std::string> & data_names,
3314 std::tuple<
unsigned int,
3327 #ifndef DEAL_II_WITH_MPI
3336 if (patches.size() == 0)
3340 const unsigned int n_data_sets = data_names.size();
3342 UcdStream ucd_out(out, flags);
3345 unsigned int n_nodes;
3347 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
3353 <<
"# This file was generated by the deal.II library." <<
'\n'
3357 <<
"# For a description of the UCD format see the AVS Developer's guide."
3363 out << n_nodes <<
' ' <<
n_cells <<
' ' << n_data_sets <<
' ' << 0
3376 if (n_data_sets != 0)
3378 out << n_data_sets <<
" ";
3379 for (
unsigned int i = 0; i < n_data_sets; ++i)
3384 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3385 out << data_names[data_set]
3389 write_data(patches, n_data_sets,
true, ucd_out);
3399 template <
int dim,
int spacedim>
3403 const std::vector<std::string> & data_names,
3405 std::tuple<
unsigned int,
3417 #ifndef DEAL_II_WITH_MPI
3426 if (patches.size() == 0)
3430 DXStream dx_out(out, flags);
3433 unsigned int offset = 0;
3435 const unsigned int n_data_sets = data_names.size();
3438 unsigned int n_nodes;
3440 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
3442 out <<
"object \"vertices\" class array type float rank 1 shape "
3443 << spacedim <<
" items " << n_nodes;
3447 out <<
" lsb ieee data 0" <<
'\n';
3448 offset += n_nodes * spacedim *
sizeof(float);
3452 out <<
" data follows" <<
'\n';
3461 out <<
"object \"cells\" class array type int rank 1 shape "
3466 out <<
" lsb binary data " << offset <<
'\n';
3467 offset +=
n_cells *
sizeof(int);
3471 out <<
" data follows" <<
'\n';
3477 out <<
"attribute \"element type\" string \"";
3484 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3491 out <<
"object \"neighbors\" class array type int rank 1 shape "
3495 for (
const auto &patch : patches)
3498 const unsigned int n1 = (dim > 0) ? n : 1;
3499 const unsigned int n2 = (dim > 1) ? n : 1;
3500 const unsigned int n3 = (dim > 2) ? n : 1;
3501 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3502 unsigned int dx = 1;
3503 unsigned int dy = n;
3504 unsigned int dz = n * n;
3506 const unsigned int patch_start =
3509 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3510 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3511 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3513 const unsigned int nx = i1 *
dx;
3514 const unsigned int ny = i2 * dy;
3515 const unsigned int nz = i3 * dz;
3527 const unsigned int nn = patch.
neighbors[0];
3531 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3537 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3542 const unsigned int nn = patch.
neighbors[1];
3545 out << (nn * cells_per_patch + ny + nz);
3551 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3558 const unsigned int nn = patch.
neighbors[2];
3562 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3568 out <<
'\t' << patch_start + nx + ny - dy + nz;
3573 const unsigned int nn = patch.
neighbors[3];
3576 out << (nn * cells_per_patch + nx + nz);
3582 out <<
'\t' << patch_start + nx + ny + dy + nz;
3590 const unsigned int nn = patch.
neighbors[4];
3594 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3600 out <<
'\t' << patch_start + nx + ny + nz - dz;
3605 const unsigned int nn = patch.
neighbors[5];
3608 out << (nn * cells_per_patch + nx + ny);
3614 out <<
'\t' << patch_start + nx + ny + nz + dz;
3622 if (n_data_sets != 0)
3624 out <<
"object \"data\" class array type float rank 1 shape "
3625 << n_data_sets <<
" items " << n_nodes;
3629 out <<
" lsb ieee data " << offset <<
'\n';
3630 offset += n_data_sets * n_nodes *
3631 ((flags.
data_double) ?
sizeof(
double) :
sizeof(float));
3635 out <<
" data follows" <<
'\n';
3640 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3644 out <<
"object \"data\" class constantarray type float rank 0 items "
3645 << n_nodes <<
" data follows" <<
'\n'
3651 out <<
"object \"deal data\" class field" <<
'\n'
3652 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3653 <<
"component \"connections\" value \"cells\"" <<
'\n'
3654 <<
"component \"data\" value \"data\"" <<
'\n';
3657 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3664 out <<
"end" <<
'\n';
3682 template <
int dim,
int spacedim>
3686 const std::vector<std::string> & data_names,
3688 std::tuple<
unsigned int,
3697 #ifndef DEAL_II_WITH_MPI
3707 if (patches.size() == 0)
3711 const unsigned int n_data_sets = data_names.size();
3715 out <<
"# This file was generated by the deal.II library." <<
'\n'
3719 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3726 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3731 for (
const auto &data_name : data_names)
3732 out <<
'<' << data_name <<
"> ";
3738 for (
const auto &patch : patches)
3741 const unsigned int n_points_per_direction = n_subdivisions + 1;
3743 Assert((patch.
data.n_rows() == n_data_sets &&
3745 (patch.
data.n_rows() == n_data_sets + spacedim &&
3748 (n_data_sets + spacedim) :
3750 patch.
data.n_rows()));
3752 auto output_point_data =
3753 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3754 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3755 out << patch.data(data_set, point_index) <<
' ';
3764 Assert(patch.data.n_cols() == 1,
3766 n_subdivisions + 1));
3770 out << get_equispaced_location(patch, {}, n_subdivisions)
3772 output_point_data(0);
3782 Assert(patch.data.n_cols() ==
3783 Utilities::fixed_power<dim>(n_points_per_direction),
3785 n_subdivisions + 1));
3787 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3790 out << get_equispaced_location(patch, {i1}, n_subdivisions)
3793 output_point_data(i1);
3806 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3807 n_points_per_direction),
3809 n_subdivisions + 1));
3811 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3813 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3817 out << get_equispaced_location(patch,
3822 output_point_data(i1 + i2 * n_points_per_direction);
3847 out << get_node_location(patch, 0) <<
' ';
3848 output_point_data(0);
3851 out << get_node_location(patch, 1) <<
' ';
3852 output_point_data(1);
3856 out << get_node_location(patch, 2) <<
' ';
3857 output_point_data(2);
3860 out << get_node_location(patch, 2) <<
' ';
3861 output_point_data(2);
3881 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3882 n_points_per_direction),
3884 n_subdivisions + 1));
3889 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3890 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3892 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3897 get_equispaced_location(patch,
3901 if (i1 < n_subdivisions)
3904 out << this_point <<
' ';
3905 output_point_data(i1 +
3906 i2 * n_points_per_direction +
3907 i3 * n_points_per_direction *
3908 n_points_per_direction);
3912 out << get_equispaced_location(patch,
3917 output_point_data((i1 + 1) +
3918 i2 * n_points_per_direction +
3919 i3 * n_points_per_direction *
3920 n_points_per_direction);
3924 out <<
'\n' <<
'\n';
3928 if (i2 < n_subdivisions)
3931 out << this_point <<
' ';
3932 output_point_data(i1 +
3933 i2 * n_points_per_direction +
3934 i3 * n_points_per_direction *
3935 n_points_per_direction);
3939 out << get_equispaced_location(patch,
3945 i1 + (i2 + 1) * n_points_per_direction +
3946 i3 * n_points_per_direction *
3947 n_points_per_direction);
3951 out <<
'\n' <<
'\n';
3955 if (i3 < n_subdivisions)
3958 out << this_point <<
' ';
3959 output_point_data(i1 +
3960 i2 * n_points_per_direction +
3961 i3 * n_points_per_direction *
3962 n_points_per_direction);
3966 out << get_equispaced_location(patch,
3972 i1 + i2 * n_points_per_direction +
3973 (i3 + 1) * n_points_per_direction *
3974 n_points_per_direction);
3977 out <<
'\n' <<
'\n';
3986 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
3988 out << get_node_location(patch, v) <<
' ';
3989 output_point_data(v);
3994 for (
const unsigned int v : {3, 1})
3996 out << get_node_location(patch, v) <<
' ';
3997 output_point_data(v);
4007 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
4009 out << get_node_location(patch, v) <<
' ';
4010 output_point_data(v);
4015 for (
const unsigned int v : {2, 4, 3})
4017 out << get_node_location(patch, v) <<
' ';
4018 output_point_data(v);
4032 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
4034 out << get_node_location(patch, v) <<
' ';
4035 output_point_data(v);
4040 for (
const unsigned int v : {1, 4})
4042 out << get_node_location(patch, v) <<
' ';
4043 output_point_data(v);
4048 for (
const unsigned int v : {2, 5})
4050 out << get_node_location(patch, v) <<
' ';
4051 output_point_data(v);
4076 template <
int dim,
int spacedim>
4078 do_write_povray(
const std::vector<Patch<dim, spacedim>> &,
4079 const std::vector<std::string> &,
4080 const PovrayFlags &,
4084 ExcMessage(
"Writing files in POVRAY format is only supported "
4085 "for two-dimensional meshes."));
4091 do_write_povray(
const std::vector<Patch<2, 2>> &patches,
4092 const std::vector<std::string> &data_names,
4093 const PovrayFlags & flags,
4098 #ifndef DEAL_II_WITH_MPI
4107 if (patches.size() == 0)
4110 constexpr
int dim = 2;
4112 constexpr
int spacedim = 2;
4114 const unsigned int n_data_sets = data_names.size();
4120 <<
"/* This file was generated by the deal.II library." <<
'\n'
4124 <<
" For a description of the POVRAY format see the POVRAY manual."
4129 out <<
"#include \"colors.inc\" " <<
'\n'
4130 <<
"#include \"textures.inc\" " <<
'\n';
4134 if (flags.external_data)
4135 out <<
"#include \"data.inc\" " <<
'\n';
4141 <<
"camera {" <<
'\n'
4142 <<
" location <1,4,-7>" <<
'\n'
4143 <<
" look_at <0,0,0>" <<
'\n'
4144 <<
" angle 30" <<
'\n'
4149 <<
"light_source {" <<
'\n'
4150 <<
" <1,4,-7>" <<
'\n'
4151 <<
" color Grey" <<
'\n'
4154 <<
"light_source {" <<
'\n'
4155 <<
" <0,20,0>" <<
'\n'
4156 <<
" color White" <<
'\n'
4163 double hmin = patches[0].data(0, 0);
4164 double hmax = patches[0].data(0, 0);
4166 for (
const auto &patch : patches)
4170 Assert((patch.
data.n_rows() == n_data_sets &&
4172 (patch.
data.n_rows() == n_data_sets + spacedim &&
4175 (n_data_sets + spacedim) :
4177 patch.
data.n_rows()));
4179 Utilities::fixed_power<dim>(n_subdivisions + 1),
4181 n_subdivisions + 1));
4183 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4184 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4186 const int dl = i * (n_subdivisions + 1) + j;
4187 if (patch.
data(0, dl) < hmin)
4188 hmin = patch.
data(0, dl);
4189 if (patch.
data(0, dl) > hmax)
4190 hmax = patch.
data(0, dl);
4194 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
4195 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
4198 if (!flags.external_data)
4201 out <<
"#declare Tex=texture{" <<
'\n'
4202 <<
" pigment {" <<
'\n'
4203 <<
" gradient y" <<
'\n'
4204 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
4205 <<
" color_map {" <<
'\n'
4206 <<
" [0.00 color Light_Purple] " <<
'\n'
4207 <<
" [0.95 color Light_Purple] " <<
'\n'
4208 <<
" [1.00 color White] " <<
'\n'
4213 if (!flags.bicubic_patch)
4216 out <<
'\n' <<
"mesh {" <<
'\n';
4220 for (
const auto &patch : patches)
4223 const unsigned int n = n_subdivisions + 1;
4224 const unsigned int d1 = 1;
4225 const unsigned int d2 = n;
4227 Assert((patch.
data.n_rows() == n_data_sets &&
4229 (patch.
data.n_rows() == n_data_sets + spacedim &&
4232 (n_data_sets + spacedim) :
4234 patch.
data.n_rows()));
4235 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
4237 n_subdivisions + 1));
4240 std::vector<Point<spacedim>> ver(n * n);
4242 for (
unsigned int i2 = 0; i2 < n; ++i2)
4243 for (
unsigned int i1 = 0; i1 < n; ++i1)
4246 ver[i1 * d1 + i2 * d2] =
4247 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4251 if (!flags.bicubic_patch)
4254 std::vector<Point<3>> nrml;
4264 for (
unsigned int i = 0; i < n; ++i)
4265 for (
unsigned int j = 0; j < n; ++j)
4267 const unsigned int il = (i == 0) ? i : (i - 1);
4268 const unsigned int ir =
4269 (i == n_subdivisions) ? i : (i + 1);
4270 const unsigned int jl = (j == 0) ? j : (j - 1);
4271 const unsigned int jr =
4272 (j == n_subdivisions) ? j : (j + 1);
4275 ver[ir * d1 + j * d2](0) - ver[il * d1 + j * d2](0);
4276 h1(1) = patch.
data(0, ir * d1 + j * d2) -
4277 patch.
data(0, il * d1 + j * d2);
4279 ver[ir * d1 + j * d2](1) - ver[il * d1 + j * d2](1);
4282 ver[i * d1 + jr * d2](0) - ver[i * d1 + jl * d2](0);
4283 h2(1) = patch.
data(0, i * d1 + jr * d2) -
4284 patch.
data(0, i * d1 + jl * d2);
4286 ver[i * d1 + jr * d2](1) - ver[i * d1 + jl * d2](1);
4288 nrml[i * d1 + j * d2](0) =
4289 h1(1) * h2(2) - h1(2) * h2(1);
4290 nrml[i * d1 + j * d2](1) =
4291 h1(2) * h2(0) - h1(0) * h2(2);
4292 nrml[i * d1 + j * d2](2) =
4293 h1(0) * h2(1) - h1(1) * h2(0);
4297 std::sqrt(std::pow(nrml[i * d1 + j * d2](0), 2.) +
4298 std::pow(nrml[i * d1 + j * d2](1), 2.) +
4299 std::pow(nrml[i * d1 + j * d2](2), 2.));
4301 if (nrml[i * d1 + j * d2](1) < 0)
4304 for (
unsigned int k = 0; k < 3; ++k)
4305 nrml[i * d1 + j * d2](k) /=
norm;
4310 for (
unsigned int i = 0; i < n_subdivisions; ++i)
4311 for (
unsigned int j = 0; j < n_subdivisions; ++j)
4314 const int dl = i * d1 + j * d2;
4320 out <<
"smooth_triangle {" <<
'\n'
4321 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4322 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0)
4323 <<
", " << nrml[dl](1) <<
", " << nrml[dl](2)
4325 out <<
" \t<" << ver[dl + d1](0) <<
","
4326 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
4327 <<
">, <" << nrml[dl + d1](0) <<
", "
4328 << nrml[dl + d1](1) <<
", " << nrml[dl + d1](2)
4330 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4331 << patch.
data(0, dl + d1 + d2) <<
","
4332 << ver[dl + d1 + d2](1) <<
">, <"
4333 << nrml[dl + d1 + d2](0) <<
", "
4334 << nrml[dl + d1 + d2](1) <<
", "
4335 << nrml[dl + d1 + d2](2) <<
">}" <<
'\n';
4338 out <<
"smooth_triangle {" <<
'\n'
4339 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4340 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0)
4341 <<
", " << nrml[dl](1) <<
", " << nrml[dl](2)
4343 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4344 << patch.
data(0, dl + d1 + d2) <<
","
4345 << ver[dl + d1 + d2](1) <<
">, <"
4346 << nrml[dl + d1 + d2](0) <<
", "
4347 << nrml[dl + d1 + d2](1) <<
", "
4348 << nrml[dl + d1 + d2](2) <<
">," <<
'\n';
4349 out <<
"\t<" << ver[dl + d2](0) <<
","
4350 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
4351 <<
">, <" << nrml[dl + d2](0) <<
", "
4352 << nrml[dl + d2](1) <<
", " << nrml[dl + d2](2)
4358 out <<
"triangle {" <<
'\n'
4359 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4360 <<
"," << ver[dl](1) <<
">," <<
'\n';
4361 out <<
"\t<" << ver[dl + d1](0) <<
","
4362 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
4364 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4365 << patch.
data(0, dl + d1 + d2) <<
","
4366 << ver[dl + d1 + d2](1) <<
">}" <<
'\n';
4369 out <<
"triangle {" <<
'\n'
4370 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4371 <<
"," << ver[dl](1) <<
">," <<
'\n';
4372 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4373 << patch.
data(0, dl + d1 + d2) <<
","
4374 << ver[dl + d1 + d2](1) <<
">," <<
'\n';
4375 out <<
"\t<" << ver[dl + d2](0) <<
","
4376 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
4384 Assert(n_subdivisions == 3,
4387 <<
"bicubic_patch {" <<
'\n'
4388 <<
" type 0" <<
'\n'
4389 <<
" flatness 0" <<
'\n'
4390 <<
" u_steps 0" <<
'\n'
4391 <<
" v_steps 0" <<
'\n';
4392 for (
int i = 0; i < 16; ++i)
4394 out <<
"\t<" << ver[i](0) <<
"," << patch.
data(0, i) <<
","
4395 << ver[i](1) <<
">";
4400 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4404 if (!flags.bicubic_patch)
4407 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4419 template <
int dim,
int spacedim>
4423 const std::vector<std::string> & data_names,
4425 std::tuple<
unsigned int,
4432 do_write_povray(patches, data_names, flags, out);
4437 template <
int dim,
int spacedim>
4441 const std::vector<std::string> & ,
4443 std::tuple<
unsigned int,
4455 template <
int spacedim>
4459 const std::vector<std::string> & ,
4461 std::tuple<
unsigned int,
4470 #ifndef DEAL_II_WITH_MPI
4479 if (patches.size() == 0)
4489 std::multiset<EpsCell2d> cells;
4498 double heights[4] = {0, 0, 0, 0};
4502 for (
const auto &patch : patches)
4505 const unsigned int n = n_subdivisions + 1;
4506 const unsigned int d1 = 1;
4507 const unsigned int d2 = n;
4509 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4510 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4514 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4516 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
4518 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
4519 points[3] = get_equispaced_location(patch,
4527 patch.
data.n_rows() == 0,
4530 patch.
data.n_rows()));
4532 patch.
data.n_rows() != 0 ?
4536 heights[1] = patch.
data.n_rows() != 0 ?
4538 (i1 + 1) * d1 + i2 * d2) *
4541 heights[2] = patch.
data.n_rows() != 0 ?
4543 i1 * d1 + (i2 + 1) * d2) *
4546 heights[3] = patch.
data.n_rows() != 0 ?
4548 (i1 + 1) * d1 + (i2 + 1) * d2) *
4555 for (
unsigned int i = 0; i < 4; ++i)
4556 heights[i] = points[i](2);
4577 cz = -std::cos(flags.
turn_angle * 2 * pi / 360.),
4580 sz = std::sin(flags.
turn_angle * 2 * pi / 360.);
4581 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4583 const double x = points[vertex](0), y = points[vertex](1),
4584 z = -heights[vertex];
4586 eps_cell.vertices[vertex](0) = -cz * x + sz * y;
4587 eps_cell.vertices[vertex](1) =
4588 -cx * sz * x - cx * cz * y - sx * z;
4612 (points[0] + points[1] + points[2] + points[3]) / 4;
4613 const double center_height =
4614 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4617 eps_cell.depth = -sx * sz * center_point(0) -
4618 sx * cz * center_point(1) + cx * center_height;
4623 patch.
data.n_rows() == 0,
4626 patch.
data.n_rows()));
4627 const double color_values[4] = {
4628 patch.
data.n_rows() != 0 ?
4632 patch.
data.n_rows() != 0 ?
4636 patch.
data.n_rows() != 0 ?
4640 patch.
data.n_rows() != 0 ?
4642 (i1 + 1) * d1 + (i2 + 1) * d2) :
4646 eps_cell.color_value = (color_values[0] + color_values[1] +
4647 color_values[3] + color_values[2]) /
4652 std::min(min_color_value, eps_cell.color_value);
4654 std::max(max_color_value, eps_cell.color_value);
4658 cells.insert(eps_cell);
4664 double x_min = cells.begin()->vertices[0](0);
4665 double x_max = x_min;
4666 double y_min = cells.begin()->vertices[0](1);
4667 double y_max = y_min;
4669 for (
const auto &cell : cells)
4670 for (
const auto &vertex : cell.vertices)
4672 x_min =
std::min(x_min, vertex(0));
4673 x_max =
std::max(x_max, vertex(0));
4674 y_min =
std::min(y_min, vertex(1));
4675 y_max =
std::max(y_max, vertex(1));
4680 const double scale =
4684 const Point<2> offset(x_min, y_min);
4689 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4690 <<
"%%Title: deal.II Output" <<
'\n'
4691 <<
"%%Creator: the deal.II library" <<
'\n'
4694 <<
"%%BoundingBox: "
4698 <<
static_cast<unsigned int>((x_max - x_min) *
scale + 0.5) <<
' '
4699 <<
static_cast<unsigned int>((y_max - y_min) *
scale + 0.5) <<
'\n';
4708 out <<
"/m {moveto} bind def" <<
'\n'
4709 <<
"/l {lineto} bind def" <<
'\n'
4710 <<
"/s {setrgbcolor} bind def" <<
'\n'
4711 <<
"/sg {setgray} bind def" <<
'\n'
4712 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4713 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4715 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4717 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4725 if (max_color_value == min_color_value)
4726 max_color_value = min_color_value + 1;
4730 for (
const auto &cell : cells)
4743 out << rgb_values.
red <<
" sg ";
4745 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4746 << rgb_values.
blue <<
" s ";
4751 out << (cell.vertices[0] - offset) *
scale <<
" m "
4752 << (cell.vertices[1] - offset) *
scale <<
" l "
4753 << (cell.vertices[3] - offset) *
scale <<
" l "
4754 << (cell.vertices[2] - offset) *
scale <<
" lf" <<
'\n';
4759 << (cell.vertices[0] - offset) *
scale <<
" m "
4760 << (cell.vertices[1] - offset) *
scale <<
" l "
4761 << (cell.vertices[3] - offset) *
scale <<
" l "
4762 << (cell.vertices[2] - offset) *
scale <<
" lx" <<
'\n';
4764 out <<
"showpage" <<
'\n';
4773 template <
int dim,
int spacedim>
4777 const std::vector<std::string> & data_names,
4779 std::tuple<
unsigned int,
4795 #ifndef DEAL_II_WITH_MPI
4804 if (patches.size() == 0)
4808 GmvStream gmv_out(out, flags);
4809 const unsigned int n_data_sets = data_names.size();
4812 Assert((patches[0].data.n_rows() == n_data_sets &&
4813 !patches[0].points_are_available) ||
4814 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4815 patches[0].points_are_available),
4817 (n_data_sets + spacedim) :
4819 patches[0].data.n_rows()));
4823 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4826 unsigned int n_nodes;
4828 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4843 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4845 &write_gmv_reorder_data_vectors<dim, spacedim>;
4853 out <<
"nodes " << n_nodes <<
'\n';
4854 for (
unsigned int d = 0;
d < spacedim; ++
d)
4856 gmv_out.selected_component =
d;
4862 for (
unsigned int d = spacedim;
d < 3; ++
d)
4864 for (
unsigned int i = 0; i < n_nodes; ++i)
4871 out <<
"cells " <<
n_cells <<
'\n';
4876 out <<
"variable" <<
'\n';
4880 reorder_task.
join();
4884 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4886 out << data_names[data_set] <<
" 1" <<
'\n';
4888 data_vectors[data_set].
end(),
4889 std::ostream_iterator<double>(out,
" "));
4890 out <<
'\n' <<
'\n';
4896 out <<
"endvars" <<
'\n';
4899 out <<
"endgmv" <<
'\n';
4910 template <
int dim,
int spacedim>
4914 const std::vector<std::string> & data_names,
4916 std::tuple<
unsigned int,
4930 #ifndef DEAL_II_WITH_MPI
4939 if (patches.size() == 0)
4943 TecplotStream tecplot_out(out, flags);
4945 const unsigned int n_data_sets = data_names.size();
4948 Assert((patches[0].data.n_rows() == n_data_sets &&
4949 !patches[0].points_are_available) ||
4950 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4951 patches[0].points_are_available),
4953 (n_data_sets + spacedim) :
4955 patches[0].data.n_rows()));
4958 unsigned int n_nodes;
4960 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4966 <<
"# This file was generated by the deal.II library." <<
'\n'
4970 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4975 out <<
"Variables=";
4983 out <<
"\"x\", \"y\"";
4986 out <<
"\"x\", \"y\", \"z\"";
4992 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4993 out <<
", \"" << data_names[data_set] <<
"\"";
4999 out <<
"t=\"" << flags.
zone_name <<
"\" ";
5002 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
5004 out <<
"f=feblock, n=" << n_nodes <<
", e=" <<
n_cells
5005 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
5024 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5026 &write_gmv_reorder_data_vectors<dim, spacedim>;
5034 for (
unsigned int d = 0;
d < spacedim; ++
d)
5036 tecplot_out.selected_component =
d;
5047 reorder_task.
join();
5050 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5053 data_vectors[data_set].
end(),
5054 std::ostream_iterator<double>(out,
"\n"));
5072 #ifdef DEAL_II_HAVE_TECPLOT
5079 TecplotMacros(
const unsigned int n_nodes = 0,
5080 const unsigned int n_vars = 0,
5081 const unsigned int n_cells = 0,
5082 const unsigned int n_vert = 0);
5085 nd(
const unsigned int i,
const unsigned int j);
5087 cd(
const unsigned int i,
const unsigned int j);
5088 std::vector<float> nodalData;
5089 std::vector<int> connData;
5092 unsigned int n_nodes;
5093 unsigned int n_vars;
5095 unsigned int n_vert;
5099 inline TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
5100 const unsigned int n_vars,
5102 const unsigned int n_vert)
5108 nodalData.resize(n_nodes * n_vars);
5109 connData.resize(
n_cells * n_vert);
5114 inline TecplotMacros::~TecplotMacros()
5120 TecplotMacros::nd(
const unsigned int i,
const unsigned int j)
5122 return nodalData[i * n_nodes + j];
5128 TecplotMacros::cd(
const unsigned int i,
const unsigned int j)
5130 return connData[i + j * n_vert];
5141 template <
int dim,
int spacedim>
5145 const std::vector<std::string> & data_names,
5147 std::tuple<
unsigned int,
5151 & nonscalar_data_ranges,
5160 #ifndef DEAL_II_HAVE_TECPLOT
5163 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
5171 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
5178 char *file_name = (
char *)flags.tecplot_binary_file_name;
5180 if (file_name ==
nullptr)
5185 ExcMessage(
"Specify the name of the tecplot_binary"
5186 " file through the TecplotFlags interface."));
5187 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
5194 # ifndef DEAL_II_WITH_MPI
5203 if (patches.size() == 0)
5207 const unsigned int n_data_sets = data_names.size();
5210 Assert((patches[0].data.n_rows() == n_data_sets &&
5211 !patches[0].points_are_available) ||
5212 (patches[0].data.n_rows() == n_data_sets + spacedim &&
5213 patches[0].points_are_available),
5215 (n_data_sets + spacedim) :
5217 patches[0].data.n_rows()));
5220 unsigned int n_nodes;
5222 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
5224 const unsigned int vars_per_node = (spacedim + n_data_sets),
5227 TecplotMacros tm(n_nodes, vars_per_node,
n_cells, nodes_per_cell);
5229 int is_double = 0, tec_debug = 0, cell_type = tecplot_binary_cell_type[dim];
5231 std::string tec_var_names;
5235 tec_var_names =
"x y";
5238 tec_var_names =
"x y z";
5244 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5246 tec_var_names +=
" ";
5247 tec_var_names += data_names[data_set];
5263 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5265 &write_gmv_reorder_data_vectors<dim, spacedim>;
5271 for (
unsigned int d = 1;
d <= spacedim; ++
d)
5273 unsigned int entry = 0;
5275 for (
const auto &patch : patches)
5283 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
5284 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
5286 const double x_frac = i * 1. / n_subdivisions,
5287 y_frac = j * 1. / n_subdivisions;
5289 tm.nd((
d - 1), entry) =
static_cast<float>(
5291 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
5294 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
5303 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
5304 for (
unsigned int k = 0; k < n_subdivisions + 1; ++k)
5305 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
5307 const double x_frac = i * 1. / n_subdivisions,
5308 y_frac = k * 1. / n_subdivisions,
5309 z_frac = j * 1. / n_subdivisions;
5312 tm.nd((
d - 1), entry) =
static_cast<float>(
5313 ((((patch.
vertices[1](
d - 1) * x_frac) +
5314 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
5317 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
5321 (patch.
vertices[4](
d - 1) * (1 - x_frac))) *
5324 (patch.
vertices[6](
d - 1) * (1 - x_frac))) *
5342 reorder_task.
join();
5345 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5346 for (
unsigned int entry = 0; entry < data_vectors[data_set].size();
5348 tm.nd((spacedim + data_set), entry) =
5349 static_cast<float>(data_vectors[data_set][entry]);
5355 unsigned int first_vertex_of_patch = 0;
5356 unsigned int elem = 0;
5358 for (
const auto &patch : patches)
5361 const unsigned int n = n_subdivisions + 1;
5362 const unsigned int d1 = 1;
5363 const unsigned int d2 = n;
5364 const unsigned int d3 = n * n;
5370 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5371 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5374 first_vertex_of_patch + (i1)*d1 + (i2)*d2 + 1;
5376 first_vertex_of_patch + (i1 + 1) * d1 + (i2)*d2 + 1;
5377 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5380 first_vertex_of_patch + (i1)*d1 + (i2 + 1) * d2 + 1;
5389 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5390 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5391 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5396 tm.cd(0, elem) = first_vertex_of_patch + (i1)*d1 +
5397 (i2)*d2 + (i3)*d3 + 1;
5398 tm.cd(1, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5399 (i2)*d2 + (i3)*d3 + 1;
5400 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5401 (i2 + 1) * d2 + (i3)*d3 + 1;
5402 tm.cd(3, elem) = first_vertex_of_patch + (i1)*d1 +
5403 (i2 + 1) * d2 + (i3)*d3 + 1;
5404 tm.cd(4, elem) = first_vertex_of_patch + (i1)*d1 +
5405 (i2)*d2 + (i3 + 1) * d3 + 1;
5406 tm.cd(5, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5407 (i2)*d2 + (i3 + 1) * d3 + 1;
5408 tm.cd(6, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5409 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
5410 tm.cd(7, elem) = first_vertex_of_patch + (i1)*d1 +
5411 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
5424 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
5429 int ierr = 0, num_nodes =
static_cast<int>(n_nodes),
5430 num_cells =
static_cast<int>(
n_cells);
5432 char dot[2] = {
'.', 0};
5436 char *var_names =
const_cast<char *
>(tec_var_names.c_str());
5437 ierr = TECINI(
nullptr, var_names, file_name, dot, &tec_debug, &is_double);
5441 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K', 0};
5443 TECZNE(
nullptr, &num_nodes, &num_cells, &cell_type, FEBLOCK,
nullptr);
5447 int total = (vars_per_node * num_nodes);
5449 ierr = TECDAT(&total, tm.nodalData.data(), &is_double);
5453 ierr = TECNOD(tm.connData.data());
5466 template <
int dim,
int spacedim>
5470 const std::vector<std::string> & data_names,
5472 std::tuple<
unsigned int,
5476 & nonscalar_data_ranges,
5482 #ifndef DEAL_II_WITH_MPI
5491 if (patches.size() == 0)
5495 VtkStream vtk_out(out, flags);
5497 const unsigned int n_data_sets = data_names.size();
5499 if (patches[0].points_are_available)
5511 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5512 <<
"#This file was generated by the deal.II library";
5520 out <<
'\n' <<
"ASCII" <<
'\n';
5522 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
5529 const unsigned int n_metadata =
5534 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5538 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5542 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5548 unsigned int n_nodes,
n_cells, n_points_and_n_cells;
5549 compute_sizes(patches,
5553 n_points_and_n_cells);
5569 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5571 &write_gmv_reorder_data_vectors<dim, spacedim>;
5579 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5584 out <<
"CELLS " <<
n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5592 out <<
"CELL_TYPES " <<
n_cells <<
'\n';
5596 for (
const auto &patch : patches)
5598 const auto vtk_cell_id =
5601 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5602 out <<
' ' << vtk_cell_id[0];
5611 reorder_task.
join();
5616 out <<
"POINT_DATA " << n_nodes <<
'\n';
5620 std::vector<bool> data_set_written(n_data_sets,
false);
5621 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5628 std::get<0>(nonscalar_data_range),
5630 std::get<0>(nonscalar_data_range)));
5631 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5635 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5636 std::get<0>(nonscalar_data_range) <=
5639 "Can't declare a vector with more than 3 components "
5643 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5644 i <= std::get<1>(nonscalar_data_range);
5646 data_set_written[i] =
true;
5652 if (!std::get<2>(nonscalar_data_range).empty())
5653 out << std::get<2>(nonscalar_data_range);
5656 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5657 i < std::get<1>(nonscalar_data_range);
5659 out << data_names[i] <<
"__";
5660 out << data_names[std::get<1>(nonscalar_data_range)];
5663 out <<
" double" <<
'\n';
5666 for (
unsigned int n = 0; n < n_nodes; ++n)
5668 switch (std::get<1>(nonscalar_data_range) -
5669 std::get<0>(nonscalar_data_range))
5672 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5677 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5679 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5683 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5685 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5687 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5700 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5701 if (data_set_written[data_set] ==
false)
5703 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5704 <<
"LOOKUP_TABLE default" <<
'\n';
5706 data_vectors[data_set].
end(),
5707 std::ostream_iterator<double>(out,
" "));
5723 out <<
"<?xml version=\"1.0\" ?> \n";
5725 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5726 <<
"#This file was generated by the deal.II library";
5735 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5736 #ifdef DEAL_II_WITH_ZLIB
5737 out <<
" compressor=\"vtkZLibDataCompressor\"";
5739 #ifdef DEAL_II_WORDS_BIGENDIAN
5740 out <<
" byte_order=\"BigEndian\"";
5742 out <<
" byte_order=\"LittleEndian\"";
5746 out <<
"<UnstructuredGrid>";
5756 out <<
" </UnstructuredGrid>\n";
5757 out <<
"</VTKFile>\n";
5762 template <
int dim,
int spacedim>
5766 const std::vector<std::string> & data_names,
5768 std::tuple<
unsigned int,
5772 & nonscalar_data_ranges,
5777 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5784 template <
int dim,
int spacedim>
5788 const std::vector<std::string> & data_names,
5790 std::tuple<
unsigned int,
5794 & nonscalar_data_ranges,
5808 unit.second.find(
'\"') == std::string::npos,
5810 "A physical unit you provided, <" + unit.second +
5811 ">, contained a quotation mark character. This is not allowed."));
5814 #ifndef DEAL_II_WITH_MPI
5823 if (patches.size() == 0)
5828 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5830 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5832 <<
" <PointData Scalars=\"scalars\">\n";
5833 std::vector<bool> data_set_written(data_names.size(),
false);
5834 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5837 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5838 i <= std::get<1>(nonscalar_data_range);
5840 data_set_written[i] =
true;
5844 out <<
" <DataArray type=\"Float32\" Name=\"";
5846 if (!std::get<2>(nonscalar_data_range).empty())
5847 out << std::get<2>(nonscalar_data_range);
5850 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5851 i < std::get<1>(nonscalar_data_range);
5853 out << data_names[i] <<
"__";
5854 out << data_names[std::get<1>(nonscalar_data_range)];
5857 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5860 for (
unsigned int data_set = 0; data_set < data_names.size();
5862 if (data_set_written[data_set] ==
false)
5864 out <<
" <DataArray type=\"Float32\" Name=\""
5865 << data_names[data_set] <<
"\"></DataArray>\n";
5868 out <<
" </PointData>\n";
5869 out <<
"</Piece>\n";
5883 const unsigned int n_metadata =
5887 out <<
"<FieldData>\n";
5892 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5893 << flags.
cycle <<
"</DataArray>\n";
5898 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5899 << flags.
time <<
"</DataArray>\n";
5903 out <<
"</FieldData>\n";
5907 VtuStream vtu_out(out, flags);
5909 const unsigned int n_data_sets = data_names.size();
5912 if (patches[0].points_are_available)
5921 #ifdef DEAL_II_WITH_ZLIB
5922 const char *ascii_or_binary =
"binary";
5924 const char * ascii_or_binary =
"ascii";
5929 unsigned int n_nodes,
n_cells, n_points_and_n_cells;
5930 compute_sizes(patches,
5934 n_points_and_n_cells);
5950 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5952 &write_gmv_reorder_data_vectors<dim, spacedim, float>;
5961 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
5963 out <<
" <Points>\n";
5964 out <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5965 << ascii_or_binary <<
"\">\n";
5967 out <<
" </DataArray>\n";
5968 out <<
" </Points>\n\n";
5971 out <<
" <Cells>\n";
5972 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5973 << ascii_or_binary <<
"\">\n";
5978 out <<
" </DataArray>\n";
5982 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5983 << ascii_or_binary <<
"\">\n";
5985 std::vector<int32_t> offsets;
5990 #ifdef DEAL_II_WITH_ZLIB
5991 std::vector<uint8_t> cell_types;
5993 std::vector<unsigned int> cell_types;
5997 unsigned int first_vertex_of_patch = 0;
5999 for (
const auto &patch : patches)
6001 const auto vtk_cell_id =
6004 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
6006 cell_types.push_back(vtk_cell_id[0]);
6007 first_vertex_of_patch += vtk_cell_id[2];
6008 offsets.push_back(first_vertex_of_patch);
6014 out <<
" </DataArray>\n";
6018 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
6019 << ascii_or_binary <<
"\">\n";
6022 vtu_out << cell_types;
6024 out <<
" </DataArray>\n";
6025 out <<
" </Cells>\n";
6033 reorder_task.
join();
6038 out <<
" <PointData Scalars=\"scalars\">\n";
6042 std::vector<bool> data_set_written(n_data_sets,
false);
6043 for (
const auto &range : nonscalar_data_ranges)
6045 const auto first_component = std::get<0>(range);
6046 const auto last_component = std::get<1>(range);
6047 const auto &name = std::get<2>(range);
6048 const bool is_tensor =
6049 (std::get<3>(range) ==
6051 const unsigned int n_components = (is_tensor ? 9 : 3);
6058 AssertThrow((last_component + 1 - first_component <= 9),
6060 "Can't declare a tensor with more than 9 components "
6061 "in VTK/VTU format."));
6065 AssertThrow((last_component + 1 - first_component <= 3),
6067 "Can't declare a vector with more than 3 components "
6068 "in VTK/VTU format."));
6072 for (
unsigned int i = first_component; i <= last_component; ++i)
6073 data_set_written[i] =
true;
6077 out <<
" <DataArray type=\"Float32\" Name=\"";
6083 for (
unsigned int i = first_component; i < last_component; ++i)
6084 out << data_names[i] <<
"__";
6085 out << data_names[last_component];
6088 out <<
"\" NumberOfComponents=\"" << n_components <<
"\" format=\""
6089 << ascii_or_binary <<
"\"";
6109 std::vector<float> data;
6110 data.reserve(n_nodes * n_components);
6112 for (
unsigned int n = 0; n < n_nodes; ++n)
6116 switch (last_component - first_component)
6119 data.push_back(data_vectors(first_component, n));
6125 data.push_back(data_vectors(first_component, n));
6126 data.push_back(data_vectors(first_component + 1, n));
6131 data.push_back(data_vectors(first_component, n));
6132 data.push_back(data_vectors(first_component + 1, n));
6133 data.push_back(data_vectors(first_component + 2, n));
6146 const unsigned int size = last_component - first_component + 1;
6150 vtk_data[0][0] = data_vectors(first_component, n);
6155 for (
unsigned int c = 0; c < size; ++c)
6159 vtk_data[ind[0]][ind[1]] =
6160 data_vectors(first_component + c, n);
6166 for (
unsigned int c = 0; c < size; ++c)
6170 vtk_data[ind[0]][ind[1]] =
6171 data_vectors(first_component + c, n);
6182 for (
unsigned int i = 0; i < 3; ++i)
6183 for (
unsigned int j = 0; j < 3; ++j)
6184 data.push_back(vtk_data[i][j]);
6190 out <<
" </DataArray>\n";
6195 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6196 if (data_set_written[data_set] ==
false)
6198 out <<
" <DataArray type=\"Float32\" Name=\""
6199 << data_names[data_set] <<
"\" format=\"" << ascii_or_binary
6204 out <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6209 std::vector<float> data(data_vectors[data_set].
begin(),
6210 data_vectors[data_set].
end());
6213 out <<
" </DataArray>\n";
6216 out <<
" </PointData>\n";
6219 out <<
" </Piece>\n";
6233 const std::vector<std::string> &piece_names,
6234 const std::vector<std::string> &data_names,
6236 std::tuple<
unsigned int,
6240 & nonscalar_data_ranges,
6253 unit.second.find(
'\"') == std::string::npos,
6255 "A physical unit you provided, <" + unit.second +
6256 ">, contained a quotation mark character. This is not allowed."));
6259 const unsigned int n_data_sets = data_names.size();
6261 out <<
"<?xml version=\"1.0\"?>\n";
6264 out <<
"#This file was generated by the deal.II library"
6269 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
6270 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
6271 out <<
" <PPointData Scalars=\"scalars\">\n";
6274 std::vector<bool> data_set_written(n_data_sets,
false);
6275 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
6277 const auto first_component = std::get<0>(nonscalar_data_range);
6278 const auto last_component = std::get<1>(nonscalar_data_range);
6279 const bool is_tensor =
6280 (std::get<3>(nonscalar_data_range) ==
6282 const unsigned int n_components = (is_tensor ? 9 : 3);
6289 AssertThrow((last_component + 1 - first_component <= 9),
6291 "Can't declare a tensor with more than 9 components "
6296 Assert((last_component + 1 - first_component <= 3),
6298 "Can't declare a vector with more than 3 components "
6303 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6304 i <= std::get<1>(nonscalar_data_range);
6306 data_set_written[i] =
true;
6310 out <<
" <PDataArray type=\"Float32\" Name=\"";
6312 const std::string &name = std::get<2>(nonscalar_data_range);
6317 for (
unsigned int i = std::get<0>(nonscalar_data_range);
6318 i < std::get<1>(nonscalar_data_range);
6320 out << data_names[i] <<
"__";
6321 out << data_names[std::get<1>(nonscalar_data_range)];
6324 out <<
"\" NumberOfComponents=\"" << n_components
6325 <<
"\" format=\"ascii\"";
6337 data_names[std::get<1>(nonscalar_data_range)]) !=
6341 data_names[std::get<1>(nonscalar_data_range)])
6349 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
6350 if (data_set_written[data_set] ==
false)
6352 out <<
" <PDataArray type=\"Float32\" Name=\""
6353 << data_names[data_set] <<
"\" format=\"ascii\"";
6357 out <<
" units=\"" << flags.
physical_units.at(data_names[data_set])
6363 out <<
" </PPointData>\n";
6365 out <<
" <PPoints>\n";
6366 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
6367 out <<
" </PPoints>\n";
6369 for (
const auto &piece_name : piece_names)
6370 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
6372 out <<
" </PUnstructuredGrid>\n";
6373 out <<
"</VTKFile>\n";
6386 const std::vector<std::pair<double, std::string>> ×_and_names)
6390 out <<
"<?xml version=\"1.0\"?>\n";
6393 out <<
"#This file was generated by the deal.II library"
6398 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
6399 out <<
" <Collection>\n";
6401 std::streamsize ss = out.precision();
6404 for (
const auto &time_and_name : times_and_names)
6405 out <<
" <DataSet timestep=\"" << time_and_name.first
6406 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
6409 out <<
" </Collection>\n";
6410 out <<
"</VTKFile>\n";