56 #ifdef DEAL_II_WITH_ZLIB
60 #ifdef DEAL_II_WITH_HDF5
74 <<
"Unexpected input: expected line\n <" << arg1
75 <<
">\nbut got\n <" << arg2 <<
">");
81 #ifdef DEAL_II_WITH_ZLIB
87 get_zlib_compression_level(
93 return Z_NO_COMPRESSION;
97 return Z_BEST_COMPRESSION;
99 return Z_DEFAULT_COMPRESSION;
102 return Z_NO_COMPRESSION;
110 template <
typename T>
112 write_compressed_block(
const std::vector<T> & data,
114 std::ostream & output_stream)
116 if (data.size() != 0)
119 auto compressed_data_length = compressBound(data.size() *
sizeof(
T));
120 std::vector<unsigned char> compressed_data(compressed_data_length);
123 compress2(&compressed_data[0],
124 &compressed_data_length,
125 reinterpret_cast<const Bytef *
>(data.data()),
126 data.size() *
sizeof(
T),
132 compressed_data.resize(compressed_data_length);
135 const uint32_t compression_header[4] = {
137 static_cast<uint32_t
>(data.size() *
sizeof(
T)),
138 static_cast<uint32_t
>(data.size() *
140 static_cast<uint32_t
>(
141 compressed_data_length)};
143 const auto header_start =
144 reinterpret_cast<const unsigned char *
>(&compression_header[0]);
147 {header_start, header_start + 4 *
sizeof(uint32_t)})
257 template <
int dim,
int spacedim,
typename Number =
double>
259 write_gmv_reorder_data_vectors(
260 const std::vector<Patch<dim, spacedim>> &patches,
264 if (patches.size() == 0)
274 const unsigned int n_data_sets = patches[0].points_are_available ?
275 (patches[0].data.n_rows() - spacedim) :
276 patches[0].data.n_rows();
281 unsigned int next_value = 0;
282 for (
const auto &patch : patches)
284 const unsigned int n_subdivisions = patch.n_subdivisions;
285 (void)n_subdivisions;
287 Assert((patch.data.n_rows() == n_data_sets &&
288 !patch.points_are_available) ||
289 (patch.data.n_rows() == n_data_sets + spacedim &&
290 patch.points_are_available),
292 (n_data_sets + spacedim) :
294 patch.data.n_rows()));
295 Assert((n_data_sets == 0) ||
296 (patch.data.n_cols() ==
297 Utilities::fixed_power<dim>(n_subdivisions + 1)),
299 n_subdivisions + 1));
301 for (
unsigned int i = 0; i < patch.data.n_cols(); ++i, ++next_value)
302 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
303 data_vectors[data_set][next_value] = patch.data(data_set, i);
306 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
336 for (
unsigned int d = 0;
d < dim; ++
d)
340 unsigned int internal_ind;
351 internal_ind = it->second;
361 const unsigned int pt_index)
376 node_data[
node_dim * existing_point.second +
d] =
377 existing_point.first(
d);
385 std::vector<unsigned int> &cell_data)
const
391 cell_data[filtered_cell.first] =
392 filtered_cell.second + local_node_offset;
461 const unsigned int start,
462 const unsigned int d1,
463 const unsigned int d2,
464 const unsigned int d3)
466 const unsigned int base_entry =
492 const unsigned int dimension,
493 const unsigned int set_num,
496 unsigned int new_dim;
515 for (
unsigned int d = 0;
d < new_dim; ++
d)
518 data_sets.back()[r * new_dim +
d] = data_vectors(set_num +
d, i);
534 const char *gmv_cell_type[4] = {
"",
"line 2",
"quad 4",
"hex 8"};
536 const char *ucd_cell_type[4] = {
"pt",
"line",
"quad",
"hex"};
538 const char *tecplot_cell_type[4] = {
"",
"lineseg",
"quadrilateral",
"brick"};
540 #ifdef DEAL_II_HAVE_TECPLOT
541 const unsigned int tecplot_binary_cell_type[4] = {0, 0, 1, 3};
548 const unsigned int vtk_cell_type[5] = {1,
552 static_cast<unsigned int>(-1)};
556 const unsigned int vtk_lagrange_cell_type[5] = {
561 static_cast<unsigned int>(-1)};
569 template <
int dim,
int spacedim>
572 const unsigned int xstep,
573 const unsigned int ystep,
574 const unsigned int zstep,
575 const unsigned int n_subdivisions)
580 unsigned int point_no = 0;
585 point_no += (n_subdivisions + 1) * (n_subdivisions + 1) * zstep;
589 point_no += (n_subdivisions + 1) * ystep;
602 for (
unsigned int d = 0;
d < spacedim; ++
d)
603 node[
d] = patch.
data(patch.
data.
size(0) - spacedim +
d, point_no);
612 const double stepsize = 1. / n_subdivisions,
613 xfrac = xstep * stepsize;
619 const double yfrac = ystep * stepsize;
621 node += ((patch.
vertices[3] * xfrac) +
622 (patch.
vertices[2] * (1 - xfrac))) *
626 const double zfrac = zstep * stepsize;
628 node += (((patch.
vertices[5] * xfrac) +
629 (patch.
vertices[4] * (1 - xfrac))) *
632 (patch.
vertices[6] * (1 - xfrac))) *
650 vtk_point_index_from_ijk(
const unsigned i,
653 const std::array<unsigned, 2> &order)
655 const bool ibdy = (i == 0 || i == order[0]);
656 const bool jbdy = (j == 0 || j == order[1]);
658 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0);
662 return (i ? (j ? 2 : 1) : (j ? 3 : 0));
670 return (i - 1) + (j ? order[0] - 1 + order[1] - 1 : 0) + offset;
676 (i ? order[0] - 1 : 2 * (order[0] - 1) + order[1] - 1) +
681 offset += 2 * (order[0] - 1 + order[1] - 1);
683 return offset + (i - 1) + (order[0] - 1) * ((j - 1));
694 vtk_point_index_from_ijk(
const unsigned i,
697 const std::array<unsigned, 3> &order)
699 const bool ibdy = (i == 0 || i == order[0]);
700 const bool jbdy = (j == 0 || j == order[1]);
701 const bool kbdy = (k == 0 || k == order[2]);
703 const int nbdy = (ibdy ? 1 : 0) + (jbdy ? 1 : 0) + (kbdy ? 1 : 0);
707 return (i ? (j ? 2 : 1) : (j ? 3 : 0)) + (k ? 4 : 0);
715 return (i - 1) + (j ? order[0] - 1 + order[1] - 1 : 0) +
716 (k ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
721 (i ? order[0] - 1 : 2 * (order[0] - 1) + order[1] - 1) +
722 (k ? 2 * (order[0] - 1 + order[1] - 1) : 0) + offset;
725 offset += 4 * (order[0] - 1) + 4 * (order[1] - 1);
726 return (k - 1) + (order[2] - 1) * (i ? (j ? 3 : 1) : (j ? 2 : 0)) +
730 offset += 4 * (order[0] - 1 + order[1] - 1 + order[2] - 1);
735 return (j - 1) + ((order[1] - 1) * (k - 1)) +
736 (i ? (order[1] - 1) * (order[2] - 1) : 0) + offset;
738 offset += 2 * (order[1] - 1) * (order[2] - 1);
741 return (i - 1) + ((order[0] - 1) * (k - 1)) +
742 (j ? (order[2] - 1) * (order[0] - 1) : 0) + offset;
744 offset += 2 * (order[2] - 1) * (order[0] - 1);
746 return (i - 1) + ((order[0] - 1) * (j - 1)) +
747 (k ? (order[0] - 1) * (order[1] - 1) : 0) + offset;
752 2 * ((order[1] - 1) * (order[2] - 1) + (order[2] - 1) * (order[0] - 1) +
753 (order[0] - 1) * (order[1] - 1));
754 return offset + (i - 1) +
755 (order[0] - 1) * ((j - 1) + (order[1] - 1) * ((k - 1)));
759 vtk_point_index_from_ijk(
const unsigned,
762 const std::array<unsigned, 0> &)
769 vtk_point_index_from_ijk(
const unsigned,
772 const std::array<unsigned, 1> &)
779 template <
int dim,
int spacedim>
782 unsigned int & n_nodes,
787 for (
const auto &patch : patches)
799 template <
typename FlagsType>
806 StreamBase(std::ostream &stream,
const FlagsType &flags)
818 write_point(
const unsigned int,
const Point<dim> &)
821 ExcMessage(
"The derived class you are using needs to "
822 "reimplement this function if you want to call "
842 write_cell(
const unsigned int ,
849 ExcMessage(
"The derived class you are using needs to "
850 "reimplement this function if you want to call "
868 template <
typename T>
882 unsigned int selected_component;
889 std::ostream &stream;
894 const FlagsType flags;
900 class DXStream :
public StreamBase<DataOutBase::DXFlags>
907 write_point(
const unsigned int index,
const Point<dim> &);
919 write_cell(
const unsigned int index,
920 const unsigned int start,
921 const unsigned int x_offset,
922 const unsigned int y_offset,
923 const unsigned int z_offset);
931 template <
typename data>
933 write_dataset(
const unsigned int index,
const std::vector<data> &values);
939 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
946 write_point(
const unsigned int index,
const Point<dim> &);
958 write_cell(
const unsigned int index,
959 const unsigned int start,
960 const unsigned int x_offset,
961 const unsigned int y_offset,
962 const unsigned int z_offset);
968 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
975 write_point(
const unsigned int index,
const Point<dim> &);
987 write_cell(
const unsigned int index,
988 const unsigned int start,
989 const unsigned int x_offset,
990 const unsigned int y_offset,
991 const unsigned int z_offset);
997 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1004 write_point(
const unsigned int index,
const Point<dim> &);
1018 write_cell(
const unsigned int index,
1019 const unsigned int start,
1020 const unsigned int x_offset,
1021 const unsigned int y_offset,
1022 const unsigned int z_offset);
1030 template <
typename data>
1032 write_dataset(
const unsigned int index,
const std::vector<data> &values);
1038 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1045 write_point(
const unsigned int index,
const Point<dim> &);
1057 write_cell(
const unsigned int index,
1058 const unsigned int start,
1059 const unsigned int x_offset,
1060 const unsigned int y_offset,
1061 const unsigned int z_offset);
1072 write_high_order_cell(
const unsigned int index,
1073 const unsigned int start,
1074 const std::vector<unsigned> &connectivity);
1078 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
1085 write_point(
const unsigned int index,
const Point<dim> &);
1100 write_cell(
const unsigned int index,
1101 const unsigned int start,
1102 const unsigned int x_offset,
1103 const unsigned int y_offset,
1104 const unsigned int z_offset);
1115 write_high_order_cell(
const unsigned int index,
1116 const unsigned int start,
1117 const std::vector<unsigned> &connectivity);
1122 template <
typename T>
1133 template <
typename T>
1147 std::vector<int32_t> cells;
1160 DXStream::write_point(
const unsigned int,
const Point<dim> &p)
1162 if (flags.coordinates_binary)
1165 for (
unsigned int d = 0;
d < dim; ++
d)
1167 stream.write(
reinterpret_cast<const char *
>(data), dim *
sizeof(*data));
1171 for (
unsigned int d = 0;
d < dim; ++
d)
1172 stream << p(
d) <<
'\t';
1181 DXStream::write_cell(
unsigned int,
1187 int nodes[1 << dim];
1208 if (flags.int_binary)
1209 stream.write(
reinterpret_cast<const char *
>(nodes),
1210 (1 << dim) *
sizeof(*nodes));
1213 const unsigned int final = (1 << dim) - 1;
1214 for (
unsigned int i = 0; i <
final; ++i)
1215 stream << nodes[i] <<
'\t';
1216 stream << nodes[
final] <<
'\n';
1222 template <
typename data>
1224 DXStream::write_dataset(
const unsigned int,
const std::vector<data> &values)
1226 if (flags.data_binary)
1228 stream.write(
reinterpret_cast<const char *
>(values.data()),
1229 values.size() *
sizeof(data));
1233 for (
unsigned int i = 0; i < values.size(); ++i)
1234 stream <<
'\t' << values[i];
1250 GmvStream::write_point(
const unsigned int,
const Point<dim> &p)
1254 stream << p(selected_component) <<
' ';
1261 GmvStream::write_cell(
unsigned int,
1268 const unsigned int start = s + 1;
1269 stream << gmv_cell_type[dim] <<
'\n';
1274 stream <<
'\t' << start + d1;
1277 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1280 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1281 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1290 TecplotStream::TecplotStream(std::ostream & out,
1298 TecplotStream::write_point(
const unsigned int,
const Point<dim> &p)
1302 stream << p(selected_component) <<
'\n';
1309 TecplotStream::write_cell(
unsigned int,
1315 const unsigned int start = s + 1;
1320 stream <<
'\t' << start + d1;
1323 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1326 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1327 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1343 UcdStream::write_point(
const unsigned int index,
const Point<dim> &p)
1345 stream << index + 1 <<
" ";
1347 for (
unsigned int i = 0; i < dim; ++i)
1348 stream << p(i) <<
' ';
1350 for (
unsigned int i = dim; i < 3; ++i)
1359 UcdStream::write_cell(
unsigned int index,
1365 int nodes[1 << dim];
1387 stream << index + 1 <<
"\t0 " << ucd_cell_type[dim];
1388 const unsigned int final = (1 << dim);
1389 for (
unsigned int i = 0; i <
final; ++i)
1390 stream <<
'\t' << nodes[i] + 1;
1396 template <
typename data>
1398 UcdStream::write_dataset(
const unsigned int index,
1399 const std::vector<data> &values)
1401 stream << index + 1;
1402 for (
unsigned int i = 0; i < values.size(); ++i)
1403 stream <<
'\t' << values[i];
1418 VtkStream::write_point(
const unsigned int,
const Point<dim> &p)
1423 for (
unsigned int i = dim; i < 3; ++i)
1432 VtkStream::write_cell(
unsigned int,
1438 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' << start;
1440 stream <<
'\t' << start + d1;
1444 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1447 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1448 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1457 VtkStream::write_high_order_cell(
const unsigned int,
1458 const unsigned int start,
1459 const std::vector<unsigned> &connectivity)
1461 stream << connectivity.size();
1462 for (
const auto &c : connectivity)
1463 stream <<
'\t' << start + c;
1474 VtuStream::write_point(
const unsigned int,
const Point<dim> &p)
1476 #if !defined(DEAL_II_WITH_ZLIB)
1480 for (
unsigned int i = dim; i < 3; ++i)
1485 for (
unsigned int i = 0; i < dim; ++i)
1487 for (
unsigned int i = dim; i < 3; ++i)
1494 VtuStream::flush_points()
1496 #ifdef DEAL_II_WITH_ZLIB
1507 VtuStream::write_cell(
unsigned int,
1513 #if !defined(DEAL_II_WITH_ZLIB)
1517 stream <<
'\t' << start + d1;
1520 stream <<
'\t' << start + d2 + d1 <<
'\t' << start + d2;
1523 stream <<
'\t' << start + d3 <<
'\t' << start + d3 + d1 <<
'\t'
1524 << start + d3 + d2 + d1 <<
'\t' << start + d3 + d2;
1530 cells.push_back(start);
1533 cells.push_back(start + d1);
1536 cells.push_back(start + d2 + d1);
1537 cells.push_back(start + d2);
1540 cells.push_back(start + d3);
1541 cells.push_back(start + d3 + d1);
1542 cells.push_back(start + d3 + d2 + d1);
1543 cells.push_back(start + d3 + d2);
1552 VtuStream::write_high_order_cell(
const unsigned int,
1553 const unsigned int start,
1554 const std::vector<unsigned> &connectivity)
1556 #if !defined(DEAL_II_WITH_ZLIB)
1557 for (
const auto &c : connectivity)
1558 stream <<
'\t' << start + c;
1561 for (
const auto &c : connectivity)
1562 cells.push_back(start + c);
1567 VtuStream::flush_cells()
1569 #ifdef DEAL_II_WITH_ZLIB
1572 *
this << cells <<
'\n';
1578 template <
typename T>
1582 #ifdef DEAL_II_WITH_ZLIB
1585 write_compressed_block(data, flags, stream);
1587 for (
unsigned int i = 0; i < data.size(); ++i)
1588 stream << data[i] <<
' ';
1602 template <
int dim,
int spacedim>
1606 template <
int dim,
int spacedim>
1610 template <
int dim,
int spacedim>
1612 : patch_index(no_neighbor)
1614 , points_are_available(false)
1619 neighbors[i] = no_neighbor;
1627 template <
int dim,
int spacedim>
1650 if (data.n_rows() != patch.
data.n_rows())
1653 if (data.n_cols() != patch.
data.n_cols())
1656 for (
unsigned int i = 0; i < data.n_rows(); ++i)
1657 for (
unsigned int j = 0; j < data.n_cols(); ++j)
1658 if (data[i][j] != patch.
data[i][j])
1666 template <
int dim,
int spacedim>
1672 sizeof(neighbors) /
sizeof(neighbors[0]) *
1682 template <
int dim,
int spacedim>
1690 data.swap(other_patch.
data);
1696 template <
int spacedim>
1700 template <
int spacedim>
1704 template <
int spacedim>
1708 template <
int spacedim>
1709 unsigned int Patch<0, spacedim>::n_subdivisions = 1;
1711 template <
int spacedim>
1713 : patch_index(no_neighbor)
1714 , points_are_available(false)
1721 template <
int spacedim>
1725 const unsigned int dim = 0;
1739 if (
data.n_rows() != patch.
data.n_rows())
1742 if (
data.n_cols() != patch.
data.n_cols())
1745 for (
unsigned int i = 0; i <
data.n_rows(); ++i)
1746 for (
unsigned int j = 0; j <
data.n_cols(); ++j)
1747 if (
data[i][j] != patch.
data[i][j])
1755 template <
int spacedim>
1767 template <
int spacedim>
1779 : write_preamble(write_preamble)
1794 : space_dimension_labels(labels)
1808 const bool bicubic_patch,
1809 const bool external_data)
1811 , bicubic_patch(bicubic_patch)
1812 , external_data(external_data)
1817 const bool xdmf_hdf5_output)
1818 : filter_duplicate_vertices(filter_duplicate_vertices)
1819 , xdmf_hdf5_output(xdmf_hdf5_output)
1827 "Filter duplicate vertices",
1830 "Whether to remove duplicate vertex values. deal.II duplicates "
1831 "vertices once for each adjacent cell so that it can output "
1832 "discontinuous quantities for which there may be more than one "
1833 "value for each vertex position. Setting this flag to "
1834 "'true' will merge all of these values by selecting a "
1835 "random one and outputting this as 'the' value for the vertex. "
1836 "As long as the data to be output corresponds to continuous "
1837 "fields, merging vertices has no effect. On the other hand, "
1838 "if the data to be output corresponds to discontinuous fields "
1839 "(either because you are using a discontinuous finite element, "
1840 "or because you are using a DataPostprocessor that yields "
1841 "discontinuous data, or because the data to be output has been "
1842 "produced by entirely different means), then the data in the "
1843 "output file no longer faithfully represents the underlying data "
1844 "because the discontinuous field has been replaced by a "
1845 "continuous one. Note also that the filtering can not occur "
1846 "on processor boundaries. Thus, a filtered discontinuous field "
1847 "looks like a continuous field inside of a subdomain, "
1848 "but like a discontinuous field at the subdomain boundary."
1850 "In any case, filtering results in drastically smaller output "
1851 "files (smaller by about a factor of 2^dim).");
1856 "Whether the data will be used in an XDMF/HDF5 combination.");
1871 const bool int_binary,
1872 const bool coordinates_binary,
1873 const bool data_binary)
1874 : write_neighbors(write_neighbors)
1875 , int_binary(int_binary)
1876 , coordinates_binary(coordinates_binary)
1877 , data_binary(data_binary)
1878 , data_double(false)
1888 "A boolean field indicating whether neighborship "
1889 "information between cells is to be written to the "
1890 "OpenDX output file");
1894 "Output format of integer numbers, which is "
1895 "either a text representation (ascii) or binary integer "
1896 "values of 32 or 64 bits length");
1900 "Output format of vertex coordinates, which is "
1901 "either a text representation (ascii) or binary "
1902 "floating point values of 32 or 64 bits length");
1906 "Output format of data values, which is "
1907 "either a text representation (ascii) or binary "
1908 "floating point values of 32 or 64 bits length");
1928 "A flag indicating whether a comment should be "
1929 "written to the beginning of the output file "
1930 "indicating date and time of creation as well "
1931 "as the creating program");
1945 const int azimuth_angle,
1946 const int polar_angle,
1947 const unsigned int line_thickness,
1949 const bool draw_colorbar)
1952 , height_vector(height_vector)
1953 , azimuth_angle(azimuth_angle)
1954 , polar_angle(polar_angle)
1955 , line_thickness(line_thickness)
1957 , draw_colorbar(draw_colorbar)
1968 "A flag indicating whether POVRAY should use smoothed "
1969 "triangles instead of the usual ones");
1973 "Whether POVRAY should use bicubic patches");
1977 "Whether camera and lighting information should "
1978 "be put into an external file \"data.inc\" or into "
1979 "the POVRAY input file");
1995 const unsigned int color_vector,
1997 const unsigned int size,
1998 const double line_width,
1999 const double azimut_angle,
2000 const double turn_angle,
2001 const double z_scaling,
2002 const bool draw_mesh,
2003 const bool draw_cells,
2004 const bool shade_cells,
2006 : height_vector(height_vector)
2007 , color_vector(color_vector)
2010 , line_width(line_width)
2011 , azimut_angle(azimut_angle)
2012 , turn_angle(turn_angle)
2013 , z_scaling(z_scaling)
2014 , draw_mesh(draw_mesh)
2015 , draw_cells(draw_cells)
2016 , shade_cells(shade_cells)
2017 , color_function(color_function)
2056 double sum = xmax + xmin;
2057 double sum13 = xmin + 3 * xmax;
2058 double sum22 = 2 * xmin + 2 * xmax;
2059 double sum31 = 3 * xmin + xmax;
2060 double dif = xmax - xmin;
2061 double rezdif = 1.0 / dif;
2065 if (x < (sum31) / 4)
2067 else if (x < (sum22) / 4)
2069 else if (x < (sum13) / 4)
2080 rgb_values.
green = 0;
2081 rgb_values.
blue = (x - xmin) * 4. * rezdif;
2085 rgb_values.
green = (4 * x - 3 * xmin - xmax) * rezdif;
2086 rgb_values.
blue = (sum22 - 4. * x) * rezdif;
2089 rgb_values.
red = (4 * x - 2 *
sum) * rezdif;
2090 rgb_values.
green = (xmin + 3 * xmax - 4 * x) * rezdif;
2091 rgb_values.
blue = 0;
2095 rgb_values.
green = (4 * x - xmin - 3 * xmax) * rezdif;
2096 rgb_values.
blue = (4. * x - sum13) * rezdif;
2103 rgb_values.
red = rgb_values.
green = rgb_values.
blue = 1;
2117 (x - xmin) / (xmax - xmin);
2130 1 - (x - xmin) / (xmax - xmin);
2142 "Number of the input vector that is to be used to "
2143 "generate height information");
2147 "Number of the input vector that is to be used to "
2148 "generate color information");
2152 "Whether width or height should be scaled to match "
2157 "The size (width or height) to which the eps output "
2158 "file is to be scaled");
2162 "The width in which the postscript renderer is to "
2167 "Angle of the viewing position against the vertical "
2172 "Angle of the viewing direction against the y-axis");
2176 "Scaling for the z-direction relative to the scaling "
2177 "used in x- and y-directions");
2181 "Whether the mesh lines, or only the surface should be "
2186 "Whether only the mesh lines, or also the interior of "
2187 "cells should be plotted. If this flag is false, then "
2188 "one can see through the mesh");
2192 "Whether the interior of cells shall be shaded");
2196 "default|grey scale|reverse grey scale"),
2197 "Name of a color function used to colorize mesh lines "
2198 "and/or cell interiors");
2208 if (prm.
get(
"Scale to width or height") ==
"width")
2220 if (prm.
get(
"Color function") ==
"default")
2222 else if (prm.
get(
"Color function") ==
"grey scale")
2224 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2235 const char * zone_name,
2236 const double solution_time)
2237 : tecplot_binary_file_name(tecplot_binary_file_name)
2238 , zone_name(zone_name)
2239 , solution_time(solution_time)
2247 return sizeof(*this) +
2255 const unsigned int cycle,
2256 const bool print_date_and_time,
2258 const bool write_higher_order_cells)
2261 , print_date_and_time(print_date_and_time)
2262 , compression_level(compression_level)
2263 , write_higher_order_cells(write_higher_order_cells)
2271 if (format_name ==
"none")
2274 if (format_name ==
"dx")
2277 if (format_name ==
"ucd")
2280 if (format_name ==
"gnuplot")
2283 if (format_name ==
"povray")
2286 if (format_name ==
"eps")
2289 if (format_name ==
"gmv")
2292 if (format_name ==
"tecplot")
2295 if (format_name ==
"tecplot_binary")
2298 if (format_name ==
"vtk")
2301 if (format_name ==
"vtu")
2304 if (format_name ==
"deal.II intermediate")
2307 if (format_name ==
"hdf5")
2311 ExcMessage(
"The given file format name is not recognized: <" +
2312 format_name +
">"));
2323 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2331 switch (output_format)
2370 template <
int dim,
int spacedim,
typename StreamType>
2375 unsigned int count = 0;
2377 for (
const auto &patch : patches)
2380 const unsigned int n = n_subdivisions + 1;
2383 const unsigned int n1 = (dim > 0) ? n : 1;
2384 const unsigned int n2 = (dim > 1) ? n : 1;
2385 const unsigned int n3 = (dim > 2) ? n : 1;
2387 for (
unsigned int i3 = 0; i3 < n3; ++i3)
2388 for (
unsigned int i2 = 0; i2 < n2; ++i2)
2389 for (
unsigned int i1 = 0; i1 < n1; ++i1)
2390 out.write_point(count++,
2391 compute_node(patch, i1, i2, i3, n_subdivisions));
2396 template <
int dim,
int spacedim,
typename StreamType>
2401 unsigned int count = 0;
2402 unsigned int first_vertex_of_patch = 0;
2403 for (
const auto &patch : patches)
2406 const unsigned int n = n_subdivisions + 1;
2408 const unsigned int n1 = (dim > 0) ? n_subdivisions : 1;
2409 const unsigned int n2 = (dim > 1) ? n_subdivisions : 1;
2410 const unsigned int n3 = (dim > 2) ? n_subdivisions : 1;
2412 const unsigned int d1 = 1;
2413 const unsigned int d2 = n;
2414 const unsigned int d3 = n * n;
2415 for (
unsigned int i3 = 0; i3 < n3; ++i3)
2416 for (
unsigned int i2 = 0; i2 < n2; ++i2)
2417 for (
unsigned int i1 = 0; i1 < n1; ++i1)
2419 const unsigned int offset =
2420 first_vertex_of_patch + i3 * d3 + i2 * d2 + i1 * d1;
2422 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2425 first_vertex_of_patch +=
2426 Utilities::fixed_power<dim>(n_subdivisions + 1);
2432 template <
int dim,
int spacedim,
typename StreamType>
2438 unsigned int first_vertex_of_patch = 0;
2439 unsigned int count = 0;
2441 std::vector<unsigned> connectivity;
2443 std::array<unsigned, dim> cell_order;
2445 for (
const auto &patch : patches)
2448 const unsigned int n = n_subdivisions + 1;
2450 cell_order.fill(n_subdivisions);
2451 connectivity.resize(Utilities::fixed_power<dim>(n));
2454 const unsigned int n1 = (dim > 0) ? n_subdivisions : 0;
2455 const unsigned int n2 = (dim > 1) ? n_subdivisions : 0;
2456 const unsigned int n3 = (dim > 2) ? n_subdivisions : 0;
2458 const unsigned int d1 = 1;
2459 const unsigned int d2 = n;
2460 const unsigned int d3 = n * n;
2461 for (
unsigned int i3 = 0; i3 <= n3; ++i3)
2462 for (
unsigned int i2 = 0; i2 <= n2; ++i2)
2463 for (
unsigned int i1 = 0; i1 <= n1; ++i1)
2465 const unsigned int local_index = i3 * d3 + i2 * d2 + i1 * d1;
2466 const unsigned int connectivity_index =
2467 vtk_point_index_from_ijk(i1, i2, i3, cell_order);
2468 connectivity[connectivity_index] = local_index;
2471 out.template write_high_order_cell<dim>(count++,
2472 first_vertex_of_patch,
2476 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
2483 template <
int dim,
int spacedim,
class StreamType>
2486 unsigned int n_data_sets,
2487 const bool double_precision,
2491 unsigned int count = 0;
2493 for (
const auto &patch : patches)
2496 const unsigned int n = n_subdivisions + 1;
2498 Assert((patch.
data.n_rows() == n_data_sets &&
2500 (patch.
data.n_rows() == n_data_sets + spacedim &&
2503 (n_data_sets + spacedim) :
2505 patch.
data.n_rows()));
2506 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
2509 std::vector<float> floats(n_data_sets);
2510 std::vector<double> doubles(n_data_sets);
2513 for (
unsigned int i = 0; i < Utilities::fixed_power<dim>(n);
2515 if (double_precision)
2517 for (
unsigned int data_set = 0; data_set < n_data_sets;
2519 doubles[data_set] = patch.
data(data_set, i);
2520 out.write_dataset(count, doubles);
2524 for (
unsigned int data_set = 0; data_set < n_data_sets;
2526 floats[data_set] = patch.
data(data_set, i);
2527 out.write_dataset(count, floats);
2551 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] -
2552 camera_horizontal[2] * camera_direction[1];
2553 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] -
2554 camera_horizontal[0] * camera_direction[2];
2555 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] -
2556 camera_horizontal[1] * camera_direction[0];
2560 phi /= (
point[0] - camera_position[0]) * camera_direction[0] +
2561 (
point[1] - camera_position[1]) * camera_direction[1] +
2562 (
point[2] - camera_position[2]) * camera_direction[2];
2566 camera_position[0] + phi * (
point[0] - camera_position[0]);
2568 camera_position[1] + phi * (
point[1] - camera_position[1]);
2570 camera_position[2] + phi * (
point[2] - camera_position[2]);
2573 projection_decomposition[0] = (projection[0] - camera_position[0] -
2574 camera_focus * camera_direction[0]) *
2575 camera_horizontal[0];
2576 projection_decomposition[0] += (projection[1] - camera_position[1] -
2577 camera_focus * camera_direction[1]) *
2578 camera_horizontal[1];
2579 projection_decomposition[0] += (projection[2] - camera_position[2] -
2580 camera_focus * camera_direction[2]) *
2581 camera_horizontal[2];
2583 projection_decomposition[1] = (projection[0] - camera_position[0] -
2584 camera_focus * camera_direction[0]) *
2586 projection_decomposition[1] += (projection[1] - camera_position[1] -
2587 camera_focus * camera_direction[1]) *
2589 projection_decomposition[1] += (projection[2] - camera_position[2] -
2590 camera_focus * camera_direction[2]) *
2593 return projection_decomposition;
2607 for (
int i = 0; i < 2; ++i)
2609 for (
int j = 0; j < 2 - i; ++j)
2611 if (points[j][2] > points[j + 1][2])
2614 points[j] = points[j + 1];
2615 points[j + 1] = temp;
2622 v_inter = points[1];
2629 A[0][0] = v_max[0] - v_min[0];
2630 A[0][1] = v_inter[0] - v_min[0];
2631 A[1][0] = v_max[1] - v_min[1];
2632 A[1][1] = v_inter[1] - v_min[1];
2638 bool col_change =
false;
2647 double temp =
A[1][0];
2652 for (
unsigned int k = 0; k < 1; k++)
2654 for (
unsigned int i = k + 1; i < 2; i++)
2656 x =
A[i][k] /
A[k][k];
2658 for (
unsigned int j = k + 1; j < 2; j++)
2659 A[i][j] =
A[i][j] -
A[k][j] * x;
2661 b[i] =
b[i] -
b[k] * x;
2665 b[1] =
b[1] /
A[1][1];
2667 for (
int i = 0; i >= 0; i--)
2671 for (
unsigned int j = i + 1; j < 2; j++)
2674 b[i] =
sum /
A[i][i];
2684 double c =
b[0] * (v_max[2] - v_min[2]) +
b[1] * (v_inter[2] - v_min[2]) +
2688 A[0][0] = v_max[0] - v_min[0];
2689 A[0][1] = v_inter[0] - v_min[0];
2690 A[1][0] = v_max[1] - v_min[1];
2691 A[1][1] = v_inter[1] - v_min[1];
2693 b[0] = 1.0 - v_min[0];
2705 double temp =
A[1][0];
2710 for (
unsigned int k = 0; k < 1; k++)
2712 for (
unsigned int i = k + 1; i < 2; i++)
2714 x =
A[i][k] /
A[k][k];
2716 for (
unsigned int j = k + 1; j < 2; j++)
2717 A[i][j] =
A[i][j] -
A[k][j] * x;
2719 b[i] =
b[i] -
b[k] * x;
2723 b[1] =
b[1] /
A[1][1];
2725 for (
int i = 0; i >= 0; i--)
2729 for (
unsigned int j = i + 1; j < 2; j++)
2732 b[i] =
sum /
A[i][i];
2742 gradient[0] =
b[0] * (v_max[2] - v_min[2]) +
2743 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2746 A[0][0] = v_max[0] - v_min[0];
2747 A[0][1] = v_inter[0] - v_min[0];
2748 A[1][0] = v_max[1] - v_min[1];
2749 A[1][1] = v_inter[1] - v_min[1];
2752 b[1] = 1.0 - v_min[1];
2763 double temp =
A[1][0];
2768 for (
unsigned int k = 0; k < 1; k++)
2770 for (
unsigned int i = k + 1; i < 2; i++)
2772 x =
A[i][k] /
A[k][k];
2774 for (
unsigned int j = k + 1; j < 2; j++)
2775 A[i][j] =
A[i][j] -
A[k][j] * x;
2777 b[i] =
b[i] -
b[k] * x;
2781 b[1] =
b[1] /
A[1][1];
2783 for (
int i = 0; i >= 0; i--)
2787 for (
unsigned int j = i + 1; j < 2; j++)
2790 b[i] =
sum /
A[i][i];
2800 gradient[1] =
b[0] * (v_max[2] - v_min[2]) +
2801 b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2804 double gradient_norm =
2805 std::sqrt(std::pow(gradient[0], 2.0) + std::pow(gradient[1], 2.0));
2806 gradient[0] /= gradient_norm;
2807 gradient[1] /= gradient_norm;
2809 double lambda = -gradient[0] * (v_min[0] - v_max[0]) -
2810 gradient[1] * (v_min[1] - v_max[1]);
2814 gradient_parameters[0] = v_min[0];
2815 gradient_parameters[1] = v_min[1];
2817 gradient_parameters[2] = v_min[0] +
lambda * gradient[0];
2818 gradient_parameters[3] = v_min[1] +
lambda * gradient[1];
2820 gradient_parameters[4] = v_min[2];
2821 gradient_parameters[5] = v_max[2];
2823 return gradient_parameters;
2829 template <
int dim,
int spacedim>
2833 const std::vector<std::string> & data_names,
2835 std::tuple<
unsigned int,
2848 #ifndef DEAL_II_WITH_MPI
2857 if (patches.size() == 0)
2861 const unsigned int n_data_sets = data_names.size();
2863 UcdStream ucd_out(out, flags);
2866 unsigned int n_nodes;
2868 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
2874 <<
"# This file was generated by the deal.II library." <<
'\n'
2878 <<
"# For a description of the UCD format see the AVS Developer's guide."
2884 out << n_nodes <<
' ' <<
n_cells <<
' ' << n_data_sets <<
' ' << 0
2897 if (n_data_sets != 0)
2899 out << n_data_sets <<
" ";
2900 for (
unsigned int i = 0; i < n_data_sets; ++i)
2905 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
2906 out << data_names[data_set]
2910 write_data(patches, n_data_sets,
true, ucd_out);
2920 template <
int dim,
int spacedim>
2924 const std::vector<std::string> & data_names,
2926 std::tuple<
unsigned int,
2938 #ifndef DEAL_II_WITH_MPI
2947 if (patches.size() == 0)
2951 DXStream dx_out(out, flags);
2954 unsigned int offset = 0;
2956 const unsigned int n_data_sets = data_names.size();
2959 unsigned int n_nodes;
2961 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
2963 out <<
"object \"vertices\" class array type float rank 1 shape "
2964 << spacedim <<
" items " << n_nodes;
2968 out <<
" lsb ieee data 0" <<
'\n';
2969 offset += n_nodes * spacedim *
sizeof(float);
2973 out <<
" data follows" <<
'\n';
2982 out <<
"object \"cells\" class array type int rank 1 shape "
2987 out <<
" lsb binary data " << offset <<
'\n';
2992 out <<
" data follows" <<
'\n';
2998 out <<
"attribute \"element type\" string \"";
3005 out <<
"\"" <<
'\n' <<
"attribute \"ref\" string \"positions\"" <<
'\n';
3012 out <<
"object \"neighbors\" class array type int rank 1 shape "
3016 for (
const auto &patch : patches)
3019 const unsigned int n1 = (dim > 0) ? n : 1;
3020 const unsigned int n2 = (dim > 1) ? n : 1;
3021 const unsigned int n3 = (dim > 2) ? n : 1;
3022 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3023 unsigned int dx = 1;
3024 unsigned int dy = n;
3025 unsigned int dz = n * n;
3027 const unsigned int patch_start =
3030 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3031 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3032 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3034 const unsigned int nx = i1 *
dx;
3035 const unsigned int ny = i2 * dy;
3036 const unsigned int nz = i3 * dz;
3048 const unsigned int nn = patch.
neighbors[0];
3052 << (nn * cells_per_patch + ny + nz +
dx * (n - 1));
3058 out <<
'\t' << patch_start + nx -
dx + ny + nz;
3063 const unsigned int nn = patch.
neighbors[1];
3066 out << (nn * cells_per_patch + ny + nz);
3072 out <<
'\t' << patch_start + nx +
dx + ny + nz;
3079 const unsigned int nn = patch.
neighbors[2];
3083 << (nn * cells_per_patch + nx + nz + dy * (n - 1));
3089 out <<
'\t' << patch_start + nx + ny - dy + nz;
3094 const unsigned int nn = patch.
neighbors[3];
3097 out << (nn * cells_per_patch + nx + nz);
3103 out <<
'\t' << patch_start + nx + ny + dy + nz;
3111 const unsigned int nn = patch.
neighbors[4];
3115 << (nn * cells_per_patch + nx + ny + dz * (n - 1));
3121 out <<
'\t' << patch_start + nx + ny + nz - dz;
3126 const unsigned int nn = patch.
neighbors[5];
3129 out << (nn * cells_per_patch + nx + ny);
3135 out <<
'\t' << patch_start + nx + ny + nz + dz;
3143 if (n_data_sets != 0)
3145 out <<
"object \"data\" class array type float rank 1 shape "
3146 << n_data_sets <<
" items " << n_nodes;
3150 out <<
" lsb ieee data " << offset <<
'\n';
3151 offset += n_data_sets * n_nodes *
3152 ((flags.
data_double) ?
sizeof(
double) :
sizeof(float));
3156 out <<
" data follows" <<
'\n';
3161 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3165 out <<
"object \"data\" class constantarray type float rank 0 items "
3166 << n_nodes <<
" data follows" <<
'\n'
3172 out <<
"object \"deal data\" class field" <<
'\n'
3173 <<
"component \"positions\" value \"vertices\"" <<
'\n'
3174 <<
"component \"connections\" value \"cells\"" <<
'\n'
3175 <<
"component \"data\" value \"data\"" <<
'\n';
3178 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3185 out <<
"end" <<
'\n';
3203 template <
int dim,
int spacedim>
3207 const std::vector<std::string> & data_names,
3209 std::tuple<
unsigned int,
3218 #ifndef DEAL_II_WITH_MPI
3228 if (patches.size() == 0)
3232 const unsigned int n_data_sets = data_names.size();
3236 out <<
"# This file was generated by the deal.II library." <<
'\n'
3240 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual."
3247 for (
unsigned int spacedim_n = 0; spacedim_n < spacedim; ++spacedim_n)
3252 for (
const auto &data_name : data_names)
3253 out <<
'<' << data_name <<
"> ";
3259 for (
const auto &patch : patches)
3262 const unsigned int n = n_subdivisions + 1;
3264 const unsigned int n1 = (dim > 0) ? n : 1;
3265 const unsigned int n2 = (dim > 1) ? n : 1;
3266 const unsigned int n3 = (dim > 2) ? n : 1;
3267 unsigned int d1 = 1;
3268 unsigned int d2 = n;
3269 unsigned int d3 = n * n;
3271 Assert((patch.
data.n_rows() == n_data_sets &&
3273 (patch.
data.n_rows() == n_data_sets + spacedim &&
3276 (n_data_sets + spacedim) :
3278 patch.
data.n_rows()));
3279 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
3285 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3287 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3290 out << compute_node(patch, i1, i2, 0, n_subdivisions)
3293 for (
unsigned int data_set = 0; data_set < n_data_sets;
3295 out << patch.
data(data_set, i1 * d1 + i2 * d2) <<
' ';
3311 for (
unsigned int i3 = 0; i3 < n3; ++i3)
3312 for (
unsigned int i2 = 0; i2 < n2; ++i2)
3313 for (
unsigned int i1 = 0; i1 < n1; ++i1)
3317 compute_node(patch, i1, i2, i3, n_subdivisions);
3319 if (i1 < n_subdivisions)
3323 for (
unsigned int data_set = 0; data_set < n_data_sets;
3326 << patch.
data(data_set,
3327 i1 * d1 + i2 * d2 + i3 * d3);
3331 out << compute_node(
3332 patch, i1 + 1, i2, i3, n_subdivisions);
3334 for (
unsigned int data_set = 0; data_set < n_data_sets;
3337 << patch.
data(data_set,
3338 (i1 + 1) * d1 + i2 * d2 + i3 * d3);
3342 out <<
'\n' <<
'\n';
3346 if (i2 < n_subdivisions)
3350 for (
unsigned int data_set = 0; data_set < n_data_sets;
3353 << patch.
data(data_set,
3354 i1 * d1 + i2 * d2 + i3 * d3);
3358 out << compute_node(
3359 patch, i1, i2 + 1, i3, n_subdivisions);
3361 for (
unsigned int data_set = 0; data_set < n_data_sets;
3364 << patch.
data(data_set,
3365 i1 * d1 + (i2 + 1) * d2 + i3 * d3);
3369 out <<
'\n' <<
'\n';
3373 if (i3 < n_subdivisions)
3377 for (
unsigned int data_set = 0; data_set < n_data_sets;
3380 << patch.
data(data_set,
3381 i1 * d1 + i2 * d2 + i3 * d3);
3385 out << compute_node(
3386 patch, i1, i2, i3 + 1, n_subdivisions);
3388 for (
unsigned int data_set = 0; data_set < n_data_sets;
3391 << patch.
data(data_set,
3392 i1 * d1 + i2 * d2 + (i3 + 1) * d3);
3395 out <<
'\n' <<
'\n';
3410 template <
int dim,
int spacedim>
3414 const std::vector<std::string> & data_names,
3416 std::tuple<
unsigned int,
3425 #ifndef DEAL_II_WITH_MPI
3434 if (patches.size() == 0)
3441 const unsigned int n_data_sets = data_names.size();
3446 out <<
"/* This file was generated by the deal.II library." <<
'\n'
3450 <<
" For a description of the POVRAY format see the POVRAY manual."
3455 out <<
"#include \"colors.inc\" " <<
'\n'
3456 <<
"#include \"textures.inc\" " <<
'\n';
3461 out <<
"#include \"data.inc\" " <<
'\n';
3467 <<
"camera {" <<
'\n'
3468 <<
" location <1,4,-7>" <<
'\n'
3469 <<
" look_at <0,0,0>" <<
'\n'
3470 <<
" angle 30" <<
'\n'
3475 <<
"light_source {" <<
'\n'
3476 <<
" <1,4,-7>" <<
'\n'
3477 <<
" color Grey" <<
'\n'
3480 <<
"light_source {" <<
'\n'
3481 <<
" <0,20,0>" <<
'\n'
3482 <<
" color White" <<
'\n'
3489 double hmin = patches[0].data(0, 0);
3490 double hmax = patches[0].data(0, 0);
3492 for (
const auto &patch : patches)
3496 Assert((patch.
data.n_rows() == n_data_sets &&
3498 (patch.
data.n_rows() == n_data_sets + spacedim &&
3501 (n_data_sets + spacedim) :
3503 patch.
data.n_rows()));
3505 Utilities::fixed_power<dim>(n_subdivisions + 1),
3508 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
3509 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
3511 const int dl = i * (n_subdivisions + 1) + j;
3512 if (patch.
data(0, dl) < hmin)
3513 hmin = patch.
data(0, dl);
3514 if (patch.
data(0, dl) > hmax)
3515 hmax = patch.
data(0, dl);
3519 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n'
3520 <<
"#declare HMAX=" << hmax <<
";" <<
'\n'
3526 out <<
"#declare Tex=texture{" <<
'\n'
3527 <<
" pigment {" <<
'\n'
3528 <<
" gradient y" <<
'\n'
3529 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n'
3530 <<
" color_map {" <<
'\n'
3531 <<
" [0.00 color Light_Purple] " <<
'\n'
3532 <<
" [0.95 color Light_Purple] " <<
'\n'
3533 <<
" [1.00 color White] " <<
'\n'
3541 out <<
'\n' <<
"mesh {" <<
'\n';
3545 for (
const auto &patch : patches)
3548 const unsigned int n = n_subdivisions + 1;
3549 const unsigned int d1 = 1;
3550 const unsigned int d2 = n;
3552 Assert((patch.
data.n_rows() == n_data_sets &&
3554 (patch.
data.n_rows() == n_data_sets + spacedim &&
3557 (n_data_sets + spacedim) :
3559 patch.
data.n_rows()));
3560 Assert(patch.
data.n_cols() == Utilities::fixed_power<dim>(n),
3564 std::vector<Point<spacedim>> ver(n * n);
3566 for (
unsigned int i2 = 0; i2 < n; ++i2)
3567 for (
unsigned int i1 = 0; i1 < n; ++i1)
3570 ver[i1 * d1 + i2 * d2] =
3571 compute_node(patch, i1, i2, 0, n_subdivisions);
3578 std::vector<Point<3>> nrml;
3588 for (
unsigned int i = 0; i < n; ++i)
3589 for (
unsigned int j = 0; j < n; ++j)
3591 const unsigned int il = (i == 0) ? i : (i - 1);
3592 const unsigned int ir =
3593 (i == n_subdivisions) ? i : (i + 1);
3594 const unsigned int jl = (j == 0) ? j : (j - 1);
3595 const unsigned int jr =
3596 (j == n_subdivisions) ? j : (j + 1);
3599 ver[ir * d1 + j * d2](0) - ver[il * d1 + j * d2](0);
3600 h1(1) = patch.
data(0, ir * d1 + j * d2) -
3601 patch.
data(0, il * d1 + j * d2);
3603 ver[ir * d1 + j * d2](1) - ver[il * d1 + j * d2](1);
3606 ver[i * d1 + jr * d2](0) - ver[i * d1 + jl * d2](0);
3607 h2(1) = patch.
data(0, i * d1 + jr * d2) -
3608 patch.
data(0, i * d1 + jl * d2);
3610 ver[i * d1 + jr * d2](1) - ver[i * d1 + jl * d2](1);
3612 nrml[i * d1 + j * d2](0) = h1(1) * h2(2) - h1(2) * h2(1);
3613 nrml[i * d1 + j * d2](1) = h1(2) * h2(0) - h1(0) * h2(2);
3614 nrml[i * d1 + j * d2](2) = h1(0) * h2(1) - h1(1) * h2(0);
3618 std::sqrt(std::pow(nrml[i * d1 + j * d2](0), 2.) +
3619 std::pow(nrml[i * d1 + j * d2](1), 2.) +
3620 std::pow(nrml[i * d1 + j * d2](2), 2.));
3622 if (nrml[i * d1 + j * d2](1) < 0)
3625 for (
unsigned int k = 0; k < 3; ++k)
3626 nrml[i * d1 + j * d2](k) /=
norm;
3631 for (
unsigned int i = 0; i < n_subdivisions; ++i)
3632 for (
unsigned int j = 0; j < n_subdivisions; ++j)
3635 const int dl = i * d1 + j * d2;
3641 out <<
"smooth_triangle {" <<
'\n'
3642 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
3643 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0) <<
", "
3644 << nrml[dl](1) <<
", " << nrml[dl](2) <<
">," <<
'\n';
3645 out <<
" \t<" << ver[dl + d1](0) <<
","
3646 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
3647 <<
">, <" << nrml[dl + d1](0) <<
", "
3648 << nrml[dl + d1](1) <<
", " << nrml[dl + d1](2)
3650 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
3651 << patch.
data(0, dl + d1 + d2) <<
","
3652 << ver[dl + d1 + d2](1) <<
">, <"
3653 << nrml[dl + d1 + d2](0) <<
", "
3654 << nrml[dl + d1 + d2](1) <<
", "
3655 << nrml[dl + d1 + d2](2) <<
">}" <<
'\n';
3658 out <<
"smooth_triangle {" <<
'\n'
3659 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
3660 <<
"," << ver[dl](1) <<
">, <" << nrml[dl](0) <<
", "
3661 << nrml[dl](1) <<
", " << nrml[dl](2) <<
">," <<
'\n';
3662 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
3663 << patch.
data(0, dl + d1 + d2) <<
","
3664 << ver[dl + d1 + d2](1) <<
">, <"
3665 << nrml[dl + d1 + d2](0) <<
", "
3666 << nrml[dl + d1 + d2](1) <<
", "
3667 << nrml[dl + d1 + d2](2) <<
">," <<
'\n';
3668 out <<
"\t<" << ver[dl + d2](0) <<
","
3669 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
3670 <<
">, <" << nrml[dl + d2](0) <<
", "
3671 << nrml[dl + d2](1) <<
", " << nrml[dl + d2](2)
3677 out <<
"triangle {" <<
'\n'
3678 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
3679 <<
"," << ver[dl](1) <<
">," <<
'\n';
3680 out <<
"\t<" << ver[dl + d1](0) <<
","
3681 << patch.
data(0, dl + d1) <<
"," << ver[dl + d1](1)
3683 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
3684 << patch.
data(0, dl + d1 + d2) <<
","
3685 << ver[dl + d1 + d2](1) <<
">}" <<
'\n';
3688 out <<
"triangle {" <<
'\n'
3689 <<
"\t<" << ver[dl](0) <<
"," << patch.
data(0, dl)
3690 <<
"," << ver[dl](1) <<
">," <<
'\n';
3691 out <<
"\t<" << ver[dl + d1 + d2](0) <<
","
3692 << patch.
data(0, dl + d1 + d2) <<
","
3693 << ver[dl + d1 + d2](1) <<
">," <<
'\n';
3694 out <<
"\t<" << ver[dl + d2](0) <<
","
3695 << patch.
data(0, dl + d2) <<
"," << ver[dl + d2](1)
3703 Assert(n_subdivisions == 3,
3706 <<
"bicubic_patch {" <<
'\n'
3707 <<
" type 0" <<
'\n'
3708 <<
" flatness 0" <<
'\n'
3709 <<
" u_steps 0" <<
'\n'
3710 <<
" v_steps 0" <<
'\n';
3711 for (
int i = 0; i < 16; ++i)
3713 out <<
"\t<" << ver[i](0) <<
"," << patch.
data(0, i) <<
","
3714 << ver[i](1) <<
">";
3719 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n';
3726 out <<
" texture {Tex}" <<
'\n' <<
"}" <<
'\n' <<
'\n';
3737 template <
int dim,
int spacedim>
3741 const std::vector<std::string> & ,
3743 std::tuple<
unsigned int,
3755 template <
int spacedim>
3759 const std::vector<std::string> & ,
3761 std::tuple<
unsigned int,
3770 #ifndef DEAL_II_WITH_MPI
3779 if (patches.size() == 0)
3789 std::multiset<EpsCell2d> cells;
3798 double heights[4] = {0, 0, 0, 0};
3802 for (
const auto &patch : patches)
3805 const unsigned int n = n_subdivisions + 1;
3806 const unsigned int d1 = 1;
3807 const unsigned int d2 = n;
3809 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
3810 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
3813 points[0] = compute_node(patch, i1, i2, 0, n_subdivisions);
3814 points[1] = compute_node(patch, i1 + 1, i2, 0, n_subdivisions);
3815 points[2] = compute_node(patch, i1, i2 + 1, 0, n_subdivisions);
3817 compute_node(patch, i1 + 1, i2 + 1, 0, n_subdivisions);
3823 patch.
data.n_rows() == 0,
3826 patch.
data.n_rows()));
3828 patch.
data.n_rows() != 0 ?
3832 heights[1] = patch.
data.n_rows() != 0 ?
3834 (i1 + 1) * d1 + i2 * d2) *
3837 heights[2] = patch.
data.n_rows() != 0 ?
3839 i1 * d1 + (i2 + 1) * d2) *
3842 heights[3] = patch.
data.n_rows() != 0 ?
3844 (i1 + 1) * d1 + (i2 + 1) * d2) *
3851 for (
unsigned int i = 0; i < 4; ++i)
3852 heights[i] = points[i](2);
3873 cz = -std::cos(flags.
turn_angle * 2 * pi / 360.),
3876 sz = std::sin(flags.
turn_angle * 2 * pi / 360.);
3877 for (
unsigned int vertex = 0; vertex < 4; ++vertex)
3879 const double x = points[vertex](0), y = points[vertex](1),
3880 z = -heights[vertex];
3882 eps_cell.vertices[vertex](0) = -cz * x + sz * y;
3883 eps_cell.vertices[vertex](1) =
3884 -cx * sz * x - cx * cz * y - sx * z;
3908 (points[0] + points[1] + points[2] + points[3]) / 4;
3909 const double center_height =
3910 -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
3913 eps_cell.depth = -sx * sz * center_point(0) -
3914 sx * cz * center_point(1) + cx * center_height;
3919 patch.
data.n_rows() == 0,
3922 patch.
data.n_rows()));
3923 const double color_values[4] = {
3924 patch.
data.n_rows() != 0 ?
3928 patch.
data.n_rows() != 0 ?
3932 patch.
data.n_rows() != 0 ?
3936 patch.
data.n_rows() != 0 ?
3938 (i1 + 1) * d1 + (i2 + 1) * d2) :
3942 eps_cell.color_value = (color_values[0] + color_values[1] +
3943 color_values[3] + color_values[2]) /
3948 std::min(min_color_value, eps_cell.color_value);
3950 std::max(max_color_value, eps_cell.color_value);
3954 cells.insert(eps_cell);
3960 double x_min = cells.begin()->vertices[0](0);
3961 double x_max = x_min;
3962 double y_min = cells.begin()->vertices[0](1);
3963 double y_max = y_min;
3965 for (
const auto &cell : cells)
3966 for (
const auto &vertex : cell.vertices)
3968 x_min =
std::min(x_min, vertex(0));
3969 x_max =
std::max(x_max, vertex(0));
3970 y_min =
std::min(y_min, vertex(1));
3971 y_max =
std::max(y_max, vertex(1));
3976 const double scale =
3980 const Point<2> offset(x_min, y_min);
3985 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
3986 <<
"%%Title: deal.II Output" <<
'\n'
3987 <<
"%%Creator: the deal.II library" <<
'\n'
3990 <<
"%%BoundingBox: "
3994 <<
static_cast<unsigned int>((x_max - x_min) *
scale + 0.5) <<
' '
3995 <<
static_cast<unsigned int>((y_max - y_min) *
scale + 0.5) <<
'\n';
4004 out <<
"/m {moveto} bind def" <<
'\n'
4005 <<
"/l {lineto} bind def" <<
'\n'
4006 <<
"/s {setrgbcolor} bind def" <<
'\n'
4007 <<
"/sg {setgray} bind def" <<
'\n'
4008 <<
"/lx {lineto closepath stroke} bind def" <<
'\n'
4009 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4011 out <<
"%%EndProlog" <<
'\n' <<
'\n';
4013 out << flags.
line_width <<
" setlinewidth" <<
'\n';
4021 if (max_color_value == min_color_value)
4022 max_color_value = min_color_value + 1;
4026 for (
const auto &cell : cells)
4039 out << rgb_values.
red <<
" sg ";
4041 out << rgb_values.
red <<
' ' << rgb_values.
green <<
' '
4042 << rgb_values.
blue <<
" s ";
4047 out << (cell.vertices[0] - offset) *
scale <<
" m "
4048 << (cell.vertices[1] - offset) *
scale <<
" l "
4049 << (cell.vertices[3] - offset) *
scale <<
" l "
4050 << (cell.vertices[2] - offset) *
scale <<
" lf" <<
'\n';
4055 << (cell.vertices[0] - offset) *
scale <<
" m "
4056 << (cell.vertices[1] - offset) *
scale <<
" l "
4057 << (cell.vertices[3] - offset) *
scale <<
" l "
4058 << (cell.vertices[2] - offset) *
scale <<
" lx" <<
'\n';
4060 out <<
"showpage" <<
'\n';
4069 template <
int dim,
int spacedim>
4073 const std::vector<std::string> & data_names,
4075 std::tuple<
unsigned int,
4091 #ifndef DEAL_II_WITH_MPI
4100 if (patches.size() == 0)
4104 GmvStream gmv_out(out, flags);
4105 const unsigned int n_data_sets = data_names.size();
4108 Assert((patches[0].data.n_rows() == n_data_sets &&
4109 !patches[0].points_are_available) ||
4110 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4111 patches[0].points_are_available),
4113 (n_data_sets + spacedim) :
4115 patches[0].data.n_rows()));
4119 out <<
"gmvinput ascii" <<
'\n' <<
'\n';
4122 unsigned int n_nodes;
4124 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4139 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4141 &write_gmv_reorder_data_vectors<dim, spacedim>;
4149 out <<
"nodes " << n_nodes <<
'\n';
4150 for (
unsigned int d = 0;
d < spacedim; ++
d)
4152 gmv_out.selected_component =
d;
4158 for (
unsigned int d = spacedim;
d < 3; ++
d)
4160 for (
unsigned int i = 0; i < n_nodes; ++i)
4167 out <<
"cells " <<
n_cells <<
'\n';
4172 out <<
"variable" <<
'\n';
4176 reorder_task.
join();
4180 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4182 out << data_names[data_set] <<
" 1" <<
'\n';
4184 data_vectors[data_set].
end(),
4185 std::ostream_iterator<double>(out,
" "));
4186 out <<
'\n' <<
'\n';
4192 out <<
"endvars" <<
'\n';
4195 out <<
"endgmv" <<
'\n';
4206 template <
int dim,
int spacedim>
4210 const std::vector<std::string> & data_names,
4212 std::tuple<
unsigned int,
4226 #ifndef DEAL_II_WITH_MPI
4235 if (patches.size() == 0)
4239 TecplotStream tecplot_out(out, flags);
4241 const unsigned int n_data_sets = data_names.size();
4244 Assert((patches[0].data.n_rows() == n_data_sets &&
4245 !patches[0].points_are_available) ||
4246 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4247 patches[0].points_are_available),
4249 (n_data_sets + spacedim) :
4251 patches[0].data.n_rows()));
4254 unsigned int n_nodes;
4256 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4262 <<
"# This file was generated by the deal.II library." <<
'\n'
4266 <<
"# For a description of the Tecplot format see the Tecplot documentation."
4271 out <<
"Variables=";
4279 out <<
"\"x\", \"y\"";
4282 out <<
"\"x\", \"y\", \"z\"";
4288 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4289 out <<
", \"" << data_names[data_set] <<
"\"";
4295 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4298 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4300 out <<
"f=feblock, n=" << n_nodes <<
", e=" <<
n_cells
4301 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4320 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4322 &write_gmv_reorder_data_vectors<dim, spacedim>;
4330 for (
unsigned int d = 0;
d < spacedim; ++
d)
4332 tecplot_out.selected_component =
d;
4343 reorder_task.
join();
4346 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4349 data_vectors[data_set].
end(),
4350 std::ostream_iterator<double>(out,
"\n"));
4368 #ifdef DEAL_II_HAVE_TECPLOT
4375 TecplotMacros(
const unsigned int n_nodes = 0,
4376 const unsigned int n_vars = 0,
4377 const unsigned int n_cells = 0,
4378 const unsigned int n_vert = 0);
4381 nd(
const unsigned int i,
const unsigned int j);
4383 cd(
const unsigned int i,
const unsigned int j);
4384 std::vector<float> nodalData;
4385 std::vector<int> connData;
4388 unsigned int n_nodes;
4389 unsigned int n_vars;
4391 unsigned int n_vert;
4395 inline TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
4396 const unsigned int n_vars,
4398 const unsigned int n_vert)
4404 nodalData.resize(n_nodes * n_vars);
4405 connData.resize(
n_cells * n_vert);
4410 inline TecplotMacros::~TecplotMacros()
4416 TecplotMacros::nd(
const unsigned int i,
const unsigned int j)
4418 return nodalData[i * n_nodes + j];
4424 TecplotMacros::cd(
const unsigned int i,
const unsigned int j)
4426 return connData[i + j * n_vert];
4437 template <
int dim,
int spacedim>
4441 const std::vector<std::string> & data_names,
4443 std::tuple<
unsigned int,
4447 & nonscalar_data_ranges,
4456 #ifndef DEAL_II_HAVE_TECPLOT
4459 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
4467 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
4476 if (file_name ==
nullptr)
4481 ExcMessage(
"Specify the name of the tecplot_binary"
4482 " file through the TecplotFlags interface."));
4483 write_tecplot(patches, data_names, nonscalar_data_ranges, flags, out);
4490 # ifndef DEAL_II_WITH_MPI
4499 if (patches.size() == 0)
4503 const unsigned int n_data_sets = data_names.size();
4506 Assert((patches[0].data.n_rows() == n_data_sets &&
4507 !patches[0].points_are_available) ||
4508 (patches[0].data.n_rows() == n_data_sets + spacedim &&
4509 patches[0].points_are_available),
4511 (n_data_sets + spacedim) :
4513 patches[0].data.n_rows()));
4516 unsigned int n_nodes;
4518 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4520 const unsigned int vars_per_node = (spacedim + n_data_sets),
4523 TecplotMacros tm(n_nodes, vars_per_node,
n_cells, nodes_per_cell);
4525 int is_double = 0, tec_debug = 0, cell_type = tecplot_binary_cell_type[dim];
4527 std::string tec_var_names;
4531 tec_var_names =
"x y";
4534 tec_var_names =
"x y z";
4540 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4542 tec_var_names +=
" ";
4543 tec_var_names += data_names[data_set];
4559 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4561 &write_gmv_reorder_data_vectors<dim, spacedim>;
4567 for (
unsigned int d = 1;
d <= spacedim; ++
d)
4569 unsigned int entry = 0;
4571 for (
const auto &patch : patches)
4579 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4580 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4582 const double x_frac = i * 1. / n_subdivisions,
4583 y_frac = j * 1. / n_subdivisions;
4585 tm.nd((
d - 1), entry) =
static_cast<float>(
4587 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
4590 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
4599 for (
unsigned int j = 0; j < n_subdivisions + 1; ++j)
4600 for (
unsigned int k = 0; k < n_subdivisions + 1; ++k)
4601 for (
unsigned int i = 0; i < n_subdivisions + 1; ++i)
4603 const double x_frac = i * 1. / n_subdivisions,
4604 y_frac = k * 1. / n_subdivisions,
4605 z_frac = j * 1. / n_subdivisions;
4608 tm.nd((
d - 1), entry) =
static_cast<float>(
4609 ((((patch.
vertices[1](
d - 1) * x_frac) +
4610 (patch.
vertices[0](
d - 1) * (1 - x_frac))) *
4613 (patch.
vertices[2](
d - 1) * (1 - x_frac))) *
4617 (patch.
vertices[4](
d - 1) * (1 - x_frac))) *
4620 (patch.
vertices[6](
d - 1) * (1 - x_frac))) *
4638 reorder_task.
join();
4641 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
4642 for (
unsigned int entry = 0; entry < data_vectors[data_set].
size();
4644 tm.nd((spacedim + data_set), entry) =
4645 static_cast<float>(data_vectors[data_set][entry]);
4651 unsigned int first_vertex_of_patch = 0;
4652 unsigned int elem = 0;
4654 for (
const auto &patch : patches)
4657 const unsigned int n = n_subdivisions + 1;
4658 const unsigned int d1 = 1;
4659 const unsigned int d2 = n;
4660 const unsigned int d3 = n * n;
4666 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4667 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4670 first_vertex_of_patch + (i1)*d1 + (i2)*d2 + 1;
4672 first_vertex_of_patch + (i1 + 1) * d1 + (i2)*d2 + 1;
4673 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
4676 first_vertex_of_patch + (i1)*d1 + (i2 + 1) * d2 + 1;
4685 for (
unsigned int i3 = 0; i3 < n_subdivisions; ++i3)
4686 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
4687 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
4692 tm.cd(0, elem) = first_vertex_of_patch + (i1)*d1 +
4693 (i2)*d2 + (i3)*d3 + 1;
4694 tm.cd(1, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
4695 (i2)*d2 + (i3)*d3 + 1;
4696 tm.cd(2, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
4697 (i2 + 1) * d2 + (i3)*d3 + 1;
4698 tm.cd(3, elem) = first_vertex_of_patch + (i1)*d1 +
4699 (i2 + 1) * d2 + (i3)*d3 + 1;
4700 tm.cd(4, elem) = first_vertex_of_patch + (i1)*d1 +
4701 (i2)*d2 + (i3 + 1) * d3 + 1;
4702 tm.cd(5, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
4703 (i2)*d2 + (i3 + 1) * d3 + 1;
4704 tm.cd(6, elem) = first_vertex_of_patch + (i1 + 1) * d1 +
4705 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
4706 tm.cd(7, elem) = first_vertex_of_patch + (i1)*d1 +
4707 (i2 + 1) * d2 + (i3 + 1) * d3 + 1;
4720 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
4725 int ierr = 0, num_nodes =
static_cast<int>(n_nodes),
4726 num_cells =
static_cast<int>(
n_cells);
4728 char dot[2] = {
'.', 0};
4732 char *var_names =
const_cast<char *
>(tec_var_names.c_str());
4733 ierr = TECINI(
nullptr, var_names, file_name, dot, &tec_debug, &is_double);
4737 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K', 0};
4739 TECZNE(
nullptr, &num_nodes, &num_cells, &cell_type, FEBLOCK,
nullptr);
4743 int total = (vars_per_node * num_nodes);
4745 ierr = TECDAT(&total, tm.nodalData.data(), &is_double);
4749 ierr = TECNOD(tm.connData.data());
4762 template <
int dim,
int spacedim>
4766 const std::vector<std::string> & data_names,
4768 std::tuple<
unsigned int,
4772 & nonscalar_data_ranges,
4778 #ifndef DEAL_II_WITH_MPI
4787 if (patches.size() == 0)
4791 VtkStream vtk_out(out, flags);
4793 const unsigned int n_data_sets = data_names.size();
4795 if (patches[0].points_are_available)
4807 out <<
"# vtk DataFile Version 3.0" <<
'\n'
4808 <<
"#This file was generated by the deal.II library";
4816 out <<
'\n' <<
"ASCII" <<
'\n';
4818 out <<
"DATASET UNSTRUCTURED_GRID\n" <<
'\n';
4825 const unsigned int n_metadata =
4830 out <<
"FIELD FieldData " << n_metadata <<
"\n";
4834 out <<
"CYCLE 1 1 int\n" << flags.
cycle <<
"\n";
4838 out <<
"TIME 1 1 double\n" << flags.
time <<
"\n";
4844 unsigned int n_nodes;
4846 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
4855 n_points_per_cell = n_nodes /
n_cells;
4872 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
4874 &write_gmv_reorder_data_vectors<dim, spacedim>;
4882 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
4887 out <<
"CELLS " <<
n_cells <<
' ' <<
n_cells * (n_points_per_cell + 1)
4896 out <<
"CELL_TYPES " <<
n_cells <<
'\n';
4900 vtk_lagrange_cell_type[dim] :
4902 for (
unsigned int i = 0; i <
n_cells; ++i)
4903 out <<
' ' << vtk_cell_id;
4910 reorder_task.
join();
4915 out <<
"POINT_DATA " << n_nodes <<
'\n';
4919 std::vector<bool> data_set_written(n_data_sets,
false);
4920 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
4927 std::get<0>(nonscalar_data_range),
4929 std::get<0>(nonscalar_data_range)));
4930 AssertThrow(std::get<1>(nonscalar_data_range) < n_data_sets,
4934 AssertThrow(std::get<1>(nonscalar_data_range) + 1 -
4935 std::get<0>(nonscalar_data_range) <=
4938 "Can't declare a vector with more than 3 components "
4942 for (
unsigned int i = std::get<0>(nonscalar_data_range);
4943 i <= std::get<1>(nonscalar_data_range);
4945 data_set_written[i] =
true;
4951 if (!std::get<2>(nonscalar_data_range).empty())
4952 out << std::get<2>(nonscalar_data_range);
4955 for (
unsigned int i = std::get<0>(nonscalar_data_range);
4956 i < std::get<1>(nonscalar_data_range);
4958 out << data_names[i] <<
"__";
4959 out << data_names[std::get<1>(nonscalar_data_range)];
4962 out <<
" double" <<
'\n';
4965 for (
unsigned int n = 0; n < n_nodes; ++n)
4967 switch (std::get<1>(nonscalar_data_range) -
4968 std::get<0>(nonscalar_data_range))
4971 out << data_vectors(std::get<0>(nonscalar_data_range), n)
4976 out << data_vectors(std::get<0>(nonscalar_data_range), n)
4978 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
4982 out << data_vectors(std::get<0>(nonscalar_data_range), n)
4984 << data_vectors(std::get<0>(nonscalar_data_range) + 1, n)
4986 << data_vectors(std::get<0>(nonscalar_data_range) + 2, n)
4999 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5000 if (data_set_written[data_set] ==
false)
5002 out <<
"SCALARS " << data_names[data_set] <<
" double 1" <<
'\n'
5003 <<
"LOOKUP_TABLE default" <<
'\n';
5005 data_vectors[data_set].
end(),
5006 std::ostream_iterator<double>(out,
" "));
5022 out <<
"<?xml version=\"1.0\" ?> \n";
5024 out <<
"# vtk DataFile Version 3.0" <<
'\n'
5025 <<
"#This file was generated by the deal.II library";
5034 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5035 #ifdef DEAL_II_WITH_ZLIB
5036 out <<
" compressor=\"vtkZLibDataCompressor\"";
5038 #ifdef DEAL_II_WORDS_BIGENDIAN
5039 out <<
" byte_order=\"BigEndian\"";
5041 out <<
" byte_order=\"LittleEndian\"";
5045 out <<
"<UnstructuredGrid>";
5055 out <<
" </UnstructuredGrid>\n";
5056 out <<
"</VTKFile>\n";
5061 template <
int dim,
int spacedim>
5065 const std::vector<std::string> & data_names,
5067 std::tuple<
unsigned int,
5071 & nonscalar_data_ranges,
5076 write_vtu_main(patches, data_names, nonscalar_data_ranges, flags, out);
5083 template <
int dim,
int spacedim>
5087 const std::vector<std::string> & data_names,
5089 std::tuple<
unsigned int,
5093 & nonscalar_data_ranges,
5099 #ifndef DEAL_II_WITH_MPI
5108 if (patches.size() == 0)
5113 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n"
5115 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n"
5117 <<
" <PointData Scalars=\"scalars\">\n";
5118 std::vector<bool> data_set_written(data_names.size(),
false);
5119 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5122 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5123 i <= std::get<1>(nonscalar_data_range);
5125 data_set_written[i] =
true;
5129 out <<
" <DataArray type=\"Float32\" Name=\"";
5131 if (!std::get<2>(nonscalar_data_range).empty())
5132 out << std::get<2>(nonscalar_data_range);
5135 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5136 i < std::get<1>(nonscalar_data_range);
5138 out << data_names[i] <<
"__";
5139 out << data_names[std::get<1>(nonscalar_data_range)];
5142 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5145 for (
unsigned int data_set = 0; data_set < data_names.size();
5147 if (data_set_written[data_set] ==
false)
5149 out <<
" <DataArray type=\"Float32\" Name=\""
5150 << data_names[data_set] <<
"\"></DataArray>\n";
5153 out <<
" </PointData>\n";
5154 out <<
"</Piece>\n";
5168 const unsigned int n_metadata =
5172 out <<
"<FieldData>\n";
5177 <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">"
5178 << flags.
cycle <<
"</DataArray>\n";
5183 <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">"
5184 << flags.
time <<
"</DataArray>\n";
5188 out <<
"</FieldData>\n";
5192 VtuStream vtu_out(out, flags);
5194 const unsigned int n_data_sets = data_names.size();
5197 if (patches[0].points_are_available)
5206 #ifdef DEAL_II_WITH_ZLIB
5207 const char *ascii_or_binary =
"binary";
5209 const char *ascii_or_binary =
"ascii";
5214 unsigned int n_nodes;
5216 compute_sizes<dim, spacedim>(patches, n_nodes,
n_cells);
5225 n_points_per_cell = n_nodes /
n_cells;
5242 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
5244 &write_gmv_reorder_data_vectors<dim, spacedim, float>;
5253 out <<
"<Piece NumberOfPoints=\"" << n_nodes <<
"\" NumberOfCells=\""
5255 out <<
" <Points>\n";
5256 out <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\""
5257 << ascii_or_binary <<
"\">\n";
5259 out <<
" </DataArray>\n";
5260 out <<
" </Points>\n\n";
5263 out <<
" <Cells>\n";
5264 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\""
5265 << ascii_or_binary <<
"\">\n";
5270 out <<
" </DataArray>\n";
5274 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\""
5275 << ascii_or_binary <<
"\">\n";
5277 std::vector<int32_t> offsets(
n_cells);
5278 for (
unsigned int i = 0; i <
n_cells; ++i)
5279 offsets[i] = (i + 1) * n_points_per_cell;
5282 out <<
" </DataArray>\n";
5286 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\""
5287 << ascii_or_binary <<
"\">\n";
5292 vtk_lagrange_cell_type[dim] :
5297 #ifdef DEAL_II_WITH_ZLIB
5298 std::vector<uint8_t> cell_types(
n_cells,
5299 static_cast<uint8_t
>(vtk_cell_id));
5301 std::vector<unsigned int> cell_types(
n_cells, vtk_cell_id);
5304 vtu_out << cell_types;
5307 out <<
" </DataArray>\n";
5308 out <<
" </Cells>\n";
5316 reorder_task.
join();
5321 out <<
" <PointData Scalars=\"scalars\">\n";
5325 std::vector<bool> data_set_written(n_data_sets,
false);
5326 for (
const auto &range : nonscalar_data_ranges)
5328 const auto first_component = std::get<0>(range);
5329 const auto last_component = std::get<1>(range);
5330 const auto &name = std::get<2>(range);
5331 const bool is_tensor =
5332 (std::get<3>(range) ==
5341 AssertThrow((last_component + 1 - first_component <= 9),
5343 "Can't declare a tensor with more than 9 components "
5348 AssertThrow((last_component + 1 - first_component <= 3),
5350 "Can't declare a vector with more than 3 components "
5355 for (
unsigned int i = first_component; i <= last_component; ++i)
5356 data_set_written[i] =
true;
5360 out <<
" <DataArray type=\"Float32\" Name=\"";
5366 for (
unsigned int i = first_component; i < last_component; ++i)
5367 out << data_names[i] <<
"__";
5368 out << data_names[last_component];
5371 out <<
"\" NumberOfComponents=\"" <<
n_components <<
"\" format=\""
5372 << ascii_or_binary <<
"\">\n";
5375 std::vector<float> data;
5378 for (
unsigned int n = 0; n < n_nodes; ++n)
5382 switch (last_component - first_component)
5385 data.push_back(data_vectors(first_component, n));
5391 data.push_back(data_vectors(first_component, n));
5392 data.push_back(data_vectors(first_component + 1, n));
5397 data.push_back(data_vectors(first_component, n));
5398 data.push_back(data_vectors(first_component + 1, n));
5399 data.push_back(data_vectors(first_component + 2, n));
5412 const unsigned int size = last_component - first_component + 1;
5416 vtk_data[0][0] = data_vectors(first_component, n);
5418 else if ((size == 4) || (size == 9))
5421 for (
unsigned int c = 0; c < size; ++c)
5425 vtk_data[ind[0]][ind[1]] =
5426 data_vectors(first_component + c, n);
5437 for (
unsigned int i = 0; i < 3; ++i)
5438 for (
unsigned int j = 0; j < 3; ++j)
5439 data.push_back(vtk_data[i][j]);
5444 out <<
" </DataArray>\n";
5449 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5450 if (data_set_written[data_set] ==
false)
5452 out <<
" <DataArray type=\"Float32\" Name=\""
5453 << data_names[data_set] <<
"\" format=\"" << ascii_or_binary
5456 std::vector<float> data(data_vectors[data_set].
begin(),
5457 data_vectors[data_set].
end());
5459 out <<
" </DataArray>\n";
5462 out <<
" </PointData>\n";
5465 out <<
" </Piece>\n";
5479 const std::vector<std::string> &piece_names,
5480 const std::vector<std::string> &data_names,
5482 std::tuple<
unsigned int,
5486 &nonscalar_data_ranges)
5490 const unsigned int n_data_sets = data_names.size();
5492 out <<
"<?xml version=\"1.0\"?>\n";
5495 out <<
"#This file was generated by the deal.II library"
5500 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
5501 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
5502 out <<
" <PPointData Scalars=\"scalars\">\n";
5505 std::vector<bool> data_set_written(n_data_sets,
false);
5506 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
5508 const auto first_component = std::get<0>(nonscalar_data_range);
5509 const auto last_component = std::get<1>(nonscalar_data_range);
5510 const bool is_tensor =
5511 (std::get<3>(nonscalar_data_range) ==
5520 AssertThrow((last_component + 1 - first_component <= 9),
5522 "Can't declare a tensor with more than 9 components "
5527 Assert((last_component + 1 - first_component <= 3),
5529 "Can't declare a vector with more than 3 components "
5534 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5535 i <= std::get<1>(nonscalar_data_range);
5537 data_set_written[i] =
true;
5541 out <<
" <PDataArray type=\"Float32\" Name=\"";
5543 if (!std::get<2>(nonscalar_data_range).empty())
5544 out << std::get<2>(nonscalar_data_range);
5547 for (
unsigned int i = std::get<0>(nonscalar_data_range);
5548 i < std::get<1>(nonscalar_data_range);
5550 out << data_names[i] <<
"__";
5551 out << data_names[std::get<1>(nonscalar_data_range)];
5555 <<
"\" format=\"ascii\"/>\n";
5558 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
5559 if (data_set_written[data_set] ==
false)
5561 out <<
" <PDataArray type=\"Float32\" Name=\""
5562 << data_names[data_set] <<
"\" format=\"ascii\"/>\n";
5565 out <<
" </PPointData>\n";
5567 out <<
" <PPoints>\n";
5568 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
5569 out <<
" </PPoints>\n";
5571 for (
const auto &piece_name : piece_names)
5572 out <<
" <Piece Source=\"" << piece_name <<
"\"/>\n";
5574 out <<
" </PUnstructuredGrid>\n";
5575 out <<
"</VTKFile>\n";
5588 const std::vector<std::pair<double, std::string>> ×_and_names)
5592 out <<
"<?xml version=\"1.0\"?>\n";
5595 out <<
"#This file was generated by the deal.II library"
5600 <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
5601 out <<
" <Collection>\n";
5603 std::streamsize ss = out.precision();
5606 for (
const auto &time_and_name : times_and_names)
5607 out <<
" <DataSet timestep=\"" << time_and_name.first
5608 <<
"\" group=\"\" part=\"0\" file=\"" << time_and_name.second
5611 out <<
" </Collection>\n";
5612 out <<
"</VTKFile>\n";
5624 const std::vector<std::string> &piece_names)
5626 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
5627 for (
const auto &piece_name : piece_names)
5628 out << piece_name <<
'\n';
5637 const std::vector<std::vector<std::string>> &piece_names)
5641 if (piece_names.size() == 0)
5644 const double nblocks = piece_names[0].size();
5646 ExcMessage(
"piece_names should be a vector of nonempty vectors."));
5648 out <<
"!NBLOCKS " << nblocks <<
'\n';
5649 for (
const auto &domain : piece_names)
5651 Assert(domain.size() == nblocks,
5653 "piece_names should be a vector of equal sized vectors."));
5654 for (
const auto &subdomain : domain)
5655 out << subdomain <<
'\n';
5666 const std::vector<std::pair<
double, std::vector<std::string>>>
5667 ×_and_piece_names)
5671 if (times_and_piece_names.size() == 0)
5674 const double nblocks = times_and_piece_names[0].second.size();
5678 "time_and_piece_names should contain nonempty vectors of filenames for every timestep."));
5680 for (
const auto &domain : times_and_piece_names)
5681 out <<
"!TIME " << domain.first <<
'\n';
5683 out <<
"!NBLOCKS " << nblocks <<
'\n';
5684 for (
const auto &domain : times_and_piece_names)
5686 Assert(domain.second.size() == nblocks,
5688 "piece_names should be a vector of equal sized vectors."));
5689 for (
const auto &subdomain : domain.second)
5690 out << subdomain <<
'\n';
5698 template <
int dim,
int spacedim>
5702 const std::vector<std::string> &,
5704 std::tuple<
unsigned int,
5714 template <
int spacedim>
5718 const std::vector<std::string> & ,
5720 std::tuple<
unsigned int,
5728 const unsigned int height = flags.
height;
5729 unsigned int width = flags.
width;
5732 unsigned int margin_in_percent = 0;
5734 margin_in_percent = 5;
5738 double x_dimension, y_dimension, z_dimension;
5740 const auto &first_patch = patches[0];
5742 unsigned int n_subdivisions = first_patch.n_subdivisions;
5743 unsigned int n = n_subdivisions + 1;
5744 const unsigned int d1 = 1;
5745 const unsigned int d2 = n;
5748 std::array<Point<spacedim>, 4> projected_points;
5751 std::array<Point<2>, 4> projection_decompositions;
5753 projected_point = compute_node(first_patch, 0, 0, 0, n_subdivisions);
5755 if (first_patch.data.n_rows() != 0)
5760 double x_min = projected_point[0];
5761 double x_max = x_min;
5762 double y_min = projected_point[1];
5763 double y_max = y_min;
5764 double z_min = first_patch.data.n_rows() != 0 ?
5767 double z_max = z_min;
5770 for (
const auto &patch : patches)
5773 n = n_subdivisions + 1;
5775 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5777 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5779 projected_points[0] =
5780 compute_node(patch, i1, i2, 0, n_subdivisions);
5781 projected_points[1] =
5782 compute_node(patch, i1 + 1, i2, 0, n_subdivisions);
5783 projected_points[2] =
5784 compute_node(patch, i1, i2 + 1, 0, n_subdivisions);
5785 projected_points[3] =
5786 compute_node(patch, i1 + 1, i2 + 1, 0, n_subdivisions);
5788 x_min =
std::min(x_min, projected_points[0][0]);
5789 x_min =
std::min(x_min, projected_points[1][0]);
5790 x_min =
std::min(x_min, projected_points[2][0]);
5791 x_min =
std::min(x_min, projected_points[3][0]);
5793 x_max =
std::max(x_max, projected_points[0][0]);
5794 x_max =
std::max(x_max, projected_points[1][0]);
5795 x_max =
std::max(x_max, projected_points[2][0]);
5796 x_max =
std::max(x_max, projected_points[3][0]);
5798 y_min =
std::min(y_min, projected_points[0][1]);
5799 y_min =
std::min(y_min, projected_points[1][1]);
5800 y_min =
std::min(y_min, projected_points[2][1]);
5801 y_min =
std::min(y_min, projected_points[3][1]);
5803 y_max =
std::max(y_max, projected_points[0][1]);
5804 y_max =
std::max(y_max, projected_points[1][1]);
5805 y_max =
std::max(y_max, projected_points[2][1]);
5806 y_max =
std::max(y_max, projected_points[3][1]);
5809 patch.
data.n_rows() == 0,
5812 patch.
data.n_rows()));
5814 z_min = std::min<double>(z_min,
5816 i1 * d1 + i2 * d2));
5817 z_min = std::min<double>(z_min,
5819 (i1 + 1) * d1 + i2 * d2));
5820 z_min = std::min<double>(z_min,
5822 i1 * d1 + (i2 + 1) * d2));
5824 std::min<double>(z_min,
5826 (i1 + 1) * d1 + (i2 + 1) * d2));
5828 z_max = std::max<double>(z_max,
5830 i1 * d1 + i2 * d2));
5831 z_max = std::max<double>(z_max,
5833 (i1 + 1) * d1 + i2 * d2));
5834 z_max = std::max<double>(z_max,
5836 i1 * d1 + (i2 + 1) * d2));
5838 std::max<double>(z_max,
5840 (i1 + 1) * d1 + (i2 + 1) * d2));
5845 x_dimension = x_max - x_min;
5846 y_dimension = y_max - y_min;
5847 z_dimension = z_max - z_min;
5854 float camera_focus = 0;
5857 camera_position[0] = 0.;
5858 camera_position[1] = 0.;
5859 camera_position[2] = z_min + 2. * z_dimension;
5861 camera_direction[0] = 0.;
5862 camera_direction[1] = 0.;
5863 camera_direction[2] = -1.;
5865 camera_horizontal[0] = 1.;
5866 camera_horizontal[1] = 0.;
5867 camera_horizontal[2] = 0.;
5869 camera_focus = .5 * z_dimension;
5875 const float angle_factor = 3.14159265f / 180.f;
5878 camera_position_temp[1] =
5879 std::cos(angle_factor * flags.
polar_angle) * camera_position[1] -
5880 std::sin(angle_factor * flags.
polar_angle) * camera_position[2];
5881 camera_position_temp[2] =
5882 std::sin(angle_factor * flags.
polar_angle) * camera_position[1] +
5883 std::cos(angle_factor * flags.
polar_angle) * camera_position[2];
5885 camera_direction_temp[1] =
5886 std::cos(angle_factor * flags.
polar_angle) * camera_direction[1] -
5887 std::sin(angle_factor * flags.
polar_angle) * camera_direction[2];
5888 camera_direction_temp[2] =
5889 std::sin(angle_factor * flags.
polar_angle) * camera_direction[1] +
5890 std::cos(angle_factor * flags.
polar_angle) * camera_direction[2];
5892 camera_horizontal_temp[1] =
5893 std::cos(angle_factor * flags.
polar_angle) * camera_horizontal[1] -
5894 std::sin(angle_factor * flags.
polar_angle) * camera_horizontal[2];
5895 camera_horizontal_temp[2] =
5896 std::sin(angle_factor * flags.
polar_angle) * camera_horizontal[1] +
5897 std::cos(angle_factor * flags.
polar_angle) * camera_horizontal[2];
5899 camera_position[1] = camera_position_temp[1];
5900 camera_position[2] = camera_position_temp[2];
5902 camera_direction[1] = camera_direction_temp[1];
5903 camera_direction[2] = camera_direction_temp[2];
5905 camera_horizontal[1] = camera_horizontal_temp[1];
5906 camera_horizontal[2] = camera_horizontal_temp[2];
5909 camera_position_temp[0] =
5910 std::cos(angle_factor * flags.
azimuth_angle) * camera_position[0] -
5911 std::sin(angle_factor * flags.
azimuth_angle) * camera_position[1];
5912 camera_position_temp[1] =
5913 std::sin(angle_factor * flags.
azimuth_angle) * camera_position[0] +
5914 std::cos(angle_factor * flags.
azimuth_angle) * camera_position[1];
5916 camera_direction_temp[0] =
5917 std::cos(angle_factor * flags.
azimuth_angle) * camera_direction[0] -
5918 std::sin(angle_factor * flags.
azimuth_angle) * camera_direction[1];
5919 camera_direction_temp[1] =
5920 std::sin(angle_factor * flags.
azimuth_angle) * camera_direction[0] +
5921 std::cos(angle_factor * flags.
azimuth_angle) * camera_direction[1];
5923 camera_horizontal_temp[0] =
5924 std::cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] -
5925 std::sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5926 camera_horizontal_temp[1] =
5927 std::sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] +
5928 std::cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5930 camera_position[0] = camera_position_temp[0];
5931 camera_position[1] = camera_position_temp[1];
5933 camera_direction[0] = camera_direction_temp[0];
5934 camera_direction[1] = camera_direction_temp[1];
5936 camera_horizontal[0] = camera_horizontal_temp[0];
5937 camera_horizontal[1] = camera_horizontal_temp[1];
5940 camera_position[0] = x_min + .5 * x_dimension;
5941 camera_position[1] = y_min + .5 * y_dimension;
5943 camera_position[0] += (z_min + 2. * z_dimension) *
5946 camera_position[1] -= (z_min + 2. * z_dimension) *
5952 double x_min_perspective, y_min_perspective;
5953 double x_max_perspective, y_max_perspective;
5954 double x_dimension_perspective, y_dimension_perspective;
5956 n_subdivisions = first_patch.n_subdivisions;
5957 n = n_subdivisions + 1;
5961 projected_point = compute_node(first_patch, 0, 0, 0, n_subdivisions);
5963 if (first_patch.data.n_rows() != 0)
5968 point[0] = projected_point[0];
5969 point[1] = projected_point[1];
5970 point[2] = first_patch.data.n_rows() != 0 ?
5974 projection_decomposition = svg_project_point(
point,
5980 x_min_perspective = projection_decomposition[0];
5981 x_max_perspective = projection_decomposition[0];
5982 y_min_perspective = projection_decomposition[1];
5983 y_max_perspective = projection_decomposition[1];
5986 for (
const auto &patch : patches)
5989 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5991 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5994 {compute_node(patch, i1, i2, 0, n_subdivisions),
5995 compute_node(patch, i1 + 1, i2, 0, n_subdivisions),
5996 compute_node(patch, i1, i2 + 1, 0, n_subdivisions),
5997 compute_node(patch, i1 + 1, i2 + 1, 0, n_subdivisions)}};
6000 patch.
data.n_rows() == 0,
6003 patch.
data.n_rows()));
6005 const std::array<Point<3>, 4>
vertices = {
6008 patch.
data.n_rows() != 0 ?
6009 patch.
data(0, i1 * d1 + i2 * d2) :
6013 patch.
data.n_rows() != 0 ?
6014 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6018 patch.
data.n_rows() != 0 ?
6019 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6023 patch.
data.n_rows() != 0 ?
6024 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6027 projection_decompositions = {
6051 static_cast<double>(
6052 projection_decompositions[0][0]));
6055 static_cast<double>(
6056 projection_decompositions[1][0]));
6059 static_cast<double>(
6060 projection_decompositions[2][0]));
6063 static_cast<double>(
6064 projection_decompositions[3][0]));
6068 static_cast<double>(
6069 projection_decompositions[0][0]));
6072 static_cast<double>(
6073 projection_decompositions[1][0]));
6076 static_cast<double>(
6077 projection_decompositions[2][0]));
6080 static_cast<double>(
6081 projection_decompositions[3][0]));
6085 static_cast<double>(
6086 projection_decompositions[0][1]));
6089 static_cast<double>(
6090 projection_decompositions[1][1]));
6093 static_cast<double>(
6094 projection_decompositions[2][1]));
6097 static_cast<double>(
6098 projection_decompositions[3][1]));
6102 static_cast<double>(
6103 projection_decompositions[0][1]));
6106 static_cast<double>(
6107 projection_decompositions[1][1]));
6110 static_cast<double>(
6111 projection_decompositions[2][1]));
6114 static_cast<double>(
6115 projection_decompositions[3][1]));
6120 x_dimension_perspective = x_max_perspective - x_min_perspective;
6121 y_dimension_perspective = y_max_perspective - y_min_perspective;
6123 std::multiset<SvgCell> cells;
6126 for (
const auto &patch : patches)
6130 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6132 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6135 {compute_node(patch, i1, i2, 0, n_subdivisions),
6136 compute_node(patch, i1 + 1, i2, 0, n_subdivisions),
6137 compute_node(patch, i1, i2 + 1, 0, n_subdivisions),
6138 compute_node(patch, i1 + 1, i2 + 1, 0, n_subdivisions)}};
6141 patch.
data.n_rows() == 0,
6144 patch.
data.n_rows()));
6150 cell.vertices[0][2] = patch.
data.n_rows() != 0 ?
6151 patch.
data(0, i1 * d1 + i2 * d2) :
6156 cell.vertices[1][2] = patch.
data.n_rows() != 0 ?
6157 patch.
data(0, (i1 + 1) * d1 + i2 * d2) :
6162 cell.vertices[2][2] = patch.
data.n_rows() != 0 ?
6163 patch.
data(0, i1 * d1 + (i2 + 1) * d2) :
6168 cell.vertices[3][2] =
6169 patch.
data.n_rows() != 0 ?
6170 patch.
data(0, (i1 + 1) * d1 + (i2 + 1) * d2) :
6173 cell.projected_vertices[0] =
6174 svg_project_point(cell.vertices[0],
6179 cell.projected_vertices[1] =
6180 svg_project_point(cell.vertices[1],
6185 cell.projected_vertices[2] =
6186 svg_project_point(cell.vertices[2],
6191 cell.projected_vertices[3] =
6192 svg_project_point(cell.vertices[3],
6198 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] +
6199 cell.vertices[2] + cell.vertices[3]);
6200 cell.projected_center = svg_project_point(cell.center,
6206 cell.depth = cell.center.distance(camera_position);
6216 width =
static_cast<unsigned int>(
6217 .5 + height * (x_dimension_perspective / y_dimension_perspective));
6218 unsigned int additional_width = 0;
6221 additional_width =
static_cast<unsigned int>(
6225 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\""
6226 << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">"
6228 <<
" <rect width=\"" << width + additional_width <<
"\" height=\""
6229 << height <<
"\" style=\"fill:white\"/>" <<
'\n'
6232 unsigned int triangle_counter = 0;
6235 for (
const auto &cell : cells)
6239 for (
unsigned int triangle_index = 0; triangle_index < 4;
6242 switch (triangle_index)
6245 points3d_triangle[0] = cell.vertices[0],
6246 points3d_triangle[1] = cell.vertices[1],
6247 points3d_triangle[2] = cell.center;
6250 points3d_triangle[0] = cell.vertices[1],
6251 points3d_triangle[1] = cell.vertices[3],
6252 points3d_triangle[2] = cell.center;
6255 points3d_triangle[0] = cell.vertices[3],
6256 points3d_triangle[1] = cell.vertices[2],
6257 points3d_triangle[2] = cell.center;
6260 points3d_triangle[0] = cell.vertices[2],
6261 points3d_triangle[1] = cell.vertices[0],
6262 points3d_triangle[2] = cell.center;
6269 svg_get_gradient_parameters(points3d_triangle);
6272 .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
6274 .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
6276 unsigned int start_r = 0;
6277 unsigned int start_g = 0;
6278 unsigned int start_b = 0;
6280 unsigned int stop_r = 0;
6281 unsigned int stop_g = 0;
6282 unsigned int stop_b = 0;
6284 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6285 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6287 double start_f = start_h * 6. - start_i;
6288 double start_q = 1. - start_f;
6290 double stop_f = stop_h * 6. - stop_i;
6291 double stop_q = 1. - stop_f;
6293 switch (start_i % 6)
6297 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6300 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
6305 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6308 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
6312 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
6317 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6327 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6330 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
6335 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6338 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
6342 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
6347 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6353 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
6355 gradient_start_point_3d[0] = gradient_param[0];
6356 gradient_start_point_3d[1] = gradient_param[1];
6357 gradient_start_point_3d[2] = gradient_param[4];
6359 gradient_stop_point_3d[0] = gradient_param[2];
6360 gradient_stop_point_3d[1] = gradient_param[3];
6361 gradient_stop_point_3d[2] = gradient_param[5];
6364 svg_project_point(gradient_start_point_3d,
6370 svg_project_point(gradient_stop_point_3d,
6377 out <<
" <linearGradient id=\"" << triangle_counter
6378 <<
"\" gradientUnits=\"userSpaceOnUse\" "
6380 <<
static_cast<unsigned int>(
6382 ((gradient_start_point[0] - x_min_perspective) /
6383 x_dimension_perspective) *
6384 (width - (width / 100.) * 2. * margin_in_percent) +
6385 ((width / 100.) * margin_in_percent))
6388 <<
static_cast<unsigned int>(
6389 .5 + height - (height / 100.) * margin_in_percent -
6390 ((gradient_start_point[1] - y_min_perspective) /
6391 y_dimension_perspective) *
6392 (height - (height / 100.) * 2. * margin_in_percent))
6395 <<
static_cast<unsigned int>(
6397 ((gradient_stop_point[0] - x_min_perspective) /
6398 x_dimension_perspective) *
6399 (width - (width / 100.) * 2. * margin_in_percent) +
6400 ((width / 100.) * margin_in_percent))
6403 <<
static_cast<unsigned int>(
6404 .5 + height - (height / 100.) * margin_in_percent -
6405 ((gradient_stop_point[1] - y_min_perspective) /
6406 y_dimension_perspective) *
6407 (height - (height / 100.) * 2. * margin_in_percent))
6410 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
6411 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
6412 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
6413 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
6414 <<
" </linearGradient>" <<
'\n';
6417 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
6418 double x3 = cell.projected_center[0];
6419 double y3 = cell.projected_center[1];
6421 switch (triangle_index)
6424 x1 = cell.projected_vertices[0][0],
6425 y1 = cell.projected_vertices[0][1],
6426 x2 = cell.projected_vertices[1][0],
6427 y2 = cell.projected_vertices[1][1];
6430 x1 = cell.projected_vertices[1][0],
6431 y1 = cell.projected_vertices[1][1],
6432 x2 = cell.projected_vertices[3][0],
6433 y2 = cell.projected_vertices[3][1];
6436 x1 = cell.projected_vertices[3][0],
6437 y1 = cell.projected_vertices[3][1],
6438 x2 = cell.projected_vertices[2][0],
6439 y2 = cell.projected_vertices[2][1];
6442 x1 = cell.projected_vertices[2][0],
6443 y1 = cell.projected_vertices[2][1],
6444 x2 = cell.projected_vertices[0][0],
6445 y2 = cell.projected_vertices[0][1];
6451 out <<
" <path d=\"M "
6452 <<
static_cast<unsigned int>(
6454 ((x1 - x_min_perspective) / x_dimension_perspective) *
6455 (width - (width / 100.) * 2. * margin_in_percent) +
6456 ((width / 100.) * margin_in_percent))
6458 <<
static_cast<unsigned int>(
6459 .5 + height - (height / 100.) * margin_in_percent -
6460 ((y1 - y_min_perspective) / y_dimension_perspective) *
6461 (height - (height / 100.) * 2. * margin_in_percent))
6463 <<
static_cast<unsigned int>(
6465 ((x2 - x_min_perspective) / x_dimension_perspective) *
6466 (width - (width / 100.) * 2. * margin_in_percent) +
6467 ((width / 100.) * margin_in_percent))
6469 <<
static_cast<unsigned int>(
6470 .5 + height - (height / 100.) * margin_in_percent -
6471 ((y2 - y_min_perspective) / y_dimension_perspective) *
6472 (height - (height / 100.) * 2. * margin_in_percent))
6474 <<
static_cast<unsigned int>(
6476 ((x3 - x_min_perspective) / x_dimension_perspective) *
6477 (width - (width / 100.) * 2. * margin_in_percent) +
6478 ((width / 100.) * margin_in_percent))
6480 <<
static_cast<unsigned int>(
6481 .5 + height - (height / 100.) * margin_in_percent -
6482 ((y3 - y_min_perspective) / y_dimension_perspective) *
6483 (height - (height / 100.) * 2. * margin_in_percent))
6485 <<
static_cast<unsigned int>(
6487 ((x1 - x_min_perspective) / x_dimension_perspective) *
6488 (width - (width / 100.) * 2. * margin_in_percent) +
6489 ((width / 100.) * margin_in_percent))
6491 <<
static_cast<unsigned int>(
6492 .5 + height - (height / 100.) * margin_in_percent -
6493 ((y1 - y_min_perspective) / y_dimension_perspective) *
6494 (height - (height / 100.) * 2. * margin_in_percent))
6495 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter
6506 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
6508 unsigned int element_height =
static_cast<unsigned int>(
6509 ((height / 100.) * (71. - 2. * margin_in_percent)) / 4);
6510 unsigned int element_width =
6511 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
6513 additional_width = 0;
6516 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
6518 for (
unsigned int index = 0; index < 4; index++)
6520 double start_h = .667 - ((index + 1) / 4.) * .667;
6521 double stop_h = .667 - (index / 4.) * .667;
6523 unsigned int start_r = 0;
6524 unsigned int start_g = 0;
6525 unsigned int start_b = 0;
6527 unsigned int stop_r = 0;
6528 unsigned int stop_g = 0;
6529 unsigned int stop_b = 0;
6531 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6532 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6534 double start_f = start_h * 6. - start_i;
6535 double start_q = 1. - start_f;
6537 double stop_f = stop_h * 6. - stop_i;
6538 double stop_q = 1. - stop_f;
6540 switch (start_i % 6)
6544 start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6547 start_r =
static_cast<unsigned int>(.5 + 255. * start_q),
6552 start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6555 start_g =
static_cast<unsigned int>(.5 + 255. * start_q),
6559 start_r =
static_cast<unsigned int>(.5 + 255. * start_f),
6564 start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6574 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6577 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q),
6582 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6585 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q),
6589 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f),
6594 stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6601 out <<
" <linearGradient id=\"colorbar_" << index
6602 <<
"\" gradientUnits=\"userSpaceOnUse\" "
6603 <<
"x1=\"" << width + additional_width <<
"\" "
6605 <<
static_cast<unsigned int>(.5 + (height / 100.) *
6606 (margin_in_percent + 29)) +
6607 (3 - index) * element_height
6609 <<
"x2=\"" << width + additional_width <<
"\" "
6611 <<
static_cast<unsigned int>(.5 + (height / 100.) *
6612 (margin_in_percent + 29)) +
6613 (4 - index) * element_height
6616 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r
6617 <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n'
6618 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r
6619 <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n'
6620 <<
" </linearGradient>" <<
'\n';
6625 <<
" x=\"" << width + additional_width <<
"\" y=\""
6626 <<
static_cast<unsigned int>(.5 + (height / 100.) *
6627 (margin_in_percent + 29)) +
6628 (3 - index) * element_height
6629 <<
"\" width=\"" << element_width <<
"\" height=\""
6631 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_"
6632 << index <<
")\"/>" <<
'\n';
6635 for (
unsigned int index = 0; index < 5; index++)
6639 << width + additional_width +
6640 static_cast<unsigned int>(1.5 * element_width)
6642 <<
static_cast<unsigned int>(
6643 .5 + (height / 100.) * (margin_in_percent + 29) +
6644 (4. - index) * element_height + 30.)
6646 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
6648 if (index == 0 || index == 4)
6649 out <<
"; font-weight:bold";
6652 <<
static_cast<float>(
6653 (
static_cast<int>((z_min + index * (z_dimension / 4.)) *
6662 out <<
"</text>" <<
'\n';
6667 out <<
'\n' <<
"</svg>";
6673 template <
int dim,
int spacedim>
6677 const std::vector<std::string> & data_names,
6679 std::tuple<
unsigned int,
6683 &nonscalar_data_ranges,
6692 out << dim <<
' ' << spacedim <<
'\n';
6695 out <<
"[deal.II intermediate format graphics data]" <<
'\n'
6698 <<
"[Version: " << Deal_II_IntermediateFlags::format_version <<
"]"
6701 out << data_names.size() <<
'\n';
6702 for (
const auto &data_name : data_names)
6703 out << data_name <<
'\n';
6705 out << patches.size() <<
'\n';
6706 for (
unsigned int i = 0; i < patches.size(); ++i)
6707 out << patches[i] <<
'\n';
6709 out << nonscalar_data_ranges.size() <<
'\n';
6710 for (
const auto &nonscalar_data_range : nonscalar_data_ranges)
6711 out << std::get<0>(nonscalar_data_range) <<
' '
6712 << std::get<1>(nonscalar_data_range) <<
'\n'
6713 << std::get<2>(nonscalar_data_range) <<
'\n';
6722 std::pair<unsigned int, unsigned int>
6727 unsigned int dim, spacedim;
6728 input >> dim >> spacedim;
6730 return std::make_pair(dim, spacedim);
6739 template <
int dim,
int spacedim>
6741 : default_subdivisions(1)
6747 template <
int dim,
int spacedim>
6752 get_dataset_names(),
6753 get_nonscalar_data_ranges(),
6760 template <
int dim,
int spacedim>
6765 get_dataset_names(),
6766 get_nonscalar_data_ranges(),
6773 template <
int dim,
int spacedim>
6778 get_dataset_names(),
6779 get_nonscalar_data_ranges(),
6786 template <
int dim,
int spacedim>
6791 get_dataset_names(),
6792 get_nonscalar_data_ranges(),
6799 template <
int dim,
int spacedim>
6804 get_dataset_names(),
6805 get_nonscalar_data_ranges(),
6812 template <
int dim,
int spacedim>
6817 get_dataset_names(),
6818 get_nonscalar_data_ranges(),
6825 template <
int dim,
int spacedim>
6830 get_dataset_names(),
6831 get_nonscalar_data_ranges(),
6838 template <
int dim,
int spacedim>
6843 get_dataset_names(),
6844 get_nonscalar_data_ranges(),
6851 template <
int dim,
int spacedim>
6856 get_dataset_names(),
6857 get_nonscalar_data_ranges(),
6862 template <
int dim,
int spacedim>
6867 get_dataset_names(),
6868 get_nonscalar_data_ranges(),
6873 template <
int dim,
int spacedim>
6878 get_dataset_names(),
6879 get_nonscalar_data_ranges(),
6884 template <
int dim,
int spacedim>
6887 const std::string &filename,
6890 #ifndef DEAL_II_WITH_MPI
6894 std::ofstream f(filename);
6901 int ierr = MPI_Info_create(&info);
6904 ierr = MPI_File_open(comm,
6906 MPI_MODE_CREATE | MPI_MODE_WRONLY,
6911 ierr = MPI_File_set_size(fh, 0);
6915 ierr = MPI_Barrier(comm);
6917 ierr = MPI_Info_free(&info);
6920 unsigned int header_size;
6925 std::stringstream ss;
6927 header_size = ss.str().size();
6928 ierr = MPI_File_write(fh,
6936 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0, comm);
6939 ierr = MPI_File_seek_shared(fh, header_size, MPI_SEEK_SET);
6942 const auto &patches = get_patches();
6951 std::stringstream ss;
6952 if (my_n_patches > 0 || (global_n_patches == 0 && myrank == 0))
6954 get_dataset_names(),
6955 get_nonscalar_data_ranges(),
6959 ierr = MPI_File_write_ordered(fh,
6970 std::stringstream ss;
6972 unsigned int footer_size = ss.str().size();
6973 ierr = MPI_File_write_shared(fh,
6980 ierr = MPI_File_close(&fh);
6986 template <
int dim,
int spacedim>
6990 const std::vector<std::string> &piece_names)
const
6994 get_dataset_names(),
6995 get_nonscalar_data_ranges());
6999 template <
int dim,
int spacedim>
7002 const std::string &directory,
7003 const std::string &filename_without_extension,
7004 const unsigned int counter,
7006 const unsigned int n_digits_for_counter,
7007 const unsigned int n_groups)
const
7010 const unsigned int n_ranks =
7012 const unsigned int n_files_written =
7013 (n_groups == 0 || n_groups > n_ranks) ? n_ranks : n_groups;
7018 const unsigned int n_digits =
7021 const unsigned int color = rank % n_files_written;
7022 const std::string filename =
7023 directory + filename_without_extension +
"_" +
7027 if (n_groups == 0 || n_groups > n_ranks)
7030 std::ofstream output(filename.c_str());
7033 else if (n_groups == 1)
7036 this->write_vtu_in_parallel(filename.c_str(), mpi_communicator);
7040 #ifdef DEAL_II_WITH_MPI
7043 int ierr = MPI_Comm_split(mpi_communicator, color, rank, &comm_group);
7045 this->write_vtu_in_parallel(filename.c_str(), comm_group);
7046 ierr = MPI_Comm_free(&comm_group);
7054 const std::string filename_master =
7055 filename_without_extension +
"_" +
7060 std::vector<std::string> filename_vector;
7061 for (
unsigned int i = 0; i < n_files_written; ++i)
7063 const std::string filename =
7064 filename_without_extension +
"_" +
7068 filename_vector.emplace_back(filename);
7071 std::ofstream master_output((directory + filename_master).c_str());
7075 return filename_master;
7080 template <
int dim,
int spacedim>
7083 std::ostream &out)
const
7086 get_dataset_names(),
7087 get_nonscalar_data_ranges(),
7088 deal_II_intermediate_flags,
7093 template <
int dim,
int spacedim>
7097 const std::string & h5_filename,
7098 const double cur_time,
7101 return create_xdmf_entry(
7102 data_filter, h5_filename, h5_filename, cur_time, comm);
7107 template <
int dim,
int spacedim>
7111 const std::string & h5_mesh_filename,
7112 const std::string & h5_solution_filename,
7113 const double cur_time,
7116 unsigned int local_node_cell_count[2], global_node_cell_count[2];
7118 #ifndef DEAL_II_WITH_HDF5
7122 (void)h5_mesh_filename;
7123 (void)h5_solution_filename;
7129 ExcMessage(
"XDMF only supports 2 or 3 space dimensions."));
7131 local_node_cell_count[0] = data_filter.
n_nodes();
7132 local_node_cell_count[1] = data_filter.
n_cells();
7135 #ifdef DEAL_II_WITH_MPI
7137 int ierr = MPI_Allreduce(local_node_cell_count,
7138 global_node_cell_count,
7146 const int myrank = 0;
7147 global_node_cell_count[0] = local_node_cell_count[0];
7148 global_node_cell_count[1] = local_node_cell_count[1];
7155 h5_solution_filename,
7157 global_node_cell_count[0],
7158 global_node_cell_count[1],
7161 unsigned int n_data_sets = data_filter.
n_data_sets();
7166 for (i = 0; i < n_data_sets; ++i)
7180 template <
int dim,
int spacedim>
7183 const std::vector<XDMFEntry> &entries,
7184 const std::string & filename,
7187 #ifdef DEAL_II_WITH_MPI
7191 const int myrank = 0;
7197 std::ofstream xdmf_file(filename.c_str());
7198 std::vector<XDMFEntry>::const_iterator it;
7200 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
7201 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
7202 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
7203 xdmf_file <<
" <Domain>\n";
7205 <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
7208 for (it = entries.begin(); it != entries.end(); ++it)
7209 xdmf_file << it->get_xdmf_content(3);
7211 xdmf_file <<
" </Grid>\n";
7212 xdmf_file <<
" </Domain>\n";
7213 xdmf_file <<
"</Xdmf>\n";
7225 template <
int dim,
int spacedim>
7231 get_dataset_names(),
7232 get_nonscalar_data_ranges(),
7238 template <
int dim,
int spacedim>
7242 const std::vector<std::string> & data_names,
7244 std::tuple<
unsigned int,
7248 & nonscalar_data_ranges,
7251 const unsigned int n_data_sets = data_names.size();
7252 unsigned int n_node, n_cell;
7256 #ifndef DEAL_II_WITH_MPI
7265 if (patches.size() == 0)
7269 compute_sizes<dim, spacedim>(patches, n_node, n_cell);
7272 void (*fun_ptr)(
const std::vector<Patch<dim, spacedim>> &,
7274 &DataOutBase::template write_gmv_reorder_data_vectors<dim, spacedim>;
7282 reorder_task.
join();
7286 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
7287 std::string vector_name;
7288 for (n_th_vector = 0, data_set = 0; data_set < n_data_sets;)
7291 while (n_th_vector < nonscalar_data_ranges.size() &&
7292 std::get<0>(nonscalar_data_ranges[n_th_vector]) < data_set)
7296 if (n_th_vector < nonscalar_data_ranges.size() &&
7297 std::get<0>(nonscalar_data_ranges[n_th_vector]) == data_set)
7300 pt_data_vector_dim = std::get<1>(nonscalar_data_ranges[n_th_vector]) -
7301 std::get<0>(nonscalar_data_ranges[n_th_vector]) +
7306 std::get<1>(nonscalar_data_ranges[n_th_vector]) >=
7307 std::get<0>(nonscalar_data_ranges[n_th_vector]),
7308 ExcLowerRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
7309 std::get<0>(nonscalar_data_ranges[n_th_vector])));
7311 std::get<1>(nonscalar_data_ranges[n_th_vector]) < n_data_sets,
7312 ExcIndexRange(std::get<1>(nonscalar_data_ranges[n_th_vector]),
7318 if (!std::get<2>(nonscalar_data_ranges[n_th_vector]).empty())
7320 vector_name = std::get<2>(nonscalar_data_ranges[n_th_vector]);
7325 for (i = std::get<0>(nonscalar_data_ranges[n_th_vector]);
7326 i < std::get<1>(nonscalar_data_ranges[n_th_vector]);
7328 vector_name += data_names[i] +
"__";
7330 data_names[std::get<1>(nonscalar_data_ranges[n_th_vector])];
7336 pt_data_vector_dim = 1;
7337 vector_name = data_names[data_set];
7347 data_set += pt_data_vector_dim;
7353 template <
int dim,
int spacedim>
7357 const std::string & filename,
7365 template <
int dim,
int spacedim>
7369 const bool write_mesh_file,
7370 const std::string & mesh_filename,
7371 const std::string & solution_filename,
7384 template <
int dim,
int spacedim>
7389 const std::string & filename,
7397 template <
int dim,
int spacedim>
7402 const bool write_mesh_file,
7403 const std::string & mesh_filename,
7404 const std::string & solution_filename,
7410 "DataOutBase was asked to write HDF5 output for a space dimension of 1. "
7411 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
7415 #ifndef DEAL_II_WITH_HDF5
7419 (void)write_mesh_file;
7420 (void)mesh_filename;
7421 (void)solution_filename;
7425 # ifndef DEAL_II_WITH_MPI
7436 hid_t h5_mesh_file_id = -1, h5_solution_file_id, file_plist_id, plist_id;
7437 hid_t node_dataspace, node_dataset, node_file_dataspace,
7438 node_memory_dataspace;
7439 hid_t cell_dataspace, cell_dataset, cell_file_dataspace,
7440 cell_memory_dataspace;
7441 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace,
7442 pt_data_memory_dataspace;
7444 unsigned int local_node_cell_count[2];
7445 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
7446 std::vector<double> node_data_vec;
7447 std::vector<unsigned int> cell_data_vec;
7450 # ifndef H5_HAVE_PARALLEL
7451 # ifdef DEAL_II_WITH_MPI
7456 "Serial HDF5 output on multiple processes is not yet supported."));
7460 local_node_cell_count[0] = data_filter.
n_nodes();
7461 local_node_cell_count[1] = data_filter.
n_cells();
7464 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
7467 # ifdef DEAL_II_WITH_MPI
7468 # ifdef H5_HAVE_PARALLEL
7470 status = H5Pset_fapl_mpio(file_plist_id, comm, MPI_INFO_NULL);
7478 unsigned int global_node_cell_count[2] = {0, 0};
7479 unsigned int global_node_cell_offsets[2] = {0, 0};
7481 # ifdef DEAL_II_WITH_MPI
7482 ierr = MPI_Allreduce(local_node_cell_count,
7483 global_node_cell_count,
7489 ierr = MPI_Exscan(local_node_cell_count,
7490 global_node_cell_offsets,
7497 global_node_cell_count[0] = local_node_cell_count[0];
7498 global_node_cell_count[1] = local_node_cell_count[1];
7499 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
7503 plist_id = H5Pcreate(H5P_DATASET_XFER);
7505 # ifdef DEAL_II_WITH_MPI
7506 # ifdef H5_HAVE_PARALLEL
7507 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
7512 if (write_mesh_file)
7515 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(),
7523 node_ds_dim[0] = global_node_cell_count[0];
7524 node_ds_dim[1] = (spacedim < 2) ? 2 : spacedim;
7525 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
7528 cell_ds_dim[0] = global_node_cell_count[1];
7530 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
7534 # if H5Gcreate_vers == 1
7535 node_dataset = H5Dcreate(h5_mesh_file_id,
7541 node_dataset = H5Dcreate(h5_mesh_file_id,
7550 # if H5Gcreate_vers == 1
7551 cell_dataset = H5Dcreate(
7552 h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
7554 cell_dataset = H5Dcreate(h5_mesh_file_id,
7565 status = H5Sclose(node_dataspace);
7567 status = H5Sclose(cell_dataspace);
7572 count[0] = local_node_cell_count[0];
7573 count[1] = (spacedim < 2) ? 2 : spacedim;
7575 offset[0] = global_node_cell_offsets[0];
7578 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7582 node_file_dataspace = H5Dget_space(node_dataset);
7584 status = H5Sselect_hyperslab(
7585 node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7589 count[0] = local_node_cell_count[1];
7591 offset[0] = global_node_cell_offsets[1];
7593 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7596 cell_file_dataspace = H5Dget_space(cell_dataset);
7598 status = H5Sselect_hyperslab(
7599 cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7604 status = H5Dwrite(node_dataset,
7606 node_memory_dataspace,
7607 node_file_dataspace,
7609 node_data_vec.data());
7611 node_data_vec.clear();
7614 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
7615 status = H5Dwrite(cell_dataset,
7617 cell_memory_dataspace,
7618 cell_file_dataspace,
7620 cell_data_vec.data());
7622 cell_data_vec.clear();
7625 status = H5Sclose(node_file_dataspace);
7627 status = H5Sclose(cell_file_dataspace);
7631 status = H5Sclose(node_memory_dataspace);
7633 status = H5Sclose(cell_memory_dataspace);
7637 status = H5Dclose(node_dataset);
7639 status = H5Dclose(cell_dataset);
7643 if (mesh_filename != solution_filename)
7645 status = H5Fclose(h5_mesh_file_id);
7651 if (mesh_filename == solution_filename && write_mesh_file)
7653 h5_solution_file_id = h5_mesh_file_id;
7658 h5_solution_file_id = H5Fcreate(solution_filename.c_str(),
7668 std::string vector_name;
7677 node_ds_dim[0] = global_node_cell_count[0];
7678 node_ds_dim[1] = pt_data_vector_dim;
7679 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
7682 # if H5Gcreate_vers == 1
7683 pt_data_dataset = H5Dcreate(h5_solution_file_id,
7684 vector_name.c_str(),
7689 pt_data_dataset = H5Dcreate(h5_solution_file_id,
7690 vector_name.c_str(),
7700 count[0] = local_node_cell_count[0];
7701 count[1] = pt_data_vector_dim;
7702 offset[0] = global_node_cell_offsets[0];
7704 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7708 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
7710 status = H5Sselect_hyperslab(pt_data_file_dataspace,
7719 status = H5Dwrite(pt_data_dataset,
7721 pt_data_memory_dataspace,
7722 pt_data_file_dataspace,
7728 status = H5Sclose(pt_data_dataspace);
7730 status = H5Sclose(pt_data_memory_dataspace);
7732 status = H5Sclose(pt_data_file_dataspace);
7735 status = H5Dclose(pt_data_dataset);
7740 status = H5Pclose(file_plist_id);
7744 status = H5Pclose(plist_id);
7748 status = H5Fclose(h5_solution_file_id);
7755 template <
int dim,
int spacedim>
7763 output_format = default_fmt;
7765 switch (output_format)
7825 template <
int dim,
int spacedim>
7834 template <
int dim,
int spacedim>
7835 template <
typename FlagType>
7841 if (
typeid(flags) ==
typeid(dx_flags))
7843 else if (
typeid(flags) ==
typeid(ucd_flags))
7845 else if (
typeid(flags) ==
typeid(povray_flags))
7847 else if (
typeid(flags) ==
typeid(eps_flags))
7849 else if (
typeid(flags) ==
typeid(gmv_flags))
7851 else if (
typeid(flags) ==
typeid(tecplot_flags))
7854 else if (
typeid(flags) ==
typeid(vtk_flags))
7856 else if (
typeid(flags) ==
typeid(svg_flags))
7858 else if (
typeid(flags) ==
typeid(gnuplot_flags))
7861 else if (
typeid(flags) ==
typeid(deal_II_intermediate_flags))
7862 deal_II_intermediate_flags =
7870 template <
int dim,
int spacedim>
7883 template <
int dim,
int spacedim>
7890 "A name for the output format to be used");
7894 "Number of subdivisions of each mesh cell");
7936 template <
int dim,
int spacedim>
7940 const std::string &output_name = prm.
get(
"Output format");
7942 default_subdivisions = prm.
get_integer(
"Subdivisions");
7945 dx_flags.parse_parameters(prm);
7949 ucd_flags.parse_parameters(prm);
7953 gnuplot_flags.parse_parameters(prm);
7957 povray_flags.parse_parameters(prm);
7961 eps_flags.parse_parameters(prm);
7965 gmv_flags.parse_parameters(prm);
7969 tecplot_flags.parse_parameters(prm);
7973 vtk_flags.parse_parameters(prm);
7977 deal_II_intermediate_flags.parse_parameters(prm);
7983 template <
int dim,
int spacedim>
7987 return (
sizeof(default_fmt) +
8002 template <
int dim,
int spacedim>
8004 std::tuple<
unsigned int,
8011 std::tuple<
unsigned int,
8018 template <
int dim,
int spacedim>
8026 std::set<std::string> all_names;
8029 std::tuple<
unsigned int,
8033 ranges = this->get_nonscalar_data_ranges();
8034 const std::vector<std::string> data_names = this->get_dataset_names();
8035 const unsigned int n_data_sets = data_names.size();
8036 std::vector<bool> data_set_written(n_data_sets,
false);
8038 for (
const auto &range : ranges)
8040 const std::string &name = std::get<2>(range);
8043 Assert(all_names.find(name) == all_names.end(),
8045 "Error: names of fields in DataOut need to be unique, "
8047 name +
"' is used more than once."));
8048 all_names.insert(name);
8049 for (
unsigned int i = std::get<0>(range); i <= std::get<1>(range);
8051 data_set_written[i] =
true;
8055 for (
unsigned int data_set = 0; data_set < n_data_sets; ++data_set)
8056 if (data_set_written[data_set] ==
false)
8058 const std::string &name = data_names[data_set];
8059 Assert(all_names.find(name) == all_names.end(),
8061 "Error: names of fields in DataOut need to be unique, "
8063 name +
"' is used more than once."));
8064 all_names.insert(name);
8074 template <
int dim,
int spacedim>
8082 std::vector<typename ::DataOutBase::Patch<dim, spacedim>> tmp;
8086 std::vector<std::string> tmp;
8087 tmp.swap(dataset_names);
8091 std::tuple<
unsigned int,
8096 tmp.swap(nonscalar_data_ranges);
8103 std::pair<unsigned int, unsigned int> dimension_info =
8106 (dimension_info.second == spacedim),
8107 ExcIncompatibleDimensions(
8108 dimension_info.first, dim, dimension_info.second, spacedim));
8117 getline(in, header);
8119 std::ostringstream s;
8120 s <<
"[deal.II intermediate format graphics data]";
8122 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
8126 getline(in, header);
8128 std::ostringstream s;
8132 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
8136 getline(in, header);
8138 std::ostringstream s;
8142 Assert(header == s.str(),
8144 "Invalid or incompatible file format. Intermediate format "
8145 "files can only be read by the same deal.II version as they "
8146 "are written by."));
8150 unsigned int n_datasets;
8152 dataset_names.resize(n_datasets);
8153 for (
unsigned int i = 0; i < n_datasets; ++i)
8154 in >> dataset_names[i];
8156 unsigned int n_patches;
8158 patches.resize(n_patches);
8159 for (
unsigned int i = 0; i < n_patches; ++i)
8162 unsigned int n_nonscalar_data_ranges;
8163 in >> n_nonscalar_data_ranges;
8164 nonscalar_data_ranges.resize(n_nonscalar_data_ranges);
8165 for (
unsigned int i = 0; i < n_nonscalar_data_ranges; ++i)
8167 in >> std::get<0>(nonscalar_data_ranges[i]) >>
8168 std::get<1>(nonscalar_data_ranges[i]);
8177 std::get<2>(nonscalar_data_ranges[i]) = name;
8185 template <
int dim,
int spacedim>
8189 using Patch = typename ::DataOutBase::Patch<dim, spacedim>;
8192 const std::vector<Patch> &source_patches = source.
get_patches();
8200 Assert(get_nonscalar_data_ranges().size() ==
8202 ExcMessage(
"Both sources need to declare the same components "
8204 for (
unsigned int i = 0; i < get_nonscalar_data_ranges().size(); ++i)
8206 Assert(std::get<0>(get_nonscalar_data_ranges()[i]) ==
8208 ExcMessage(
"Both sources need to declare the same components "
8210 Assert(std::get<1>(get_nonscalar_data_ranges()[i]) ==
8212 ExcMessage(
"Both sources need to declare the same components "
8214 Assert(std::get<2>(get_nonscalar_data_ranges()[i]) ==
8216 ExcMessage(
"Both sources need to declare the same components "
8221 Assert(patches[0].n_subdivisions == source_patches[0].n_subdivisions,
8223 Assert(patches[0].data.n_rows() == source_patches[0].data.n_rows(),
8225 Assert(patches[0].data.n_cols() == source_patches[0].data.n_cols(),
8230 const unsigned int old_n_patches = patches.size();
8231 patches.insert(patches.end(), source_patches.begin(), source_patches.end());
8234 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
8235 patches[i].patch_index += old_n_patches;
8238 for (
unsigned int i = old_n_patches; i < patches.size(); ++i)
8240 if (patches[i].neighbors[n] !=
8242 patches[i].neighbors[n] += old_n_patches;
8247 template <
int dim,
int spacedim>
8248 const std::vector<typename ::DataOutBase::Patch<dim, spacedim>> &
8256 template <
int dim,
int spacedim>
8257 std::vector<std::string>
8260 return dataset_names;
8265 template <
int dim,
int spacedim>
8267 std::tuple<
unsigned int,
8273 return nonscalar_data_ranges;
8282 , h5_sol_filename(
"")
8283 , h5_mesh_filename(
"")
8295 const unsigned int nodes,
8296 const unsigned int cells,
8297 const unsigned int dim)
8298 :
XDMFEntry(filename, filename, time, nodes, cells, dim, dim)
8304 const std::string &solution_filename,
8306 const unsigned int nodes,
8307 const unsigned int cells,
8308 const unsigned int dim)
8309 :
XDMFEntry(mesh_filename, solution_filename, time, nodes, cells, dim, dim)
8315 const std::string &solution_filename,
8317 const unsigned int nodes,
8318 const unsigned int cells,
8319 const unsigned int dim,
8320 const unsigned int spacedim)
8322 , h5_sol_filename(solution_filename)
8323 , h5_mesh_filename(mesh_filename)
8328 , space_dimension(spacedim)
8335 const unsigned int dimension)
8348 indent(
const unsigned int indent_level)
8350 std::string res =
"";
8351 for (
unsigned int i = 0; i < indent_level; ++i)
8365 std::stringstream ss;
8366 ss << indent(indent_level + 0)
8367 <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
8368 ss << indent(indent_level + 1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
8369 ss << indent(indent_level + 1) <<
"<Geometry GeometryType=\""
8371 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
8373 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
8375 ss << indent(indent_level + 2) <<
"</DataItem>\n";
8376 ss << indent(indent_level + 1) <<
"</Geometry>\n";
8381 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\""
8383 <<
"\" NumberOfElements=\"" <<
num_cells
8384 <<
"\" NodesPerElement=\"1\">\n";
8386 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\""
8388 <<
"\" NumberOfElements=\"" <<
num_cells
8389 <<
"\" NodesPerElement=\"2\">\n";
8391 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\""
8393 <<
"\" NumberOfElements=\"" <<
num_cells <<
"\">\n";
8395 ss << indent(indent_level + 1) <<
"<Topology TopologyType=\""
8397 <<
"\" NumberOfElements=\"" <<
num_cells <<
"\">\n";
8399 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_cells
8401 <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
8403 ss << indent(indent_level + 2) <<
"</DataItem>\n";
8404 ss << indent(indent_level + 1) <<
"</Topology>\n";
8410 ss << indent(indent_level + 1)
8411 <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\""
8413 ss << indent(indent_level + 1) <<
"</Topology>\n";
8418 ss << indent(indent_level + 1) <<
"<Attribute Name=\""
8419 << attribute_dim.first <<
"\" AttributeType=\""
8420 << (attribute_dim.second > 1 ?
"Vector" :
"Scalar")
8421 <<
"\" Center=\"Node\">\n";
8423 ss << indent(indent_level + 2) <<
"<DataItem Dimensions=\"" <<
num_nodes
8424 <<
" " << (attribute_dim.second > 1 ? 3 : 1)
8425 <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
8427 << attribute_dim.first <<
"\n";
8428 ss << indent(indent_level + 2) <<
"</DataItem>\n";
8429 ss << indent(indent_level + 1) <<
"</Attribute>\n";
8432 ss << indent(indent_level + 0) <<
"</Grid>\n";
8441 template <
int dim,
int spacedim>
8446 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]"
8462 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
8463 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
8464 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
8465 out << patch.
data[i][j] <<
' ';
8473 template <
int dim,
int spacedim>
8485 getline(in, header);
8486 while ((header.size() != 0) && (header[header.size() - 1] ==
' '))
8487 header.erase(header.size() - 1);
8489 while ((header.empty()) && in);
8491 std::ostringstream s;
8492 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
8494 Assert(header == s.str(), ExcUnexpectedInput(s.str(), header));
8509 unsigned int n_rows, n_cols;
8510 in >> n_rows >> n_cols;
8512 for (
unsigned int i = 0; i < patch.
data.n_rows(); ++i)
8513 for (
unsigned int j = 0; j < patch.
data.n_cols(); ++j)
8514 in >> patch.
data[i][j];
8525 #include "data_out_base.inst"