34 #include <deal.II/base/data_out_base.h> 35 #include <deal.II/base/utilities.h> 36 #include <deal.II/base/parameter_handler.h> 37 #include <deal.II/base/thread_management.h> 38 #include <deal.II/base/memory_consumption.h> 39 #include <deal.II/base/std_cxx11/shared_ptr.h> 40 #include <deal.II/base/mpi.h> 54 #ifdef DEAL_II_WITH_ZLIB 58 #ifdef DEAL_II_WITH_HDF5 62 DEAL_II_NAMESPACE_OPEN
70 std::string, std::string,
71 <<
"Unexpected input: expected line\n <" 80 #ifdef DEAL_II_WITH_ZLIB 91 step_A, step_B, step_C
96 base64_encodestep step;
100 void base64_init_encodestate(base64_encodestate *state_in)
102 state_in->step = step_A;
103 state_in->result = 0;
107 char base64_encode_value(
char value_in)
109 static const char *encoding
110 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
111 if (value_in > 63)
return '=';
112 return encoding[(int)value_in];
115 int base64_encode_block(
const char *plaintext_in,
118 base64_encodestate *state_in)
120 const char *plainchar = plaintext_in;
121 const char *
const plaintextend = plaintext_in + length_in;
122 char *codechar = code_out;
125 result = state_in->result;
127 switch (state_in->step)
133 if (plainchar == plaintextend)
135 state_in->result = result;
136 state_in->step = step_A;
137 return codechar - code_out;
139 const char fragment = *plainchar++;
140 result = (fragment & 0x0fc) >> 2;
141 *codechar++ = base64_encode_value(result);
142 result = (fragment & 0x003) << 4;
146 if (plainchar == plaintextend)
148 state_in->result = result;
149 state_in->step = step_B;
150 return codechar - code_out;
152 const char fragment = *plainchar++;
153 result |= (fragment & 0x0f0) >> 4;
154 *codechar++ = base64_encode_value(result);
155 result = (fragment & 0x00f) << 2;
159 if (plainchar == plaintextend)
161 state_in->result = result;
162 state_in->step = step_C;
163 return codechar - code_out;
165 const char fragment = *plainchar++;
166 result |= (fragment & 0x0c0) >> 6;
167 *codechar++ = base64_encode_value(result);
168 result = (fragment & 0x03f) >> 0;
169 *codechar++ = base64_encode_value(result);
174 return codechar - code_out;
177 int base64_encode_blockend(
char *code_out, base64_encodestate *state_in)
179 char *codechar = code_out;
181 switch (state_in->step)
184 *codechar++ = base64_encode_value(state_in->result);
189 *codechar++ = base64_encode_value(state_in->result);
197 return codechar - code_out;
211 encode_block (
const char *data,
214 base64::base64_encodestate state;
215 base64::base64_init_encodestate(&state);
217 char *encoded_data =
new char[2*data_size+1];
219 const int encoded_length_data
220 = base64::base64_encode_block (data, data_size,
221 encoded_data, &state);
222 base64::base64_encode_blockend (encoded_data + encoded_length_data,
238 return Z_NO_COMPRESSION;
242 return Z_BEST_COMPRESSION;
244 return Z_DEFAULT_COMPRESSION;
247 return Z_NO_COMPRESSION;
257 template <
typename T>
258 void write_compressed_block (
const std::vector<T> &data,
260 std::ostream &output_stream)
262 if (data.size() != 0)
266 uLongf compressed_data_length
267 = compressBound (data.size() *
sizeof(T));
268 char *compressed_data =
new char[compressed_data_length];
269 int err = compress2 ((Bytef *) compressed_data,
270 &compressed_data_length,
271 (
const Bytef *) &data[0],
272 data.size() *
sizeof(T),
278 const uint32_t compression_header[4]
280 (uint32_t)(data.size() *
sizeof(T)),
281 (uint32_t)(data.size() *
sizeof(T)),
282 (uint32_t)compressed_data_length
285 char *encoded_header = encode_block ((
char *)&compression_header[0],
286 4 *
sizeof(compression_header[0]));
287 output_stream << encoded_header;
288 delete[] encoded_header;
292 char *encoded_data = encode_block (compressed_data,
293 compressed_data_length);
294 delete[] compressed_data;
296 output_stream << encoded_data;
297 delete[] encoded_data;
344 bool operator < (
const SvgCell &)
const;
347 bool SvgCell::operator < (
const SvgCell &e)
const 351 return depth >
e.depth;
386 bool operator < (
const EpsCell2d &)
const;
400 template <
int dim,
int spacedim>
402 write_gmv_reorder_data_vectors (
const std::vector<Patch<dim,spacedim> > &patches,
416 const unsigned int n_data_sets
417 =patches[0].points_are_available ? (patches[0].data.n_rows() - spacedim) : patches[0].data.n_rows();
419 Assert (data_vectors.
size()[0] == n_data_sets,
423 unsigned int next_value = 0;
424 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
425 patch != patches.end(); ++patch)
427 const unsigned int n_subdivisions = patch->n_subdivisions;
428 (void)n_subdivisions;
430 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
431 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
434 (n_data_sets + spacedim)
437 patch->data.n_rows()));
438 Assert ((n_data_sets == 0)
440 (patch->data.n_cols() == Utilities::fixed_power<dim>(n_subdivisions+1)),
443 for (
unsigned int i=0; i<patch->data.n_cols(); ++i, ++next_value)
444 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
445 data_vectors[data_set][next_value] = patch->data(data_set,i);
448 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
449 Assert (data_vectors[data_set].size() == next_value,
462 Map3DPoint::const_iterator it;
463 unsigned int internal_ind;
466 for (
int d=0; d<3; ++d) int_pt(d) = (d < dim ? p(d) : 0);
478 internal_ind = it->second;
486 filtered_cells[cell_index] = filtered_points[pt_index];
491 Map3DPoint::const_iterator it;
493 node_data.resize(existing_points.size()*node_dim);
495 for (it=existing_points.begin(); it!=existing_points.end(); ++it)
497 for (
unsigned int d=0; d<node_dim; ++d)
498 node_data[node_dim*it->second+d] = it->first(d);
504 std::map<unsigned int, unsigned int>::const_iterator it;
506 cell_data.resize(filtered_cells.size());
508 for (it=filtered_cells.begin(); it!=filtered_cells.end(); ++it)
510 cell_data[it->first] = it->second+local_node_offset;
525 internal_add_cell(base_entry+0, start);
526 internal_add_cell(base_entry+1, start+d1);
529 internal_add_cell(base_entry+2, start+d2+d1);
530 internal_add_cell(base_entry+3, start+d2);
533 internal_add_cell(base_entry+4, start+d3);
534 internal_add_cell(base_entry+5, start+d3+d1);
535 internal_add_cell(base_entry+6, start+d3+d2+d1);
536 internal_add_cell(base_entry+7, start+d3+d2);
543 unsigned int num_verts = existing_points.size();
544 unsigned int i, r, d, new_dim;
547 if (flags.xdmf_hdf5_output && dimension != 1) new_dim = 3;
548 else new_dim = dimension;
551 data_set_names.push_back(name);
552 data_set_dims.push_back(new_dim);
553 data_sets.push_back(std::vector<double>(new_dim*num_verts));
556 for (i=0; i<filtered_points.size(); ++i)
558 for (d=0; d<new_dim; ++d)
560 r = filtered_points[i];
561 if (d < dimension) data_sets.back()[r*new_dim+d] = data_vectors(set_num+d, i);
562 else data_sets.back()[r*new_dim+d] = 0;
574 const char *gmv_cell_type[4] =
576 "",
"line 2",
"quad 4",
"hex 8" 579 const char *ucd_cell_type[4] =
581 "",
"line",
"quad",
"hex" 584 const char *tecplot_cell_type[4] =
586 "",
"lineseg",
"quadrilateral",
"brick" 589 #ifdef DEAL_II_HAVE_TECPLOT 590 const unsigned int tecplot_binary_cell_type[4] =
600 const unsigned int vtk_cell_type[5] =
602 0, 3, 9, 12,
static_cast<unsigned int>(-1)
615 template <
int dim,
int spacedim>
621 const unsigned int xstep,
622 const unsigned int ystep,
623 const unsigned int zstep,
624 const unsigned int n_subdivisions)
628 unsigned int point_no=0;
634 point_no+=(n_subdivisions+1)*(n_subdivisions+1)*zstep;
637 point_no+=(n_subdivisions+1)*ystep;
648 for (
unsigned int d=0;
d<spacedim; ++
d)
649 node[d]=patch->
data(patch->
data.
size(0)-spacedim+
d,point_no);
654 const double stepsize=1./n_subdivisions,
655 xfrac=xstep*stepsize;
660 const double yfrac=ystep*stepsize;
662 node += ((patch->
vertices[3] * xfrac) + (patch->
vertices[2] * (1-xfrac))) * yfrac;
665 const double zfrac=zstep*stepsize;
678 template<
int dim,
int spacedim>
682 unsigned int &n_nodes,
683 unsigned int &n_cells)
688 patch!=patches.end(); ++patch)
700 template<
typename FlagsType>
707 StreamBase (std::ostream &stream,
708 const FlagsType &flags)
710 selected_component (
numbers::invalid_unsigned_int),
720 void write_point (
const unsigned int,
724 "reimplement this function if you want to call " 733 void flush_points () {}
741 void write_cell (
const unsigned int ,
748 "reimplement this function if you want to call " 758 void flush_cells () {}
764 template <
typename T>
777 unsigned int selected_component;
784 std::ostream &stream;
789 const FlagsType flags;
798 class DXStream :
public StreamBase<DataOutBase::DXFlags>
801 DXStream (std::ostream &stream,
805 void write_point (
const unsigned int index,
819 void write_cell (
const unsigned int index,
820 const unsigned int start,
821 const unsigned int x_offset,
822 const unsigned int y_offset,
823 const unsigned int z_offset);
835 template<
typename data>
836 void write_dataset (
const unsigned int index,
837 const std::vector<data> &values);
846 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
849 GmvStream (std::ostream &stream,
853 void write_point (
const unsigned int index,
867 void write_cell (
const unsigned int index,
868 const unsigned int start,
869 const unsigned int x_offset,
870 const unsigned int y_offset,
871 const unsigned int z_offset);
880 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
883 TecplotStream (std::ostream &stream,
887 void write_point (
const unsigned int index,
901 void write_cell (
const unsigned int index,
902 const unsigned int start,
903 const unsigned int x_offset,
904 const unsigned int y_offset,
905 const unsigned int z_offset);
914 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
917 UcdStream (std::ostream &stream,
921 void write_point (
const unsigned int index,
939 void write_cell (
const unsigned int index,
940 const unsigned int start,
941 const unsigned int x_offset,
942 const unsigned int y_offset,
943 const unsigned int z_offset);
955 template<
typename data>
956 void write_dataset (
const unsigned int index,
957 const std::vector<data> &values);
966 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
969 VtkStream (std::ostream &stream,
973 void write_point (
const unsigned int index,
987 void 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);
995 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
998 VtuStream (std::ostream &stream,
1002 void write_point (
const unsigned int index,
1005 void flush_points ();
1018 void 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);
1024 void flush_cells ();
1026 template <
typename T>
1040 template <
typename T>
1041 std::ostream &operator<< (const std::vector<T> &);
1056 std::vector<double> vertices;
1057 std::vector<int32_t> cells;
1063 DXStream::DXStream (std::ostream &out,
1072 DXStream::write_point (
const unsigned int,
1075 if (flags.coordinates_binary)
1078 for (
unsigned int d=0;
d<dim; ++
d)
1080 stream.write(reinterpret_cast<const char *>(data),
1081 dim *
sizeof(*data));
1085 for (
unsigned int d=0;
d<dim; ++
d)
1086 stream << p(d) <<
'\t';
1095 DXStream::write_cell (
unsigned int,
1119 if (flags.int_binary)
1120 stream.write(reinterpret_cast<const char *>(nodes),
1121 (1<<dim) *
sizeof(*nodes));
1124 const unsigned int final = (1<<dim) - 1;
1125 for (
unsigned int i=0; i<final ; ++i)
1126 stream << nodes[i] <<
'\t';
1127 stream << nodes[
final] <<
'\n';
1133 template<
typename data>
1136 DXStream::write_dataset (
const unsigned int,
1137 const std::vector<data> &values)
1139 if (flags.data_binary)
1141 stream.write(reinterpret_cast<const char *>(&values[0]),
1142 values.size()*
sizeof(data));
1146 for (
unsigned int i=0; i<values.size(); ++i)
1147 stream <<
'\t' << values[i];
1156 GmvStream::GmvStream (std::ostream &out,
1165 GmvStream::write_point (
const unsigned int,
1170 stream << p(selected_component) <<
' ';
1177 GmvStream::write_cell (
unsigned int,
1185 const unsigned int start=s+1;
1186 stream << gmv_cell_type[dim] <<
'\n';
1188 stream << start <<
'\t' 1192 stream <<
'\t' << start+d2+d1
1193 <<
'\t' << start+d2;
1196 stream <<
'\t' << start+d3
1197 <<
'\t' << start+d3+d1
1198 <<
'\t' << start+d3+d2+d1
1199 <<
'\t' << start+d3+d2;
1207 TecplotStream::TecplotStream (std::ostream &out,
1216 TecplotStream::write_point (
const unsigned int,
1221 stream << p(selected_component) <<
'\n';
1228 TecplotStream::write_cell (
unsigned int,
1234 const unsigned int start = s+1;
1236 stream << start <<
'\t' 1240 stream <<
'\t' << start+d2+d1
1241 <<
'\t' << start+d2;
1244 stream <<
'\t' << start+d3
1245 <<
'\t' << start+d3+d1
1246 <<
'\t' << start+d3+d2+d1
1247 <<
'\t' << start+d3+d2;
1255 UcdStream::UcdStream (std::ostream &out,
1264 UcdStream::write_point (
const unsigned int index,
1270 for (
unsigned int i=0; i<dim; ++i)
1271 stream << p(i) <<
' ';
1273 for (
unsigned int i=dim; i<3; ++i)
1282 UcdStream::write_cell (
unsigned int index,
1309 stream << index+1 <<
"\t0 " << ucd_cell_type[dim];
1310 const unsigned int final = (1<<dim);
1311 for (
unsigned int i=0; i<final ; ++i)
1312 stream <<
'\t' << nodes[i]+1;
1318 template<
typename data>
1321 UcdStream::write_dataset (
const unsigned int index,
1322 const std::vector<data> &values)
1325 for (
unsigned int i=0; i<values.size(); ++i)
1326 stream <<
'\t' << values[i];
1334 VtkStream::VtkStream (std::ostream &out,
1343 VtkStream::write_point (
const unsigned int,
1349 for (
unsigned int i=dim; i<3; ++i)
1358 VtkStream::write_cell (
unsigned int,
1364 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' 1369 stream <<
'\t' << start+d2+d1
1370 <<
'\t' << start+d2;
1373 stream <<
'\t' << start+d3
1374 <<
'\t' << start+d3+d1
1375 <<
'\t' << start+d3+d2+d1
1376 <<
'\t' << start+d3+d2;
1384 VtuStream::VtuStream (std::ostream &out,
1393 VtuStream::write_point (
const unsigned int,
1396 #if !defined(DEAL_II_WITH_ZLIB) 1400 for (
unsigned int i=dim; i<3; ++i)
1407 for (
unsigned int i=0; i<dim; ++i)
1408 vertices.push_back(p[i]);
1409 for (
unsigned int i=dim; i<3; ++i)
1410 vertices.push_back(0);
1416 VtuStream::flush_points ()
1418 #ifdef DEAL_II_WITH_ZLIB 1422 *
this << vertices <<
'\n';
1430 VtuStream::write_cell (
unsigned int,
1436 #if !defined(DEAL_II_WITH_ZLIB) 1437 stream << start <<
'\t' 1441 stream <<
'\t' << start+d2+d1
1442 <<
'\t' << start+d2;
1445 stream <<
'\t' << start+d3
1446 <<
'\t' << start+d3+d1
1447 <<
'\t' << start+d3+d2+d1
1448 <<
'\t' << start+d3+d2;
1453 cells.push_back (start);
1454 cells.push_back (start+d1);
1457 cells.push_back (start+d2+d1);
1458 cells.push_back (start+d2);
1461 cells.push_back (start+d3);
1462 cells.push_back (start+d3+d1);
1463 cells.push_back (start+d3+d2+d1);
1464 cells.push_back (start+d3+d2);
1473 VtuStream::flush_cells ()
1475 #ifdef DEAL_II_WITH_ZLIB 1479 *
this << cells <<
'\n';
1485 template <
typename T>
1487 VtuStream::operator<< (const std::vector<T> &data)
1489 #ifdef DEAL_II_WITH_ZLIB 1493 write_compressed_block (data, flags, stream);
1495 for (
unsigned int i=0; i<data.size(); ++i)
1496 stream << data[i] <<
' ';
1507 template <
int dim,
int spacedim>
1514 template <
int dim,
int spacedim>
1518 template <
int dim,
int spacedim>
1521 patch_index(no_neighbor),
1523 points_are_available(false)
1529 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
1530 neighbors[i] = no_neighbor;
1538 template <
int dim,
int spacedim>
1543 const double epsilon=3e-16;
1544 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1545 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1548 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
1561 if (data.n_rows() != patch.
data.n_rows())
1564 if (data.n_cols() != patch.
data.n_cols())
1567 for (
unsigned int i=0; i<data.n_rows(); ++i)
1568 for (
unsigned int j=0; j<data.n_cols(); ++j)
1569 if (data[i][j] != patch.
data[i][j])
1577 template <
int dim,
int spacedim>
1581 return (
sizeof(vertices) /
sizeof(vertices[0]) *
1593 template <
int dim,
int spacedim>
1597 std::swap (vertices, other_patch.
vertices);
1598 std::swap (neighbors, other_patch.
neighbors);
1601 data.swap (other_patch.
data);
1607 UcdFlags::UcdFlags (
const bool write_preamble)
1609 write_preamble (write_preamble)
1624 : space_dimension_labels(labels)
1638 const bool bicubic_patch,
1639 const bool external_data)
1642 bicubic_patch(bicubic_patch),
1643 external_data(external_data)
1648 const bool xdmf_hdf5_output) :
1649 filter_duplicate_vertices(filter_duplicate_vertices),
1650 xdmf_hdf5_output(xdmf_hdf5_output)
1658 "Whether to remove duplicate vertex values.");
1661 "Whether the data will be used in an XDMF/HDF5 combination.");
1675 const bool int_binary,
1676 const bool coordinates_binary,
1677 const bool data_binary)
1679 write_neighbors(write_neighbors),
1680 int_binary(int_binary),
1681 coordinates_binary(coordinates_binary),
1682 data_binary(data_binary),
1691 "A boolean field indicating whether neighborship " 1692 "information between cells is to be written to the " 1693 "OpenDX output file");
1696 "Output format of integer numbers, which is " 1697 "either a text representation (ascii) or binary integer " 1698 "values of 32 or 64 bits length");
1701 "Output format of vertex coordinates, which is " 1702 "either a text representation (ascii) or binary " 1703 "floating point values of 32 or 64 bits length");
1706 "Output format of data values, which is " 1707 "either a text representation (ascii) or binary " 1708 "floating point values of 32 or 64 bits length");
1725 "A flag indicating whether a comment should be " 1726 "written to the beginning of the output file " 1727 "indicating date and time of creation as well " 1728 "as the creating program");
1741 const int azimuth_angle,
1742 const int polar_angle,
1743 const unsigned int line_thickness,
1745 const bool draw_colorbar)
1749 height_vector(height_vector),
1750 azimuth_angle(azimuth_angle),
1751 polar_angle(polar_angle),
1752 line_thickness(line_thickness),
1754 draw_colorbar(draw_colorbar)
1763 "A flag indicating whether POVRAY should use smoothed " 1764 "triangles instead of the usual ones");
1767 "Whether POVRAY should use bicubic patches");
1770 "Whether camera and lighting information should " 1771 "be put into an external file \"data.inc\" or into " 1772 "the POVRAY input file");
1787 const unsigned int color_vector,
1789 const unsigned int size,
1790 const double line_width,
1791 const double azimut_angle,
1792 const double turn_angle,
1793 const double z_scaling,
1794 const bool draw_mesh,
1795 const bool draw_cells,
1796 const bool shade_cells,
1797 const ColorFunction color_function)
1799 height_vector(height_vector),
1800 color_vector(color_vector),
1801 size_type(size_type),
1803 line_width(line_width),
1804 azimut_angle(azimut_angle),
1805 turn_angle(turn_angle),
1806 z_scaling(z_scaling),
1807 draw_mesh(draw_mesh),
1808 draw_cells(draw_cells),
1809 shade_cells(shade_cells),
1810 color_function(color_function)
1849 double sum = xmax+ xmin;
1850 double sum13 = xmin+3*xmax;
1851 double sum22 = 2*xmin+2*xmax;
1852 double sum31 = 3*xmin+ xmax;
1853 double dif = xmax-xmin;
1854 double rezdif = 1.0/dif;
1860 else if (x<(sum22)/4)
1862 else if (x<(sum13)/4)
1873 rgb_values.green = 0;
1874 rgb_values.blue = (x-xmin)*4.*rezdif;
1878 rgb_values.green = (4*x-3*xmin-xmax)*rezdif;
1879 rgb_values.blue = (sum22-4.*x)*rezdif;
1882 rgb_values.red = (4*x-2*sum)*rezdif;
1883 rgb_values.green = (xmin+3*xmax-4*x)*rezdif;
1884 rgb_values.blue = 0;
1888 rgb_values.green = (4*x-xmin-3*xmax)*rezdif;
1889 rgb_values.blue = (4.*x-sum13)*rezdif;
1895 rgb_values.red = rgb_values.green = rgb_values.blue = 1;
1908 rgb_values.red = rgb_values.blue = rgb_values.green
1909 = (x-xmin)/(xmax-xmin);
1921 rgb_values.red = rgb_values.blue = rgb_values.green
1922 = 1-(x-xmin)/(xmax-xmin);
1928 bool EpsCell2d::operator < (
const EpsCell2d &e)
const 1932 return depth > e.depth;
1941 "Number of the input vector that is to be used to " 1942 "generate height information");
1945 "Number of the input vector that is to be used to " 1946 "generate color information");
1949 "Whether width or height should be scaled to match " 1951 prm.
declare_entry (
"Size (width or height) in eps units",
"300",
1953 "The size (width or height) to which the eps output " 1954 "file is to be scaled");
1957 "The width in which the postscript renderer is to " 1961 "Angle of the viewing position against the vertical " 1965 "Angle of the viewing direction against the y-axis");
1968 "Scaling for the z-direction relative to the scaling " 1969 "used in x- and y-directions");
1972 "Whether the mesh lines, or only the surface should be " 1976 "Whether only the mesh lines, or also the interior of " 1977 "cells should be plotted. If this flag is false, then " 1978 "one can see through the mesh");
1979 prm.
declare_entry (
"Color shading of interior of cells",
"true",
1981 "Whether the interior of cells shall be shaded");
1984 "Name of a color function used to colorize mesh lines " 1985 "and/or cell interiors");
1994 if (prm.
get (
"Scale to width or height") ==
"width")
2006 if (prm.
get(
"Color function") ==
"default")
2008 else if (prm.
get(
"Color function") ==
"grey scale")
2010 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2024 const char *zone_name,
2025 const double solution_time)
2027 tecplot_binary_file_name(tecplot_binary_file_name),
2028 zone_name(zone_name),
2029 solution_time (solution_time)
2037 return sizeof(*this)
2045 const unsigned int cycle,
2046 const bool print_date_and_time,
2051 print_date_and_time (print_date_and_time),
2052 compression_level (compression_level)
2060 if (format_name ==
"none")
2063 if (format_name ==
"dx")
2066 if (format_name ==
"ucd")
2069 if (format_name ==
"gnuplot")
2072 if (format_name ==
"povray")
2075 if (format_name ==
"eps")
2078 if (format_name ==
"gmv")
2081 if (format_name ==
"tecplot")
2084 if (format_name ==
"tecplot_binary")
2087 if (format_name ==
"vtk")
2090 if (format_name ==
"vtu")
2093 if (format_name ==
"deal.II intermediate")
2096 if (format_name ==
"hdf5")
2100 ExcMessage (
"The given file format name is not recognized: <" 2101 + format_name +
">"));
2112 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2120 switch (output_format)
2159 template <
int dim,
int spacedim,
typename StreamType>
2161 write_nodes (
const std::vector<Patch<dim,spacedim> > &patches,
2165 unsigned int count = 0;
2171 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator
2172 patch=patches.begin();
2173 patch!=patches.end(); ++patch)
2176 const unsigned int n = n_subdivisions+1;
2181 const unsigned int n1 = (dim>0) ? n : 1;
2182 const unsigned int n2 = (dim>1) ? n : 1;
2183 const unsigned int n3 = (dim>2) ? n : 1;
2185 for (
unsigned int i3=0; i3<n3; ++i3)
2186 for (
unsigned int i2=0; i2<n2; ++i2)
2187 for (
unsigned int i1=0; i1<n1; ++i1)
2189 compute_node(node, &*patch,
2194 out.write_point(count++, node);
2197 out.flush_points ();
2200 template <
int dim,
int spacedim,
typename StreamType>
2202 write_cells (
const std::vector<Patch<dim,spacedim> > &patches,
2206 unsigned int count = 0;
2207 unsigned int first_vertex_of_patch = 0;
2211 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator
2212 patch=patches.begin();
2213 patch!=patches.end(); ++patch)
2216 const unsigned int n = n_subdivisions+1;
2218 const unsigned int n1 = (dim>0) ? n_subdivisions : 1;
2219 const unsigned int n2 = (dim>1) ? n_subdivisions : 1;
2220 const unsigned int n3 = (dim>2) ? n_subdivisions : 1;
2222 unsigned int d1 = 1;
2223 unsigned int d2 = n;
2224 unsigned int d3 = n*n;
2225 for (
unsigned int i3=0; i3<n3; ++i3)
2226 for (
unsigned int i2=0; i2<n2; ++i2)
2227 for (
unsigned int i1=0; i1<n1; ++i1)
2229 const unsigned int offset = first_vertex_of_patch+i3*d3+i2*d2+i1*d1;
2231 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2235 first_vertex_of_patch += Utilities::fixed_power<dim>(n_subdivisions+1);
2242 template <
int dim,
int spacedim,
class StreamType>
2245 (
const std::vector<Patch<dim,spacedim> > &patches,
2246 unsigned int n_data_sets,
2247 const bool double_precision,
2251 unsigned int count = 0;
2253 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator patch
2255 patch != patches.end(); ++patch)
2258 const unsigned int n = n_subdivisions+1;
2264 (n_data_sets + spacedim)
2267 patch->
data.n_rows()));
2268 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n),
2271 std::vector<float> floats(n_data_sets);
2272 std::vector<double> doubles(n_data_sets);
2276 for (
unsigned int i=0; i<Utilities::fixed_power<dim>(n); ++i, ++count)
2277 if (double_precision)
2279 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2280 doubles[data_set] = patch->
data(data_set, i);
2281 out.write_dataset(count, doubles);
2285 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2286 floats[data_set] = patch->
data(data_set, i);
2287 out.write_dataset(count, floats);
2307 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] - camera_horizontal[2] * camera_direction[1];
2308 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] - camera_horizontal[0] * camera_direction[2];
2309 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] - camera_horizontal[1] * camera_direction[0];
2313 phi /= (
point[0] - camera_position[0]) * camera_direction[0] + (point[1] - camera_position[1]) * camera_direction[1] + (
point[2] - camera_position[2]) * camera_direction[2];
2316 projection[0] = camera_position[0] + phi * (
point[0] - camera_position[0]);
2317 projection[1] = camera_position[1] + phi * (
point[1] - camera_position[1]);
2318 projection[2] = camera_position[2] + phi * (
point[2] - camera_position[2]);
2321 projection_decomposition[0] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_horizontal[0];
2322 projection_decomposition[0] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_horizontal[1];
2323 projection_decomposition[0] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_horizontal[2];
2325 projection_decomposition[1] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_vertical[0];
2326 projection_decomposition[1] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_vertical[1];
2327 projection_decomposition[1] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_vertical[2];
2329 return projection_decomposition;
2342 for (
int i = 0; i < 2; ++i)
2344 for (
int j = 0; j < 2-i; ++j)
2346 if (points[j][2] > points[j + 1][2])
2349 points[j] = points[j+1];
2357 v_inter = points[1];
2364 A[0][0] = v_max[0] - v_min[0];
2365 A[0][1] = v_inter[0] - v_min[0];
2366 A[1][0] = v_max[1] - v_min[1];
2367 A[1][1] = v_inter[1] - v_min[1];
2373 bool col_change =
false;
2382 double temp = A[1][0];
2387 for (
unsigned int k = 0; k < 1; k++)
2389 for (
unsigned int i = k+1; i < 2; i++)
2391 x = A[i][k] / A[k][k];
2393 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2395 b[i] =
b[i] -
b[k]*x;
2400 b[1] =
b[1] / A[1][1];
2402 for (
int i = 0; i >= 0; i--)
2406 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
2408 b[i] =
sum / A[i][i];
2418 double c =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) + v_min[2];
2421 A[0][0] = v_max[0] - v_min[0];
2422 A[0][1] = v_inter[0] - v_min[0];
2423 A[1][0] = v_max[1] - v_min[1];
2424 A[1][1] = v_inter[1] - v_min[1];
2426 b[0] = 1.0 - v_min[0];
2438 double temp = A[1][0];
2443 for (
unsigned int k = 0; k < 1; k++)
2445 for (
unsigned int i = k+1; i < 2; i++)
2447 x = A[i][k] / A[k][k];
2449 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2451 b[i] =
b[i] -
b[k] * x;
2456 b[1]=
b[1] / A[1][1];
2458 for (
int i = 0; i >= 0; i--)
2462 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j]*b[j];
2464 b[i] =
sum / A[i][i];
2474 gradient[0] =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2477 A[0][0] = v_max[0] - v_min[0];
2478 A[0][1] = v_inter[0] - v_min[0];
2479 A[1][0] = v_max[1] - v_min[1];
2480 A[1][1] = v_inter[1] - v_min[1];
2483 b[1] = 1.0 - v_min[1];
2494 double temp = A[1][0];
2499 for (
unsigned int k = 0; k < 1; k++)
2501 for (
unsigned int i = k+1; i < 2; i++)
2503 x = A[i][k] / A[k][k];
2505 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2507 b[i] =
b[i] -
b[k] * x;
2511 b[1] =
b[1] / A[1][1];
2513 for (
int i = 0; i >= 0; i--)
2517 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
2519 b[i] =
sum / A[i][i];
2529 gradient[1] =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2532 double gradient_norm = sqrt(pow(gradient[0], 2.0) + pow(gradient[1], 2.0));
2533 gradient[0] /= gradient_norm;
2534 gradient[1] /= gradient_norm;
2536 double lambda = - gradient[0] * (v_min[0] - v_max[0]) - gradient[1] * (v_min[1] - v_max[1]);
2540 gradient_parameters[0] = v_min[0];
2541 gradient_parameters[1] = v_min[1];
2543 gradient_parameters[2] = v_min[0] + lambda * gradient[0];
2544 gradient_parameters[3] = v_min[1] + lambda * gradient[1];
2546 gradient_parameters[4] = v_min[2];
2547 gradient_parameters[5] = v_max[2];
2549 return gradient_parameters;
2555 template <
int dim,
int spacedim>
2557 const std::vector<std::string> &data_names,
2558 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
2564 #ifndef DEAL_II_WITH_MPI 2580 if (patches.size() == 0)
2584 const unsigned int n_data_sets = data_names.size();
2586 UcdStream ucd_out(out, flags);
2590 unsigned int n_nodes;
2591 unsigned int n_cells;
2592 compute_sizes<dim,spacedim> (patches, n_nodes, n_cells);
2597 out <<
"# This file was generated by the deal.II library." <<
'\n' 2601 <<
"# For a description of the UCD format see the AVS Developer's guide." 2607 out << n_nodes <<
' ' 2609 << n_data_sets <<
' ' 2614 write_nodes(patches, ucd_out);
2617 write_cells(patches, ucd_out);
2622 if (n_data_sets != 0)
2624 out << n_data_sets <<
" ";
2625 for (
unsigned int i=0; i<n_data_sets; ++i)
2630 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2631 out << data_names[data_set]
2635 write_data(patches, n_data_sets,
true, ucd_out);
2646 template <
int dim,
int spacedim>
2648 const std::vector<std::string> &data_names,
2649 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
2655 #ifndef DEAL_II_WITH_MPI 2671 if (patches.size() == 0)
2675 DXStream dx_out(out, flags);
2679 unsigned int offset = 0;
2681 const unsigned int n_data_sets = data_names.size();
2685 unsigned int n_nodes;
2686 unsigned int n_cells;
2687 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
2691 out <<
"object \"vertices\" class array type float rank 1 shape " << spacedim
2692 <<
" items " << n_nodes;
2696 out <<
" lsb ieee data 0" <<
'\n';
2697 offset += n_nodes * spacedim *
sizeof(float);
2701 out <<
" data follows" <<
'\n';
2702 write_nodes(patches, dx_out);
2710 out <<
"object \"cells\" class array type int rank 1 shape " 2712 <<
" items " << n_cells;
2716 out <<
" lsb binary data " << offset <<
'\n';
2717 offset += n_cells *
sizeof (int);
2721 out <<
" data follows" <<
'\n';
2722 write_cells(patches, dx_out);
2727 out <<
"attribute \"element type\" string \"";
2728 if (dim==1) out <<
"lines";
2729 if (dim==2) out <<
"quads";
2730 if (dim==3) out <<
"cubes";
2732 <<
"attribute \"ref\" string \"positions\"" <<
'\n';
2739 out <<
"object \"neighbors\" class array type int rank 1 shape " 2741 <<
" items " << n_cells
2745 patch=patches.begin();
2746 patch!=patches.end(); ++patch)
2749 const unsigned int n1 = (dim>0) ? n : 1;
2750 const unsigned int n2 = (dim>1) ? n : 1;
2751 const unsigned int n3 = (dim>2) ? n : 1;
2752 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
2753 unsigned int dx = 1;
2754 unsigned int dy = n;
2755 unsigned int dz = n*n;
2757 const unsigned int patch_start = patch->
patch_index * cells_per_patch;
2759 for (
unsigned int i3=0; i3<n3; ++i3)
2760 for (
unsigned int i2=0; i2<n2; ++i2)
2761 for (
unsigned int i1=0; i1<n1; ++i1)
2763 const unsigned int nx = i1*
dx;
2764 const unsigned int ny = i2*dy;
2765 const unsigned int nz = i3*dz;
2773 const unsigned int nn = patch->
neighbors[0];
2776 out << (nn*cells_per_patch+ny+nz+
dx*(n-1));
2783 << patch_start+nx-
dx+ny+nz;
2790 const unsigned int nn = patch->
neighbors[1];
2793 out << (nn*cells_per_patch+ny+nz);
2800 << patch_start+nx+
dx+ny+nz;
2807 const unsigned int nn = patch->
neighbors[2];
2810 out << (nn*cells_per_patch+nx+nz+dy*(n-1));
2817 << patch_start+nx+ny-dy+nz;
2822 const unsigned int nn = patch->
neighbors[3];
2825 out << (nn*cells_per_patch+nx+nz);
2832 << patch_start+nx+ny+dy+nz;
2840 const unsigned int nn = patch->
neighbors[4];
2843 out << (nn*cells_per_patch+nx+ny+dz*(n-1));
2850 << patch_start+nx+ny+nz-dz;
2855 const unsigned int nn = patch->
neighbors[5];
2858 out << (nn*cells_per_patch+nx+ny);
2865 << patch_start+nx+ny+nz+dz;
2873 if (n_data_sets != 0)
2875 out <<
"object \"data\" class array type float rank 1 shape " 2877 <<
" items " << n_nodes;
2881 out <<
" lsb ieee data " << offset <<
'\n';
2882 offset += n_data_sets * n_nodes * ((flags.
data_double)
2888 out <<
" data follows" <<
'\n';
2889 write_data(patches, n_data_sets, flags.
data_double, dx_out);
2893 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
2897 out <<
"object \"data\" class constantarray type float rank 0 items " << n_nodes <<
" data follows" 2898 <<
'\n' <<
'0' <<
'\n';
2903 out <<
"object \"deal data\" class field" <<
'\n' 2904 <<
"component \"positions\" value \"vertices\"" <<
'\n' 2905 <<
"component \"connections\" value \"cells\"" <<
'\n' 2906 <<
"component \"data\" value \"data\"" <<
'\n';
2909 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
2912 out <<
"attribute \"created\" string \"" 2918 out <<
"end" <<
'\n';
2921 write_nodes(patches, dx_out);
2923 write_cells(patches, dx_out);
2925 write_data(patches, n_data_sets, flags.
data_double, dx_out);
2937 template <
int dim,
int spacedim>
2939 const std::vector<std::string> &data_names,
2940 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
2946 #ifndef DEAL_II_WITH_MPI 2962 if (patches.size() == 0)
2966 const unsigned int n_data_sets = data_names.size();
2970 out <<
"# This file was generated by the deal.II library." <<
'\n' 2974 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual." 2981 for (
unsigned int spacedim_n=0; spacedim_n<spacedim; ++spacedim_n)
2986 for (
unsigned int i=0; i<data_names.size(); ++i)
2987 out <<
'<' << data_names[i] <<
"> ";
2994 patch != patches.end(); ++patch)
2997 const unsigned int n = n_subdivisions+1;
2999 const unsigned int n1 = (dim>0) ? n : 1;
3000 const unsigned int n2 = (dim>1) ? n : 1;
3001 const unsigned int n3 = (dim>2) ? n : 1;
3002 unsigned int d1 = 1;
3003 unsigned int d2 = n;
3004 unsigned int d3 = n*n;
3010 (n_data_sets + spacedim)
3013 patch->
data.n_rows()));
3014 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n),
3021 for (
unsigned int i2=0; i2<n2; ++i2)
3023 for (
unsigned int i1=0; i1<n1; ++i1)
3027 compute_node(node, &*patch, i1, i2, 0, n_subdivisions);
3030 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3031 out << patch->
data(data_set,i1*d1+i2*d2) <<
' ';
3050 for (
unsigned int i3=0; i3<n3; ++i3)
3051 for (
unsigned int i2=0; i2<n2; ++i2)
3052 for (
unsigned int i1=0; i1<n1; ++i1)
3056 compute_node(this_point, &*patch, i1, i2, i3, n_subdivisions);
3059 if (i1 < n_subdivisions)
3064 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3066 << patch->
data(data_set,i1*d1+i2*d2+i3*d3);
3071 compute_node(node, &*patch, i1+1, i2, i3, n_subdivisions);
3074 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3076 << patch->
data(data_set,(i1+1)*d1+i2*d2+i3*d3);
3086 if (i2 < n_subdivisions)
3091 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3093 << patch->
data(data_set, i1*d1+i2*d2+i3*d3);
3098 compute_node(node, &*patch, i1, i2+1, i3, n_subdivisions);
3101 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3103 << patch->
data(data_set,i1*d1+(i2+1)*d2+i3*d3);
3113 if (i3 < n_subdivisions)
3118 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3120 << patch->
data(data_set,i1*d1+i2*d2+i3*d3);
3125 compute_node(node, &*patch, i1, i2, i3+1, n_subdivisions);
3128 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3130 << patch->
data(data_set,i1*d1+i2*d2+(i3+1)*d3);
3151 template <
int dim,
int spacedim>
3153 const std::vector<std::string> &data_names,
3154 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3160 #ifndef DEAL_II_WITH_MPI 3176 if (patches.size() == 0)
3182 const unsigned int n_data_sets = data_names.size();
3187 out <<
"/* This file was generated by the deal.II library." <<
'\n' 3191 <<
" For a description of the POVRAY format see the POVRAY manual." 3196 out <<
"#include \"colors.inc\" " <<
'\n' 3197 <<
"#include \"textures.inc\" " <<
'\n';
3203 out <<
"#include \"data.inc\" " <<
'\n';
3208 <<
"camera {" <<
'\n' 3209 <<
" location <1,4,-7>" <<
'\n' 3210 <<
" look_at <0,0,0>" <<
'\n' 3211 <<
" angle 30" <<
'\n' 3216 <<
"light_source {" <<
'\n' 3217 <<
" <1,4,-7>" <<
'\n' 3218 <<
" color Grey" <<
'\n' 3221 <<
"light_source {" <<
'\n' 3222 <<
" <0,20,0>" <<
'\n' 3223 <<
" color White" <<
'\n' 3230 double hmin=patches[0].data(0,0);
3231 double hmax=patches[0].data(0,0);
3234 patch != patches.end(); ++patch)
3242 (n_data_sets + spacedim)
3245 patch->
data.n_rows()));
3246 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n_subdivisions+1),
3249 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
3250 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
3252 const int dl = i*(n_subdivisions+1)+j;
3253 if (patch->
data(0,dl)<hmin)
3254 hmin=patch->
data(0,dl);
3255 if (patch->
data(0,dl)>hmax)
3256 hmax=patch->
data(0,dl);
3260 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n' 3261 <<
"#declare HMAX=" << hmax <<
";" <<
'\n' <<
'\n';
3267 out <<
"#declare Tex=texture{" <<
'\n' 3268 <<
" pigment {" <<
'\n' 3269 <<
" gradient y" <<
'\n' 3270 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n' 3271 <<
" color_map {" <<
'\n' 3272 <<
" [0.00 color Light_Purple] " <<
'\n' 3273 <<
" [0.95 color Light_Purple] " <<
'\n' 3274 <<
" [1.00 color White] " <<
'\n' 3275 <<
"} } }" <<
'\n' <<
'\n';
3282 <<
"mesh {" <<
'\n';
3287 patch != patches.end(); ++patch)
3290 const unsigned int n = n_subdivisions+1;
3291 const unsigned int d1=1;
3292 const unsigned int d2=n;
3298 (n_data_sets + spacedim)
3301 patch->
data.n_rows()));
3302 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n),
3306 std::vector<Point<spacedim> > ver(n*n);
3308 for (
unsigned int i2=0; i2<n; ++i2)
3309 for (
unsigned int i1=0; i1<n; ++i1)
3313 compute_node(ver[i1*d1+i2*d2], &*patch, i1, i2, 0, n_subdivisions);
3321 std::vector<Point<3> > nrml;
3339 for (
unsigned int i=0; i<n; ++i)
3340 for (
unsigned int j=0; j<n; ++j)
3342 const unsigned int il = (i==0) ? i : (i-1);
3343 const unsigned int ir = (i==n_subdivisions) ? i : (i+1);
3344 const unsigned int jl = (j==0) ? j : (j-1);
3345 const unsigned int jr = (j==n_subdivisions) ? j : (j+1);
3347 h1(0)=ver[ir*d1+j*d2](0) - ver[il*d1+j*d2](0);
3348 h1(1)=patch->
data(0,ir*d1+j*d2)-
3349 patch->
data(0,il*d1+j*d2);
3350 h1(2)=ver[ir*d1+j*d2](1) - ver[il*d1+j*d2](1);
3352 h2(0)=ver[i*d1+jr*d2](0) - ver[i*d1+jl*d2](0);
3353 h2(1)=patch->
data(0,i*d1+jr*d2)-
3354 patch->
data(0,i*d1+jl*d2);
3355 h2(2)=ver[i*d1+jr*d2](1) - ver[i*d1+jl*d2](1);
3357 nrml[i*d1+j*d2](0)=h1(1)*h2(2)-h1(2)*h2(1);
3358 nrml[i*d1+j*d2](1)=h1(2)*h2(0)-h1(0)*h2(2);
3359 nrml[i*d1+j*d2](2)=h1(0)*h2(1)-h1(1)*h2(0);
3362 double norm=std::sqrt(
3363 std::pow(nrml[i*d1+j*d2](0),2.)+
3364 std::pow(nrml[i*d1+j*d2](1),2.)+
3365 std::pow(nrml[i*d1+j*d2](2),2.));
3367 if (nrml[i*d1+j*d2](1)<0)
3370 for (
unsigned int k=0; k<3; ++k)
3371 nrml[i*d1+j*d2](k)/=norm;
3376 for (
unsigned int i=0; i<n_subdivisions; ++i)
3377 for (
unsigned int j=0; j<n_subdivisions; ++j)
3380 const int dl = i*d1+j*d2;
3386 out <<
"smooth_triangle {" <<
'\n' <<
"\t<" 3387 << ver[dl](0) <<
"," 3388 << patch->
data(0,dl) <<
"," 3389 << ver[dl](1) <<
">, <" 3390 << nrml[dl](0) <<
", " 3391 << nrml[dl](1) <<
", " 3395 << ver[dl+d1](0) <<
"," 3396 << patch->
data(0,dl+d1) <<
"," 3397 << ver[dl+d1](1) <<
">, <" 3398 << nrml[dl+d1](0) <<
", " 3399 << nrml[dl+d1](1) <<
", " 3403 << ver[dl+d1+d2](0) <<
"," 3404 << patch->
data(0,dl+d1+d2) <<
"," 3405 << ver[dl+d1+d2](1) <<
">, <" 3406 << nrml[dl+d1+d2](0) <<
", " 3407 << nrml[dl+d1+d2](1) <<
", " 3408 << nrml[dl+d1+d2](2)
3412 out <<
"smooth_triangle {" <<
'\n' <<
"\t<" 3413 << ver[dl](0) <<
"," 3414 << patch->
data(0,dl) <<
"," 3415 << ver[dl](1) <<
">, <" 3416 << nrml[dl](0) <<
", " 3417 << nrml[dl](1) <<
", " 3421 << ver[dl+d1+d2](0) <<
"," 3422 << patch->
data(0,dl+d1+d2) <<
"," 3423 << ver[dl+d1+d2](1) <<
">, <" 3424 << nrml[dl+d1+d2](0) <<
", " 3425 << nrml[dl+d1+d2](1) <<
", " 3426 << nrml[dl+d1+d2](2)
3429 << ver[dl+d2](0) <<
"," 3430 << patch->
data(0,dl+d2) <<
"," 3431 << ver[dl+d2](1) <<
">, <" 3432 << nrml[dl+d2](0) <<
", " 3433 << nrml[dl+d2](1) <<
", " 3441 out <<
"triangle {" <<
'\n' <<
"\t<" 3442 << ver[dl](0) <<
"," 3443 << patch->
data(0,dl) <<
"," 3444 << ver[dl](1) <<
">," <<
'\n';
3446 << ver[dl+d1](0) <<
"," 3447 << patch->
data(0,dl+d1) <<
"," 3448 << ver[dl+d1](1) <<
">," <<
'\n';
3450 << ver[dl+d1+d2](0) <<
"," 3451 << patch->
data(0,dl+d1+d2) <<
"," 3452 << ver[dl+d1+d2](1) <<
">}" <<
'\n';
3455 out <<
"triangle {" <<
'\n' <<
"\t<" 3456 << ver[dl](0) <<
"," 3457 << patch->
data(0,dl) <<
"," 3458 << ver[dl](1) <<
">," <<
'\n';
3460 << ver[dl+d1+d2](0) <<
"," 3461 << patch->
data(0,dl+d1+d2) <<
"," 3462 << ver[dl+d1+d2](1) <<
">," <<
'\n';
3464 << ver[dl+d2](0) <<
"," 3465 << patch->
data(0,dl+d2) <<
"," 3466 << ver[dl+d2](1) <<
">}" <<
'\n';
3475 <<
"bicubic_patch {" <<
'\n' 3476 <<
" type 0" <<
'\n' 3477 <<
" flatness 0" <<
'\n' 3478 <<
" u_steps 0" <<
'\n' 3479 <<
" v_steps 0" <<
'\n';
3480 for (
int i=0; i<16; ++i)
3482 out <<
"\t<" << ver[i](0) <<
"," << patch->
data(0,i) <<
"," << ver[i](1) <<
">";
3483 if (i!=15) out <<
",";
3486 out <<
" texture {Tex}" <<
'\n' 3494 out <<
" texture {Tex}" <<
'\n' 3508 template <
int dim,
int spacedim>
3510 const std::vector<std::string> &,
3511 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3520 template <
int spacedim>
3522 const std::vector<std::string> &,
3523 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3529 #ifndef DEAL_II_WITH_MPI 3545 if (patches.size() == 0)
3549 const unsigned int old_precision = out.precision();
3562 std::multiset<EpsCell2d> cells;
3571 double min_color_value=0, max_color_value=0;
3576 double heights[4] = { 0, 0, 0, 0 };
3583 for (
typename std::vector<
Patch<2,spacedim> >::const_iterator patch=patches.begin();
3584 patch!=patches.end(); ++patch)
3587 const unsigned int n = n_subdivisions+1;
3588 const unsigned int d1 = 1;
3589 const unsigned int d2 = n;
3591 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
3592 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
3595 compute_node(points[0], &*patch, i1, i2, 0, n_subdivisions);
3596 compute_node(points[1], &*patch, i1+1, i2, 0, n_subdivisions);
3597 compute_node(points[2], &*patch, i1, i2+1, 0, n_subdivisions);
3598 compute_node(points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
3604 patch->
data.n_rows() == 0,
3606 patch->
data.n_rows()));
3607 heights[0] = patch->
data.n_rows() != 0 ?
3610 heights[1] = patch->
data.n_rows() != 0 ?
3613 heights[2] = patch->
data.n_rows() != 0 ?
3616 heights[3] = patch->
data.n_rows() != 0 ?
3623 for (
unsigned int i=0; i<4; ++i)
3624 heights[i] = points[i](2);
3652 const double cx = -std::cos(pi-flags.
azimut_angle * 2*pi / 360.),
3653 cz = -std::cos(flags.
turn_angle * 2*pi / 360.),
3655 sz = std::sin(flags.
turn_angle * 2*pi / 360.);
3656 for (
unsigned int vertex=0; vertex<4; ++vertex)
3658 const double x = points[vertex](0),
3659 y = points[vertex](1),
3660 z = -heights[vertex];
3662 eps_cell.vertices[vertex](0) = - cz*x+ sz*y;
3663 eps_cell.vertices[vertex](1) = -cx*sz*x-cx*cz*y-sx*z;
3685 = (points[0] + points[1] + points[2] + points[3]) / 4;
3686 const double center_height
3687 = -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
3691 eps_cell.depth = -sx*sz*center_point(0)
3692 -sx*cz*center_point(1)
3698 patch->
data.n_rows() == 0,
3700 patch->
data.n_rows()));
3701 const double color_values[4]
3702 = { patch->
data.n_rows() != 0 ?
3705 patch->
data.n_rows() != 0 ?
3708 patch->
data.n_rows() != 0 ?
3711 patch->
data.n_rows() != 0 ?
3717 eps_cell.color_value = (color_values[0] +
3720 color_values[2]) / 4;
3724 if (patch == patches.begin())
3725 min_color_value = max_color_value = eps_cell.color_value;
3728 min_color_value = (min_color_value < eps_cell.color_value ?
3729 min_color_value : eps_cell.color_value);
3730 max_color_value = (max_color_value > eps_cell.color_value ?
3731 max_color_value : eps_cell.color_value);
3736 cells.insert (eps_cell);
3743 double x_min = cells.begin()->vertices[0](0);
3744 double x_max = x_min;
3745 double y_min = cells.begin()->vertices[0](1);
3746 double y_max = y_min;
3748 for (
typename std::multiset<EpsCell2d>::const_iterator
3750 cell!=cells.end(); ++cell)
3751 for (
unsigned int vertex=0; vertex<4; ++vertex)
3753 x_min = std::min (x_min, cell->vertices[vertex](0));
3754 x_max = std::max (x_max, cell->vertices[vertex](0));
3755 y_min = std::min (y_min, cell->vertices[vertex](1));
3756 y_max = std::max (y_max, cell->vertices[vertex](1));
3764 const double scale = (flags.size /
3769 const Point<2> offset(x_min, y_min);
3774 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n' 3775 <<
"%%Title: deal.II Output" <<
'\n' 3776 <<
"%%Creator: the deal.II library" <<
'\n' 3777 <<
"%%Creation Date: " 3781 <<
"%%BoundingBox: " 3785 <<
static_cast<unsigned int>( (x_max-x_min) * scale + 0.5)
3787 <<
static_cast<unsigned int>( (y_max-y_min) * scale + 0.5)
3798 out <<
"/m {moveto} bind def" <<
'\n' 3799 <<
"/l {lineto} bind def" <<
'\n' 3800 <<
"/s {setrgbcolor} bind def" <<
'\n' 3801 <<
"/sg {setgray} bind def" <<
'\n' 3802 <<
"/lx {lineto closepath stroke} bind def" <<
'\n' 3803 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
3805 out <<
"%%EndProlog" <<
'\n' 3808 out << flags.line_width <<
" setlinewidth" <<
'\n';
3814 out << std::setprecision (5);
3831 if (max_color_value == min_color_value)
3832 max_color_value = min_color_value+1;
3839 for (
typename std::multiset<EpsCell2d>::const_iterator
3841 cell!=cells.end(); ++cell)
3843 if (flags.draw_cells)
3845 if (flags.shade_cells)
3847 const EpsFlags::RgbValues rgb_values
3848 = (*flags.color_function) (cell->color_value,
3853 if (rgb_values.is_grey())
3854 out << rgb_values.red <<
" sg ";
3856 out << rgb_values.red <<
' ' 3857 << rgb_values.green <<
' ' 3858 << rgb_values.blue <<
" s ";
3863 out << (cell->vertices[0]-offset) * scale <<
" m " 3864 << (cell->vertices[1]-offset) *
scale <<
" l " 3865 << (cell->vertices[3]-offset) * scale <<
" l " 3866 << (cell->vertices[2]-offset) *
scale <<
" lf" 3870 if (flags.draw_mesh)
3872 << (cell->vertices[0]-offset) * scale <<
" m " 3873 << (cell->vertices[1]-offset) *
scale <<
" l " 3874 << (cell->vertices[3]-offset) * scale <<
" l " 3875 << (cell->vertices[2]-offset) *
scale <<
" lx" 3878 out <<
"showpage" <<
'\n';
3881 out << std::setprecision(old_precision);
3889 template <
int dim,
int spacedim>
3891 const std::vector<std::string> &data_names,
3892 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3899 #ifndef DEAL_II_WITH_MPI 3915 if (patches.size() == 0)
3919 GmvStream gmv_out(out, flags);
3920 const unsigned int n_data_sets = data_names.size();
3925 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
3926 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
3929 (n_data_sets + spacedim)
3932 patches[0].data.n_rows()));
3936 out <<
"gmvinput ascii" 3942 unsigned int n_nodes;
3943 unsigned int n_cells;
3944 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
3968 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
3970 = &write_gmv_reorder_data_vectors<dim,spacedim>;
3980 out <<
"nodes " << n_nodes <<
'\n';
3981 for (
unsigned int d=0; d<spacedim; ++d)
3983 gmv_out.selected_component = d;
3984 write_nodes(patches, gmv_out);
3989 for (
unsigned int d=spacedim; d<3; ++d)
3991 for (
unsigned int i=0; i<n_nodes; ++i)
3999 out <<
"cells " << n_cells <<
'\n';
4000 write_cells(patches, gmv_out);
4004 out <<
"variable" <<
'\n';
4009 reorder_task.
join ();
4015 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4017 out << data_names[data_set] <<
" 1" <<
'\n';
4018 std::copy (data_vectors[data_set].begin(),
4019 data_vectors[data_set].end(),
4020 std::ostream_iterator<double>(out,
" "));
4028 out <<
"endvars" <<
'\n';
4044 template <
int dim,
int spacedim>
4046 const std::vector<std::string> &data_names,
4047 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
4053 #ifndef DEAL_II_WITH_MPI 4069 if (patches.size() == 0)
4073 TecplotStream tecplot_out(out, flags);
4075 const unsigned int n_data_sets = data_names.size();
4080 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4081 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4084 (n_data_sets + spacedim)
4087 patches[0].data.n_rows()));
4091 unsigned int n_nodes;
4092 unsigned int n_cells;
4093 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4098 out <<
"# This file was generated by the deal.II library." <<
'\n' 4102 <<
"# For a description of the Tecplot format see the Tecplot documentation." 4107 out <<
"Variables=";
4115 out <<
"\"x\", \"y\"";
4118 out <<
"\"x\", \"y\", \"z\"";
4124 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4125 out <<
", \"" << data_names[data_set] <<
"\"";
4131 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4134 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4136 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4137 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4165 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4167 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4176 for (
unsigned int d=0; d<spacedim; ++d)
4178 tecplot_out.selected_component = d;
4179 write_nodes(patches, tecplot_out);
4190 reorder_task.
join ();
4193 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4195 std::copy (data_vectors[data_set].begin(),
4196 data_vectors[data_set].end(),
4197 std::ostream_iterator<double>(out,
"\n"));
4201 write_cells(patches, tecplot_out);
4216 #ifdef DEAL_II_HAVE_TECPLOT 4223 TecplotMacros(
const unsigned int n_nodes = 0,
4224 const unsigned int n_vars = 0,
4225 const unsigned int n_cells = 0,
4226 const unsigned int n_vert = 0);
4228 float &nd(
const unsigned int i,
const unsigned int j);
4229 int &cd(
const unsigned int i,
const unsigned int j);
4230 std::vector<float> nodalData;
4231 std::vector<int> connData;
4233 unsigned int n_nodes;
4234 unsigned int n_vars;
4235 unsigned int n_cells;
4236 unsigned int n_vert;
4241 TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
4242 const unsigned int n_vars,
4243 const unsigned int n_cells,
4244 const unsigned int n_vert)
4251 nodalData.resize(n_nodes*n_vars);
4252 connData.resize(n_cells*n_vert);
4258 TecplotMacros::~TecplotMacros()
4264 float &TecplotMacros::nd (
const unsigned int i,
4265 const unsigned int j)
4267 return nodalData[i*n_nodes+j];
4273 int &TecplotMacros::cd (
const unsigned int i,
4274 const unsigned int j)
4276 return connData[i+j*n_vert];
4287 template <
int dim,
int spacedim>
4289 const std::vector<std::string> &data_names,
4290 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4295 #ifndef DEAL_II_HAVE_TECPLOT 4300 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4309 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4320 if (file_name == NULL)
4327 " file through the TecplotFlags interface."));
4328 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4335 #ifndef DEAL_II_WITH_MPI 4351 if (patches.size() == 0)
4355 const unsigned int n_data_sets = data_names.size();
4360 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4361 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4364 (n_data_sets + spacedim)
4367 patches[0].data.n_rows()));
4371 unsigned int n_nodes;
4372 unsigned int n_cells;
4373 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4376 const unsigned int vars_per_node = (spacedim+n_data_sets),
4379 TecplotMacros tm(n_nodes, vars_per_node, n_cells, nodes_per_cell);
4383 cell_type = tecplot_binary_cell_type[dim];
4385 std::string tec_var_names;
4389 tec_var_names =
"x y";
4392 tec_var_names =
"x y z";
4398 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4400 tec_var_names +=
" ";
4401 tec_var_names += data_names[data_set];
4426 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4428 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4435 for (
unsigned int d=1; d<=spacedim; ++d)
4437 unsigned int entry=0;
4440 patch!=patches.end(); ++patch)
4448 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
4449 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
4451 const double x_frac = i * 1./n_subdivisions,
4452 y_frac = j * 1./n_subdivisions;
4454 tm.nd((d-1),entry) =
static_cast<float>(
4455 (((patch->
vertices[1](d-1) * x_frac) +
4456 (patch->
vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
4457 ((patch->
vertices[3](d-1) * x_frac) +
4458 (patch->
vertices[2](d-1) * (1-x_frac))) * y_frac)
4467 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
4468 for (
unsigned int k=0; k<n_subdivisions+1; ++k)
4469 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
4471 const double x_frac = i * 1./n_subdivisions,
4472 y_frac = k * 1./n_subdivisions,
4473 z_frac = j * 1./n_subdivisions;
4477 tm.nd((d-1),entry) =
static_cast<float>(
4478 ((((patch->
vertices[1](d-1) * x_frac) +
4479 (patch->
vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
4480 ((patch->
vertices[3](d-1) * x_frac) +
4481 (patch->
vertices[2](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) +
4482 (((patch->
vertices[5](d-1) * x_frac) +
4483 (patch->
vertices[4](d-1) * (1-x_frac))) * (1-y_frac) +
4484 ((patch->
vertices[7](d-1) * x_frac) +
4485 (patch->
vertices[6](d-1) * (1-x_frac))) * y_frac) * z_frac)
4502 reorder_task.
join ();
4505 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4506 for (
unsigned int entry=0; entry<data_vectors[data_set].
size(); entry++)
4507 tm.nd((spacedim+data_set),entry) =
static_cast<float>(data_vectors[data_set][entry]);
4515 unsigned int first_vertex_of_patch = 0;
4516 unsigned int elem=0;
4519 patch!=patches.end(); ++patch)
4522 const unsigned int n = n_subdivisions+1;
4523 const unsigned int d1=1;
4524 const unsigned int d2=n;
4525 const unsigned int d3=n*n;
4532 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
4533 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
4535 tm.cd(0,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+1;
4536 tm.cd(1,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+1;
4537 tm.cd(2,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+1;
4538 tm.cd(3,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+1;
4547 for (
unsigned int i3=0; i3<n_subdivisions; ++i3)
4548 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
4549 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
4554 tm.cd(0,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+(i3 )*d3+1;
4555 tm.cd(1,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+(i3 )*d3+1;
4556 tm.cd(2,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+(i3 )*d3+1;
4557 tm.cd(3,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+(i3 )*d3+1;
4558 tm.cd(4,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+(i3+1)*d3+1;
4559 tm.cd(5,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+(i3+1)*d3+1;
4560 tm.cd(6,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+(i3+1)*d3+1;
4561 tm.cd(7,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+(i3+1)*d3+1;
4575 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
4581 num_nodes =
static_cast<int>(n_nodes),
4582 num_cells = static_cast<int>(n_cells);
4584 char dot[2] = {
'.', 0};
4591 char *var_names=
const_cast<char *
> (tec_var_names.c_str());
4592 ierr = TECINI (NULL,
4601 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K',0};
4602 ierr = TECZNE (NULL,
4611 int total = (vars_per_node*num_nodes);
4613 ierr = TECDAT (&total,
4619 ierr = TECNOD (&tm.connData[0]);
4632 template <
int dim,
int spacedim>
4635 const std::vector<std::string> &data_names,
4636 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4642 #ifndef DEAL_II_WITH_MPI 4658 if (patches.size() == 0)
4662 VtkStream vtk_out(out, flags);
4664 const unsigned int n_data_sets = data_names.size();
4667 if (patches[0].points_are_available)
4679 out <<
"# vtk DataFile Version 3.0" 4681 <<
"#This file was generated by the deal.II library";
4693 out <<
"DATASET UNSTRUCTURED_GRID\n" 4702 n_metadata = ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0)
4704 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
4706 out <<
"FIELD FieldData " << n_metadata <<
"\n";
4708 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
4710 out <<
"CYCLE 1 1 int\n" 4711 << flags.
cycle <<
"\n";
4713 if (flags.
time != std::numeric_limits<double>::min())
4715 out <<
"TIME 1 1 double\n" 4716 << flags.
time <<
"\n";
4722 unsigned int n_nodes;
4723 unsigned int n_cells;
4724 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4748 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4750 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4760 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
4761 write_nodes(patches, vtk_out);
4765 out <<
"CELLS " << n_cells <<
' ' 4768 write_cells(patches, vtk_out);
4773 out <<
"CELL_TYPES " << n_cells <<
'\n';
4774 for (
unsigned int i=0; i<n_cells; ++i)
4775 out <<
' ' << vtk_cell_type[dim];
4783 reorder_task.
join ();
4791 out <<
"POINT_DATA " << n_nodes
4798 std::vector<bool> data_set_written (n_data_sets,
false);
4799 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
4801 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
4802 std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
4803 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
4804 std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
4805 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
4806 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
4808 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
4809 - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
4810 ExcMessage (
"Can't declare a vector with more than 3 components " 4814 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4815 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
4817 data_set_written[i] =
true;
4826 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
4827 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
4830 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4831 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
4833 out << data_names[i] <<
"__";
4834 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
4843 for (
unsigned int n=0; n<n_nodes; ++n)
4845 switch (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) -
4846 std_cxx11::get<0>(vector_data_ranges[n_th_vector]))
4849 out << data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n) <<
" 0 0" 4854 out << data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n) <<
' '<< data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n) <<
" 0" 4858 out << data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n) <<
' '<< data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n) <<
' '<< data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+2, n)
4875 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4876 if (data_set_written[data_set] ==
false)
4879 << data_names[data_set]
4882 <<
"LOOKUP_TABLE default" 4884 std::copy (data_vectors[data_set].begin(),
4885 data_vectors[data_set].end(),
4886 std::ostream_iterator<double>(out,
" "));
4903 out <<
"<?xml version=\"1.0\" ?> \n";
4905 out <<
"# vtk DataFile Version 3.0" 4907 <<
"#This file was generated by the deal.II library";
4916 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
4917 #ifdef DEAL_II_WITH_ZLIB 4918 out <<
" compressor=\"vtkZLibDataCompressor\"";
4920 #ifdef DEAL_II_WORDS_BIGENDIAN 4921 out <<
" byte_order=\"BigEndian\"";
4923 out <<
" byte_order=\"LittleEndian\"";
4927 out <<
"<UnstructuredGrid>";
4936 out <<
" </UnstructuredGrid>\n";
4937 out <<
"</VTKFile>\n";
4942 template <
int dim,
int spacedim>
4945 const std::vector<std::string> &data_names,
4946 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4951 write_vtu_main (patches, data_names, vector_data_ranges, flags, out);
4958 template <
int dim,
int spacedim>
4960 const std::vector<std::string> &data_names,
4961 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4967 #ifndef DEAL_II_WITH_MPI 4983 if (patches.size() == 0)
4988 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n" 4990 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n" 4992 <<
" <PointData Scalars=\"scalars\">\n";
4993 std::vector<bool> data_set_written (data_names.size(),
false);
4994 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
4998 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4999 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5001 data_set_written[i] =
true;
5008 out <<
" <DataArray type=\"Float64\" Name=\"";
5010 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5011 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
5014 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5015 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5017 out << data_names[i] <<
"__";
5018 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
5021 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5024 for (
unsigned int data_set=0; data_set<data_names.size(); ++data_set)
5025 if (data_set_written[data_set] ==
false)
5027 out <<
" <DataArray type=\"Float64\" Name=\"" 5028 << data_names[data_set]
5029 <<
"\"></DataArray>\n";
5032 out <<
" </PointData>\n";
5033 out <<
"</Piece>\n";
5048 n_metadata = ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0)
5050 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5052 out <<
"<FieldData>\n";
5054 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5056 out <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">" 5058 <<
"</DataArray>\n";
5060 if (flags.
time != std::numeric_limits<double>::min())
5062 out <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">" 5064 <<
"</DataArray>\n";
5068 out <<
"</FieldData>\n";
5072 VtuStream vtu_out(out, flags);
5074 const unsigned int n_data_sets = data_names.size();
5079 if (patches[0].points_are_available)
5088 #ifdef DEAL_II_WITH_ZLIB 5089 const char *ascii_or_binary =
"binary";
5091 const char *ascii_or_binary =
"ascii";
5097 unsigned int n_nodes;
5098 unsigned int n_cells;
5099 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
5123 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
5125 = &write_gmv_reorder_data_vectors<dim,spacedim>;
5137 out <<
"<Piece NumberOfPoints=\"" << n_nodes
5138 <<
"\" NumberOfCells=\"" << n_cells <<
"\" >\n";
5139 out <<
" <Points>\n";
5140 out <<
" <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"" 5141 << ascii_or_binary <<
"\">\n";
5142 write_nodes(patches, vtu_out);
5143 out <<
" </DataArray>\n";
5144 out <<
" </Points>\n\n";
5147 out <<
" <Cells>\n";
5148 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"" 5149 << ascii_or_binary <<
"\">\n";
5150 write_cells(patches, vtu_out);
5151 out <<
" </DataArray>\n";
5157 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\"" 5158 << ascii_or_binary <<
"\">\n";
5160 std::vector<int32_t> offsets (n_cells);
5161 for (
unsigned int i=0; i<n_cells; ++i)
5165 out <<
" </DataArray>\n";
5170 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\"" 5171 << ascii_or_binary <<
"\">\n";
5177 #ifdef DEAL_II_WITH_ZLIB 5178 std::vector<uint8_t> cell_types (n_cells,
5179 static_cast<uint8_t>(vtk_cell_type[dim]));
5181 std::vector<unsigned int> cell_types (n_cells,
5182 vtk_cell_type[dim]);
5185 vtu_out << cell_types;
5188 out <<
" </DataArray>\n";
5189 out <<
" </Cells>\n";
5198 reorder_task.
join ();
5206 out <<
" <PointData Scalars=\"scalars\">\n";
5212 std::vector<bool> data_set_written (n_data_sets,
false);
5213 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5215 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
5216 std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
5217 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
5218 std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
5219 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
5220 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
5222 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
5223 - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
5224 ExcMessage (
"Can't declare a vector with more than 3 components " 5229 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5230 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5232 data_set_written[i] =
true;
5239 out <<
" <DataArray type=\"Float64\" Name=\"";
5241 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5242 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
5245 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5246 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5248 out << data_names[i] <<
"__";
5249 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
5252 out <<
"\" NumberOfComponents=\"3\" format=\"" 5253 << ascii_or_binary <<
"\">\n";
5258 std::vector<double> data;
5259 data.reserve (n_nodes*dim);
5261 for (
unsigned int n=0; n<n_nodes; ++n)
5263 switch (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) -
5264 std_cxx11::get<0>(vector_data_ranges[n_th_vector]))
5267 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n));
5273 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n));
5274 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n));
5278 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n));
5279 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n));
5280 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+2, n));
5294 out <<
" </DataArray>\n";
5298 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
5299 if (data_set_written[data_set] ==
false)
5301 out <<
" <DataArray type=\"Float64\" Name=\"" 5302 << data_names[data_set]
5304 << ascii_or_binary <<
"\">\n";
5306 std::vector<double> data (data_vectors[data_set].begin(),
5307 data_vectors[data_set].end());
5309 out <<
" </DataArray>\n";
5312 out <<
" </PointData>\n";
5315 out <<
" </Piece>\n";
5329 const std::vector<std::string> &piece_names,
5330 const std::vector<std::string> &data_names,
5331 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges)
5335 const unsigned int n_data_sets = data_names.size();
5337 out <<
"<?xml version=\"1.0\"?>\n";
5340 out <<
"#This file was generated by the deal.II library" 5345 out <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
5346 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
5347 out <<
" <PPointData Scalars=\"scalars\">\n";
5351 std::vector<bool> data_set_written (n_data_sets,
false);
5352 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5354 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
5355 std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
5356 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
5357 std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
5358 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
5359 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
5361 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
5362 - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
5363 ExcMessage (
"Can't declare a vector with more than 3 components " 5368 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5369 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5371 data_set_written[i] =
true;
5378 out <<
" <PDataArray type=\"Float64\" Name=\"";
5380 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5381 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
5384 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5385 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5387 out << data_names[i] <<
"__";
5388 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
5391 out <<
"\" NumberOfComponents=\"3\" format=\"ascii\"/>\n";
5394 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
5395 if (data_set_written[data_set] ==
false)
5397 out <<
" <PDataArray type=\"Float64\" Name=\"" 5398 << data_names[data_set]
5399 <<
"\" format=\"ascii\"/>\n";
5402 out <<
" </PPointData>\n";
5404 out <<
" <PPoints>\n";
5405 out <<
" <PDataArray type=\"Float64\" NumberOfComponents=\"3\"/>\n";
5406 out <<
" </PPoints>\n";
5408 for (
unsigned int i=0; i<piece_names.size(); ++i)
5409 out <<
" <Piece Source=\"" << piece_names[i] <<
"\"/>\n";
5411 out <<
" </PUnstructuredGrid>\n";
5412 out <<
"</VTKFile>\n";
5424 const std::vector<std::pair<double,std::string> > ×_and_names)
5428 out <<
"<?xml version=\"1.0\"?>\n";
5431 out <<
"#This file was generated by the deal.II library" 5436 out <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
5437 out <<
" <Collection>\n";
5439 std::streamsize ss = out.precision();
5442 for (
unsigned int i=0; i<times_and_names.size(); ++i)
5443 out <<
" <DataSet timestep=\"" << times_and_names[i].first
5444 <<
"\" group=\"\" part=\"0\" file=\"" << times_and_names[i].second
5447 out <<
" </Collection>\n";
5448 out <<
"</VTKFile>\n";
5460 const std::vector<std::string> &piece_names)
5462 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
5463 for (
unsigned int i=0; i<piece_names.size(); ++i)
5464 out << piece_names[i] <<
'\n';
5473 const std::vector<std::vector<std::string> > &piece_names)
5477 if (piece_names.size() == 0)
5480 const double nblocks = piece_names[0].size();
5481 Assert(nblocks > 0,
ExcMessage(
"piece_names should be a vector of nonempty vectors.") )
5483 out <<
"!NBLOCKS " << nblocks <<
'\n';
5484 for (std::vector<std::vector<std::string> >::const_iterator domain = piece_names.begin(); domain != piece_names.end(); ++domain)
5486 Assert(domain->size() == nblocks,
ExcMessage(
"piece_names should be a vector of equal sized vectors.") )
5487 for (std::vector<std::string>::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain)
5488 out << *subdomain <<
'\n';
5498 const std::vector<std::pair<
double,std::vector<std::string> > > ×_and_piece_names)
5502 if (times_and_piece_names.size() == 0)
5505 const double nblocks = times_and_piece_names[0].second.size();
5506 Assert(nblocks > 0,
ExcMessage(
"time_and_piece_names should contain nonempty vectors of filenames for every timestep.") )
5508 for (std::vector<std::pair<
double,std::vector<std::string> > >::const_iterator domain = times_and_piece_names.begin();
5509 domain != times_and_piece_names.end(); ++domain)
5510 out <<
"!TIME " << domain->first <<
'\n';
5512 out <<
"!NBLOCKS " << nblocks <<
'\n';
5513 for (std::vector<std::pair<
double,std::vector<std::string> > >::const_iterator domain = times_and_piece_names.begin();
5514 domain != times_and_piece_names.end(); ++domain)
5516 Assert(domain->second.size() == nblocks,
ExcMessage(
"piece_names should be a vector of equal sized vectors.") )
5517 for (std::vector<std::string>::const_iterator subdomain = domain->second.begin(); subdomain != domain->second.end(); ++subdomain)
5518 out << *subdomain <<
'\n';
5526 template <
int dim,
int spacedim>
5527 void write_svg (
const std::vector<Patch<dim,spacedim> > &,
5528 const std::vector<std::string> &,
5529 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
5536 template <
int spacedim>
5538 const std::vector<std::string> &,
5539 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
5544 const unsigned int height = flags.
height;
5545 unsigned int width = flags.
width;
5548 unsigned int margin_in_percent = 0;
5549 if (flags.
margin) margin_in_percent = 5;
5553 double x_dimension, y_dimension, z_dimension;
5555 typename std::vector<Patch<dim,spacedim> >::const_iterator patch = patches.begin();
5557 unsigned int n_subdivisions = patch->n_subdivisions;
5558 unsigned int n = n_subdivisions + 1;
5559 const unsigned int d1 = 1;
5560 const unsigned int d2 = n;
5566 Point<2> projection_decompositions[4];
5568 compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
5571 patch->data.n_rows() == 0,
5574 double x_min = projected_point[0];
5575 double x_max = x_min;
5576 double y_min = projected_point[1];
5577 double y_max = y_min;
5578 double z_min = patch->data.n_rows() != 0 ? patch->data(flags.
height_vector,0) : 0;
5579 double z_max = z_min;
5582 for (; patch != patches.end(); ++patch)
5584 n_subdivisions = patch->n_subdivisions;
5585 n = n_subdivisions + 1;
5587 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5589 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5591 compute_node(projected_points[0], &*patch, i1, i2, 0, n_subdivisions);
5592 compute_node(projected_points[1], &*patch, i1+1, i2, 0, n_subdivisions);
5593 compute_node(projected_points[2], &*patch, i1, i2+1, 0, n_subdivisions);
5594 compute_node(projected_points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5596 x_min = std::min(x_min, (
double)projected_points[0][0]);
5597 x_min = std::min(x_min, (
double)projected_points[1][0]);
5598 x_min = std::min(x_min, (
double)projected_points[2][0]);
5599 x_min = std::min(x_min, (
double)projected_points[3][0]);
5601 x_max = std::max(x_max, (
double)projected_points[0][0]);
5602 x_max = std::max(x_max, (
double)projected_points[1][0]);
5603 x_max = std::max(x_max, (
double)projected_points[2][0]);
5604 x_max = std::max(x_max, (
double)projected_points[3][0]);
5606 y_min = std::min(y_min, (
double)projected_points[0][1]);
5607 y_min = std::min(y_min, (
double)projected_points[1][1]);
5608 y_min = std::min(y_min, (
double)projected_points[2][1]);
5609 y_min = std::min(y_min, (
double)projected_points[3][1]);
5611 y_max = std::max(y_max, (
double)projected_points[0][1]);
5612 y_max = std::max(y_max, (
double)projected_points[1][1]);
5613 y_max = std::max(y_max, (
double)projected_points[2][1]);
5614 y_max = std::max(y_max, (
double)projected_points[3][1]);
5617 patch->data.n_rows() == 0,
5620 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, i1*d1 + i2*d2));
5621 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + i2*d2));
5622 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, i1*d1 + (i2+1)*d2));
5623 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + (i2+1)*d2));
5625 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, i1*d1 + i2*d2));
5626 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + i2*d2));
5627 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, i1*d1 + (i2+1)*d2));
5628 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + (i2+1)*d2));
5633 x_dimension = x_max - x_min;
5634 y_dimension = y_max - y_min;
5635 z_dimension = z_max - z_min;
5642 float camera_focus = 0;
5645 camera_position[0] = 0.;
5646 camera_position[1] = 0.;
5647 camera_position[2] = z_min + 2. * z_dimension;
5649 camera_direction[0] = 0.;
5650 camera_direction[1] = 0.;
5651 camera_direction[2] = - 1.;
5653 camera_horizontal[0] = 1.;
5654 camera_horizontal[1] = 0.;
5655 camera_horizontal[2] = 0.;
5657 camera_focus = .5 * z_dimension;
5663 const float angle_factor = 3.14159265f / 180.f;
5666 camera_position_temp[1] =
cos(angle_factor * flags.polar_angle) * camera_position[1] -
sin(angle_factor * flags.polar_angle) * camera_position[2];
5667 camera_position_temp[2] =
sin(angle_factor * flags.polar_angle) * camera_position[1] +
cos(angle_factor * flags.polar_angle) * camera_position[2];
5669 camera_direction_temp[1] =
cos(angle_factor * flags.polar_angle) * camera_direction[1] -
sin(angle_factor * flags.polar_angle) * camera_direction[2];
5670 camera_direction_temp[2] =
sin(angle_factor * flags.polar_angle) * camera_direction[1] +
cos(angle_factor * flags.polar_angle) * camera_direction[2];
5672 camera_horizontal_temp[1] =
cos(angle_factor * flags.polar_angle) * camera_horizontal[1] -
sin(angle_factor * flags.polar_angle) * camera_horizontal[2];
5673 camera_horizontal_temp[2] =
sin(angle_factor * flags.polar_angle) * camera_horizontal[1] +
cos(angle_factor * flags.polar_angle) * camera_horizontal[2];
5675 camera_position[1] = camera_position_temp[1];
5676 camera_position[2] = camera_position_temp[2];
5678 camera_direction[1] = camera_direction_temp[1];
5679 camera_direction[2] = camera_direction_temp[2];
5681 camera_horizontal[1] = camera_horizontal_temp[1];
5682 camera_horizontal[2] = camera_horizontal_temp[2];
5691 camera_horizontal_temp[0] =
cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] -
sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5692 camera_horizontal_temp[1] =
sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] +
cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5694 camera_position[0] = camera_position_temp[0];
5695 camera_position[1] = camera_position_temp[1];
5697 camera_direction[0] = camera_direction_temp[0];
5698 camera_direction[1] = camera_direction_temp[1];
5700 camera_horizontal[0] = camera_horizontal_temp[0];
5701 camera_horizontal[1] = camera_horizontal_temp[1];
5704 camera_position[0] = x_min + .5 * x_dimension;
5705 camera_position[1] = y_min + .5 * y_dimension;
5707 camera_position[0] += (z_min + 2. * z_dimension) *
sin(angle_factor * flags.polar_angle) *
sin(angle_factor * flags.
azimuth_angle);
5708 camera_position[1] -= (z_min + 2. * z_dimension) *
sin(angle_factor * flags.polar_angle) *
cos(angle_factor * flags.
azimuth_angle);
5712 double x_min_perspective, y_min_perspective;
5713 double x_max_perspective, y_max_perspective;
5714 double x_dimension_perspective, y_dimension_perspective;
5716 patch = patches.begin();
5718 n_subdivisions = patch->n_subdivisions;
5719 n = n_subdivisions + 1;
5723 compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
5726 patch->data.n_rows() == 0,
5729 point[0] = projected_point[0];
5730 point[1] = projected_point[1];
5731 point[2] = patch->data.n_rows() != 0 ? patch->data(flags.
height_vector, 0) : 0;
5733 projection_decomposition = svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
5735 x_min_perspective = projection_decomposition[0];
5736 x_max_perspective = projection_decomposition[0];
5737 y_min_perspective = projection_decomposition[1];
5738 y_max_perspective = projection_decomposition[1];
5741 for (; patch != patches.end(); ++patch)
5743 n_subdivisions = patch->n_subdivisions;
5744 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5746 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5751 compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
5752 compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
5753 compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
5754 compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5757 patch->data.n_rows() == 0,
5760 vertices[0][0] = projected_vertices[0][0];
5761 vertices[0][1] = projected_vertices[0][1];
5762 vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
5764 vertices[1][0] = projected_vertices[1][0];
5765 vertices[1][1] = projected_vertices[1][1];
5766 vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
5768 vertices[2][0] = projected_vertices[2][0];
5769 vertices[2][1] = projected_vertices[2][1];
5770 vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
5772 vertices[3][0] = projected_vertices[3][0];
5773 vertices[3][1] = projected_vertices[3][1];
5774 vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
5776 projection_decompositions[0] = svg_project_point(vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
5777 projection_decompositions[1] = svg_project_point(vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
5778 projection_decompositions[2] = svg_project_point(vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
5779 projection_decompositions[3] = svg_project_point(vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
5781 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[0][0]);
5782 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[1][0]);
5783 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[2][0]);
5784 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[3][0]);
5786 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[0][0]);
5787 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[1][0]);
5788 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[2][0]);
5789 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[3][0]);
5791 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[0][1]);
5792 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[1][1]);
5793 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[2][1]);
5794 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[3][1]);
5796 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[0][1]);
5797 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[1][1]);
5798 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[2][1]);
5799 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[3][1]);
5804 x_dimension_perspective = x_max_perspective - x_min_perspective;
5805 y_dimension_perspective = y_max_perspective - y_min_perspective;
5807 std::multiset<SvgCell> cells;
5810 for (patch = patches.begin(); patch != patches.end(); ++patch)
5812 n_subdivisions = patch->n_subdivisions;
5814 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5816 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5821 compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
5822 compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
5823 compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
5824 compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5827 patch->data.n_rows() == 0,
5830 cell.vertices[0][0] = projected_vertices[0][0];
5831 cell.vertices[0][1] = projected_vertices[0][1];
5832 cell.vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
5834 cell.vertices[1][0] = projected_vertices[1][0];
5835 cell.vertices[1][1] = projected_vertices[1][1];
5836 cell.vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
5838 cell.vertices[2][0] = projected_vertices[2][0];
5839 cell.vertices[2][1] = projected_vertices[2][1];
5840 cell.vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
5842 cell.vertices[3][0] = projected_vertices[3][0];
5843 cell.vertices[3][1] = projected_vertices[3][1];
5844 cell.vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
5846 cell.projected_vertices[0] = svg_project_point(cell.vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
5847 cell.projected_vertices[1] = svg_project_point(cell.vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
5848 cell.projected_vertices[2] = svg_project_point(cell.vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
5849 cell.projected_vertices[3] = svg_project_point(cell.vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
5851 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] + cell.vertices[2] + cell.vertices[3]);
5852 cell.projected_center = svg_project_point(cell.center, camera_position, camera_direction, camera_horizontal, camera_focus);
5854 cell.depth = cell.center.distance(camera_position);
5864 width =
static_cast<unsigned int>(.5 + height * (x_dimension_perspective / y_dimension_perspective));
5865 unsigned int additional_width = 0;
5867 if (flags.
draw_colorbar) additional_width =
static_cast<unsigned int>(.5 + height * .3);
5870 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\"" << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" <<
'\n' 5871 <<
" <rect width=\"" << width + additional_width <<
"\" height=\"" << height <<
"\" style=\"fill:white\"/>" <<
'\n' <<
'\n';
5873 unsigned int triangle_counter = 0;
5876 for (
typename std::multiset<SvgCell>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell)
5880 for (
unsigned int triangle_index = 0; triangle_index < 4; triangle_index++)
5882 switch (triangle_index)
5885 points3d_triangle[0] = cell->vertices[0], points3d_triangle[1] = cell->vertices[1], points3d_triangle[2] = cell->center;
5888 points3d_triangle[0] = cell->vertices[1], points3d_triangle[1] = cell->vertices[3], points3d_triangle[2] = cell->center;
5891 points3d_triangle[0] = cell->vertices[3], points3d_triangle[1] = cell->vertices[2], points3d_triangle[2] = cell->center;
5894 points3d_triangle[0] = cell->vertices[2], points3d_triangle[1] = cell->vertices[0], points3d_triangle[2] = cell->center;
5900 Point<6> gradient_param = svg_get_gradient_parameters(points3d_triangle);
5902 double start_h = .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
5903 double stop_h = .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
5905 unsigned int start_r = 0;
5906 unsigned int start_g = 0;
5907 unsigned int start_b = 0;
5909 unsigned int stop_r = 0;
5910 unsigned int stop_g = 0;
5911 unsigned int stop_b = 0;
5913 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
5914 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
5916 double start_f = start_h * 6. - start_i;
5917 double start_q = 1. - start_f;
5919 double stop_f = stop_h * 6. - stop_i;
5920 double stop_q = 1. - stop_f;
5922 switch (start_i % 6)
5925 start_r = 255, start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
5928 start_r =
static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
5931 start_g = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
5934 start_g =
static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
5937 start_r =
static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
5940 start_r = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
5949 stop_r = 255, stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
5952 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
5955 stop_g = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
5958 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
5961 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
5964 stop_r = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
5970 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
5972 gradient_start_point_3d[0] = gradient_param[0];
5973 gradient_start_point_3d[1] = gradient_param[1];
5974 gradient_start_point_3d[2] = gradient_param[4];
5976 gradient_stop_point_3d[0] = gradient_param[2];
5977 gradient_stop_point_3d[1] = gradient_param[3];
5978 gradient_stop_point_3d[2] = gradient_param[5];
5980 Point<2> gradient_start_point = svg_project_point(gradient_start_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
5981 Point<2> gradient_stop_point = svg_project_point(gradient_stop_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
5984 out <<
" <linearGradient id=\"" << triangle_counter <<
"\" gradientUnits=\"userSpaceOnUse\" " 5986 <<
static_cast<unsigned int>(.5 + ((gradient_start_point[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
5989 <<
static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((gradient_start_point[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
5992 <<
static_cast<unsigned int>(.5 + ((gradient_stop_point[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
5995 <<
static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((gradient_stop_point[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
5998 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n' 5999 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n' 6000 <<
" </linearGradient>" <<
'\n';
6003 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
6004 double x3 = cell->projected_center[0];
6005 double y3 = cell->projected_center[1];
6007 switch (triangle_index)
6010 x1 = cell->projected_vertices[0][0], y1 = cell->projected_vertices[0][1], x2 = cell->projected_vertices[1][0], y2 = cell->projected_vertices[1][1];
6013 x1 = cell->projected_vertices[1][0], y1 = cell->projected_vertices[1][1], x2 = cell->projected_vertices[3][0], y2 = cell->projected_vertices[3][1];
6016 x1 = cell->projected_vertices[3][0], y1 = cell->projected_vertices[3][1], x2 = cell->projected_vertices[2][0], y2 = cell->projected_vertices[2][1];
6019 x1 = cell->projected_vertices[2][0], y1 = cell->projected_vertices[2][1], x2 = cell->projected_vertices[0][0], y2 = cell->projected_vertices[0][1];
6025 out <<
" <path d=\"M " 6026 <<
static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6028 <<
static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y1 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
6030 <<
static_cast<unsigned int>(.5 + ((x2 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6032 <<
static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y2 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
6034 <<
static_cast<unsigned int>(.5 + ((x3 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6036 <<
static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y3 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
6038 <<
static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6040 <<
static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y1 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
6041 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter <<
"); stroke-width:" << flags.line_thickness <<
"\"/>" <<
'\n';
6051 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
6053 unsigned int element_height =
static_cast<unsigned int>(((height/100.) * (71. - 2.*margin_in_percent)) / 4);
6054 unsigned int element_width =
static_cast<unsigned int>(.5 + (height/100.) * 2.5);
6056 additional_width = 0;
6057 if (!flags.
margin) additional_width =
static_cast<unsigned int>(.5 + (height/100.) * 2.5);
6059 for (
unsigned int index = 0; index < 4; index++)
6061 double start_h = .667 - ((index+1) / 4.) * .667;
6062 double stop_h = .667 - (index / 4.) * .667;
6064 unsigned int start_r = 0;
6065 unsigned int start_g = 0;
6066 unsigned int start_b = 0;
6068 unsigned int stop_r = 0;
6069 unsigned int stop_g = 0;
6070 unsigned int stop_b = 0;
6072 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6073 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6075 double start_f = start_h * 6. - start_i;
6076 double start_q = 1. - start_f;
6078 double stop_f = stop_h * 6. - stop_i;
6079 double stop_q = 1. - stop_f;
6081 switch (start_i % 6)
6084 start_r = 255, start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6087 start_r =
static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
6090 start_g = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6093 start_g =
static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
6096 start_r =
static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
6099 start_r = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6108 stop_r = 255, stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6111 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
6114 stop_g = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6117 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
6120 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
6123 stop_r = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6130 out <<
" <linearGradient id=\"colorbar_" << index <<
"\" gradientUnits=\"userSpaceOnUse\" " 6131 <<
"x1=\"" << width + additional_width <<
"\" " 6132 <<
"y1=\"" <<
static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height <<
"\" " 6133 <<
"x2=\"" << width + additional_width <<
"\" " 6134 <<
"y2=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (4-index) * element_height <<
"\"" 6136 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n' 6137 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n' 6138 <<
" </linearGradient>" <<
'\n';
6142 <<
" x=\"" << width + additional_width
6143 <<
"\" y=\"" <<
static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height
6144 <<
"\" width=\"" << element_width
6145 <<
"\" height=\"" << element_height
6146 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_" << index <<
")\"/>" <<
'\n';
6149 for (
unsigned int index = 0; index < 5; index++)
6151 out <<
" <text x=\"" << width + additional_width +
static_cast<unsigned int>(1.5 * element_width)
6152 <<
"\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29) + (4.-index) * element_height + 30.) <<
"\"" 6153 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
6155 if (index == 0 || index == 4) out <<
"; font-weight:bold";
6157 out <<
"\">" << (float)(((
int)((z_min + index * (z_dimension / 4.))*10000))/10000.);
6159 if (index == 4) out <<
" max";
6160 if (index == 0) out <<
" min";
6162 out <<
"</text>" <<
'\n';
6167 out <<
'\n' <<
"</svg>";
6174 template <
int dim,
int spacedim>
6177 const std::vector<std::string> &data_names,
6178 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
6189 out << dim <<
' ' << spacedim <<
'\n';
6192 out <<
"[deal.II intermediate format graphics data]" <<
'\n' 6193 <<
"[written by " << DEAL_II_PACKAGE_NAME <<
" " << DEAL_II_PACKAGE_VERSION <<
"]" <<
'\n' 6194 <<
"[Version: " << Deal_II_IntermediateFlags::format_version <<
"]" <<
'\n';
6196 out << data_names.size() <<
'\n';
6197 for (
unsigned int i=0; i<data_names.size(); ++i)
6198 out << data_names[i] <<
'\n';
6200 out << patches.size() <<
'\n';
6201 for (
unsigned int i=0; i<patches.size(); ++i)
6202 out << patches[i] <<
'\n';
6204 out << vector_data_ranges.size() <<
'\n';
6205 for (
unsigned int i=0; i<vector_data_ranges.size(); ++i)
6206 out << std_cxx11::get<0>(vector_data_ranges[i]) <<
' ' 6207 << std_cxx11::get<1>(vector_data_ranges[i]) <<
'\n' 6208 << std_cxx11::get<2>(vector_data_ranges[i]) <<
'\n';
6218 std::pair<unsigned int, unsigned int>
6223 unsigned int dim, spacedim;
6224 input >> dim >> spacedim;
6226 return std::make_pair (dim, spacedim);
6236 template <
int dim,
int spacedim>
6238 : default_subdivisions(1)
6242 template <
int dim,
int spacedim>
6249 template <
int dim,
int spacedim>
6253 get_vector_data_ranges(),
6259 template <
int dim,
int spacedim>
6263 get_vector_data_ranges(),
6269 template <
int dim,
int spacedim>
6273 get_vector_data_ranges(),
6274 gnuplot_flags, out);
6279 template <
int dim,
int spacedim>
6283 get_vector_data_ranges(),
6289 template <
int dim,
int spacedim>
6293 get_vector_data_ranges(),
6299 template <
int dim,
int spacedim>
6303 get_vector_data_ranges(),
6309 template <
int dim,
int spacedim>
6313 get_vector_data_ranges(),
6314 tecplot_flags, out);
6319 template <
int dim,
int spacedim>
6323 get_vector_data_ranges(),
6324 tecplot_flags, out);
6329 template <
int dim,
int spacedim>
6333 get_vector_data_ranges(),
6337 template <
int dim,
int spacedim>
6341 get_vector_data_ranges(),
6345 template <
int dim,
int spacedim>
6349 get_vector_data_ranges(),
6353 template <
int dim,
int spacedim>
6356 #ifndef DEAL_II_WITH_MPI 6360 std::ofstream f(filename);
6365 int ierr = MPI_Comm_rank(comm, &myrank);
6367 ierr = MPI_Comm_size(comm, &nproc);
6371 ierr = MPI_Info_create(&info);
6374 ierr = MPI_File_open(comm, const_cast<char *>(filename),
6375 MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
6378 ierr = MPI_File_set_size(fh, 0);
6382 ierr = MPI_Barrier(comm);
6384 ierr = MPI_Info_free(&info);
6387 unsigned int header_size;
6392 std::stringstream ss;
6394 header_size = ss.str().size();
6395 ierr = MPI_File_write(fh, const_cast<char *>(ss.str().c_str()), header_size,
6396 MPI_CHAR, MPI_STATUS_IGNORE);
6400 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0, comm);
6403 ierr = MPI_File_seek_shared( fh, header_size, MPI_SEEK_SET );
6406 std::stringstream ss;
6408 get_vector_data_ranges(),
6410 ierr = MPI_File_write_ordered(fh, const_cast<char *>(ss.str().c_str()),
6411 ss.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
6418 std::stringstream ss;
6420 unsigned int footer_size = ss.str().size();
6421 ierr = MPI_File_write_shared(fh, const_cast<char *>(ss.str().c_str()),
6422 footer_size, MPI_CHAR, MPI_STATUS_IGNORE);
6425 ierr = MPI_File_close( &fh );
6431 template <
int dim,
int spacedim>
6434 const std::vector<std::string> &piece_names)
const 6438 get_dataset_names(),
6439 get_vector_data_ranges());
6444 template <
int dim,
int spacedim>
6448 const std::vector<std::pair<double,std::string> > ×_and_names)
6454 template <
int dim,
int spacedim>
6457 const std::vector<std::string> &piece_names)
6464 template <
int dim,
int spacedim>
6467 const std::vector<std::vector<std::string> > &piece_names)
6474 template <
int dim,
int spacedim>
6477 const std::vector<std::pair<
double,std::vector<std::string> > > ×_and_piece_names)
6484 template <
int dim,
int spacedim>
6489 get_vector_data_ranges(),
6490 deal_II_intermediate_flags, out);
6494 template <
int dim,
int spacedim>
6497 const std::string &h5_filename,
const double cur_time, MPI_Comm comm)
const 6499 return create_xdmf_entry(data_filter, h5_filename, h5_filename, cur_time, comm);
6504 template <
int dim,
int spacedim>
6507 const std::string &h5_mesh_filename,
6508 const std::string &h5_solution_filename,
6509 const double cur_time,
6510 MPI_Comm comm)
const 6512 unsigned int local_node_cell_count[2], global_node_cell_count[2];
6515 #ifndef DEAL_II_WITH_HDF5 6520 (void)h5_mesh_filename;
6521 (void)h5_solution_filename;
6528 local_node_cell_count[0] = data_filter.
n_nodes();
6529 local_node_cell_count[1] = data_filter.
n_cells();
6532 #ifdef DEAL_II_WITH_MPI 6533 int ierr = MPI_Comm_rank(comm, &myrank);
6535 ierr = MPI_Allreduce(local_node_cell_count, global_node_cell_count, 2, MPI_UNSIGNED, MPI_SUM, comm);
6539 global_node_cell_count[0] = local_node_cell_count[0];
6540 global_node_cell_count[1] = local_node_cell_count[1];
6546 XDMFEntry entry(h5_mesh_filename, h5_solution_filename, cur_time, global_node_cell_count[0], global_node_cell_count[1], dim);
6547 unsigned int n_data_sets = data_filter.
n_data_sets();
6551 for (i=0; i<n_data_sets; ++i)
6564 template <
int dim,
int spacedim>
6567 const std::string &filename,
6568 MPI_Comm comm)
const 6572 #ifdef DEAL_II_WITH_MPI 6573 const int ierr = MPI_Comm_rank(comm, &myrank);
6583 std::ofstream xdmf_file(filename.c_str());
6584 std::vector<XDMFEntry>::const_iterator it;
6586 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
6587 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
6588 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
6589 xdmf_file <<
" <Domain>\n";
6590 xdmf_file <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
6593 for (it=entries.begin(); it!=entries.end(); ++it)
6594 xdmf_file << it->get_xdmf_content(3);
6596 xdmf_file <<
" </Grid>\n";
6597 xdmf_file <<
" </Domain>\n";
6598 xdmf_file <<
"</Xdmf>\n";
6611 std::stringstream ss;
6612 std::map<std::string, unsigned int>::const_iterator it;
6614 if (!
valid)
return "";
6616 ss <<
indent(indent_level+0) <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
6617 ss <<
indent(indent_level+1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
6618 ss <<
indent(indent_level+1) <<
"<Geometry GeometryType=\"" << (dimension == 2 ?
"XY" :
"XYZ" ) <<
"\">\n";
6619 ss <<
indent(indent_level+2) <<
"<DataItem Dimensions=\"" <<
num_nodes <<
" " << dimension <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
6620 ss <<
indent(indent_level+3) << h5_mesh_filename <<
":/nodes\n";
6621 ss <<
indent(indent_level+2) <<
"</DataItem>\n";
6622 ss <<
indent(indent_level+1) <<
"</Geometry>\n";
6626 ss <<
indent(indent_level+1) <<
"<Topology TopologyType=\"" << (dimension == 2 ?
"Quadrilateral" :
"Hexahedron") <<
"\" NumberOfElements=\"" << num_cells <<
"\">\n";
6627 ss <<
indent(indent_level+2) <<
"<DataItem Dimensions=\"" << num_cells <<
" " << (2 << (dimension-1)) <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
6628 ss <<
indent(indent_level+3) << h5_mesh_filename <<
":/cells\n";
6629 ss <<
indent(indent_level+2) <<
"</DataItem>\n";
6630 ss <<
indent(indent_level+1) <<
"</Topology>\n";
6635 ss <<
indent(indent_level+1) <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\"" <<
num_nodes <<
"\">\n";
6636 ss <<
indent(indent_level+1) <<
"</Topology>\n";
6641 ss <<
indent(indent_level+1) <<
"<Attribute Name=\"" << it->first <<
"\" AttributeType=\"" << (it->second > 1 ?
"Vector" :
"Scalar") <<
"\" Center=\"Node\">\n";
6643 ss <<
indent(indent_level+2) <<
"<DataItem Dimensions=\"" <<
num_nodes <<
" " << (it->second > 1 ? 3 : 1) <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
6645 ss <<
indent(indent_level+2) <<
"</DataItem>\n";
6646 ss <<
indent(indent_level+1) <<
"</Attribute>\n";
6649 ss <<
indent(indent_level+0) <<
"</Grid>\n";
6658 template <
int dim,
int spacedim>
6663 get_vector_data_ranges(),
6667 template <
int dim,
int spacedim>
6669 const std::vector<std::string> &data_names,
6670 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
6673 const unsigned int n_data_sets = data_names.size();
6674 unsigned int n_node, n_cell;
6678 #ifndef DEAL_II_WITH_MPI 6695 compute_sizes<dim,spacedim>(patches, n_node, n_cell);
6698 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
6702 write_nodes(patches, filtered_data);
6703 write_cells(patches, filtered_data);
6706 reorder_task.join ();
6712 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
6713 std::string vector_name;
6714 for (n_th_vector=0,data_set=0; data_set<n_data_sets;)
6717 while (n_th_vector < vector_data_ranges.size() && std_cxx11::get<0>(vector_data_ranges[n_th_vector]) < data_set) n_th_vector++;
6720 if (n_th_vector < vector_data_ranges.size() && std_cxx11::get<0>(vector_data_ranges[n_th_vector]) == data_set)
6723 pt_data_vector_dim = std_cxx11::get<1>(vector_data_ranges[n_th_vector]) - std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1;
6726 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >= std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
6727 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]), std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
6728 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
6729 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]), 0, n_data_sets));
6736 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
6738 vector_name = std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
6743 for (i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]); i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]); ++i)
6744 vector_name += data_names[i] +
"__";
6745 vector_name += data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
6751 pt_data_vector_dim = 1;
6752 vector_name = data_names[data_set];
6756 filtered_data.
write_data_set(vector_name, pt_data_vector_dim, data_set, data_vectors);
6759 data_set += pt_data_vector_dim;
6765 template <
int dim,
int spacedim>
6768 const std::string &filename, MPI_Comm comm)
const 6775 template <
int dim,
int spacedim>
6778 const bool write_mesh_file,
const std::string &mesh_filename,
const std::string &solution_filename, MPI_Comm comm)
const 6785 template <
int dim,
int spacedim>
6788 const std::string &filename,
6796 template <
int dim,
int spacedim>
6799 const bool write_mesh_file,
6800 const std::string &mesh_filename,
6801 const std::string &solution_filename,
6806 #ifndef DEAL_II_WITH_HDF5 6811 (void)write_mesh_file;
6812 (void)mesh_filename;
6813 (void)solution_filename;
6817 #ifndef DEAL_II_WITH_MPI 6833 hid_t h5_mesh_file_id=-1, h5_solution_file_id, file_plist_id, plist_id;
6834 hid_t node_dataspace, node_dataset, node_file_dataspace, node_memory_dataspace;
6835 hid_t cell_dataspace, cell_dataset, cell_file_dataspace, cell_memory_dataspace;
6836 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace, pt_data_memory_dataspace;
6838 unsigned int local_node_cell_count[2], global_node_cell_count[2], global_node_cell_offsets[2];
6839 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
6840 std::vector<double> node_data_vec;
6841 std::vector<unsigned int> cell_data_vec;
6844 #ifndef H5_HAVE_PARALLEL 6845 # ifdef DEAL_II_WITH_MPI 6847 ierr = MPI_Comm_size(comm, &world_size);
6850 ExcMessage (
"Serial HDF5 output on multiple processes is not yet supported."));
6854 local_node_cell_count[0] = data_filter.
n_nodes();
6855 local_node_cell_count[1] = data_filter.
n_cells();
6858 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
6861 #ifdef DEAL_II_WITH_MPI 6862 #ifdef H5_HAVE_PARALLEL 6864 status = H5Pset_fapl_mpio(file_plist_id, comm, MPI_INFO_NULL);
6871 #ifdef DEAL_II_WITH_MPI 6872 ierr = MPI_Allreduce(local_node_cell_count, global_node_cell_count, 2, MPI_UNSIGNED, MPI_SUM, comm);
6874 ierr = MPI_Scan(local_node_cell_count, global_node_cell_offsets, 2, MPI_UNSIGNED, MPI_SUM, comm);
6876 global_node_cell_offsets[0] -= local_node_cell_count[0];
6877 global_node_cell_offsets[1] -= local_node_cell_count[1];
6879 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
6883 plist_id = H5Pcreate(H5P_DATASET_XFER);
6885 #ifdef DEAL_II_WITH_MPI 6886 #ifdef H5_HAVE_PARALLEL 6887 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
6892 if (write_mesh_file)
6895 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
6899 node_ds_dim[0] = global_node_cell_count[0];
6900 node_ds_dim[1] = dim;
6901 node_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
6904 cell_ds_dim[0] = global_node_cell_count[1];
6906 cell_dataspace = H5Screate_simple(2, cell_ds_dim, NULL);
6910 #if H5Gcreate_vers == 1 6911 node_dataset = H5Dcreate(h5_mesh_file_id,
"nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT);
6913 node_dataset = H5Dcreate(h5_mesh_file_id,
"nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
6916 #if H5Gcreate_vers == 1 6917 cell_dataset = H5Dcreate(h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
6919 cell_dataset = H5Dcreate(h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
6924 status = H5Sclose(node_dataspace);
6926 status = H5Sclose(cell_dataspace);
6930 count[0] = local_node_cell_count[0];
6932 offset[0] = global_node_cell_offsets[0];
6934 node_memory_dataspace = H5Screate_simple(2, count, NULL);
6938 node_file_dataspace = H5Dget_space(node_dataset);
6940 status = H5Sselect_hyperslab(node_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
6944 count[0] = local_node_cell_count[1];
6946 offset[0] = global_node_cell_offsets[1];
6948 cell_memory_dataspace = H5Screate_simple(2, count, NULL);
6951 cell_file_dataspace = H5Dget_space(cell_dataset);
6953 status = H5Sselect_hyperslab(cell_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
6958 status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, &node_data_vec[0]);
6960 node_data_vec.clear();
6963 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
6964 status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, &cell_data_vec[0]);
6966 cell_data_vec.clear();
6969 status = H5Sclose(node_file_dataspace);
6971 status = H5Sclose(cell_file_dataspace);
6975 status = H5Sclose(node_memory_dataspace);
6977 status = H5Sclose(cell_memory_dataspace);
6981 status = H5Dclose(node_dataset);
6983 status = H5Dclose(cell_dataset);
6987 if (mesh_filename != solution_filename)
6989 status = H5Fclose(h5_mesh_file_id);
6995 if (mesh_filename == solution_filename && write_mesh_file)
6997 h5_solution_file_id = h5_mesh_file_id;
7002 h5_solution_file_id = H5Fcreate(solution_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
7011 std::string vector_name;
7020 node_ds_dim[0] = global_node_cell_count[0];
7021 node_ds_dim[1] = pt_data_vector_dim;
7022 pt_data_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
7025 #if H5Gcreate_vers == 1 7026 pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT);
7028 pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
7033 count[0] = local_node_cell_count[0];
7034 count[1] = pt_data_vector_dim;
7035 offset[0] = global_node_cell_offsets[0];
7037 pt_data_memory_dataspace = H5Screate_simple(2, count, NULL);
7041 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
7043 status = H5Sselect_hyperslab(pt_data_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
7047 status = H5Dwrite(pt_data_dataset, H5T_NATIVE_DOUBLE, pt_data_memory_dataspace, pt_data_file_dataspace, plist_id, data_filter.
get_data_set(i));
7051 status = H5Sclose(pt_data_dataspace);
7053 status = H5Sclose(pt_data_memory_dataspace);
7055 status = H5Sclose(pt_data_file_dataspace);
7058 status = H5Dclose(pt_data_dataset);
7063 status = H5Pclose(file_plist_id);
7067 status = H5Pclose(plist_id);
7071 status = H5Fclose(h5_solution_file_id);
7079 template <
int dim,
int spacedim>
7086 output_format = default_fmt;
7088 switch (output_format)
7102 write_gnuplot (out);
7118 write_tecplot (out);
7122 write_tecplot_binary (out);
7138 write_deal_II_intermediate (out);
7148 template <
int dim,
int spacedim>
7156 template <
int dim,
int spacedim>
7157 template <
typename FlagType>
7163 if (
typeid(flags) ==
typeid(dx_flags))
7165 else if (
typeid(flags) ==
typeid(ucd_flags))
7167 else if (
typeid(flags) ==
typeid(povray_flags))
7169 else if (
typeid(flags) ==
typeid(eps_flags))
7171 else if (
typeid(flags) ==
typeid(gmv_flags))
7173 else if (
typeid(flags) ==
typeid(tecplot_flags))
7175 else if (
typeid(flags) ==
typeid(vtk_flags))
7177 else if (
typeid(flags) ==
typeid(svg_flags))
7179 else if (
typeid(flags) ==
typeid(deal_II_intermediate_flags))
7187 template <
int dim,
int spacedim>
7200 template <
int dim,
int spacedim>
7206 "A name for the output format to be used");
7208 "Number of subdivisions of each mesh cell");
7250 template <
int dim,
int spacedim>
7254 const std::string &output_name = prm.
get (
"Output format");
7256 default_subdivisions = prm.
get_integer (
"Subdivisions");
7259 dx_flags.parse_parameters (prm);
7263 ucd_flags.parse_parameters (prm);
7267 gnuplot_flags.parse_parameters (prm);
7271 povray_flags.parse_parameters (prm);
7275 eps_flags.parse_parameters (prm);
7279 gmv_flags.parse_parameters (prm);
7283 tecplot_flags.parse_parameters (prm);
7287 vtk_flags.parse_parameters (prm);
7291 deal_II_intermediate_flags.parse_parameters (prm);
7297 template <
int dim,
int spacedim>
7301 return (
sizeof (default_fmt) +
7316 template <
int dim,
int spacedim>
7317 std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
7320 return std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >();
7324 template <
int dim,
int spacedim>
7333 std::set<std::string> all_names;
7335 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
7336 ranges = this->get_vector_data_ranges();
7337 const std::vector<std::string> data_names = this->get_dataset_names();
7338 const unsigned int n_data_sets = data_names.size();
7339 std::vector<bool> data_set_written (n_data_sets,
false);
7341 for (
unsigned int n_th_vector=0; n_th_vector<ranges.size(); ++n_th_vector)
7343 const std::string &name = std_cxx11::get<2>(ranges[n_th_vector]);
7346 Assert(all_names.find(name) == all_names.end(),
7347 ExcMessage(
"Error: names of fields in DataOut need to be unique, " 7348 "but '" + name +
"' is used more than once."));
7349 all_names.insert(name);
7350 for (
unsigned int i=std_cxx11::get<0>(ranges[n_th_vector]);
7351 i<=std_cxx11::get<1>(ranges[n_th_vector]);
7353 data_set_written[i] =
true;
7357 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
7358 if (data_set_written[data_set] ==
false)
7360 const std::string &name = data_names[data_set];
7361 Assert(all_names.find(name) == all_names.end(),
7362 ExcMessage(
"Error: names of fields in DataOut need to be unique, " 7363 "but '" + name +
"' is used more than once."));
7364 all_names.insert(name);
7374 template <
int dim,
int spacedim>
7382 std::vector<typename ::DataOutBase::Patch<dim,spacedim> >
7387 std::vector<std::string> tmp;
7388 tmp.swap (dataset_names);
7391 std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > tmp;
7392 tmp.swap (vector_data_ranges);
7404 std::pair<unsigned int, unsigned int>
7408 (dimension_info.second == spacedim),
7409 ExcIncompatibleDimensions (dimension_info.first, dim,
7410 dimension_info.second, spacedim));
7419 getline (in, header);
7421 std::ostringstream s;
7422 s <<
"[deal.II intermediate format graphics data]";
7424 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7428 getline (in, header);
7430 std::ostringstream s;
7431 s <<
"[written by " << DEAL_II_PACKAGE_NAME <<
" " << DEAL_II_PACKAGE_VERSION <<
"]";
7433 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7437 getline (in, header);
7439 std::ostringstream s;
7442 Assert (header == s.str(),
7443 ExcMessage(
"Invalid or incompatible file format. Intermediate format " 7444 "files can only be read by the same deal.II version as they " 7445 "are written by."));
7449 unsigned int n_datasets;
7451 dataset_names.resize (n_datasets);
7452 for (
unsigned int i=0; i<n_datasets; ++i)
7453 in >> dataset_names[i];
7455 unsigned int n_patches;
7457 patches.resize (n_patches);
7458 for (
unsigned int i=0; i<n_patches; ++i)
7461 unsigned int n_vector_data_ranges;
7462 in >> n_vector_data_ranges;
7463 vector_data_ranges.resize (n_vector_data_ranges);
7464 for (
unsigned int i=0; i<n_vector_data_ranges; ++i)
7466 in >> std_cxx11::get<0>(vector_data_ranges[i])
7467 >> std_cxx11::get<1>(vector_data_ranges[i]);
7480 std_cxx11::get<2>(vector_data_ranges[i]) = name;
7488 template <
int dim,
int spacedim>
7493 typedef typename ::DataOutBase::Patch<dim,spacedim> Patch;
7496 const std::vector<Patch> source_patches = source.
get_patches ();
7506 Assert (get_vector_data_ranges().size() ==
7508 ExcMessage (
"Both sources need to declare the same components " 7510 for (
unsigned int i=0; i<get_vector_data_ranges().size(); ++i)
7512 Assert (std_cxx11::get<0>(get_vector_data_ranges()[i]) ==
7514 ExcMessage (
"Both sources need to declare the same components " 7516 Assert (std_cxx11::get<1>(get_vector_data_ranges()[i]) ==
7518 ExcMessage (
"Both sources need to declare the same components " 7520 Assert (std_cxx11::get<2>(get_vector_data_ranges()[i]) ==
7522 ExcMessage (
"Both sources need to declare the same components " 7527 Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
7529 Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
7531 Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
7538 const unsigned int old_n_patches = patches.size();
7539 patches.insert (patches.end(),
7540 source_patches.begin(),
7541 source_patches.end());
7544 for (
unsigned int i=old_n_patches; i<patches.size(); ++i)
7545 patches[i].patch_index += old_n_patches;
7548 for (
unsigned int i=old_n_patches; i<patches.size(); ++i)
7549 for (
unsigned int n=0; n<GeometryInfo<dim>::faces_per_cell; ++n)
7551 patches[i].neighbors[n] += old_n_patches;
7556 template <
int dim,
int spacedim>
7557 const std::vector<typename ::DataOutBase::Patch<dim,spacedim> > &
7565 template <
int dim,
int spacedim>
7566 std::vector<std::string>
7569 return dataset_names;
7574 template <
int dim,
int spacedim>
7575 std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
7578 return vector_data_ranges;
7585 template <
int dim,
int spacedim>
7591 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]" 7596 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
7600 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
7609 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
7610 for (
unsigned int i=0; i<patch.
data.n_rows(); ++i)
7611 for (
unsigned int j=0; j<patch.
data.n_cols(); ++j)
7612 out << patch.
data[i][j] <<
' ';
7620 template <
int dim,
int spacedim>
7635 getline (in, header);
7636 while ((header.size() != 0) &&
7637 (header[header.size()-1] ==
' '))
7638 header.erase(header.size()-1);
7640 while ((header ==
"") && in);
7642 std::ostringstream s;
7643 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
7645 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7651 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
7654 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
7661 unsigned int n_rows, n_cols;
7662 in >> n_rows >> n_cols;
7664 for (
unsigned int i=0; i<patch.
data.n_rows(); ++i)
7665 for (
unsigned int j=0; j<patch.
data.n_cols(); ++j)
7666 in >> patch.
data[i][j];
7677 #include "data_out_base.inst" 7679 DEAL_II_NAMESPACE_CLOSE
void write_gmv(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const GmvFlags &flags, std::ostream &out)
virtual std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
static void declare_parameters(ParameterHandler &prm)
long int get_integer(const std::string &entry_string) const
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static const unsigned int invalid_unsigned_int
Map3DPoint existing_points
Map of points to an internal index.
unsigned int height_vector
void write_vtu_footer(std::ostream &out)
virtual std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
static void declare_parameters(ParameterHandler &prm)
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcIncompatiblePatchLists()
#define AssertDimension(dim1, dim2)
void parse_parameters(const ParameterHandler &prm)
void write_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const UcdFlags &flags, std::ostream &out)
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm) const
void write_tecplot_binary(std::ostream &out) const
void set_flags(const FlagType &flags)
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const
static ::ExceptionBase & ExcIO()
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names)
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
void write_cell(unsigned int index, unsigned int start, unsigned int d1, unsigned int d2, unsigned int d3)
void parse_parameters(const ParameterHandler &prm)
void merge(const DataOutReader< dim, spacedim > &other)
std::string get(const std::string &entry_string) const
bool valid
Whether this entry is valid and contains data to be written.
unsigned int neighbors[dim > 0 ? GeometryInfo< dim >::faces_per_cell :1]
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
unsigned int n_nodes() const
static RgbValues default_color_function(const double value, const double min_value, const double max_value)
double entry_time
The simulation time associated with this entry.
ZlibCompressionLevel compression_level
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
VtkFlags(const double time=std::numeric_limits< double >::min(), const unsigned int cycle=std::numeric_limits< unsigned int >::min(), const bool print_date_and_time=true, const ZlibCompressionLevel compression_level=best_compression)
void write_vtk(std::ostream &out) const
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, DataOutFilter &filtered_data)
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
std::string get_xdmf_content(const unsigned int indent_level) const
bool filter_duplicate_vertices
static void declare_parameters(ParameterHandler &prm)
std::map< std::string, unsigned int > attribute_dims
The attributes associated with this entry and their dimension.
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void parse_parameters(ParameterHandler &prm)
void write_ucd(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
const char * tecplot_binary_file_name
void enter_subsection(const std::string &subsection)
static ::ExceptionBase & ExcNoPatches()
std::string get_data_set_name(const unsigned int &set_num) const
DataOutBase::DataOutFilterFlags flags
Flags used to specify filtering behavior.
SvgFlags(const unsigned int height_vector=0, const int azimuth_angle=37, const int polar_angle=45, const unsigned int line_thickness=1, const bool margin=true, const bool draw_colorbar=true)
unsigned int n_data_sets() const
std::string default_suffix(const OutputFormat output_format)
EpsFlags(const unsigned int height_vector=0, const unsigned int color_vector=0, const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const double azimut_angle=60, const double turn_angle=30, const double z_scaling=1.0, const bool draw_mesh=true, const bool draw_cells=true, const bool shade_cells=true, const ColorFunction color_function=&default_color_function)
static ::ExceptionBase & ExcNotEnoughSpaceDimensionLabels()
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::vector< std::string > space_dimension_labels
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
std::string indent(const unsigned int indent_level) const
Small function to create indentation for XML file.
double get_double(const std::string &entry_name) const
unsigned int n_cells() const
std::size_t memory_consumption() const
static void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names) 1
T sum(const T &t, const MPI_Comm &mpi_communicator)
void add_attribute(const std::string &attr_name, const unsigned int dimension)
void write_tecplot(std::ostream &out) const
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
void write_povray(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const PovrayFlags &flags, std::ostream &out)
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const EpsFlags &flags, std::ostream &out)
#define Assert(cond, exc)
DXFlags(const bool write_neighbors=false, const bool int_binary=false, const bool coordinates_binary=false, const bool data_binary=false)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names)
void read(std::istream &in)
void internal_add_cell(const unsigned int &cell_index, const unsigned int &pt_index)
OutputFormat parse_output_format(const std::string &format_name)
void write_svg(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const SvgFlags &flags, std::ostream &out)
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, MPI_Comm comm) const
static ::ExceptionBase & ExcIncompatibleDatasetNames()
void write_dx(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const DXFlags &flags, std::ostream &out)
ColorFunction color_function
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
void write_svg(std::ostream &out) const
unsigned int n_subdivisions
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges)
bool get_bool(const std::string &entry_name) const
void parse_parameters(const ParameterHandler &prm)
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
void fill_cell_data(const unsigned int &local_node_offset, std::vector< unsigned int > &cell_data) const
std::string h5_sol_filename
The name of the HDF5 heavy data solution and/or mesh files this entry references. ...
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
virtual ~DataOutInterface()
void parse_parameters(const ParameterHandler &prm)
const double * get_data_set(const unsigned int &set_num) const
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
TecplotFlags(const char *tecplot_binary_file_name=NULL, const char *zone_name=NULL, const double solution_time=-1.0)
void fill_node_data(std::vector< double > &node_data) const
unsigned int get_data_set_dim(const unsigned int &set_num) const
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static void declare_parameters(ParameterHandler &prm)
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
static void declare_parameters(ParameterHandler &prm)
void write_eps(std::ostream &out) const
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_deal_II_intermediate(std::ostream &out) const
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static void declare_parameters(ParameterHandler &prm)
VectorizedArray< Number > sin(const ::VectorizedArray< Number > &x)
static const unsigned int no_neighbor
void write_point(const unsigned int &index, const Point< dim > &p)
std::size_t memory_consumption() const
#define AssertThrowMPI(error_code)
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_tecplot_binary(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_povray(std::ostream &out) const
static const unsigned int space_dim
void set_default_format(const DataOutBase::OutputFormat default_format)
void write_gmv(std::ostream &out) const
unsigned int num_nodes
The number of nodes, cells and dimensionality associated with the data.
PovrayFlags(const bool smooth=false, const bool bicubic_patch=false, const bool external_data=false)
void write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const TecplotFlags &flags, std::ostream &out)
unsigned int color_vector
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
std::size_t memory_consumption() const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
void validate_dataset_names() const
static ::ExceptionBase & ExcNotImplemented()
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim > > &patches, const DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm)
static void declare_parameters(ParameterHandler &prm)
void write_vtu_in_parallel(const char *filename, MPI_Comm comm) const
unsigned int size(const unsigned int i) const
void write_dx(std::ostream &out) const
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const GnuplotFlags &flags, std::ostream &out)
virtual std::vector< std::string > get_dataset_names() const
std::map< unsigned int, unsigned int > filtered_points
Map of actual point index to internal point index.
bool points_are_available
void write_gnuplot(std::ostream &out) const
void write_data_set(const std::string &name, const unsigned int &dimension, const unsigned int &set_num, const Table< 2, double > &data_vectors)
void write_vtu(std::ostream &out) const
void parse_parameters(const ParameterHandler &prm)
Point< 3 > point(const gp_Pnt &p)
std::string get_output_format_names()
VectorizedArray< Number > cos(const ::VectorizedArray< Number > &x)
unsigned int height_vector
static void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names) 1
Task< RT > new_task(const std_cxx11::function< RT()> &function)
static ::ExceptionBase & ExcErrorOpeningTecplotFile(char *arg1)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcTecplotAPIError()
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, MPI_Comm comm) const