58#ifdef DEAL_II_WITH_ZLIB
62#ifdef DEAL_II_WITH_HDF5
76 <<
"Unexpected input: expected line\n <" << arg1
77 <<
">\nbut got\n <" << arg2 <<
">");
83#ifdef DEAL_II_WITH_ZLIB
89 get_zlib_compression_level(
95 return Z_NO_COMPRESSION;
99 return Z_BEST_COMPRESSION;
101 return Z_DEFAULT_COMPRESSION;
104 return Z_NO_COMPRESSION;
112 template <
typename T>
114 write_compressed_block(
const std::vector<T> & data,
116 std::ostream & output_stream)
118 if (data.size() != 0)
120 const std::size_t uncompressed_size = (data.size() *
sizeof(
T));
132 auto compressed_data_length = compressBound(uncompressed_size);
137 std::vector<unsigned char> compressed_data(compressed_data_length);
140 compress2(&compressed_data[0],
141 &compressed_data_length,
142 reinterpret_cast<const Bytef *
>(data.data()),
149 compressed_data.resize(compressed_data_length);
152 const std::uint32_t compression_header[4] = {
154 static_cast<std::uint32_t
>(uncompressed_size),
155 static_cast<std::uint32_t
>(
157 static_cast<std::uint32_t
>(
158 compressed_data_length)};
160 const auto header_start =
161 reinterpret_cast<const unsigned char *
>(&compression_header[0]);
165 header_start + 4 *
sizeof(std::uint32_t)})
275 template <
int dim,
int spacedim,
typename Number =
double>
277 write_gmv_reorder_data_vectors(
278 const std::vector<Patch<dim, spacedim>> &patches,
282 if (patches.size() == 0)
292 const unsigned int n_data_sets = patches[0].points_are_available ?
293 (patches[0].data.n_rows() - spacedim) :
294 patches[0].data.n_rows();
299 unsigned int next_value = 0;
300 for (
const auto &patch : patches)
302 const unsigned int n_subdivisions = patch.n_subdivisions;
303 (void)n_subdivisions;
305 Assert((patch.data.n_rows() == n_data_sets &&
306 !patch.points_are_available) ||
307 (patch.data.n_rows() == n_data_sets + spacedim &&
308 patch.points_are_available),
310 (n_data_sets + spacedim) :
312 patch.data.n_rows()));
313 Assert(patch.reference_cell != ReferenceCells::get_hypercube<dim>() ||
314 (n_data_sets == 0) ||
315 (patch.data.n_cols() ==
316 Utilities::fixed_power<dim>(n_subdivisions + 1)),
318 n_subdivisions + 1));
320 for (
unsigned int i = 0; i < patch.data.n_cols(); ++i, ++next_value)
321 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
322 data_vectors[data_set][next_value] = patch.data(data_set, i);
325 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
355 for (
unsigned int d = 0;
d < dim; ++
d)
359 unsigned int internal_ind;
370 internal_ind = it->second;
380 const unsigned int pt_index)
399 node_data[
node_dim * existing_point.second +
d] =
400 existing_point.first(
d);
408 std::vector<unsigned int> &cell_data)
const
414 cell_data[filtered_cell.first] =
415 filtered_cell.second + local_node_offset;
484 const unsigned int start,
485 const unsigned int d1,
486 const unsigned int d2,
487 const unsigned int d3)
491 const unsigned int base_entry =
517 const unsigned int start,
518 const unsigned int n_points,
523 const unsigned int base_entry = index * n_points;
525 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
527 for (
unsigned int i = 0; i < n_points; ++i)
538 const unsigned int dimension,
539 const unsigned int set_num,
542 unsigned int new_dim;
561 for (
unsigned int d = 0;
d < new_dim; ++
d)
564 data_sets.back()[r * new_dim +
d] = data_vectors(set_num +
d, i);
580 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
582 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
584 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
586#ifdef DEAL_II_HAVE_TECPLOT
587 const unsigned int tecplot_binary_cell_type[4] = {0, 0, 1, 3};
592 enum vtk_linear_cell_type
604 enum vtk_quadratic_cell_type
606 VTK_QUADRATIC_EDGE = 21,
607 VTK_QUADRATIC_TRIANGLE = 22,
608 VTK_QUADRATIC_QUAD = 23,
609 VTK_QUADRATIC_TETRA = 24,
610 VTK_QUADRATIC_HEXAHEDRON = 25,
611 VTK_QUADRATIC_WEDGE = 26,
612 VTK_QUADRATIC_PYRAMID = 27
615 enum vtk_lagrange_cell_type
617 VTK_LAGRANGE_CURVE = 68,
618 VTK_LAGRANGE_TRIANGLE = 69,
619 VTK_LAGRANGE_QUADRILATERAL = 70,
620 VTK_LAGRANGE_TETRAHEDRON = 71,
621 VTK_LAGRANGE_HEXAHEDRON = 72,
622 VTK_LAGRANGE_WEDGE = 73,
623 VTK_LAGRANGE_PYRAMID = 74
630 template <
int dim,
int spacedim>
631 std::array<unsigned int, 3>
633 const bool write_higher_order_cells)
635 std::array<unsigned int, 3> vtk_cell_id{};
637 if (write_higher_order_cells)
641 const std::array<unsigned int, 4> cell_type_by_dim{
644 VTK_LAGRANGE_QUADRILATERAL,
645 VTK_LAGRANGE_HEXAHEDRON}};
646 vtk_cell_id[0] = cell_type_by_dim[dim];
651 vtk_cell_id[0] = VTK_LAGRANGE_TRIANGLE;
660 patch.
data.n_cols() == 3)
662 vtk_cell_id[0] = VTK_TRIANGLE;
666 patch.
data.n_cols() == 6)
668 vtk_cell_id[0] = VTK_QUADRATIC_TRIANGLE;
672 patch.
data.n_cols() == 4)
674 vtk_cell_id[0] = VTK_TETRA;
678 patch.
data.n_cols() == 10)
680 vtk_cell_id[0] = VTK_QUADRATIC_TETRA;
684 patch.
data.n_cols() == 6)
686 vtk_cell_id[0] = VTK_WEDGE;
690 patch.
data.n_cols() == 5)
692 vtk_cell_id[0] = VTK_PYRAMID;
695 else if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
697 const std::array<unsigned int, 4> cell_type_by_dim{
698 {VTK_VERTEX, VTK_LINE, VTK_QUAD, VTK_HEXAHEDRON}};
699 vtk_cell_id[0] = cell_type_by_dim[dim];
707 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>() ||
708 write_higher_order_cells)
709 vtk_cell_id[2] = patch.
data.n_cols();
725 template <
int dim,
int spacedim>
727 get_equispaced_location(
729 const std::initializer_list<unsigned int> &lattice_location,
730 const unsigned int n_subdivisions)
738 const unsigned int xstep = (dim > 0 ? *(lattice_location.begin() + 0) : 0);
739 const unsigned int ystep = (dim > 1 ? *(lattice_location.begin() + 1) : 0);
740 const unsigned int zstep = (dim > 2 ? *(lattice_location.begin() + 2) : 0);
748 unsigned int point_no = 0;
753 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
757 point_no += (n_subdivisions + 1) * ystep;
771 for (
unsigned int d = 0;
d < spacedim; ++
d)
772 node[
d] = patch.
data(patch.
data.size(0) - spacedim +
d, point_no);
784 const double stepsize = 1. / n_subdivisions;
785 const double xfrac = xstep * stepsize;
791 const double yfrac = ystep * stepsize;
793 node += ((patch.
vertices[3] * xfrac) +
794 (patch.
vertices[2] * (1 - xfrac))) *
798 const double zfrac = zstep * stepsize;
800 node += (((patch.
vertices[5] * xfrac) +
801 (patch.
vertices[4] * (1 - xfrac))) *
804 (patch.
vertices[6] * (1 - xfrac))) *
817 template <
int dim,
int spacedim>
820 const unsigned int node_index)
825 unsigned int point_no_actual = node_index;
830 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
831 point_no_actual = table[node_index];
839 for (
unsigned int d = 0;
d < spacedim; ++
d)
841 patch.
data(patch.
data.size(0) - spacedim +
d, point_no_actual);
854 return patch.
vertices[point_no_actual];
868 vtk_point_index_from_ijk(
const unsigned i,
871 const std::array<unsigned, 2> &order)
873 const bool ibdy = (i == 0 || i == order[0]);
874 const bool jbdy = (j == 0 || j == order[1]);
876 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0);
880 return (i != 0u ? (j != 0u ? 2 : 1) : (j != 0u ? 3 : 0));
888 return (i - 1) + (j != 0u ? order[0] - 1 + order[1] - 1 : 0) +
895 (i != 0u ? order[0] - 1 :
896 2 * (order[0] - 1) + order[1] - 1) +
901 offset += 2 * (order[0] - 1 + order[1] - 1);
903 return offset + (i - 1) + (order[0] - 1) * ((j - 1));
916 vtk_point_index_from_ijk(
const unsigned i,
919 const std::array<unsigned, 3> &order)
921 const bool ibdy = (i == 0 || i == order[0]);
922 const bool jbdy = (j == 0 || j == order[1]);
923 const bool kbdy = (k == 0 || k == order[2]);
925 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0) + (kbdy ? 1 : 0);
929 return (i != 0u ? (j != 0u ? 2 : 1) : (j != 0u ? 3 : 0)) +
938 return (i - 1) + (j != 0u ? order[0] - 1 + order[1] - 1 : 0) +
939 (k != 0u ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
944 (i != 0u ? order[0] - 1 :
945 2 * (order[0] - 1) + order[1] - 1) +
946 (k != 0u ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
949 offset += 4 * (order[0] - 1) + 4 * (order[1] - 1);
952 (i != 0u ? (j != 0u ? 3 : 1) : (j != 0u ? 2 : 0)) +
956 offset += 4 * (order[0] - 1 + order[1] - 1 + order[2] - 1);
961 return (j - 1) + ((order[1] - 1) * (k - 1)) +
962 (i != 0u ? (order[1] - 1) * (order[2] - 1) : 0) + offset;
964 offset += 2 * (order[1] - 1) * (order[2] - 1);
967 return (i - 1) + ((order[0] - 1) * (k - 1)) +
968 (j != 0u ? (order[2] - 1) * (order[0] - 1) : 0) + offset;
970 offset += 2 * (order[2] - 1) * (order[0] - 1);
972 return (i - 1) + ((order[0] - 1) * (j - 1)) +
973 (k != 0u ? (order[0] - 1) * (order[1] - 1) : 0) + offset;
978 2 * ((order[1] - 1) * (order[2] - 1) + (order[2] - 1) * (order[0] - 1) +
979 (order[0] - 1) * (order[1] - 1));
980 return offset + (i - 1) +
981 (order[0] - 1) * ((j - 1) + (order[1] - 1) * ((k - 1)));
987 vtk_point_index_from_ijk(
const unsigned,
990 const std::array<unsigned, 0> &)
999 vtk_point_index_from_ijk(
const unsigned,
1002 const std::array<unsigned, 1> &)
1010 template <
int dim,
int spacedim>
1013 unsigned int & n_nodes,
1018 for (
const auto &patch : patches)
1022 "The reference cell for this patch is set to 'Invalid', "
1023 "but that is clearly not a valid choice. Did you forget "
1024 "to set the reference cell for the patch?"));
1027 if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
1029 n_nodes += Utilities::fixed_power<dim>(patch.
n_subdivisions + 1);
1043 template <
int dim,
int spacedim>
1046 const bool write_higher_order_cells,
1047 unsigned int &n_nodes,
1049 unsigned int &n_points_and_n_cells)
1053 n_points_and_n_cells = 0;
1055 for (
const auto &patch : patches)
1058 if (patch.
reference_cell == ReferenceCells::get_hypercube<dim>())
1060 n_nodes += Utilities::fixed_power<dim>(patch.
n_subdivisions + 1);
1062 if (write_higher_order_cells)
1065 n_points_and_n_cells +=
1071 n_points_and_n_cells +=
1078 n_nodes += patch.
data.n_cols();
1080 n_points_and_n_cells += patch.
data.n_cols() + 1;
1090 template <
typename FlagsType>
1097 StreamBase(std::ostream &stream,
const FlagsType &flags)
1109 write_point(
const unsigned int,
const Point<dim> &)
1112 ExcMessage(
"The derived class you are using needs to "
1113 "reimplement this function if you want to call "
1133 write_cell(
const unsigned int ,
1134 const unsigned int ,
1135 const unsigned int ,
1136 const unsigned int ,
1137 const unsigned int )
1140 ExcMessage(
"The derived class you are using needs to "
1141 "reimplement this function if you want to call "
1152 write_cell_single(
const unsigned int index,
1153 const unsigned int start,
1154 const unsigned int n_points,
1163 ExcMessage(
"The derived class you are using needs to "
1164 "reimplement this function if you want to call "
1182 template <
typename T>
1196 unsigned int selected_component;
1203 std::ostream &stream;
1208 const FlagsType flags;
1214 class DXStream :
public StreamBase<DataOutBase::DXFlags>
1221 write_point(
const unsigned int index,
const Point<dim> &);
1233 write_cell(
const unsigned int index,
1234 const unsigned int start,
1235 const unsigned int x_offset,
1236 const unsigned int y_offset,
1237 const unsigned int z_offset);
1245 template <
typename data>
1247 write_dataset(
const unsigned int index,
const std::vector<data> &
values);
1253 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
1260 write_point(
const unsigned int index,
const Point<dim> &);
1272 write_cell(
const unsigned int index,
1273 const unsigned int start,
1274 const unsigned int x_offset,
1275 const unsigned int y_offset,
1276 const unsigned int z_offset);
1282 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
1289 write_point(
const unsigned int index,
const Point<dim> &);
1301 write_cell(
const unsigned int index,
1302 const unsigned int start,
1303 const unsigned int x_offset,
1304 const unsigned int y_offset,
1305 const unsigned int z_offset);
1311 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1318 write_point(
const unsigned int index,
const Point<dim> &);
1332 write_cell(
const unsigned int index,
1333 const unsigned int start,
1334 const unsigned int x_offset,
1335 const unsigned int y_offset,
1336 const unsigned int z_offset);
1344 template <
typename data>
1346 write_dataset(
const unsigned int index,
const std::vector<data> &
values);
1352 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1359 write_point(
const unsigned int index,
const Point<dim> &);
1371 write_cell(
const unsigned int index,
1372 const unsigned int start,
1373 const unsigned int x_offset,
1374 const unsigned int y_offset,
1375 const unsigned int z_offset);
1381 write_cell_single(
const unsigned int index,
1382 const unsigned int start,
1383 const unsigned int n_points,
1395 write_high_order_cell(
const unsigned int index,
1396 const unsigned int start,
1397 const std::vector<unsigned> &connectivity);
1401 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
1408 write_point(
const unsigned int index,
const Point<dim> &);
1423 write_cell(
const unsigned int index,
1424 const unsigned int start,
1425 const unsigned int x_offset,
1426 const unsigned int y_offset,
1427 const unsigned int z_offset);
1433 write_cell_single(
const unsigned int index,
1434 const unsigned int start,
1435 const unsigned int n_points,
1447 write_high_order_cell(
const unsigned int index,
1448 const unsigned int start,
1449 const std::vector<unsigned> &connectivity);
1454 template <
typename T>
1465 template <
typename T>
1479 std::vector<int32_t> cells;
1492 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1494 if (flags.coordinates_binary)
1497 for (
unsigned int d = 0;
d < dim; ++
d)
1499 stream.write(
reinterpret_cast<const char *
>(data), dim *
sizeof(*data));
1503 for (
unsigned int d = 0;
d < dim; ++
d)
1504 stream << p(
d) <<
'\t';
1519 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell>
1520 set_node_numbers(
const unsigned int ,
1521 const unsigned int ,
1522 const unsigned int ,
1523 const unsigned int )
1532 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell>
1533 set_node_numbers<1>(
const unsigned int start,
1534 const unsigned int d1,
1535 const unsigned int ,
1536 const unsigned int )
1539 std::array<unsigned int, GeometryInfo<1>::vertices_per_cell> nodes;
1541 nodes[1] = start + d1;
1548 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell>
1549 set_node_numbers<2>(
const unsigned int start,
1550 const unsigned int d1,
1551 const unsigned int d2,
1552 const unsigned int )
1555 std::array<unsigned int, GeometryInfo<2>::vertices_per_cell> nodes;
1557 nodes[1] = start + d1;
1558 nodes[2] = start + d2;
1559 nodes[3] = start + d2 + d1;
1566 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell>
1567 set_node_numbers<3>(
const unsigned int start,
1568 const unsigned int d1,
1569 const unsigned int d2,
1570 const unsigned int d3)
1572 std::array<unsigned int, GeometryInfo<3>::vertices_per_cell> nodes;
1574 nodes[1] = start + d1;
1575 nodes[2] = start + d2;
1576 nodes[3] = start + d2 + d1;
1577 nodes[4] = start + d3;
1578 nodes[5] = start + d3 + d1;
1579 nodes[6] = start + d3 + d2;
1580 nodes[7] = start + d3 + d2 + d1;
1589 DXStream::write_cell(
unsigned int,
1596 DataOutBaseImplementation::set_node_numbers<dim>(start, d1, d2, d3);
1598 if (flags.int_binary)
1600 std::array<unsigned int, GeometryInfo<dim>::vertices_per_cell> temp;
1601 for (
unsigned int i = 0; i < nodes.size(); ++i)
1603 stream.write(
reinterpret_cast<const char *
>(temp.data()),
1604 temp.size() *
sizeof(temp[0]));
1608 for (
unsigned int i = 0; i < nodes.size() - 1; ++i)
1610 stream << nodes[GeometryInfo<dim>::dx_to_deal[nodes.size() - 1]]
1617 template <
typename data>
1619 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &
values)
1621 if (flags.data_binary)
1623 stream.write(
reinterpret_cast<const char *
>(
values.data()),
1624 values.size() *
sizeof(data));
1628 for (
unsigned int i = 0; i <
values.size(); ++i)
1629 stream <<
'\t' <<
values[i];
1645 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1649 stream << p(selected_component) <<
' ';
1656 GmvStream::write_cell(
unsigned int,
1663 const unsigned int start = s + 1;
1664 stream << gmv_cell_type[dim] <<
'\n';
1669 stream <<
'\t' << start + d1;
1672 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1675 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1676 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1685 TecplotStream::TecplotStream(std::ostream & out,
1693 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1697 stream << p(selected_component) <<
'\n';
1704 TecplotStream::write_cell(
unsigned int,
1710 const unsigned int start = s + 1;
1715 stream <<
'\t' << start + d1;
1718 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1721 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1722 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1738 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1740 stream <<
index + 1 <<
" ";
1742 for (
unsigned int i = 0; i < dim; ++i)
1743 stream << p(i) <<
' ';
1745 for (
unsigned int i = dim; i < 3; ++i)
1754 UcdStream::write_cell(
unsigned int index,
1761 DataOutBaseImplementation::set_node_numbers<dim>(start, d1, d2, d3);
1764 stream <<
index + 1 <<
"\t0 " << ucd_cell_type[dim];
1765 for (
unsigned int i = 0; i < nodes.size(); ++i)
1772 template <
typename data>
1774 UcdStream::write_dataset(
const unsigned int index,
1775 const std::vector<data> &
values)
1777 stream <<
index + 1;
1778 for (
unsigned int i = 0; i <
values.size(); ++i)
1779 stream <<
'\t' <<
values[i];
1794 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1799 for (
unsigned int i = dim; i < 3; ++i)
1808 VtkStream::write_cell(
unsigned int,
1814 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' << start;
1817 stream <<
'\t' << start + d1;
1821 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1824 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1825 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1833 VtkStream::write_cell_single(
const unsigned int index,
1834 const unsigned int start,
1835 const unsigned int n_points,
1840 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1842 stream <<
'\t' << n_points;
1843 for (
unsigned int i = 0; i < n_points; ++i)
1852 VtkStream::write_high_order_cell(
const unsigned int,
1853 const unsigned int start,
1854 const std::vector<unsigned> &connectivity)
1856 stream << connectivity.size();
1857 for (
const auto &c : connectivity)
1858 stream <<
'\t' << start + c;
1869 VtuStream::write_point(
const unsigned int,
const Point<dim> &p)
1871#if !defined(DEAL_II_WITH_ZLIB)
1875 for (
unsigned int i = dim; i < 3; ++i)
1880 for (
unsigned int i = 0; i < dim; ++i)
1882 for (
unsigned int i = dim; i < 3; ++i)
1889 VtuStream::flush_points()
1891#ifdef DEAL_II_WITH_ZLIB
1902 VtuStream::write_cell(
unsigned int,
1908#if !defined(DEAL_II_WITH_ZLIB)
1912 stream <<
'\t' << start + d1;
1915 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1918 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1919 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1925 cells.push_back(start);
1928 cells.push_back(start + d1);
1931 cells.push_back(start + d2 + d1);
1932 cells.push_back(start + d2);
1935 cells.push_back(start + d3);
1936 cells.push_back(start + d3 + d1);
1937 cells.push_back(start + d3 + d2 + d1);
1938 cells.push_back(start + d3 + d2);
1946 VtuStream::write_cell_single(
const unsigned int index,
1947 const unsigned int start,
1948 const unsigned int n_points,
1953 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
1955#if !defined(DEAL_II_WITH_ZLIB)
1956 for (
unsigned int i = 0; i < n_points; ++i)
1962 for (
unsigned int i = 0; i < n_points; ++i)
1970 VtuStream::write_high_order_cell(
const unsigned int,
1971 const unsigned int start,
1972 const std::vector<unsigned> &connectivity)
1974#if !defined(DEAL_II_WITH_ZLIB)
1975 for (
const auto &c : connectivity)
1976 stream <<
'\t' << start + c;
1979 for (
const auto &c : connectivity)
1980 cells.push_back(start + c);
1985 VtuStream::flush_cells()
1987#ifdef DEAL_II_WITH_ZLIB
1990 *
this << cells <<
'\n';
1996 template <
typename T>
2000#ifdef DEAL_II_WITH_ZLIB
2003 write_compressed_block(data, flags, stream);
2005 for (
unsigned int i = 0; i < data.size(); ++i)
2006 stream << data[i] <<
' ';
2020 template <
int dim,
int spacedim>
2024 template <
int dim,
int spacedim>
2028 template <
int dim,
int spacedim>
2030 : patch_index(no_neighbor)
2032 , points_are_available(false)
2046 template <
int dim,
int spacedim>
2072 if (data.n_rows() != patch.
data.n_rows())
2075 if (data.n_cols() != patch.
data.n_cols())
2078 for (
unsigned int i = 0; i < data.n_rows(); ++i)
2079 for (
unsigned int j = 0; j < data.n_cols(); ++j)
2080 if (data[i][j] != patch.
data[i][j])
2088 template <
int dim,
int spacedim>
2094 sizeof(neighbors) /
sizeof(neighbors[0]) *
2105 template <
int dim,
int spacedim>
2113 data.swap(other_patch.
data);
2120 template <
int spacedim>
2124 template <
int spacedim>
2128 template <
int spacedim>
2132 template <
int spacedim>
2135 template <
int spacedim>
2139 template <
int spacedim>
2141 : patch_index(no_neighbor)
2142 , points_are_available(false)
2149 template <
int spacedim>
2153 const unsigned int dim = 0;
2167 if (
data.n_rows() != patch.
data.n_rows())
2170 if (
data.n_cols() != patch.
data.n_cols())
2173 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
2174 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
2175 if (
data[i][j] != patch.
data[i][j])
2183 template <
int spacedim>
2195 template <
int spacedim>
2208 : write_preamble(write_preamble)
2223 : space_dimension_labels(labels)
2237 const bool bicubic_patch,
2238 const bool external_data)
2240 , bicubic_patch(bicubic_patch)
2241 , external_data(external_data)
2246 const bool xdmf_hdf5_output)
2247 : filter_duplicate_vertices(filter_duplicate_vertices)
2248 , xdmf_hdf5_output(xdmf_hdf5_output)
2256 "Filter duplicate vertices",
2259 "Whether to remove duplicate vertex values. deal.II duplicates "
2260 "vertices once for each adjacent cell so that it can output "
2261 "discontinuous quantities for which there may be more than one "
2262 "value for each vertex position. Setting this flag to "
2263 "'true' will merge all of these values by selecting a "
2264 "random one and outputting this as 'the' value for the vertex. "
2265 "As long as the data to be output corresponds to continuous "
2266 "fields, merging vertices has no effect. On the other hand, "
2267 "if the data to be output corresponds to discontinuous fields "
2268 "(either because you are using a discontinuous finite element, "
2269 "or because you are using a DataPostprocessor that yields "
2270 "discontinuous data, or because the data to be output has been "
2271 "produced by entirely different means), then the data in the "
2272 "output file no longer faithfully represents the underlying data "
2273 "because the discontinuous field has been replaced by a "
2274 "continuous one. Note also that the filtering can not occur "
2275 "on processor boundaries. Thus, a filtered discontinuous field "
2276 "looks like a continuous field inside of a subdomain, "
2277 "but like a discontinuous field at the subdomain boundary."
2279 "In any case, filtering results in drastically smaller output "
2280 "files (smaller by about a factor of 2^dim).");
2285 "Whether the data will be used in an XDMF/HDF5 combination.");
2300 const bool int_binary,
2301 const bool coordinates_binary,
2302 const bool data_binary)
2303 : write_neighbors(write_neighbors)
2304 , int_binary(int_binary)
2305 , coordinates_binary(coordinates_binary)
2306 , data_binary(data_binary)
2307 , data_double(false)
2317 "A boolean field indicating whether neighborship "
2318 "information between cells is to be written to the "
2319 "OpenDX output file");
2323 "Output format of integer numbers, which is "
2324 "either a text representation (ascii) or binary integer "
2325 "values of 32 or 64 bits length");
2329 "Output format of vertex coordinates, which is "
2330 "either a text representation (ascii) or binary "
2331 "floating point values of 32 or 64 bits length");
2335 "Output format of data values, which is "
2336 "either a text representation (ascii) or binary "
2337 "floating point values of 32 or 64 bits length");
2357 "A flag indicating whether a comment should be "
2358 "written to the beginning of the output file "
2359 "indicating date and time of creation as well "
2360 "as the creating program");
2374 const int azimuth_angle,
2375 const int polar_angle,
2376 const unsigned int line_thickness,
2378 const bool draw_colorbar)
2381 , height_vector(height_vector)
2382 , azimuth_angle(azimuth_angle)
2383 , polar_angle(polar_angle)
2384 , line_thickness(line_thickness)
2386 , draw_colorbar(draw_colorbar)
2397 "A flag indicating whether POVRAY should use smoothed "
2398 "triangles instead of the usual ones");
2402 "Whether POVRAY should use bicubic patches");
2406 "Whether camera and lighting information should "
2407 "be put into an external file \"data.inc\" or into "
2408 "the POVRAY input file");
2424 const unsigned int color_vector,
2426 const unsigned int size,
2427 const double line_width,
2428 const double azimut_angle,
2429 const double turn_angle,
2430 const double z_scaling,
2431 const bool draw_mesh,
2432 const bool draw_cells,
2433 const bool shade_cells,
2435 : height_vector(height_vector)
2436 , color_vector(color_vector)
2439 , line_width(line_width)
2440 , azimut_angle(azimut_angle)
2441 , turn_angle(turn_angle)
2442 , z_scaling(z_scaling)
2443 , draw_mesh(draw_mesh)
2444 , draw_cells(draw_cells)
2445 , shade_cells(shade_cells)
2446 , color_function(color_function)
2485 double sum = xmax + xmin;
2486 double sum13 = xmin + 3 * xmax;
2487 double sum22 = 2 * xmin + 2 * xmax;
2488 double sum31 = 3 * xmin + xmax;
2489 double dif = xmax - xmin;
2490 double rezdif = 1.0 / dif;
2494 if (x < (sum31) / 4)
2496 else if (x < (sum22) / 4)
2498 else if (x < (sum13) / 4)
2509 rgb_values.
green = 0;
2510 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2514 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2515 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2518 rgb_values.
red = (4 * x - 2 *
sum) * rezdif;
2519 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2520 rgb_values.
blue = 0;
2524 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2525 rgb_values.
blue = (4. * x - sum13) * rezdif;
2532 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2546 (x - xmin) / (xmax - xmin);
2559 1 - (x - xmin) / (xmax - xmin);
2571 "Number of the input vector that is to be used to "
2572 "generate height information");
2576 "Number of the input vector that is to be used to "
2577 "generate color information");
2581 "Whether width or height should be scaled to match "
2586 "The size (width or height) to which the eps output "
2587 "file is to be scaled");
2591 "The width in which the postscript renderer is to "
2596 "Angle of the viewing position against the vertical "
2601 "Angle of the viewing direction against the y-axis");
2605 "Scaling for the z-direction relative to the scaling "
2606 "used in x- and y-directions");
2610 "Whether the mesh lines, or only the surface should be "
2615 "Whether only the mesh lines, or also the interior of "
2616 "cells should be plotted. If this flag is false, then "
2617 "one can see through the mesh");
2621 "Whether the interior of cells shall be shaded");
2625 "default|grey scale|reverse grey scale"),
2626 "Name of a color function used to colorize mesh lines "
2627 "and/or cell interiors");
2637 if (prm.
get(
"Scale to width or height") ==
"width")
2649 if (prm.
get(
"Color function") ==
"default")
2651 else if (prm.
get(
"Color function") ==
"grey scale")
2653 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2664 : zone_name(zone_name)
2665 , solution_time(solution_time)
2679 const unsigned int cycle,
2680 const bool print_date_and_time,
2682 const bool write_higher_order_cells,
2683 const std::map<std::string, std::string> &physical_units)
2686 , print_date_and_time(print_date_and_time)
2687 , compression_level(compression_level)
2688 , write_higher_order_cells(write_higher_order_cells)
2689 , physical_units(physical_units)
2697 if (format_name ==
"none")
2700 if (format_name ==
"dx")
2703 if (format_name ==
"ucd")
2706 if (format_name ==
"gnuplot")
2709 if (format_name ==
"povray")
2712 if (format_name ==
"eps")
2715 if (format_name ==
"gmv")
2718 if (format_name ==
"tecplot")
2721 if (format_name ==
"tecplot_binary")
2724 if (format_name ==
"vtk")
2727 if (format_name ==
"vtu")
2730 if (format_name ==
"deal.II intermediate")
2733 if (format_name ==
"hdf5")
2737 ExcMessage(
"The given file format name is not recognized: <" +
2738 format_name +
">"));
2749 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2757 switch (output_format)
2796 template <
int dim,
int spacedim,
typename StreamType>
2801 unsigned int count = 0;
2803 static const std::array<unsigned int, 5> table = {{0, 1, 3, 2, 4}};
2805 for (
const auto &patch : patches)
2808 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2810 for (
unsigned int point_no = 0; point_no < patch.
data.n_cols();
2812 out.write_point(count++,
2813 get_node_location(patch,
2822 const unsigned int n = n_subdivisions + 1;
2827 out.write_point(count++,
2828 get_equispaced_location(patch,
2833 for (
unsigned int i1 = 0; i1 < n; ++i1)
2834 out.write_point(count++,
2835 get_equispaced_location(patch,
2840 for (
unsigned int i2 = 0; i2 < n; ++i2)
2841 for (
unsigned int i1 = 0; i1 < n; ++i1)
2842 out.write_point(count++,
2843 get_equispaced_location(patch,
2848 for (
unsigned int i3 = 0; i3 < n; ++i3)
2849 for (
unsigned int i2 = 0; i2 < n; ++i2)
2850 for (
unsigned int i1 = 0; i1 < n; ++i1)
2851 out.write_point(count++,
2852 get_equispaced_location(
2853 patch, {i1, i2, i3}, n_subdivisions));
2864 template <
int dim,
int spacedim,
typename StreamType>
2869 unsigned int count = 0;
2870 unsigned int first_vertex_of_patch = 0;
2871 for (
const auto &patch : patches)
2874 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2876 out.write_cell_single(count++,
2877 first_vertex_of_patch,
2878 patch.
data.n_cols(),
2880 first_vertex_of_patch += patch.
data.n_cols();
2885 const unsigned int n = n_subdivisions + 1;
2887 const unsigned int n1 = (dim > 0) ? n_subdivisions : 1;
2888 const unsigned int n2 = (dim > 1) ? n_subdivisions : 1;
2889 const unsigned int n3 = (dim > 2) ? n_subdivisions : 1;
2891 const unsigned int d1 = 1;
2892 const unsigned int d2 = n;
2893 const unsigned int d3 = n * n;
2894 for (
unsigned int i3 = 0; i3 < n3; ++i3)
2895 for (
unsigned int i2 = 0; i2 < n2; ++i2)
2896 for (
unsigned int i1 = 0; i1 < n1; ++i1)
2898 const unsigned int offset =
2899 first_vertex_of_patch + i3 * d3 + i2 * d2 + i1 * d1;
2901 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2904 first_vertex_of_patch +=
2905 Utilities::fixed_power<dim>(n_subdivisions + 1);
2912 template <
int dim,
int spacedim,
typename StreamType>
2918 unsigned int first_vertex_of_patch = 0;
2919 unsigned int count = 0;
2921 std::vector<unsigned> connectivity;
2923 std::array<unsigned, dim> cell_order;
2925 for (
const auto &patch : patches)
2927 if (patch.
reference_cell != ReferenceCells::get_hypercube<dim>())
2929 connectivity.resize(patch.
data.n_cols());
2931 for (
unsigned int i = 0; i < patch.
data.n_cols(); ++i)
2932 connectivity[i] = i;
2934 out.template write_high_order_cell<dim>(count++,
2935 first_vertex_of_patch,
2938 first_vertex_of_patch += patch.
data.n_cols();
2943 const unsigned int n = n_subdivisions + 1;
2945 cell_order.fill(n_subdivisions);
2946 connectivity.resize(Utilities::fixed_power<dim>(n));
2949 const unsigned int n1 = (dim > 0) ? n_subdivisions : 0;
2950 const unsigned int n2 = (dim > 1) ? n_subdivisions : 0;
2951 const unsigned int n3 = (dim > 2) ? n_subdivisions : 0;
2953 const unsigned int d1 = 1;
2954 const unsigned int d2 = n;
2955 const unsigned int d3 = n * n;
2956 for (
unsigned int i3 = 0; i3 <= n3; ++i3)
2957 for (
unsigned int i2 = 0; i2 <= n2; ++i2)
2958 for (
unsigned int i1 = 0; i1 <= n1; ++i1)
2960 const unsigned int local_index =
2961 i3 * d3 + i2 * d2 + i1 * d1;
2962 const unsigned int connectivity_index =
2963 vtk_point_index_from_ijk(i1, i2, i3, cell_order);
2964 connectivity[connectivity_index] = local_index;
2967 out.template write_high_order_cell<dim>(count++,
2968 first_vertex_of_patch,
2972 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
2980 template <
int dim,
int spacedim,
class StreamType>
2983 unsigned int n_data_sets,
2984 const bool double_precision,
2988 unsigned int count = 0;
2990 for (
const auto &patch : patches)
2993 const unsigned int n = n_subdivisions + 1;
2995 Assert((patch.
data.n_rows() == n_data_sets &&
2997 (patch.
data.n_rows() == n_data_sets + spacedim &&
3000 (n_data_sets + spacedim) :
3002 patch.
data.n_rows()));
3003 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
3006 std::vector<float> floats(n_data_sets);
3007 std::vector<double> doubles(n_data_sets);
3010 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
3012 if (double_precision)
3014 for (
unsigned int data_set = 0; data_set < n_data_sets;
3016 doubles[data_set] = patch.
data(data_set, i);
3017 out.write_dataset(count, doubles);
3021 for (
unsigned int data_set = 0; data_set < n_data_sets;
3023 floats[data_set] = patch.
data(data_set, i);
3024 out.write_dataset(count, floats);
3049 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
3050 camera_horizontal[2] * camera_direction[1];
3051 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
3052 camera_horizontal[0] * camera_direction[2];
3053 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
3054 camera_horizontal[1] * camera_direction[0];
3058 phi /= (
point[0] - camera_position[0]) * camera_direction[0] +
3059 (
point[1] - camera_position[1]) * camera_direction[1] +
3060 (
point[2] - camera_position[2]) * camera_direction[2];
3064 camera_position[0] + phi * (
point[0] - camera_position[0]);
3066 camera_position[1] + phi * (
point[1] - camera_position[1]);
3068 camera_position[2] + phi * (
point[2] - camera_position[2]);
3071 projection_decomposition[0] = (projection[0] - camera_position[0] -
3072 camera_focus * camera_direction[0]) *
3073 camera_horizontal[0];
3074 projection_decomposition[0] += (projection[1] - camera_position[1] -
3075 camera_focus * camera_direction[1]) *
3076 camera_horizontal[1];
3077 projection_decomposition[0] += (projection[2] - camera_position[2] -
3078 camera_focus * camera_direction[2]) *
3079 camera_horizontal[2];
3081 projection_decomposition[1] = (projection[0] - camera_position[0] -
3082 camera_focus * camera_direction[0]) *
3084 projection_decomposition[1] += (projection[1] - camera_position[1] -
3085 camera_focus * camera_direction[1]) *
3087 projection_decomposition[1] += (projection[2] - camera_position[2] -
3088 camera_focus * camera_direction[2]) *
3091 return projection_decomposition;
3100 svg_get_gradient_parameters(
Point<3> points[])
3106 for (
int i = 0; i < 2; ++i)
3108 for (
int j = 0; j < 2 - i; ++j)
3110 if (points[j][2] > points[j + 1][2])
3113 points[j] = points[j + 1];
3114 points[j + 1] = temp;
3121 v_inter = points[1];
3128 A[0][0] = v_max[0] - v_min[0];
3129 A[0][1] = v_inter[0] - v_min[0];
3130 A[1][0] = v_max[1] - v_min[1];
3131 A[1][1] = v_inter[1] - v_min[1];
3137 bool col_change =
false;
3146 double temp =
A[1][0];
3151 for (
unsigned int k = 0; k < 1; ++k)
3153 for (
unsigned int i = k + 1; i < 2; ++i)
3155 x =
A[i][k] /
A[k][k];
3157 for (
unsigned int j = k + 1; j < 2; ++j)
3158 A[i][j] =
A[i][j] -
A[k][j] * x;
3160 b[i] =
b[i] -
b[k] * x;
3164 b[1] =
b[1] /
A[1][1];
3166 for (
int i = 0; i >= 0; i--)
3170 for (
unsigned int j = i + 1; j < 2; ++j)
3173 b[i] =
sum /
A[i][i];
3183 double c =
b[0] * (v_max[2] - v_min[2]) +
b[1] * (v_inter[2] - v_min[2]) +
3187 A[0][0] = v_max[0] - v_min[0];
3188 A[0][1] = v_inter[0] - v_min[0];
3189 A[1][0] = v_max[1] - v_min[1];
3190 A[1][1] = v_inter[1] - v_min[1];
3192 b[0] = 1.0 - v_min[0];
3204 double temp =
A[1][0];
3209 for (
unsigned int k = 0; k < 1; ++k)
3211 for (
unsigned int i = k + 1; i < 2; ++i)
3213 x =
A[i][k] /
A[k][k];
3215 for (
unsigned int j = k + 1; j < 2; ++j)
3216 A[i][j] =
A[i][j] -
A[k][j] * x;
3218 b[i] =
b[i] -
b[k] * x;
3222 b[1] =
b[1] /
A[1][1];
3224 for (
int i = 0; i >= 0; i--)
3228 for (
unsigned int j = i + 1; j < 2; ++j)
3231 b[i] =
sum /
A[i][i];
3241 gradient[0] =
b[0] * (v_max[2] - v_min[2]) +
3242 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3245 A[0][0] = v_max[0] - v_min[0];
3246 A[0][1] = v_inter[0] - v_min[0];
3247 A[1][0] = v_max[1] - v_min[1];
3248 A[1][1] = v_inter[1] - v_min[1];
3251 b[1] = 1.0 - v_min[1];
3262 double temp =
A[1][0];
3267 for (
unsigned int k = 0; k < 1; ++k)
3269 for (
unsigned int i = k + 1; i < 2; ++i)
3271 x =
A[i][k] /
A[k][k];
3273 for (
unsigned int j = k + 1; j < 2; ++j)
3274 A[i][j] =
A[i][j] -
A[k][j] * x;
3276 b[i] =
b[i] -
b[k] * x;
3280 b[1] =
b[1] /
A[1][1];
3282 for (
int i = 0; i >= 0; i--)
3286 for (
unsigned int j = i + 1; j < 2; ++j)
3289 b[i] =
sum /
A[i][i];
3299 gradient[1] =
b[0] * (v_max[2] - v_min[2]) +
3300 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
3306 gradient[1] * (v_min[1] - v_max[1]);
3310 gradient_parameters[0] = v_min[0];
3311 gradient_parameters[1] = v_min[1];
3316 gradient_parameters[4] = v_min[2];
3317 gradient_parameters[5] = v_max[2];
3319 return gradient_parameters;
3325 template <
int dim,
int spacedim>
3329 const std::vector<std::string> & data_names,
3331 std::tuple<
unsigned int,
3344#ifndef DEAL_II_WITH_MPI
3353 if (patches.size() == 0)
3357 const unsigned int n_data_sets = data_names.size();
3359 UcdStream ucd_out(out, flags);
3362 unsigned int n_nodes;
3364 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
3370 <<
"# This file was generated by the deal.II library." <<
'\n'
3374 <<
"# For a description of the UCD format see the AVS Developer's guide."
3380 out << n_nodes <<
' ' <<
n_cells <<
' ' << n_data_sets <<
' ' << 0
3393 if (n_data_sets != 0)
3395 out << n_data_sets <<
" ";
3396 for (
unsigned int i = 0; i < n_data_sets; ++i)
3401 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3402 out << data_names[data_set]
3406 write_data(patches, n_data_sets,
true, ucd_out);
3416 template <
int dim,
int spacedim>
3420 const std::vector<std::string> & data_names,
3422 std::tuple<
unsigned int,
3434#ifndef DEAL_II_WITH_MPI
3443 if (patches.size() == 0)
3447 DXStream dx_out(out, flags);
3450 unsigned int offset = 0;
3452 const unsigned int n_data_sets = data_names.size();
3455 unsigned int n_nodes;
3457 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
3459 out <<
"object \"vertices\" class array type float rank 1 shape "
3460 << spacedim <<
" items " << n_nodes;
3464 out <<
" lsb ieee data 0" <<
'\n';
3465 offset += n_nodes * spacedim *
sizeof(float);
3469 out <<
" data follows" <<
'\n';
3478 out <<
"object \"cells\" class array type int rank 1 shape "
3483 out <<
" lsb binary data " << offset <<
'\n';
3488 out <<
" data follows" <<
'\n';
3494 out <<
"attribute \"element type\" string \"";
3501 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3508 out <<
"object \"neighbors\" class array type int rank 1 shape "
3512 for (
const auto &patch : patches)
3515 const unsigned int n1 = (dim > 0) ? n : 1;
3516 const unsigned int n2 = (dim > 1) ? n : 1;
3517 const unsigned int n3 = (dim > 2) ? n : 1;
3518 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3519 unsigned int dx = 1;
3520 unsigned int dy = n;
3521 unsigned int dz = n * n;
3523 const unsigned int patch_start =
3526 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3527 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3528 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3530 const unsigned int nx = i1 *
dx;
3531 const unsigned int ny = i2 * dy;
3532 const unsigned int nz = i3 * dz;
3544 const unsigned int nn = patch.
neighbors[0];
3548 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3554 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3559 const unsigned int nn = patch.
neighbors[1];
3562 out << (nn * cells_per_patch + ny + nz);
3568 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3575 const unsigned int nn = patch.
neighbors[2];
3579 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3585 out <<
'\t' << patch_start + nx + ny - dy + nz;
3590 const unsigned int nn = patch.
neighbors[3];
3593 out << (nn * cells_per_patch + nx + nz);
3599 out <<
'\t' << patch_start + nx + ny + dy + nz;
3607 const unsigned int nn = patch.
neighbors[4];
3611 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3617 out <<
'\t' << patch_start + nx + ny + nz - dz;
3622 const unsigned int nn = patch.
neighbors[5];
3625 out << (nn * cells_per_patch + nx + ny);
3631 out <<
'\t' << patch_start + nx + ny + nz + dz;
3639 if (n_data_sets != 0)
3641 out <<
"object \"data\" class array type float rank 1 shape "
3642 << n_data_sets <<
" items " << n_nodes;
3646 out <<
" lsb ieee data " << offset <<
'\n';
3647 offset += n_data_sets * n_nodes *
3648 ((flags.
data_double) ?
sizeof(
double) :
sizeof(float));
3652 out <<
" data follows" <<
'\n';
3657 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3661 out <<
"object \"data\" class constantarray type float rank 0 items "
3662 << n_nodes <<
" data follows" <<
'\n'
3668 out <<
"object \"deal data\" class field" <<
'\n'
3669 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3670 <<
"component \"connections\" value \"cells\"" <<
'\n'
3671 <<
"component \"data\" value \"data\"" <<
'\n';
3674 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3681 out <<
"end" <<
'\n';
3699 template <
int dim,
int spacedim>
3703 const std::vector<std::string> & data_names,
3705 std::tuple<
unsigned int,
3714#ifndef DEAL_II_WITH_MPI
3724 if (patches.size() == 0)
3728 const unsigned int n_data_sets = data_names.size();
3732 out <<
"# This file was generated by the deal.II library." <<
'\n'
3736 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3743 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3748 for (
const auto &data_name : data_names)
3749 out <<
'<' << data_name <<
"> ";
3755 for (
const auto &patch : patches)
3758 const unsigned int n_points_per_direction = n_subdivisions + 1;
3760 Assert((patch.
data.n_rows() == n_data_sets &&
3762 (patch.
data.n_rows() == n_data_sets + spacedim &&
3765 (n_data_sets + spacedim) :
3767 patch.
data.n_rows()));
3769 auto output_point_data =
3770 [&out, &patch, n_data_sets](
const unsigned int point_index)
mutable {
3771 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
3772 out << patch.data(data_set, point_index) <<
' ';
3781 Assert(patch.data.n_cols() == 1,
3783 n_subdivisions + 1));
3787 out << get_equispaced_location(patch, {}, n_subdivisions)
3789 output_point_data(0);
3799 Assert(patch.data.n_cols() ==
3800 Utilities::fixed_power<dim>(n_points_per_direction),
3802 n_subdivisions + 1));
3804 for (
unsigned int i1 = 0; i1 < n_points_per_direction; ++i1)
3807 out << get_equispaced_location(patch, {i1}, n_subdivisions)
3810 output_point_data(i1);
3823 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3824 n_points_per_direction),
3826 n_subdivisions + 1));
3828 for (
unsigned int i2 = 0; i2 < n_points_per_direction; ++i2)
3830 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3834 out << get_equispaced_location(patch,
3839 output_point_data(i1 + i2 * n_points_per_direction);
3864 out << get_node_location(patch, 0) <<
' ';
3865 output_point_data(0);
3868 out << get_node_location(patch, 1) <<
' ';
3869 output_point_data(1);
3873 out << get_node_location(patch, 2) <<
' ';
3874 output_point_data(2);
3877 out << get_node_location(patch, 2) <<
' ';
3878 output_point_data(2);
3898 Assert(patch.data.n_cols() == Utilities::fixed_power<dim>(
3899 n_points_per_direction),
3901 n_subdivisions + 1));
3906 for (
unsigned int i3 = 0; i3 < n_points_per_direction; ++i3)
3907 for (
unsigned int i2 = 0; i2 < n_points_per_direction;
3909 for (
unsigned int i1 = 0; i1 < n_points_per_direction;
3914 get_equispaced_location(patch,
3918 if (i1 < n_subdivisions)
3921 out << this_point <<
' ';
3922 output_point_data(i1 +
3923 i2 * n_points_per_direction +
3924 i3 * n_points_per_direction *
3925 n_points_per_direction);
3929 out << get_equispaced_location(patch,
3934 output_point_data((i1 + 1) +
3935 i2 * n_points_per_direction +
3936 i3 * n_points_per_direction *
3937 n_points_per_direction);
3941 out <<
'\n' <<
'\n';
3945 if (i2 < n_subdivisions)
3948 out << this_point <<
' ';
3949 output_point_data(i1 +
3950 i2 * n_points_per_direction +
3951 i3 * n_points_per_direction *
3952 n_points_per_direction);
3956 out << get_equispaced_location(patch,
3962 i1 + (i2 + 1) * n_points_per_direction +
3963 i3 * n_points_per_direction *
3964 n_points_per_direction);
3968 out <<
'\n' <<
'\n';
3972 if (i3 < n_subdivisions)
3975 out << this_point <<
' ';
3976 output_point_data(i1 +
3977 i2 * n_points_per_direction +
3978 i3 * n_points_per_direction *
3979 n_points_per_direction);
3983 out << get_equispaced_location(patch,
3989 i1 + i2 * n_points_per_direction +
3990 (i3 + 1) * n_points_per_direction *
3991 n_points_per_direction);
3994 out <<
'\n' <<
'\n';
4003 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
4005 out << get_node_location(patch, v) <<
' ';
4006 output_point_data(v);
4011 for (
const unsigned int v : {3, 1})
4013 out << get_node_location(patch, v) <<
' ';
4014 output_point_data(v);
4024 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
4026 out << get_node_location(patch, v) <<
' ';
4027 output_point_data(v);
4032 for (
const unsigned int v : {2, 4, 3})
4034 out << get_node_location(patch, v) <<
' ';
4035 output_point_data(v);
4049 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
4051 out << get_node_location(patch, v) <<
' ';
4052 output_point_data(v);
4057 for (
const unsigned int v : {1, 4})
4059 out << get_node_location(patch, v) <<
' ';
4060 output_point_data(v);
4065 for (
const unsigned int v : {2, 5})
4067 out << get_node_location(patch, v) <<
' ';
4068 output_point_data(v);
4093 template <
int dim,
int spacedim>
4095 do_write_povray(
const std::vector<Patch<dim, spacedim>> &,
4096 const std::vector<std::string> &,
4097 const PovrayFlags &,
4101 ExcMessage(
"Writing files in POVRAY format is only supported "
4102 "for two-dimensional meshes."));
4108 do_write_povray(
const std::vector<Patch<2, 2>> &patches,
4109 const std::vector<std::string> &data_names,
4110 const PovrayFlags & flags,
4115#ifndef DEAL_II_WITH_MPI
4124 if (patches.size() == 0)
4127 constexpr int dim = 2;
4129 constexpr int spacedim = 2;
4131 const unsigned int n_data_sets = data_names.size();
4137 <<
"/* This file was generated by the deal.II library." <<
'\n'
4141 <<
" For a description of the POVRAY format see the POVRAY manual."
4146 out <<
"#include \"colors.inc\" " <<
'\n'
4147 <<
"#include \"textures.inc\" " <<
'\n';
4151 if (flags.external_data)
4152 out <<
"#include \"data.inc\" " <<
'\n';
4158 <<
"camera {" <<
'\n'
4159 <<
" location <1,4,-7>" <<
'\n'
4160 <<
" look_at <0,0,0>" <<
'\n'
4161 <<
" angle 30" <<
'\n'
4166 <<
"light_source {" <<
'\n'
4167 <<
" <1,4,-7>" <<
'\n'
4168 <<
" color Grey" <<
'\n'
4171 <<
"light_source {" <<
'\n'
4172 <<
" <0,20,0>" <<
'\n'
4173 <<
" color White" <<
'\n'
4180 double hmin = patches[0].data(0, 0);
4181 double hmax = patches[0].data(0, 0);
4183 for (
const auto &patch : patches)
4187 Assert((patch.
data.n_rows() == n_data_sets &&
4189 (patch.
data.n_rows() == n_data_sets + spacedim &&
4192 (n_data_sets + spacedim) :
4194 patch.
data.n_rows()));
4196 Utilities::fixed_power<dim>(n_subdivisions + 1),
4198 n_subdivisions + 1));
4200 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4201 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4203 const int dl = i * (n_subdivisions + 1) + j;
4204 if (patch.
data(0, dl) < hmin)
4205 hmin = patch.
data(0, dl);
4206 if (patch.
data(0, dl) > hmax)
4207 hmax = patch.
data(0, dl);
4211 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
4212 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
4215 if (!flags.external_data)
4218 out <<
"#declare Tex=texture{" <<
'\n'
4219 <<
" pigment {" <<
'\n'
4220 <<
" gradient y" <<
'\n'
4221 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
4222 <<
" color_map {" <<
'\n'
4223 <<
" [0.00 color Light_Purple] " <<
'\n'
4224 <<
" [0.95 color Light_Purple] " <<
'\n'
4225 <<
" [1.00 color White] " <<
'\n'
4230 if (!flags.bicubic_patch)
4233 out <<
'\n' <<
"mesh {" <<
'\n';
4237 for (
const auto &patch : patches)
4240 const unsigned int n = n_subdivisions + 1;
4241 const unsigned int d1 = 1;
4242 const unsigned int d2 = n;
4244 Assert((patch.
data.n_rows() == n_data_sets &&
4246 (patch.
data.n_rows() == n_data_sets + spacedim &&
4249 (n_data_sets + spacedim) :
4251 patch.
data.n_rows()));
4252 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
4254 n_subdivisions + 1));
4257 std::vector<Point<spacedim>> ver(n * n);
4259 for (
unsigned int i2 = 0; i2 < n; ++i2)
4260 for (
unsigned int i1 = 0; i1 < n; ++i1)
4263 ver[i1 * d1 + i2 * d2] =
4264 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4268 if (!flags.bicubic_patch)
4271 std::vector<Point<3>> nrml;
4281 for (
unsigned int i = 0; i < n; ++i)
4282 for (
unsigned int j = 0; j < n; ++j)
4284 const unsigned int il = (i == 0) ? i : (i - 1);
4285 const unsigned int ir =
4286 (i == n_subdivisions) ? i : (i + 1);
4287 const unsigned int jl = (j == 0) ? j : (j - 1);
4288 const unsigned int jr =
4289 (j == n_subdivisions) ? j : (j + 1);
4292 ver[ir * d1 + j * d2](0) - ver[il * d1 + j * d2](0);
4293 h1(1) = patch.
data(0, ir * d1 + j * d2) -
4294 patch.
data(0, il * d1 + j * d2);
4296 ver[ir * d1 + j * d2](1) - ver[il * d1 + j * d2](1);
4299 ver[i * d1 + jr * d2](0) - ver[i * d1 + jl * d2](0);
4300 h2(1) = patch.
data(0, i * d1 + jr * d2) -
4301 patch.
data(0, i * d1 + jl * d2);
4303 ver[i * d1 + jr * d2](1) - ver[i * d1 + jl * d2](1);
4305 nrml[i * d1 + j * d2](0) =
4306 h1(1) * h2(2) - h1(2) * h2(1);
4307 nrml[i * d1 + j * d2](1) =
4308 h1(2) * h2(0) - h1(0) * h2(2);
4309 nrml[i * d1 + j * d2](2) =
4310 h1(0) * h2(1) - h1(1) * h2(0);
4315 std::pow(nrml[i * d1 + j * d2](1), 2.) +
4316 std::pow(nrml[i * d1 + j * d2](2), 2.));
4318 if (nrml[i * d1 + j * d2](1) < 0)
4321 for (
unsigned int k = 0; k < 3; ++k)
4322 nrml[i * d1 + j * d2](k) /=
norm;
4327 for (
unsigned int i = 0; i < n_subdivisions; ++i)
4328 for (
unsigned int j = 0; j < n_subdivisions; ++j)
4331 const int dl = i * d1 + j * d2;
4337 out <<
"smooth_triangle {" <<
'\n'
4338 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4339 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0)
4340 <<
", " << nrml[dl](1) <<
", " << nrml[dl](2)
4342 out <<
" \t<" << ver[dl + d1](0) <<
","
4343 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
4344 <<
">, <" << nrml[dl + d1](0) <<
", "
4345 << nrml[dl + d1](1) <<
", " << nrml[dl + d1](2)
4347 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4348 << patch.
data(0, dl + d1 + d2) <<
","
4349 << ver[dl + d1 + d2](1) <<
">, <"
4350 << nrml[dl + d1 + d2](0) <<
", "
4351 << nrml[dl + d1 + d2](1) <<
", "
4352 << nrml[dl + d1 + d2](2) <<
">}" <<
'\n';
4355 out <<
"smooth_triangle {" <<
'\n'
4356 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4357 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0)
4358 <<
", " << nrml[dl](1) <<
", " << nrml[dl](2)
4360 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4361 << patch.
data(0, dl + d1 + d2) <<
","
4362 << ver[dl + d1 + d2](1) <<
">, <"
4363 << nrml[dl + d1 + d2](0) <<
", "
4364 << nrml[dl + d1 + d2](1) <<
", "
4365 << nrml[dl + d1 + d2](2) <<
">," <<
'\n';
4366 out <<
"\t<" << ver[dl + d2](0) <<
","
4367 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
4368 <<
">, <" << nrml[dl + d2](0) <<
", "
4369 << nrml[dl + d2](1) <<
", " << nrml[dl + d2](2)
4375 out <<
"triangle {" <<
'\n'
4376 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4377 <<
"," << ver[dl](1) <<
">," <<
'\n';
4378 out <<
"\t<" << ver[dl + d1](0) <<
","
4379 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
4381 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4382 << patch.
data(0, dl + d1 + d2) <<
","
4383 << ver[dl + d1 + d2](1) <<
">}" <<
'\n';
4386 out <<
"triangle {" <<
'\n'
4387 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
4388 <<
"," << ver[dl](1) <<
">," <<
'\n';
4389 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
4390 << patch.
data(0, dl + d1 + d2) <<
","
4391 << ver[dl + d1 + d2](1) <<
">," <<
'\n';
4392 out <<
"\t<" << ver[dl + d2](0) <<
","
4393 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
4401 Assert(n_subdivisions == 3,
4404 <<
"bicubic_patch {" <<
'\n'
4405 <<
" type 0" <<
'\n'
4406 <<
" flatness 0" <<
'\n'
4407 <<
" u_steps 0" <<
'\n'
4408 <<
" v_steps 0" <<
'\n';
4409 for (
int i = 0; i < 16; ++i)
4411 out <<
"\t<" << ver[i](0) <<
"," << patch.
data(0, i) <<
","
4412 << ver[i](1) <<
">";
4417 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
4421 if (!flags.bicubic_patch)
4424 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
4436 template <
int dim,
int spacedim>
4440 const std::vector<std::string> & data_names,
4442 std::tuple<
unsigned int,
4449 do_write_povray(patches, data_names, flags, out);
4454 template <
int dim,
int spacedim>
4458 const std::vector<std::string> & ,
4460 std::tuple<
unsigned int,
4472 template <
int spacedim>
4476 const std::vector<std::string> & ,
4478 std::tuple<
unsigned int,
4487#ifndef DEAL_II_WITH_MPI
4496 if (patches.size() == 0)
4506 std::multiset<EpsCell2d> cells;
4515 double heights[4] = {0, 0, 0, 0};
4519 for (
const auto &patch : patches)
4522 const unsigned int n = n_subdivisions + 1;
4523 const unsigned int d1 = 1;
4524 const unsigned int d2 = n;
4526 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4527 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4531 get_equispaced_location(patch, {i1, i2}, n_subdivisions);
4533 get_equispaced_location(patch, {i1 + 1, i2}, n_subdivisions);
4535 get_equispaced_location(patch, {i1, i2 + 1}, n_subdivisions);
4536 points[3] = get_equispaced_location(patch,
4544 patch.
data.n_rows() == 0,
4547 patch.
data.n_rows()));
4549 patch.
data.n_rows() != 0 ?
4553 heights[1] = patch.
data.n_rows() != 0 ?
4555 (i1 + 1) * d1 + i2 * d2) *
4558 heights[2] = patch.
data.n_rows() != 0 ?
4560 i1 * d1 + (i2 + 1) * d2) *
4563 heights[3] = patch.
data.n_rows() != 0 ?
4565 (i1 + 1) * d1 + (i2 + 1) * d2) *
4572 for (
unsigned int i = 0; i < 4; ++i)
4573 heights[i] = points[i](2);
4598 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
4600 const double x = points[vertex](0), y = points[vertex](1),
4601 z = -heights[vertex];
4603 eps_cell.vertices[vertex](0) = -cz * x + sz * y;
4604 eps_cell.vertices[vertex](1) =
4605 -cx * sz * x - cx * cz * y - sx * z;
4629 (points[0] + points[1] + points[2] + points[3]) / 4;
4630 const double center_height =
4631 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
4634 eps_cell.depth = -sx * sz * center_point(0) -
4635 sx * cz * center_point(1) + cx * center_height;
4640 patch.
data.n_rows() == 0,
4643 patch.
data.n_rows()));
4644 const double color_values[4] = {
4645 patch.
data.n_rows() != 0 ?
4649 patch.
data.n_rows() != 0 ?
4653 patch.
data.n_rows() != 0 ?
4657 patch.
data.n_rows() != 0 ?
4659 (i1 + 1) * d1 + (i2 + 1) * d2) :
4663 eps_cell.color_value = (color_values[0] + color_values[1] +
4664 color_values[3] + color_values[2]) /
4669 std::min(min_color_value, eps_cell.color_value);
4671 std::max(max_color_value, eps_cell.color_value);
4675 cells.insert(eps_cell);
4681 double x_min = cells.begin()->vertices[0](0);
4682 double x_max = x_min;
4683 double y_min = cells.begin()->vertices[0](1);
4684 double y_max = y_min;
4686 for (
const auto &cell : cells)
4687 for (
const auto &vertex : cell.vertices)
4689 x_min =
std::min(x_min, vertex(0));
4690 x_max =
std::max(x_max, vertex(0));
4691 y_min =
std::min(y_min, vertex(1));
4692 y_max =
std::max(y_max, vertex(1));
4697 const double scale =
4701 const Point<2> offset(x_min, y_min);
4706 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4707 <<
"%%Title: deal.II Output" <<
'\n'
4708 <<
"%%Creator: the deal.II library" <<
'\n'
4711 <<
"%%BoundingBox: "
4715 <<
static_cast<unsigned int>((x_max - x_min) *
scale + 0.5) <<
' '
4716 <<
static_cast<unsigned int>((y_max - y_min) *
scale + 0.5) <<
'\n';
4725 out <<
"/m {moveto} bind def" <<
'\n'
4726 <<
"/l {lineto} bind def" <<
'\n'
4727 <<
"/s {setrgbcolor} bind def" <<
'\n'
4728 <<
"/sg {setgray} bind def" <<
'\n'
4729 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4730 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4732 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4734 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4742 if (max_color_value == min_color_value)
4743 max_color_value = min_color_value + 1;
4747 for (
const auto &cell : cells)
4760 out << rgb_values.
red <<
" sg ";
4762 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4763 << rgb_values.
blue <<
" s ";
4768 out << (cell.vertices[0] - offset) *
scale <<
" m "
4769 << (cell.vertices[1] - offset) *
scale <<
" l "
4770 << (cell.vertices[3] - offset) *
scale <<
" l "
4771 << (cell.vertices[2] - offset) *
scale <<
" lf" <<
'\n';
4776 << (cell.vertices[0] - offset) *
scale <<
" m "
4777 << (cell.vertices[1] - offset) *
scale <<
" l "
4778 << (cell.vertices[3] - offset) *
scale <<
" l "
4779 << (cell.vertices[2] - offset) *
scale <<
" lx" <<
'\n';
4781 out <<
"showpage" <<
'\n';
4790 template <
int dim,
int spacedim>
4794 const std::vector<std::string> & data_names,
4796 std::tuple<
unsigned int,
4812#ifndef DEAL_II_WITH_MPI
4821 if (patches.size() == 0)
4825 GmvStream gmv_out(out, flags);
4826 const unsigned int n_data_sets = data_names.size();
4829 Assert((patches[0].data.n_rows() == n_data_sets &&
4830 !patches[0].points_are_available) ||
4831 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4832 patches[0].points_are_available),
4834 (n_data_sets + spacedim) :
4836 patches[0].data.n_rows()));
4840 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4843 unsigned int n_nodes;
4845 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4860 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4862 &write_gmv_reorder_data_vectors<dim, spacedim>;
4870 out <<
"nodes " << n_nodes <<
'\n';
4871 for (
unsigned int d = 0;
d < spacedim; ++
d)
4873 gmv_out.selected_component =
d;
4879 for (
unsigned int d = spacedim;
d < 3; ++
d)
4881 for (
unsigned int i = 0; i < n_nodes; ++i)
4888 out <<
"cells " <<
n_cells <<
'\n';
4893 out <<
"variable" <<
'\n';
4897 reorder_task.
join();
4901 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4903 out << data_names[data_set] <<
" 1" <<
'\n';
4905 data_vectors[data_set].
end(),
4906 std::ostream_iterator<double>(out,
" "));
4907 out <<
'\n' <<
'\n';
4913 out <<
"endvars" <<
'\n';
4916 out <<
"endgmv" <<
'\n';
4927 template <
int dim,
int spacedim>
4931 const std::vector<std::string> & data_names,
4933 std::tuple<
unsigned int,
4947#ifndef DEAL_II_WITH_MPI
4956 if (patches.size() == 0)
4960 TecplotStream tecplot_out(out, flags);
4962 const unsigned int n_data_sets = data_names.size();
4965 Assert((patches[0].data.n_rows() == n_data_sets &&
4966 !patches[0].points_are_available) ||
4967 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4968 patches[0].points_are_available),
4970 (n_data_sets + spacedim) :
4972 patches[0].data.n_rows()));
4975 unsigned int n_nodes;
4977 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4983 <<
"# This file was generated by the deal.II library." <<
'\n'
4987 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4992 out <<
"Variables=";
5000 out <<
"\"x\", \"y\"";
5003 out <<
"\"x\", \"y\", \"z\"";
5009 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5010 out <<
", \"" << data_names[data_set] <<
"\"";
5016 out <<
"t=\"" << flags.
zone_name <<
"\" ";
5019 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
5021 out <<
"f=feblock, n=" << n_nodes <<
", e=" <<
n_cells
5022 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
5041 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5043 &write_gmv_reorder_data_vectors<dim, spacedim>;
5051 for (
unsigned int d = 0;
d < spacedim; ++
d)
5053 tecplot_out.selected_component =
d;
5064 reorder_task.
join();
5067 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5070 data_vectors[data_set].
end(),
5071 std::ostream_iterator<double>(out,
"\n"));
5089#ifdef DEAL_II_HAVE_TECPLOT
5096 TecplotMacros(
const unsigned int n_nodes = 0,
5097 const unsigned int n_vars = 0,
5098 const unsigned int n_cells = 0,
5099 const unsigned int n_vert = 0);
5102 nd(
const unsigned int i,
const unsigned int j);
5104 cd(
const unsigned int i,
const unsigned int j);
5105 std::vector<float> nodalData;
5106 std::vector<int> connData;
5109 unsigned int n_nodes;
5110 unsigned int n_vars;
5112 unsigned int n_vert;
5116 inline TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
5117 const unsigned int n_vars,
5119 const unsigned int n_vert)
5125 nodalData.resize(n_nodes * n_vars);
5126 connData.resize(
n_cells * n_vert);
5131 inline TecplotMacros::~TecplotMacros()
5137 TecplotMacros::nd(
const unsigned int i,
const unsigned int j)
5139 return nodalData[i * n_nodes + j];
5145 TecplotMacros::cd(
const unsigned int i,
const unsigned int j)
5147 return connData[i + j * n_vert];
5158 template <
int dim,
int spacedim>
5162 const std::vector<std::string> & data_names,
5164 std::tuple<
unsigned int,
5168 & nonscalar_data_ranges,
5177#ifndef DEAL_II_HAVE_TECPLOT
5180 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
5188 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
5195 char *file_name = (
char *)flags.tecplot_binary_file_name;
5197 if (file_name ==
nullptr)
5202 ExcMessage(
"Specify the name of the tecplot_binary"
5203 " file through the TecplotFlags interface."));
5204 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
5211# ifndef DEAL_II_WITH_MPI
5220 if (patches.size() == 0)
5224 const unsigned int n_data_sets = data_names.size();
5227 Assert((patches[0].data.n_rows() == n_data_sets &&
5228 !patches[0].points_are_available) ||
5229 (patches[0].data.n_rows() == n_data_sets + spacedim &&
5230 patches[0].points_are_available),
5232 (n_data_sets + spacedim) :
5234 patches[0].data.n_rows()));
5237 unsigned int n_nodes;
5239 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
5241 const unsigned int vars_per_node = (spacedim + n_data_sets),
5244 TecplotMacros tm(n_nodes, vars_per_node,
n_cells, nodes_per_cell);
5246 int is_double = 0, tec_debug = 0, cell_type = tecplot_binary_cell_type[dim];
5248 std::string tec_var_names;
5252 tec_var_names =
"x y";
5255 tec_var_names =
"x y z";
5261 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5263 tec_var_names +=
" ";
5264 tec_var_names += data_names[data_set];
5280 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5282 &write_gmv_reorder_data_vectors<dim, spacedim>;
5288 for (
unsigned int d = 1;
d <= spacedim; ++
d)
5290 unsigned int entry = 0;
5292 for (
const auto &patch : patches)
5300 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
5301 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
5303 const double x_frac = i * 1. / n_subdivisions,
5304 y_frac = j * 1. / n_subdivisions;
5306 tm.nd((
d - 1), entry) =
static_cast<float>(
5308 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
5311 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
5320 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
5321 for (
unsigned int k = 0; k < n_subdivisions + 1; ++k)
5322 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
5324 const double x_frac = i * 1. / n_subdivisions,
5325 y_frac = k * 1. / n_subdivisions,
5326 z_frac = j * 1. / n_subdivisions;
5329 tm.nd((
d - 1), entry) =
static_cast<float>(
5330 ((((patch.
vertices[1](
d - 1) * x_frac) +
5331 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
5334 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
5338 (patch.
vertices[4](
d - 1) * (1 - x_frac))) *
5341 (patch.
vertices[6](
d - 1) * (1 - x_frac))) *
5359 reorder_task.
join();
5362 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5363 for (
unsigned int entry = 0; entry < data_vectors[data_set].size();
5365 tm.nd((spacedim + data_set), entry) =
5366 static_cast<float>(data_vectors[data_set][entry]);
5372 unsigned int first_vertex_of_patch = 0;
5373 unsigned int elem = 0;
5375 for (
const auto &patch : patches)
5378 const unsigned int n = n_subdivisions + 1;
5379 const unsigned int d1 = 1;
5380 const unsigned int d2 = n;
5381 const unsigned int d3 = n * n;
5387 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5388 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5391 first_vertex_of_patch + (i1)*d1 + (i2)*d2 + 1;
5393 first_vertex_of_patch + (i1 + 1) * d1 + (i2)*d2 + 1;
5394 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5397 first_vertex_of_patch + (i1)*d1 + (i2 + 1) * d2 + 1;
5406 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
5407 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5408 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5413 tm.cd(0, elem) = first_vertex_of_patch + (i1)*d1 +
5414 (i2)*d2 + (i3)*d3 + 1;
5415 tm.cd(1, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5416 (i2)*d2 + (i3)*d3 + 1;
5417 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5418 (i2 + 1) * d2 + (i3)*d3 + 1;
5419 tm.cd(3, elem) = first_vertex_of_patch + (i1)*d1 +
5420 (i2 + 1) * d2 + (i3)*d3 + 1;
5421 tm.cd(4, elem) = first_vertex_of_patch + (i1)*d1 +
5422 (i2)*d2 + (i3 + 1) * d3 + 1;
5423 tm.cd(5, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5424 (i2)*d2 + (i3 + 1) * d3 + 1;
5425 tm.cd(6, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
5426 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
5427 tm.cd(7, elem) = first_vertex_of_patch + (i1)*d1 +
5428 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
5441 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
5446 int ierr = 0, num_nodes =
static_cast<int>(n_nodes),
5447 num_cells =
static_cast<int>(
n_cells);
5449 char dot[2] = {
'.', 0};
5453 char *var_names =
const_cast<char *
>(tec_var_names.c_str());
5454 ierr = TECINI(
nullptr, var_names, file_name, dot, &tec_debug, &is_double);
5458 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K', 0};
5460 TECZNE(
nullptr, &num_nodes, &num_cells, &cell_type, FEBLOCK,
nullptr);
5464 int total = (vars_per_node * num_nodes);
5466 ierr = TECDAT(&total, tm.nodalData.data(), &is_double);
5470 ierr = TECNOD(tm.connData.data());
5483 template <
int dim,
int spacedim>
5487 const std::vector<std::string> & data_names,
5489 std::tuple<
unsigned int,
5493 & nonscalar_data_ranges,
5499#ifndef DEAL_II_WITH_MPI
5508 if (patches.size() == 0)
5512 VtkStream vtk_out(out, flags);
5514 const unsigned int n_data_sets = data_names.size();
5516 if (patches[0].points_are_available)
5528 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5529 <<
"#This file was generated by the deal.II library";
5537 out <<
'\n' <<
"ASCII" <<
'\n';
5539 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
5546 const unsigned int n_metadata =
5551 out <<
"FIELD FieldData " << n_metadata <<
'\n';
5555 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
'\n';
5559 out <<
"TIME 1 1 double\n" << flags.
time <<
'\n';
5565 unsigned int n_nodes,
n_cells, n_points_and_n_cells;
5566 compute_sizes(patches,
5570 n_points_and_n_cells);
5586 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5588 &write_gmv_reorder_data_vectors<dim, spacedim>;
5596 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5601 out <<
"CELLS " <<
n_cells <<
' ' << n_points_and_n_cells <<
'\n';
5609 out <<
"CELL_TYPES " <<
n_cells <<
'\n';
5613 for (
const auto &patch : patches)
5615 const auto vtk_cell_id =
5618 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
5619 out <<
' ' << vtk_cell_id[0];
5628 reorder_task.
join();
5633 out <<
"POINT_DATA " << n_nodes <<
'\n';
5637 std::vector<bool> data_set_written(n_data_sets,
false);
5638 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5645 std::get<0>(nonscalar_data_range),
5647 std::get<0>(nonscalar_data_range)));
5648 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
5652 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
5653 std::get<0>(nonscalar_data_range) <=
5656 "Can't declare a vector with more than 3 components "
5660 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5661 i <= std::get<1>(nonscalar_data_range);
5663 data_set_written[i] =
true;
5669 if (!std::get<2>(nonscalar_data_range).empty())
5670 out << std::get<2>(nonscalar_data_range);
5673 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5674 i < std::get<1>(nonscalar_data_range);
5676 out << data_names[i] <<
"__";
5677 out << data_names[std::get<1>(nonscalar_data_range)];
5680 out <<
" double" <<
'\n';
5683 for (
unsigned int n = 0; n < n_nodes; ++n)
5685 switch (std::get<1>(nonscalar_data_range) -
5686 std::get<0>(nonscalar_data_range))
5689 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5694 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5696 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5700 out << data_vectors(std::get<0>(nonscalar_data_range), n)
5702 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
5704 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
5717 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5718 if (data_set_written[data_set] ==
false)
5720 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5721 <<
"LOOKUP_TABLE default" <<
'\n';
5723 data_vectors[data_set].
end(),
5724 std::ostream_iterator<double>(out,
" "));
5740 out <<
"<?xml version=\"1.0\" ?> \n";
5742 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5743 <<
"#This file was generated by the deal.II library";
5752 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5753#ifdef DEAL_II_WITH_ZLIB
5754 out <<
" compressor=\"vtkZLibDataCompressor\"";
5756#ifdef DEAL_II_WORDS_BIGENDIAN
5757 out <<
" byte_order=\"BigEndian\"";
5759 out <<
" byte_order=\"LittleEndian\"";
5763 out <<
"<UnstructuredGrid>";
5773 out <<
" </UnstructuredGrid>\n";
5774 out <<
"</VTKFile>\n";
5779 template <
int dim,
int spacedim>
5783 const std::vector<std::string> & data_names,
5785 std::tuple<
unsigned int,
5789 & nonscalar_data_ranges,
5794 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5801 template <
int dim,
int spacedim>
5805 const std::vector<std::string> & data_names,
5807 std::tuple<
unsigned int,
5811 & nonscalar_data_ranges,
5825 unit.second.find(
'\"') == std::string::npos,
5827 "A physical unit you provided, <" + unit.second +
5828 ">, contained a quotation mark character. This is not allowed."));
5831#ifndef DEAL_II_WITH_MPI
5840 if (patches.size() == 0)
5845 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5847 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5849 <<
" <PointData Scalars=\"scalars\">\n";
5850 std::vector<bool> data_set_written(data_names.size(),
false);
5851 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5854 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5855 i <= std::get<1>(nonscalar_data_range);
5857 data_set_written[i] =
true;
5861 out <<
" <DataArray type=\"Float32\" Name=\"";
5863 if (!std::get<2>(nonscalar_data_range).empty())
5864 out << std::get<2>(nonscalar_data_range);
5867 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5868 i < std::get<1>(nonscalar_data_range);
5870 out << data_names[i] <<
"__";
5871 out << data_names[std::get<1>(nonscalar_data_range)];
5874 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5877 for (
unsigned int data_set = 0; data_set < data_names.size();
5879 if (data_set_written[data_set] ==
false)
5881 out <<
" <DataArray type=\"Float32\" Name=\""
5882 << data_names[data_set] <<
"\"></DataArray>\n";
5885 out <<
" </PointData>\n";
5886 out <<
"</Piece>\n";
5900 const unsigned int n_metadata =
5904 out <<
"<FieldData>\n";
5909 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5910 << flags.
cycle <<
"</DataArray>\n";
5915 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5916 << flags.
time <<
"</DataArray>\n";
5920 out <<
"</FieldData>\n";
5924 VtuStream vtu_out(out, flags);
5926 const unsigned int n_data_sets = data_names.size();
5929 if (patches[0].points_are_available)
5938#ifdef DEAL_II_WITH_ZLIB
5939 const char *ascii_or_binary =
"binary";
5941 const char * ascii_or_binary =
"ascii";
5946 unsigned int n_nodes,
n_cells, n_points_and_n_cells;
5947 compute_sizes(patches,
5951 n_points_and_n_cells);
5967 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5969 &write_gmv_reorder_data_vectors<dim, spacedim, float>;
5978 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
5980 out <<
" <Points>\n";
5981 out <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5982 << ascii_or_binary <<
"\">\n";
5984 out <<
" </DataArray>\n";
5985 out <<
" </Points>\n\n";
5988 out <<
" <Cells>\n";
5989 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5990 << ascii_or_binary <<
"\">\n";
5995 out <<
" </DataArray>\n";
5999 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
6000 << ascii_or_binary <<
"\">\n";
6002 std::vector<int32_t> offsets;
6007#ifdef DEAL_II_WITH_ZLIB
6008 std::vector<std::uint8_t> cell_types;
6010 std::vector<unsigned int> cell_types;
6014 unsigned int first_vertex_of_patch = 0;
6016 for (
const auto &patch : patches)
6018 const auto vtk_cell_id =
6021 for (
unsigned int i = 0; i < vtk_cell_id[1]; ++i)
6023 cell_types.push_back(vtk_cell_id[0]);
6024 first_vertex_of_patch += vtk_cell_id[2];
6025 offsets.push_back(first_vertex_of_patch);
6031 out <<
" </DataArray>\n";
6035 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
6036 << ascii_or_binary <<
"\">\n";
6039 vtu_out << cell_types;
6041 out <<
" </DataArray>\n";
6042 out <<
" </Cells>\n";
6050 reorder_task.
join();
6055 out <<
" <PointData Scalars=\"scalars\">\n";
6059 std::vector<bool> data_set_written(n_data_sets,
false);
6060 for (
const auto &range : nonscalar_data_ranges)
6062 const auto first_component = std::get<0>(range);
6063 const auto last_component = std::get<1>(range);
6064 const auto &name = std::get<2>(range);
6065 const bool is_tensor =
6066 (std::get<3>(range) ==
6068 const unsigned int n_components = (is_tensor ? 9 : 3);
6075 AssertThrow((last_component + 1 - first_component <= 9),
6077 "Can't declare a tensor with more than 9 components "
6078 "in VTK/VTU format."));
6082 AssertThrow((last_component + 1 - first_component <= 3),
6084 "Can't declare a vector with more than 3 components "
6085 "in VTK/VTU format."));
6089 for (
unsigned int i = first_component; i <= last_component; ++i)
6090 data_set_written[i] =
true;