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/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)
134 if (plainchar == plaintextend)
136 state_in->result = result;
137 state_in->step = step_A;
138 return codechar - code_out;
140 const char fragment = *plainchar++;
141 result = (fragment & 0x0fc) >> 2;
142 *codechar++ = base64_encode_value(result);
143 result = (fragment & 0x003) << 4;
148 if (plainchar == plaintextend)
150 state_in->result = result;
151 state_in->step = step_B;
152 return codechar - code_out;
154 const char fragment = *plainchar++;
155 result |= (fragment & 0x0f0) >> 4;
156 *codechar++ = base64_encode_value(result);
157 result = (fragment & 0x00f) << 2;
162 if (plainchar == plaintextend)
164 state_in->result = result;
165 state_in->step = step_C;
166 return codechar - code_out;
168 const char fragment = *plainchar++;
169 result |= (fragment & 0x0c0) >> 6;
170 *codechar++ = base64_encode_value(result);
171 result = (fragment & 0x03f) >> 0;
172 *codechar++ = base64_encode_value(result);
177 return codechar - code_out;
180 int base64_encode_blockend(
char *code_out, base64_encodestate *state_in)
182 char *codechar = code_out;
184 switch (state_in->step)
187 *codechar++ = base64_encode_value(state_in->result);
192 *codechar++ = base64_encode_value(state_in->result);
200 return codechar - code_out;
214 encode_block (
const char *data,
217 base64::base64_encodestate state;
218 base64::base64_init_encodestate(&state);
220 char *encoded_data =
new char[2*data_size+1];
222 const int encoded_length_data
223 = base64::base64_encode_block (data, data_size,
224 encoded_data, &state);
225 base64::base64_encode_blockend (encoded_data + encoded_length_data,
241 return Z_NO_COMPRESSION;
245 return Z_BEST_COMPRESSION;
247 return Z_DEFAULT_COMPRESSION;
250 return Z_NO_COMPRESSION;
260 template <
typename T>
261 void write_compressed_block (
const std::vector<T> &data,
263 std::ostream &output_stream)
265 if (data.size() != 0)
269 uLongf compressed_data_length
270 = compressBound (data.size() *
sizeof(T));
271 char *compressed_data =
new char[compressed_data_length];
272 int err = compress2 ((Bytef *) compressed_data,
273 &compressed_data_length,
274 (
const Bytef *) data.data(),
275 data.size() *
sizeof(T),
281 const uint32_t compression_header[4]
283 (uint32_t)(data.size() *
sizeof(T)),
284 (uint32_t)(data.size() *
sizeof(T)),
285 (uint32_t)compressed_data_length
288 char *encoded_header = encode_block (reinterpret_cast<const char *>(&compression_header[0]),
289 4 *
sizeof(compression_header[0]));
290 output_stream << encoded_header;
291 delete[] encoded_header;
295 char *encoded_data = encode_block (compressed_data,
296 compressed_data_length);
297 delete[] compressed_data;
299 output_stream << encoded_data;
300 delete[] encoded_data;
347 bool operator < (
const SvgCell &)
const;
350 bool SvgCell::operator < (
const SvgCell &e)
const 354 return depth >
e.depth;
389 bool operator < (
const EpsCell2d &)
const;
403 template <
int dim,
int spacedim,
typename Number=
double>
405 write_gmv_reorder_data_vectors (
const std::vector<Patch<dim,spacedim> > &patches,
419 const unsigned int n_data_sets
420 =patches[0].points_are_available ? (patches[0].data.n_rows() - spacedim) : patches[0].data.n_rows();
422 Assert (data_vectors.
size()[0] == n_data_sets,
426 unsigned int next_value = 0;
427 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
428 patch != patches.end(); ++patch)
430 const unsigned int n_subdivisions = patch->n_subdivisions;
431 (void)n_subdivisions;
433 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
434 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
437 (n_data_sets + spacedim)
440 patch->data.n_rows()));
441 Assert ((n_data_sets == 0)
443 (patch->data.n_cols() == Utilities::fixed_power<dim>(n_subdivisions+1)),
446 for (
unsigned int i=0; i<patch->data.n_cols(); ++i, ++next_value)
447 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
448 data_vectors[data_set][next_value] = patch->data(data_set,i);
451 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
452 Assert (data_vectors[data_set].size() == next_value,
462 node_dim (
numbers::invalid_unsigned_int),
463 vertices_per_cell (
numbers::invalid_unsigned_int)
471 node_dim (
numbers::invalid_unsigned_int),
472 vertices_per_cell (
numbers::invalid_unsigned_int)
485 for (
unsigned int d=0; d<dim; ++d)
489 unsigned int internal_ind;
499 internal_ind = it->second;
509 const unsigned int pt_index)
523 for (
unsigned int d=0; d<
node_dim; ++d)
524 node_data[
node_dim*it->second+d] = it->first(d);
532 std::vector<unsigned int> &cell_data)
const 538 cell_data[it->first] = it->second+local_node_offset;
607 const unsigned int start,
608 const unsigned int d1,
609 const unsigned int d2,
610 const unsigned int d3)
636 const unsigned int dimension,
637 const unsigned int set_num,
640 unsigned int new_dim;
658 for (
unsigned int d=0; d<new_dim; ++d)
661 data_sets.back()[r*new_dim+d] = data_vectors(set_num+d, i);
677 const char *gmv_cell_type[4] =
679 "",
"line 2",
"quad 4",
"hex 8" 682 const char *ucd_cell_type[4] =
684 "pt",
"line",
"quad",
"hex" 687 const char *tecplot_cell_type[4] =
689 "",
"lineseg",
"quadrilateral",
"brick" 692 #ifdef DEAL_II_HAVE_TECPLOT 693 const unsigned int tecplot_binary_cell_type[4] =
703 const unsigned int vtk_cell_type[5] =
705 1, 3, 9, 12,
static_cast<unsigned int>(-1)
718 template <
int dim,
int spacedim>
724 const unsigned int xstep,
725 const unsigned int ystep,
726 const unsigned int zstep,
727 const unsigned int n_subdivisions)
731 unsigned int point_no=0;
736 point_no+=(n_subdivisions+1)*(n_subdivisions+1)*zstep;
740 point_no+=(n_subdivisions+1)*ystep;
753 for (
unsigned int d=0;
d<spacedim; ++
d)
754 node[d]=patch->
data(patch->
data.
size(0)-spacedim+
d,point_no);
763 const double stepsize=1./n_subdivisions,
764 xfrac=xstep*stepsize;
769 const double yfrac=ystep*stepsize;
771 node += ((patch->
vertices[3] * xfrac) + (patch->
vertices[2] * (1-xfrac))) * yfrac;
774 const double zfrac=zstep*stepsize;
788 template <
int dim,
int spacedim>
792 unsigned int &n_nodes,
793 unsigned int &n_cells)
798 patch!=patches.end(); ++patch)
810 template <
typename FlagsType>
817 StreamBase (std::ostream &stream,
818 const FlagsType &flags)
820 selected_component (
numbers::invalid_unsigned_int),
830 void write_point (
const unsigned int,
834 "reimplement this function if you want to call " 843 void flush_points () {}
851 void write_cell (
const unsigned int ,
858 "reimplement this function if you want to call " 868 void flush_cells () {}
874 template <
typename T>
887 unsigned int selected_component;
894 std::ostream &stream;
899 const FlagsType flags;
908 class DXStream :
public StreamBase<DataOutBase::DXFlags>
911 DXStream (std::ostream &stream,
915 void write_point (
const unsigned int index,
929 void write_cell (
const unsigned int index,
930 const unsigned int start,
931 const unsigned int x_offset,
932 const unsigned int y_offset,
933 const unsigned int z_offset);
945 template <
typename data>
946 void write_dataset (
const unsigned int index,
947 const std::vector<data> &values);
956 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
959 GmvStream (std::ostream &stream,
963 void write_point (
const unsigned int index,
977 void write_cell (
const unsigned int index,
978 const unsigned int start,
979 const unsigned int x_offset,
980 const unsigned int y_offset,
981 const unsigned int z_offset);
990 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
993 TecplotStream (std::ostream &stream,
997 void write_point (
const unsigned int index,
1011 void write_cell (
const unsigned int index,
1012 const unsigned int start,
1013 const unsigned int x_offset,
1014 const unsigned int y_offset,
1015 const unsigned int z_offset);
1024 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
1027 UcdStream (std::ostream &stream,
1031 void write_point (
const unsigned int index,
1049 void write_cell (
const unsigned int index,
1050 const unsigned int start,
1051 const unsigned int x_offset,
1052 const unsigned int y_offset,
1053 const unsigned int z_offset);
1065 template <
typename data>
1066 void write_dataset (
const unsigned int index,
1067 const std::vector<data> &values);
1076 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
1079 VtkStream (std::ostream &stream,
1083 void write_point (
const unsigned int index,
1097 void write_cell (
const unsigned int index,
1098 const unsigned int start,
1099 const unsigned int x_offset,
1100 const unsigned int y_offset,
1101 const unsigned int z_offset);
1105 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
1108 VtuStream (std::ostream &stream,
1112 void write_point (
const unsigned int index,
1115 void flush_points ();
1128 void write_cell (
const unsigned int index,
1129 const unsigned int start,
1130 const unsigned int x_offset,
1131 const unsigned int y_offset,
1132 const unsigned int z_offset);
1134 void flush_cells ();
1136 template <
typename T>
1150 template <
typename T>
1151 std::ostream &operator<< (const std::vector<T> &);
1166 std::vector<float> vertices;
1167 std::vector<int32_t> cells;
1173 DXStream::DXStream (std::ostream &out,
1182 DXStream::write_point (
const unsigned int,
1185 if (flags.coordinates_binary)
1188 for (
unsigned int d=0;
d<dim; ++
d)
1190 stream.write(reinterpret_cast<const char *>(data),
1191 dim *
sizeof(*data));
1195 for (
unsigned int d=0;
d<dim; ++
d)
1196 stream << p(d) <<
'\t';
1205 DXStream::write_cell (
unsigned int,
1232 if (flags.int_binary)
1233 stream.write(reinterpret_cast<const char *>(nodes),
1234 (1<<dim) *
sizeof(*nodes));
1237 const unsigned int final = (1<<dim) - 1;
1238 for (
unsigned int i=0; i<final ; ++i)
1239 stream << nodes[i] <<
'\t';
1240 stream << nodes[
final] <<
'\n';
1246 template <
typename data>
1249 DXStream::write_dataset (
const unsigned int,
1250 const std::vector<data> &values)
1252 if (flags.data_binary)
1254 stream.write(reinterpret_cast<const char *>(values.data()),
1255 values.size()*
sizeof(data));
1259 for (
unsigned int i=0; i<values.size(); ++i)
1260 stream <<
'\t' << values[i];
1269 GmvStream::GmvStream (std::ostream &out,
1278 GmvStream::write_point (
const unsigned int,
1283 stream << p(selected_component) <<
' ';
1290 GmvStream::write_cell (
unsigned int,
1298 const unsigned int start=s+1;
1299 stream << gmv_cell_type[dim] <<
'\n';
1304 stream <<
'\t' << start+d1;
1307 stream <<
'\t' << start+d2+d1
1308 <<
'\t' << start+d2;
1311 stream <<
'\t' << start+d3
1312 <<
'\t' << start+d3+d1
1313 <<
'\t' << start+d3+d2+d1
1314 <<
'\t' << start+d3+d2;
1323 TecplotStream::TecplotStream (std::ostream &out,
1332 TecplotStream::write_point (
const unsigned int,
1337 stream << p(selected_component) <<
'\n';
1344 TecplotStream::write_cell (
unsigned int,
1350 const unsigned int start = s+1;
1355 stream <<
'\t' << start+d1;
1358 stream <<
'\t' << start+d2+d1
1359 <<
'\t' << start+d2;
1362 stream <<
'\t' << start+d3
1363 <<
'\t' << start+d3+d1
1364 <<
'\t' << start+d3+d2+d1
1365 <<
'\t' << start+d3+d2;
1374 UcdStream::UcdStream (std::ostream &out,
1383 UcdStream::write_point (
const unsigned int index,
1389 for (
unsigned int i=0; i<dim; ++i)
1390 stream << p(i) <<
' ';
1392 for (
unsigned int i=dim; i<3; ++i)
1401 UcdStream::write_cell (
unsigned int index,
1431 stream << index+1 <<
"\t0 " << ucd_cell_type[dim];
1432 const unsigned int final = (1<<dim);
1433 for (
unsigned int i=0; i<final ; ++i)
1434 stream <<
'\t' << nodes[i]+1;
1440 template <
typename data>
1443 UcdStream::write_dataset (
const unsigned int index,
1444 const std::vector<data> &values)
1447 for (
unsigned int i=0; i<values.size(); ++i)
1448 stream <<
'\t' << values[i];
1456 VtkStream::VtkStream (std::ostream &out,
1465 VtkStream::write_point (
const unsigned int,
1471 for (
unsigned int i=dim; i<3; ++i)
1480 VtkStream::write_cell (
unsigned int,
1486 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' 1489 stream <<
'\t' << start+d1;
1493 stream <<
'\t' << start+d2+d1
1494 <<
'\t' << start+d2;
1497 stream <<
'\t' << start+d3
1498 <<
'\t' << start+d3+d1
1499 <<
'\t' << start+d3+d2+d1
1500 <<
'\t' << start+d3+d2;
1509 VtuStream::VtuStream (std::ostream &out,
1518 VtuStream::write_point (
const unsigned int,
1521 #if !defined(DEAL_II_WITH_ZLIB) 1525 for (
unsigned int i=dim; i<3; ++i)
1532 for (
unsigned int i=0; i<dim; ++i)
1533 vertices.push_back(p[i]);
1534 for (
unsigned int i=dim; i<3; ++i)
1535 vertices.push_back(0);
1541 VtuStream::flush_points ()
1543 #ifdef DEAL_II_WITH_ZLIB 1547 *
this << vertices <<
'\n';
1555 VtuStream::write_cell (
unsigned int,
1561 #if !defined(DEAL_II_WITH_ZLIB) 1569 stream <<
'\t' << start+d2+d1
1570 <<
'\t' << start+d2;
1573 stream <<
'\t' << start+d3
1574 <<
'\t' << start+d3+d1
1575 <<
'\t' << start+d3+d2+d1
1576 <<
'\t' << start+d3+d2;
1582 cells.push_back (start);
1585 cells.push_back (start+d1);
1588 cells.push_back (start+d2+d1);
1589 cells.push_back (start+d2);
1592 cells.push_back (start+d3);
1593 cells.push_back (start+d3+d1);
1594 cells.push_back (start+d3+d2+d1);
1595 cells.push_back (start+d3+d2);
1605 VtuStream::flush_cells ()
1607 #ifdef DEAL_II_WITH_ZLIB 1611 *
this << cells <<
'\n';
1617 template <
typename T>
1619 VtuStream::operator<< (const std::vector<T> &data)
1621 #ifdef DEAL_II_WITH_ZLIB 1625 write_compressed_block (data, flags, stream);
1627 for (
unsigned int i=0; i<data.size(); ++i)
1628 stream << data[i] <<
' ';
1642 template <
int dim,
int spacedim>
1646 template <
int dim,
int spacedim>
1650 template <
int dim,
int spacedim>
1653 patch_index(no_neighbor),
1655 points_are_available(false)
1659 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
1660 neighbors[i] = no_neighbor;
1668 template <
int dim,
int spacedim>
1673 const double epsilon=3e-16;
1674 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1675 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1678 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
1691 if (data.n_rows() != patch.
data.n_rows())
1694 if (data.n_cols() != patch.
data.n_cols())
1697 for (
unsigned int i=0; i<data.n_rows(); ++i)
1698 for (
unsigned int j=0; j<data.n_cols(); ++j)
1699 if (data[i][j] != patch.
data[i][j])
1707 template <
int dim,
int spacedim>
1711 return (
sizeof(vertices)/
sizeof(vertices[0]) *
1714 sizeof(neighbors)/
sizeof(neighbors[0]) *
1728 template <
int dim,
int spacedim>
1736 data.swap (other_patch.
data);
1742 template <
int spacedim>
1746 template <
int spacedim>
1750 template <
int spacedim>
1753 template <
int spacedim>
1754 unsigned int Patch<0,spacedim>::n_subdivisions = 1;
1756 template <
int spacedim>
1759 patch_index(no_neighbor),
1760 points_are_available(false)
1767 template <
int spacedim>
1771 const unsigned int dim = 0;
1774 const double epsilon=3e-16;
1775 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1785 if (
data.n_rows() != patch.
data.n_rows())
1788 if (
data.n_cols() != patch.
data.n_cols())
1791 for (
unsigned int i=0; i<
data.n_rows(); ++i)
1792 for (
unsigned int j=0; j<
data.n_cols(); ++j)
1793 if (
data[i][j] != patch.
data[i][j])
1801 template <
int spacedim>
1815 template <
int spacedim>
1829 write_preamble (write_preamble)
1844 : space_dimension_labels(labels)
1858 const bool bicubic_patch,
1859 const bool external_data)
1862 bicubic_patch(bicubic_patch),
1863 external_data(external_data)
1868 const bool xdmf_hdf5_output) :
1869 filter_duplicate_vertices(filter_duplicate_vertices),
1870 xdmf_hdf5_output(xdmf_hdf5_output)
1878 "Whether to remove duplicate vertex values. deal.II duplicates " 1879 "vertices once for each adjacent cell so that it can output " 1880 "discontinuous quantities for which there may be more than one " 1881 "value for each vertex position. Setting this flag to " 1882 "'true' will merge all of these values by selecting a " 1883 "random one and outputting this as 'the' value for the vertex. " 1884 "As long as the data to be output corresponds to continuous " 1885 "fields, merging vertices has no effect. On the other hand, " 1886 "if the data to be output corresponds to discontinuous fields " 1887 "(either because you are using a discontinuous finite element, " 1888 "or because you are using a DataPostprocessor that yields " 1889 "discontinuous data, or because the data to be output has been " 1890 "produced by entirely different means), then the data in the " 1891 "output file no longer faithfully represents the underlying data " 1892 "because the discontinuous field has been replaced by a " 1893 "continuous one. Note also that the filtering can not occur " 1894 "on processor boundaries. Thus, a filtered discontinuous field " 1895 "looks like a continuous field inside of a subdomain, " 1896 "but like a discontinuous field at the subdomain boundary." 1898 "In any case, filtering results in drastically smaller output " 1899 "files (smaller by about a factor of 2^dim).");
1902 "Whether the data will be used in an XDMF/HDF5 combination.");
1916 const bool int_binary,
1917 const bool coordinates_binary,
1918 const bool data_binary)
1920 write_neighbors(write_neighbors),
1921 int_binary(int_binary),
1922 coordinates_binary(coordinates_binary),
1923 data_binary(data_binary),
1932 "A boolean field indicating whether neighborship " 1933 "information between cells is to be written to the " 1934 "OpenDX output file");
1937 "Output format of integer numbers, which is " 1938 "either a text representation (ascii) or binary integer " 1939 "values of 32 or 64 bits length");
1942 "Output format of vertex coordinates, which is " 1943 "either a text representation (ascii) or binary " 1944 "floating point values of 32 or 64 bits length");
1947 "Output format of data values, which is " 1948 "either a text representation (ascii) or binary " 1949 "floating point values of 32 or 64 bits length");
1966 "A flag indicating whether a comment should be " 1967 "written to the beginning of the output file " 1968 "indicating date and time of creation as well " 1969 "as the creating program");
1982 const int azimuth_angle,
1983 const int polar_angle,
1984 const unsigned int line_thickness,
1986 const bool draw_colorbar)
1990 height_vector(height_vector),
1991 azimuth_angle(azimuth_angle),
1992 polar_angle(polar_angle),
1993 line_thickness(line_thickness),
1995 draw_colorbar(draw_colorbar)
2004 "A flag indicating whether POVRAY should use smoothed " 2005 "triangles instead of the usual ones");
2008 "Whether POVRAY should use bicubic patches");
2011 "Whether camera and lighting information should " 2012 "be put into an external file \"data.inc\" or into " 2013 "the POVRAY input file");
2028 const unsigned int color_vector,
2030 const unsigned int size,
2031 const double line_width,
2032 const double azimut_angle,
2033 const double turn_angle,
2034 const double z_scaling,
2035 const bool draw_mesh,
2036 const bool draw_cells,
2037 const bool shade_cells,
2038 const ColorFunction color_function)
2040 height_vector(height_vector),
2041 color_vector(color_vector),
2042 size_type(size_type),
2044 line_width(line_width),
2045 azimut_angle(azimut_angle),
2046 turn_angle(turn_angle),
2047 z_scaling(z_scaling),
2048 draw_mesh(draw_mesh),
2049 draw_cells(draw_cells),
2050 shade_cells(shade_cells),
2051 color_function(color_function)
2090 double sum = xmax+ xmin;
2091 double sum13 = xmin+3*xmax;
2092 double sum22 = 2*xmin+2*xmax;
2093 double sum31 = 3*xmin+ xmax;
2094 double dif = xmax-xmin;
2095 double rezdif = 1.0/dif;
2101 else if (x<(sum22)/4)
2103 else if (x<(sum13)/4)
2114 rgb_values.green = 0;
2115 rgb_values.blue = (x-xmin)*4.*rezdif;
2119 rgb_values.green = (4*x-3*xmin-xmax)*rezdif;
2120 rgb_values.blue = (sum22-4.*x)*rezdif;
2123 rgb_values.red = (4*x-2*sum)*rezdif;
2124 rgb_values.green = (xmin+3*xmax-4*x)*rezdif;
2125 rgb_values.blue = 0;
2129 rgb_values.green = (4*x-xmin-3*xmax)*rezdif;
2130 rgb_values.blue = (4.*x-sum13)*rezdif;
2137 rgb_values.red = rgb_values.green = rgb_values.blue = 1;
2150 rgb_values.red = rgb_values.blue = rgb_values.green
2151 = (x-xmin)/(xmax-xmin);
2163 rgb_values.red = rgb_values.blue = rgb_values.green
2164 = 1-(x-xmin)/(xmax-xmin);
2170 bool EpsCell2d::operator < (
const EpsCell2d &e)
const 2174 return depth > e.depth;
2183 "Number of the input vector that is to be used to " 2184 "generate height information");
2187 "Number of the input vector that is to be used to " 2188 "generate color information");
2191 "Whether width or height should be scaled to match " 2193 prm.
declare_entry (
"Size (width or height) in eps units",
"300",
2195 "The size (width or height) to which the eps output " 2196 "file is to be scaled");
2199 "The width in which the postscript renderer is to " 2203 "Angle of the viewing position against the vertical " 2207 "Angle of the viewing direction against the y-axis");
2210 "Scaling for the z-direction relative to the scaling " 2211 "used in x- and y-directions");
2214 "Whether the mesh lines, or only the surface should be " 2218 "Whether only the mesh lines, or also the interior of " 2219 "cells should be plotted. If this flag is false, then " 2220 "one can see through the mesh");
2221 prm.
declare_entry (
"Color shading of interior of cells",
"true",
2223 "Whether the interior of cells shall be shaded");
2226 "Name of a color function used to colorize mesh lines " 2227 "and/or cell interiors");
2236 if (prm.
get (
"Scale to width or height") ==
"width")
2248 if (prm.
get(
"Color function") ==
"default")
2250 else if (prm.
get(
"Color function") ==
"grey scale")
2252 else if (prm.
get(
"Color function") ==
"reverse grey scale")
2266 const char *zone_name,
2267 const double solution_time)
2269 tecplot_binary_file_name(tecplot_binary_file_name),
2270 zone_name(zone_name),
2271 solution_time (solution_time)
2279 return sizeof(*this)
2287 const unsigned int cycle,
2288 const bool print_date_and_time,
2293 print_date_and_time (print_date_and_time),
2294 compression_level (compression_level)
2302 if (format_name ==
"none")
2305 if (format_name ==
"dx")
2308 if (format_name ==
"ucd")
2311 if (format_name ==
"gnuplot")
2314 if (format_name ==
"povray")
2317 if (format_name ==
"eps")
2320 if (format_name ==
"gmv")
2323 if (format_name ==
"tecplot")
2326 if (format_name ==
"tecplot_binary")
2329 if (format_name ==
"vtk")
2332 if (format_name ==
"vtu")
2335 if (format_name ==
"deal.II intermediate")
2338 if (format_name ==
"hdf5")
2342 ExcMessage (
"The given file format name is not recognized: <" 2343 + format_name +
">"));
2354 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2362 switch (output_format)
2401 template <
int dim,
int spacedim,
typename StreamType>
2403 write_nodes (
const std::vector<Patch<dim,spacedim> > &patches,
2407 unsigned int count = 0;
2413 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator
2414 patch=patches.begin();
2415 patch!=patches.end(); ++patch)
2418 const unsigned int n = n_subdivisions+1;
2423 const unsigned int n1 = (dim>0) ? n : 1;
2424 const unsigned int n2 = (dim>1) ? n : 1;
2425 const unsigned int n3 = (dim>2) ? n : 1;
2427 for (
unsigned int i3=0; i3<n3; ++i3)
2428 for (
unsigned int i2=0; i2<n2; ++i2)
2429 for (
unsigned int i1=0; i1<n1; ++i1)
2431 compute_node(node, &*patch,
2436 out.write_point(count++, node);
2439 out.flush_points ();
2442 template <
int dim,
int spacedim,
typename StreamType>
2444 write_cells (
const std::vector<Patch<dim,spacedim> > &patches,
2448 unsigned int count = 0;
2449 unsigned int first_vertex_of_patch = 0;
2453 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator
2454 patch=patches.begin();
2455 patch!=patches.end(); ++patch)
2458 const unsigned int n = n_subdivisions+1;
2460 const unsigned int n1 = (dim>0) ? n_subdivisions : 1;
2461 const unsigned int n2 = (dim>1) ? n_subdivisions : 1;
2462 const unsigned int n3 = (dim>2) ? n_subdivisions : 1;
2464 unsigned int d1 = 1;
2465 unsigned int d2 = n;
2466 unsigned int d3 = n*n;
2467 for (
unsigned int i3=0; i3<n3; ++i3)
2468 for (
unsigned int i2=0; i2<n2; ++i2)
2469 for (
unsigned int i1=0; i1<n1; ++i1)
2471 const unsigned int offset = first_vertex_of_patch+i3*d3+i2*d2+i1*d1;
2473 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2477 first_vertex_of_patch += Utilities::fixed_power<dim>(n_subdivisions+1);
2484 template <
int dim,
int spacedim,
class StreamType>
2487 (
const std::vector<Patch<dim,spacedim> > &patches,
2488 unsigned int n_data_sets,
2489 const bool double_precision,
2493 unsigned int count = 0;
2495 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator patch
2497 patch != patches.end(); ++patch)
2500 const unsigned int n = n_subdivisions+1;
2506 (n_data_sets + spacedim)
2509 patch->
data.n_rows()));
2510 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n),
2513 std::vector<float> floats(n_data_sets);
2514 std::vector<double> doubles(n_data_sets);
2518 for (
unsigned int i=0; i<Utilities::fixed_power<dim>(n); ++i, ++count)
2519 if (double_precision)
2521 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2522 doubles[data_set] = patch->
data(data_set, i);
2523 out.write_dataset(count, doubles);
2527 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2528 floats[data_set] = patch->
data(data_set, i);
2529 out.write_dataset(count, floats);
2549 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] - camera_horizontal[2] * camera_direction[1];
2550 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] - camera_horizontal[0] * camera_direction[2];
2551 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] - camera_horizontal[1] * camera_direction[0];
2555 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];
2558 projection[0] = camera_position[0] + phi * (
point[0] - camera_position[0]);
2559 projection[1] = camera_position[1] + phi * (
point[1] - camera_position[1]);
2560 projection[2] = camera_position[2] + phi * (
point[2] - camera_position[2]);
2563 projection_decomposition[0] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_horizontal[0];
2564 projection_decomposition[0] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_horizontal[1];
2565 projection_decomposition[0] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_horizontal[2];
2567 projection_decomposition[1] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_vertical[0];
2568 projection_decomposition[1] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_vertical[1];
2569 projection_decomposition[1] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_vertical[2];
2571 return projection_decomposition;
2584 for (
int i = 0; i < 2; ++i)
2586 for (
int j = 0; j < 2-i; ++j)
2588 if (points[j][2] > points[j + 1][2])
2591 points[j] = points[j+1];
2599 v_inter = points[1];
2606 A[0][0] = v_max[0] - v_min[0];
2607 A[0][1] = v_inter[0] - v_min[0];
2608 A[1][0] = v_max[1] - v_min[1];
2609 A[1][1] = v_inter[1] - v_min[1];
2615 bool col_change =
false;
2624 double temp = A[1][0];
2629 for (
unsigned int k = 0; k < 1; k++)
2631 for (
unsigned int i = k+1; i < 2; i++)
2633 x = A[i][k] / A[k][k];
2635 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2637 b[i] =
b[i] -
b[k]*x;
2642 b[1] =
b[1] / A[1][1];
2644 for (
int i = 0; i >= 0; i--)
2648 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
2650 b[i] =
sum / A[i][i];
2660 double c =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) + v_min[2];
2663 A[0][0] = v_max[0] - v_min[0];
2664 A[0][1] = v_inter[0] - v_min[0];
2665 A[1][0] = v_max[1] - v_min[1];
2666 A[1][1] = v_inter[1] - v_min[1];
2668 b[0] = 1.0 - v_min[0];
2680 double temp = A[1][0];
2685 for (
unsigned int k = 0; k < 1; k++)
2687 for (
unsigned int i = k+1; i < 2; i++)
2689 x = A[i][k] / A[k][k];
2691 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2693 b[i] =
b[i] -
b[k] * x;
2698 b[1]=
b[1] / A[1][1];
2700 for (
int i = 0; i >= 0; i--)
2704 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j]*b[j];
2706 b[i] =
sum / A[i][i];
2716 gradient[0] =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2719 A[0][0] = v_max[0] - v_min[0];
2720 A[0][1] = v_inter[0] - v_min[0];
2721 A[1][0] = v_max[1] - v_min[1];
2722 A[1][1] = v_inter[1] - v_min[1];
2725 b[1] = 1.0 - v_min[1];
2736 double temp = A[1][0];
2741 for (
unsigned int k = 0; k < 1; k++)
2743 for (
unsigned int i = k+1; i < 2; i++)
2745 x = A[i][k] / A[k][k];
2747 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2749 b[i] =
b[i] -
b[k] * x;
2753 b[1] =
b[1] / A[1][1];
2755 for (
int i = 0; i >= 0; i--)
2759 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
2761 b[i] =
sum / A[i][i];
2771 gradient[1] =
b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2774 double gradient_norm = sqrt(pow(gradient[0], 2.0) + pow(gradient[1], 2.0));
2775 gradient[0] /= gradient_norm;
2776 gradient[1] /= gradient_norm;
2778 double lambda = - gradient[0] * (v_min[0] - v_max[0]) - gradient[1] * (v_min[1] - v_max[1]);
2782 gradient_parameters[0] = v_min[0];
2783 gradient_parameters[1] = v_min[1];
2785 gradient_parameters[2] = v_min[0] + lambda * gradient[0];
2786 gradient_parameters[3] = v_min[1] + lambda * gradient[1];
2788 gradient_parameters[4] = v_min[2];
2789 gradient_parameters[5] = v_max[2];
2791 return gradient_parameters;
2797 template <
int dim,
int spacedim>
2799 const std::vector<std::string> &data_names,
2800 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
2810 #ifndef DEAL_II_WITH_MPI 2826 if (patches.size() == 0)
2830 const unsigned int n_data_sets = data_names.size();
2832 UcdStream ucd_out(out, flags);
2836 unsigned int n_nodes;
2837 unsigned int n_cells;
2838 compute_sizes<dim,spacedim> (patches, n_nodes, n_cells);
2843 out <<
"# This file was generated by the deal.II library." <<
'\n' 2847 <<
"# For a description of the UCD format see the AVS Developer's guide." 2853 out << n_nodes <<
' ' 2855 << n_data_sets <<
' ' 2860 write_nodes(patches, ucd_out);
2863 write_cells(patches, ucd_out);
2868 if (n_data_sets != 0)
2870 out << n_data_sets <<
" ";
2871 for (
unsigned int i=0; i<n_data_sets; ++i)
2876 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2877 out << data_names[data_set]
2881 write_data(patches, n_data_sets,
true, ucd_out);
2892 template <
int dim,
int spacedim>
2894 const std::vector<std::string> &data_names,
2895 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
2904 #ifndef DEAL_II_WITH_MPI 2920 if (patches.size() == 0)
2924 DXStream dx_out(out, flags);
2928 unsigned int offset = 0;
2930 const unsigned int n_data_sets = data_names.size();
2934 unsigned int n_nodes;
2935 unsigned int n_cells;
2936 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
2940 out <<
"object \"vertices\" class array type float rank 1 shape " << spacedim
2941 <<
" items " << n_nodes;
2945 out <<
" lsb ieee data 0" <<
'\n';
2946 offset += n_nodes * spacedim *
sizeof(float);
2950 out <<
" data follows" <<
'\n';
2951 write_nodes(patches, dx_out);
2959 out <<
"object \"cells\" class array type int rank 1 shape " 2961 <<
" items " << n_cells;
2965 out <<
" lsb binary data " << offset <<
'\n';
2966 offset += n_cells *
sizeof (int);
2970 out <<
" data follows" <<
'\n';
2971 write_cells(patches, dx_out);
2976 out <<
"attribute \"element type\" string \"";
2977 if (dim==1) out <<
"lines";
2978 if (dim==2) out <<
"quads";
2979 if (dim==3) out <<
"cubes";
2981 <<
"attribute \"ref\" string \"positions\"" <<
'\n';
2988 out <<
"object \"neighbors\" class array type int rank 1 shape " 2990 <<
" items " << n_cells
2994 patch=patches.begin();
2995 patch!=patches.end(); ++patch)
2998 const unsigned int n1 = (dim>0) ? n : 1;
2999 const unsigned int n2 = (dim>1) ? n : 1;
3000 const unsigned int n3 = (dim>2) ? n : 1;
3001 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
3002 unsigned int dx = 1;
3003 unsigned int dy = n;
3004 unsigned int dz = n*n;
3006 const unsigned int patch_start = patch->
patch_index * cells_per_patch;
3008 for (
unsigned int i3=0; i3<n3; ++i3)
3009 for (
unsigned int i2=0; i2<n2; ++i2)
3010 for (
unsigned int i1=0; i1<n1; ++i1)
3012 const unsigned int nx = i1*
dx;
3013 const unsigned int ny = i2*dy;
3014 const unsigned int nz = i3*dz;
3029 const unsigned int nn = patch->
neighbors[0];
3032 out << (nn*cells_per_patch+ny+nz+
dx*(n-1));
3039 << patch_start+nx-
dx+ny+nz;
3046 const unsigned int nn = patch->
neighbors[1];
3049 out << (nn*cells_per_patch+ny+nz);
3056 << patch_start+nx+
dx+ny+nz;
3063 const unsigned int nn = patch->
neighbors[2];
3066 out << (nn*cells_per_patch+nx+nz+dy*(n-1));
3073 << patch_start+nx+ny-dy+nz;
3078 const unsigned int nn = patch->
neighbors[3];
3081 out << (nn*cells_per_patch+nx+nz);
3088 << patch_start+nx+ny+dy+nz;
3096 const unsigned int nn = patch->
neighbors[4];
3099 out << (nn*cells_per_patch+nx+ny+dz*(n-1));
3106 << patch_start+nx+ny+nz-dz;
3111 const unsigned int nn = patch->
neighbors[5];
3114 out << (nn*cells_per_patch+nx+ny);
3121 << patch_start+nx+ny+nz+dz;
3129 if (n_data_sets != 0)
3131 out <<
"object \"data\" class array type float rank 1 shape " 3133 <<
" items " << n_nodes;
3137 out <<
" lsb ieee data " << offset <<
'\n';
3138 offset += n_data_sets * n_nodes * ((flags.
data_double)
3144 out <<
" data follows" <<
'\n';
3145 write_data(patches, n_data_sets, flags.
data_double, dx_out);
3149 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
3153 out <<
"object \"data\" class constantarray type float rank 0 items " << n_nodes <<
" data follows" 3154 <<
'\n' <<
'0' <<
'\n';
3159 out <<
"object \"deal data\" class field" <<
'\n' 3160 <<
"component \"positions\" value \"vertices\"" <<
'\n' 3161 <<
"component \"connections\" value \"cells\"" <<
'\n' 3162 <<
"component \"data\" value \"data\"" <<
'\n';
3165 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
3168 out <<
"attribute \"created\" string \"" 3174 out <<
"end" <<
'\n';
3177 write_nodes(patches, dx_out);
3179 write_cells(patches, dx_out);
3181 write_data(patches, n_data_sets, flags.
data_double, dx_out);
3193 template <
int dim,
int spacedim>
3195 const std::vector<std::string> &data_names,
3196 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
3202 #ifndef DEAL_II_WITH_MPI 3218 if (patches.size() == 0)
3222 const unsigned int n_data_sets = data_names.size();
3226 out <<
"# This file was generated by the deal.II library." <<
'\n' 3230 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual." 3237 for (
unsigned int spacedim_n=0; spacedim_n<spacedim; ++spacedim_n)
3242 for (
unsigned int i=0; i<data_names.size(); ++i)
3243 out <<
'<' << data_names[i] <<
"> ";
3250 patch != patches.end(); ++patch)
3253 const unsigned int n = n_subdivisions+1;
3255 const unsigned int n1 = (dim>0) ? n : 1;
3256 const unsigned int n2 = (dim>1) ? n : 1;
3257 const unsigned int n3 = (dim>2) ? n : 1;
3258 unsigned int d1 = 1;
3259 unsigned int d2 = n;
3260 unsigned int d3 = n*n;
3266 (n_data_sets + spacedim)
3269 patch->
data.n_rows()));
3270 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n),
3277 for (
unsigned int i2=0; i2<n2; ++i2)
3279 for (
unsigned int i1=0; i1<n1; ++i1)
3283 compute_node(node, &*patch, i1, i2, 0, n_subdivisions);
3286 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3287 out << patch->
data(data_set,i1*d1+i2*d2) <<
' ';
3306 for (
unsigned int i3=0; i3<n3; ++i3)
3307 for (
unsigned int i2=0; i2<n2; ++i2)
3308 for (
unsigned int i1=0; i1<n1; ++i1)
3312 compute_node(this_point, &*patch, i1, i2, i3, n_subdivisions);
3315 if (i1 < n_subdivisions)
3320 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3322 << patch->
data(data_set,i1*d1+i2*d2+i3*d3);
3327 compute_node(node, &*patch, i1+1, i2, i3, n_subdivisions);
3330 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3332 << patch->
data(data_set,(i1+1)*d1+i2*d2+i3*d3);
3342 if (i2 < n_subdivisions)
3347 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3349 << patch->
data(data_set, i1*d1+i2*d2+i3*d3);
3354 compute_node(node, &*patch, i1, i2+1, i3, n_subdivisions);
3357 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3359 << patch->
data(data_set,i1*d1+(i2+1)*d2+i3*d3);
3369 if (i3 < n_subdivisions)
3374 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3376 << patch->
data(data_set,i1*d1+i2*d2+i3*d3);
3381 compute_node(node, &*patch, i1, i2, i3+1, n_subdivisions);
3384 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3386 << patch->
data(data_set,i1*d1+i2*d2+(i3+1)*d3);
3407 template <
int dim,
int spacedim>
3409 const std::vector<std::string> &data_names,
3410 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
3416 #ifndef DEAL_II_WITH_MPI 3432 if (patches.size() == 0)
3438 const unsigned int n_data_sets = data_names.size();
3443 out <<
"/* This file was generated by the deal.II library." <<
'\n' 3447 <<
" For a description of the POVRAY format see the POVRAY manual." 3452 out <<
"#include \"colors.inc\" " <<
'\n' 3453 <<
"#include \"textures.inc\" " <<
'\n';
3459 out <<
"#include \"data.inc\" " <<
'\n';
3464 <<
"camera {" <<
'\n' 3465 <<
" location <1,4,-7>" <<
'\n' 3466 <<
" look_at <0,0,0>" <<
'\n' 3467 <<
" angle 30" <<
'\n' 3472 <<
"light_source {" <<
'\n' 3473 <<
" <1,4,-7>" <<
'\n' 3474 <<
" color Grey" <<
'\n' 3477 <<
"light_source {" <<
'\n' 3478 <<
" <0,20,0>" <<
'\n' 3479 <<
" color White" <<
'\n' 3486 double hmin=patches[0].data(0,0);
3487 double hmax=patches[0].data(0,0);
3490 patch != patches.end(); ++patch)
3498 (n_data_sets + spacedim)
3501 patch->
data.n_rows()));
3502 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n_subdivisions+1),
3505 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
3506 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
3508 const int dl = i*(n_subdivisions+1)+j;
3509 if (patch->
data(0,dl)<hmin)
3510 hmin=patch->
data(0,dl);
3511 if (patch->
data(0,dl)>hmax)
3512 hmax=patch->
data(0,dl);
3516 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n' 3517 <<
"#declare HMAX=" << hmax <<
";" <<
'\n' <<
'\n';
3523 out <<
"#declare Tex=texture{" <<
'\n' 3524 <<
" pigment {" <<
'\n' 3525 <<
" gradient y" <<
'\n' 3526 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n' 3527 <<
" color_map {" <<
'\n' 3528 <<
" [0.00 color Light_Purple] " <<
'\n' 3529 <<
" [0.95 color Light_Purple] " <<
'\n' 3530 <<
" [1.00 color White] " <<
'\n' 3531 <<
"} } }" <<
'\n' <<
'\n';
3538 <<
"mesh {" <<
'\n';
3543 patch != patches.end(); ++patch)
3546 const unsigned int n = n_subdivisions+1;
3547 const unsigned int d1=1;
3548 const unsigned int d2=n;
3554 (n_data_sets + spacedim)
3557 patch->
data.n_rows()));
3558 Assert (patch->
data.n_cols() == Utilities::fixed_power<dim>(n),
3562 std::vector<Point<spacedim> > ver(n*n);
3564 for (
unsigned int i2=0; i2<n; ++i2)
3565 for (
unsigned int i1=0; i1<n; ++i1)
3569 compute_node(ver[i1*d1+i2*d2], &*patch, i1, i2, 0, n_subdivisions);
3577 std::vector<Point<3> > nrml;
3595 for (
unsigned int i=0; i<n; ++i)
3596 for (
unsigned int j=0; j<n; ++j)
3598 const unsigned int il = (i==0) ? i : (i-1);
3599 const unsigned int ir = (i==n_subdivisions) ? i : (i+1);
3600 const unsigned int jl = (j==0) ? j : (j-1);
3601 const unsigned int jr = (j==n_subdivisions) ? j : (j+1);
3603 h1(0)=ver[ir*d1+j*d2](0) - ver[il*d1+j*d2](0);
3604 h1(1)=patch->
data(0,ir*d1+j*d2)-
3605 patch->
data(0,il*d1+j*d2);
3606 h1(2)=ver[ir*d1+j*d2](1) - ver[il*d1+j*d2](1);
3608 h2(0)=ver[i*d1+jr*d2](0) - ver[i*d1+jl*d2](0);
3609 h2(1)=patch->
data(0,i*d1+jr*d2)-
3610 patch->
data(0,i*d1+jl*d2);
3611 h2(2)=ver[i*d1+jr*d2](1) - ver[i*d1+jl*d2](1);
3613 nrml[i*d1+j*d2](0)=h1(1)*h2(2)-h1(2)*h2(1);
3614 nrml[i*d1+j*d2](1)=h1(2)*h2(0)-h1(0)*h2(2);
3615 nrml[i*d1+j*d2](2)=h1(0)*h2(1)-h1(1)*h2(0);
3618 double norm=std::sqrt(
3619 std::pow(nrml[i*d1+j*d2](0),2.)+
3620 std::pow(nrml[i*d1+j*d2](1),2.)+
3621 std::pow(nrml[i*d1+j*d2](2),2.));
3623 if (nrml[i*d1+j*d2](1)<0)
3626 for (
unsigned int k=0; k<3; ++k)
3627 nrml[i*d1+j*d2](k)/=norm;
3632 for (
unsigned int i=0; i<n_subdivisions; ++i)
3633 for (
unsigned int j=0; j<n_subdivisions; ++j)
3636 const int dl = i*d1+j*d2;
3642 out <<
"smooth_triangle {" <<
'\n' <<
"\t<" 3643 << ver[dl](0) <<
"," 3644 << patch->
data(0,dl) <<
"," 3645 << ver[dl](1) <<
">, <" 3646 << nrml[dl](0) <<
", " 3647 << nrml[dl](1) <<
", " 3651 << ver[dl+d1](0) <<
"," 3652 << patch->
data(0,dl+d1) <<
"," 3653 << ver[dl+d1](1) <<
">, <" 3654 << nrml[dl+d1](0) <<
", " 3655 << nrml[dl+d1](1) <<
", " 3659 << ver[dl+d1+d2](0) <<
"," 3660 << patch->
data(0,dl+d1+d2) <<
"," 3661 << ver[dl+d1+d2](1) <<
">, <" 3662 << nrml[dl+d1+d2](0) <<
", " 3663 << nrml[dl+d1+d2](1) <<
", " 3664 << nrml[dl+d1+d2](2)
3668 out <<
"smooth_triangle {" <<
'\n' <<
"\t<" 3669 << ver[dl](0) <<
"," 3670 << patch->
data(0,dl) <<
"," 3671 << ver[dl](1) <<
">, <" 3672 << nrml[dl](0) <<
", " 3673 << nrml[dl](1) <<
", " 3677 << ver[dl+d1+d2](0) <<
"," 3678 << patch->
data(0,dl+d1+d2) <<
"," 3679 << ver[dl+d1+d2](1) <<
">, <" 3680 << nrml[dl+d1+d2](0) <<
", " 3681 << nrml[dl+d1+d2](1) <<
", " 3682 << nrml[dl+d1+d2](2)
3685 << ver[dl+d2](0) <<
"," 3686 << patch->
data(0,dl+d2) <<
"," 3687 << ver[dl+d2](1) <<
">, <" 3688 << nrml[dl+d2](0) <<
", " 3689 << nrml[dl+d2](1) <<
", " 3697 out <<
"triangle {" <<
'\n' <<
"\t<" 3698 << ver[dl](0) <<
"," 3699 << patch->
data(0,dl) <<
"," 3700 << ver[dl](1) <<
">," <<
'\n';
3702 << ver[dl+d1](0) <<
"," 3703 << patch->
data(0,dl+d1) <<
"," 3704 << ver[dl+d1](1) <<
">," <<
'\n';
3706 << ver[dl+d1+d2](0) <<
"," 3707 << patch->
data(0,dl+d1+d2) <<
"," 3708 << ver[dl+d1+d2](1) <<
">}" <<
'\n';
3711 out <<
"triangle {" <<
'\n' <<
"\t<" 3712 << ver[dl](0) <<
"," 3713 << patch->
data(0,dl) <<
"," 3714 << ver[dl](1) <<
">," <<
'\n';
3716 << ver[dl+d1+d2](0) <<
"," 3717 << patch->
data(0,dl+d1+d2) <<
"," 3718 << ver[dl+d1+d2](1) <<
">," <<
'\n';
3720 << ver[dl+d2](0) <<
"," 3721 << patch->
data(0,dl+d2) <<
"," 3722 << ver[dl+d2](1) <<
">}" <<
'\n';
3731 <<
"bicubic_patch {" <<
'\n' 3732 <<
" type 0" <<
'\n' 3733 <<
" flatness 0" <<
'\n' 3734 <<
" u_steps 0" <<
'\n' 3735 <<
" v_steps 0" <<
'\n';
3736 for (
int i=0; i<16; ++i)
3738 out <<
"\t<" << ver[i](0) <<
"," << patch->
data(0,i) <<
"," << ver[i](1) <<
">";
3739 if (i!=15) out <<
",";
3742 out <<
" texture {Tex}" <<
'\n' 3750 out <<
" texture {Tex}" <<
'\n' 3764 template <
int dim,
int spacedim>
3766 const std::vector<std::string> &,
3767 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
3776 template <
int spacedim>
3778 const std::vector<std::string> &,
3779 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
3785 #ifndef DEAL_II_WITH_MPI 3801 if (patches.size() == 0)
3816 std::multiset<EpsCell2d> cells;
3825 double min_color_value=0, max_color_value=0;
3830 double heights[4] = { 0, 0, 0, 0 };
3837 for (
typename std::vector<
Patch<2,spacedim> >::const_iterator patch=patches.begin();
3838 patch!=patches.end(); ++patch)
3841 const unsigned int n = n_subdivisions+1;
3842 const unsigned int d1 = 1;
3843 const unsigned int d2 = n;
3845 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
3846 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
3849 compute_node(points[0], &*patch, i1, i2, 0, n_subdivisions);
3850 compute_node(points[1], &*patch, i1+1, i2, 0, n_subdivisions);
3851 compute_node(points[2], &*patch, i1, i2+1, 0, n_subdivisions);
3852 compute_node(points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
3858 patch->
data.n_rows() == 0,
3860 patch->
data.n_rows()));
3861 heights[0] = patch->
data.n_rows() != 0 ?
3864 heights[1] = patch->
data.n_rows() != 0 ?
3867 heights[2] = patch->
data.n_rows() != 0 ?
3870 heights[3] = patch->
data.n_rows() != 0 ?
3877 for (
unsigned int i=0; i<4; ++i)
3878 heights[i] = points[i](2);
3906 const double cx = -std::cos(pi-flags.
azimut_angle * 2*pi / 360.),
3907 cz = -std::cos(flags.
turn_angle * 2*pi / 360.),
3909 sz = std::sin(flags.
turn_angle * 2*pi / 360.);
3910 for (
unsigned int vertex=0; vertex<4; ++vertex)
3912 const double x = points[vertex](0),
3913 y = points[vertex](1),
3914 z = -heights[vertex];
3916 eps_cell.vertices[vertex](0) = - cz*x+ sz*y;
3917 eps_cell.vertices[vertex](1) = -cx*sz*x-cx*cz*y-sx*z;
3939 = (points[0] + points[1] + points[2] + points[3]) / 4;
3940 const double center_height
3941 = -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
3945 eps_cell.depth = -sx*sz*center_point(0)
3946 -sx*cz*center_point(1)
3952 patch->
data.n_rows() == 0,
3954 patch->
data.n_rows()));
3955 const double color_values[4]
3956 = { patch->
data.n_rows() != 0 ?
3959 patch->
data.n_rows() != 0 ?
3962 patch->
data.n_rows() != 0 ?
3965 patch->
data.n_rows() != 0 ?
3971 eps_cell.color_value = (color_values[0] +
3974 color_values[2]) / 4;
3978 if (patch == patches.begin())
3979 min_color_value = max_color_value = eps_cell.color_value;
3982 min_color_value = (min_color_value < eps_cell.color_value ?
3983 min_color_value : eps_cell.color_value);
3984 max_color_value = (max_color_value > eps_cell.color_value ?
3985 max_color_value : eps_cell.color_value);
3990 cells.insert (eps_cell);
3997 double x_min = cells.begin()->vertices[0](0);
3998 double x_max = x_min;
3999 double y_min = cells.begin()->vertices[0](1);
4000 double y_max = y_min;
4002 for (
typename std::multiset<EpsCell2d>::const_iterator
4004 cell!=cells.end(); ++cell)
4005 for (
unsigned int vertex=0; vertex<4; ++vertex)
4007 x_min = std::min (x_min, cell->vertices[vertex](0));
4008 x_max = std::max (x_max, cell->vertices[vertex](0));
4009 y_min = std::min (y_min, cell->vertices[vertex](1));
4010 y_max = std::max (y_max, cell->vertices[vertex](1));
4018 const double scale = (flags.size /
4023 const Point<2> offset(x_min, y_min);
4028 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n' 4029 <<
"%%Title: deal.II Output" <<
'\n' 4030 <<
"%%Creator: the deal.II library" <<
'\n' 4031 <<
"%%Creation Date: " 4035 <<
"%%BoundingBox: " 4039 <<
static_cast<unsigned int>( (x_max-x_min) * scale + 0.5)
4041 <<
static_cast<unsigned int>( (y_max-y_min) * scale + 0.5)
4052 out <<
"/m {moveto} bind def" <<
'\n' 4053 <<
"/l {lineto} bind def" <<
'\n' 4054 <<
"/s {setrgbcolor} bind def" <<
'\n' 4055 <<
"/sg {setgray} bind def" <<
'\n' 4056 <<
"/lx {lineto closepath stroke} bind def" <<
'\n' 4057 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
4059 out <<
"%%EndProlog" <<
'\n' 4062 out << flags.line_width <<
" setlinewidth" <<
'\n';
4079 if (max_color_value == min_color_value)
4080 max_color_value = min_color_value+1;
4087 for (
typename std::multiset<EpsCell2d>::const_iterator
4089 cell!=cells.end(); ++cell)
4091 if (flags.draw_cells)
4093 if (flags.shade_cells)
4095 const EpsFlags::RgbValues rgb_values
4096 = (*flags.color_function) (cell->color_value,
4101 if (rgb_values.is_grey())
4102 out << rgb_values.red <<
" sg ";
4104 out << rgb_values.red <<
' ' 4105 << rgb_values.green <<
' ' 4106 << rgb_values.blue <<
" s ";
4111 out << (cell->vertices[0]-offset) * scale <<
" m " 4112 << (cell->vertices[1]-offset) *
scale <<
" l " 4113 << (cell->vertices[3]-offset) * scale <<
" l " 4114 << (cell->vertices[2]-offset) *
scale <<
" lf" 4118 if (flags.draw_mesh)
4120 << (cell->vertices[0]-offset) * scale <<
" m " 4121 << (cell->vertices[1]-offset) *
scale <<
" l " 4122 << (cell->vertices[3]-offset) * scale <<
" l " 4123 << (cell->vertices[2]-offset) *
scale <<
" lx" 4126 out <<
"showpage" <<
'\n';
4135 template <
int dim,
int spacedim>
4137 const std::vector<std::string> &data_names,
4138 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
4151 #ifndef DEAL_II_WITH_MPI 4167 if (patches.size() == 0)
4171 GmvStream gmv_out(out, flags);
4172 const unsigned int n_data_sets = data_names.size();
4177 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4178 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4181 (n_data_sets + spacedim)
4184 patches[0].data.n_rows()));
4188 out <<
"gmvinput ascii" 4194 unsigned int n_nodes;
4195 unsigned int n_cells;
4196 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4220 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4222 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4232 out <<
"nodes " << n_nodes <<
'\n';
4233 for (
unsigned int d=0; d<spacedim; ++d)
4235 gmv_out.selected_component = d;
4236 write_nodes(patches, gmv_out);
4241 for (
unsigned int d=spacedim; d<3; ++d)
4243 for (
unsigned int i=0; i<n_nodes; ++i)
4251 out <<
"cells " << n_cells <<
'\n';
4252 write_cells(patches, gmv_out);
4256 out <<
"variable" <<
'\n';
4261 reorder_task.
join ();
4267 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4269 out << data_names[data_set] <<
" 1" <<
'\n';
4270 std::copy (data_vectors[data_set].begin(),
4271 data_vectors[data_set].end(),
4272 std::ostream_iterator<double>(out,
" "));
4280 out <<
"endvars" <<
'\n';
4296 template <
int dim,
int spacedim>
4298 const std::vector<std::string> &data_names,
4299 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
4310 #ifndef DEAL_II_WITH_MPI 4326 if (patches.size() == 0)
4330 TecplotStream tecplot_out(out, flags);
4332 const unsigned int n_data_sets = data_names.size();
4337 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4338 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4341 (n_data_sets + spacedim)
4344 patches[0].data.n_rows()));
4348 unsigned int n_nodes;
4349 unsigned int n_cells;
4350 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4355 out <<
"# This file was generated by the deal.II library." <<
'\n' 4359 <<
"# For a description of the Tecplot format see the Tecplot documentation." 4364 out <<
"Variables=";
4372 out <<
"\"x\", \"y\"";
4375 out <<
"\"x\", \"y\", \"z\"";
4381 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4382 out <<
", \"" << data_names[data_set] <<
"\"";
4388 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4391 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4393 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4394 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4422 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4424 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4433 for (
unsigned int d=0; d<spacedim; ++d)
4435 tecplot_out.selected_component = d;
4436 write_nodes(patches, tecplot_out);
4447 reorder_task.
join ();
4450 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4452 std::copy (data_vectors[data_set].begin(),
4453 data_vectors[data_set].end(),
4454 std::ostream_iterator<double>(out,
"\n"));
4458 write_cells(patches, tecplot_out);
4473 #ifdef DEAL_II_HAVE_TECPLOT 4480 TecplotMacros(
const unsigned int n_nodes = 0,
4481 const unsigned int n_vars = 0,
4482 const unsigned int n_cells = 0,
4483 const unsigned int n_vert = 0);
4485 float &nd(
const unsigned int i,
const unsigned int j);
4486 int &cd(
const unsigned int i,
const unsigned int j);
4487 std::vector<float> nodalData;
4488 std::vector<int> connData;
4490 unsigned int n_nodes;
4491 unsigned int n_vars;
4492 unsigned int n_cells;
4493 unsigned int n_vert;
4498 TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
4499 const unsigned int n_vars,
4500 const unsigned int n_cells,
4501 const unsigned int n_vert)
4508 nodalData.resize(n_nodes*n_vars);
4509 connData.resize(n_cells*n_vert);
4515 TecplotMacros::~TecplotMacros()
4521 float &TecplotMacros::nd (
const unsigned int i,
4522 const unsigned int j)
4524 return nodalData[i*n_nodes+j];
4530 int &TecplotMacros::cd (
const unsigned int i,
4531 const unsigned int j)
4533 return connData[i+j*n_vert];
4544 template <
int dim,
int spacedim>
4546 const std::vector<std::string> &data_names,
4547 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4556 #ifndef DEAL_II_HAVE_TECPLOT 4561 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4570 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4581 if (file_name == NULL)
4588 " file through the TecplotFlags interface."));
4589 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4596 #ifndef DEAL_II_WITH_MPI 4612 if (patches.size() == 0)
4616 const unsigned int n_data_sets = data_names.size();
4621 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4622 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4625 (n_data_sets + spacedim)
4628 patches[0].data.n_rows()));
4632 unsigned int n_nodes;
4633 unsigned int n_cells;
4634 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4637 const unsigned int vars_per_node = (spacedim+n_data_sets),
4640 TecplotMacros tm(n_nodes, vars_per_node, n_cells, nodes_per_cell);
4644 cell_type = tecplot_binary_cell_type[dim];
4646 std::string tec_var_names;
4650 tec_var_names =
"x y";
4653 tec_var_names =
"x y z";
4659 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4661 tec_var_names +=
" ";
4662 tec_var_names += data_names[data_set];
4687 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4689 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4696 for (
unsigned int d=1; d<=spacedim; ++d)
4698 unsigned int entry=0;
4701 patch!=patches.end(); ++patch)
4709 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
4710 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
4712 const double x_frac = i * 1./n_subdivisions,
4713 y_frac = j * 1./n_subdivisions;
4715 tm.nd((d-1),entry) =
static_cast<float>(
4716 (((patch->
vertices[1](d-1) * x_frac) +
4717 (patch->
vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
4718 ((patch->
vertices[3](d-1) * x_frac) +
4719 (patch->
vertices[2](d-1) * (1-x_frac))) * y_frac)
4728 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
4729 for (
unsigned int k=0; k<n_subdivisions+1; ++k)
4730 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
4732 const double x_frac = i * 1./n_subdivisions,
4733 y_frac = k * 1./n_subdivisions,
4734 z_frac = j * 1./n_subdivisions;
4738 tm.nd((d-1),entry) =
static_cast<float>(
4739 ((((patch->
vertices[1](d-1) * x_frac) +
4740 (patch->
vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
4741 ((patch->
vertices[3](d-1) * x_frac) +
4742 (patch->
vertices[2](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) +
4743 (((patch->
vertices[5](d-1) * x_frac) +
4744 (patch->
vertices[4](d-1) * (1-x_frac))) * (1-y_frac) +
4745 ((patch->
vertices[7](d-1) * x_frac) +
4746 (patch->
vertices[6](d-1) * (1-x_frac))) * y_frac) * z_frac)
4763 reorder_task.
join ();
4766 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4767 for (
unsigned int entry=0; entry<data_vectors[data_set].
size(); entry++)
4768 tm.nd((spacedim+data_set),entry) =
static_cast<float>(data_vectors[data_set][entry]);
4776 unsigned int first_vertex_of_patch = 0;
4777 unsigned int elem=0;
4780 patch!=patches.end(); ++patch)
4783 const unsigned int n = n_subdivisions+1;
4784 const unsigned int d1=1;
4785 const unsigned int d2=n;
4786 const unsigned int d3=n*n;
4793 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
4794 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
4796 tm.cd(0,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+1;
4797 tm.cd(1,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+1;
4798 tm.cd(2,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+1;
4799 tm.cd(3,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+1;
4808 for (
unsigned int i3=0; i3<n_subdivisions; ++i3)
4809 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
4810 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
4815 tm.cd(0,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+(i3 )*d3+1;
4816 tm.cd(1,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+(i3 )*d3+1;
4817 tm.cd(2,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+(i3 )*d3+1;
4818 tm.cd(3,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+(i3 )*d3+1;
4819 tm.cd(4,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+(i3+1)*d3+1;
4820 tm.cd(5,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+(i3+1)*d3+1;
4821 tm.cd(6,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+(i3+1)*d3+1;
4822 tm.cd(7,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+(i3+1)*d3+1;
4836 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
4842 num_nodes =
static_cast<int>(n_nodes),
4843 num_cells = static_cast<int>(n_cells);
4845 char dot[2] = {
'.', 0};
4852 char *var_names=
const_cast<char *
> (tec_var_names.c_str());
4853 ierr = TECINI (NULL,
4862 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K',0};
4863 ierr = TECZNE (NULL,
4872 int total = (vars_per_node*num_nodes);
4874 ierr = TECDAT (&total,
4880 ierr = TECNOD (&tm.connData[0]);
4893 template <
int dim,
int spacedim>
4896 const std::vector<std::string> &data_names,
4897 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4903 #ifndef DEAL_II_WITH_MPI 4919 if (patches.size() == 0)
4923 VtkStream vtk_out(out, flags);
4925 const unsigned int n_data_sets = data_names.size();
4928 if (patches[0].points_are_available)
4940 out <<
"# vtk DataFile Version 3.0" 4942 <<
"#This file was generated by the deal.II library";
4954 out <<
"DATASET UNSTRUCTURED_GRID\n" 4963 n_metadata = ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0)
4965 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
4967 out <<
"FIELD FieldData " << n_metadata <<
"\n";
4969 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
4971 out <<
"CYCLE 1 1 int\n" 4972 << flags.
cycle <<
"\n";
4974 if (flags.
time != std::numeric_limits<double>::min())
4976 out <<
"TIME 1 1 double\n" 4977 << flags.
time <<
"\n";
4983 unsigned int n_nodes;
4984 unsigned int n_cells;
4985 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
5009 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
5011 = &write_gmv_reorder_data_vectors<dim,spacedim>;
5021 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
5022 write_nodes(patches, vtk_out);
5026 out <<
"CELLS " << n_cells <<
' ' 5029 write_cells(patches, vtk_out);
5034 out <<
"CELL_TYPES " << n_cells <<
'\n';
5035 for (
unsigned int i=0; i<n_cells; ++i)
5036 out <<
' ' << vtk_cell_type[dim];
5044 reorder_task.
join ();
5052 out <<
"POINT_DATA " << n_nodes
5059 std::vector<bool> data_set_written (n_data_sets,
false);
5060 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5062 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) >=
5063 std::get<0>(vector_data_ranges[n_th_vector]),
5064 ExcLowerRange (std::get<1>(vector_data_ranges[n_th_vector]),
5065 std::get<0>(vector_data_ranges[n_th_vector])));
5066 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
5067 ExcIndexRange (std::get<1>(vector_data_ranges[n_th_vector]),
5069 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) + 1
5070 - std::get<0>(vector_data_ranges[n_th_vector]) <= 3,
5071 ExcMessage (
"Can't declare a vector with more than 3 components " 5075 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5076 i<=std::get<1>(vector_data_ranges[n_th_vector]);
5078 data_set_written[i] =
true;
5087 if (std::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5088 out << std::get<2>(vector_data_ranges[n_th_vector]);
5091 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5092 i<std::get<1>(vector_data_ranges[n_th_vector]);
5094 out << data_names[i] <<
"__";
5095 out << data_names[std::get<1>(vector_data_ranges[n_th_vector])];
5104 for (
unsigned int n=0; n<n_nodes; ++n)
5106 switch (std::get<1>(vector_data_ranges[n_th_vector]) -
5107 std::get<0>(vector_data_ranges[n_th_vector]))
5110 out << data_vectors(std::get<0>(vector_data_ranges[n_th_vector]), n) <<
" 0 0" 5115 out << data_vectors(std::get<0>(vector_data_ranges[n_th_vector]), n) <<
' '<< data_vectors(std::get<0>(vector_data_ranges[n_th_vector])+1, n) <<
" 0" 5119 out << data_vectors(std::get<0>(vector_data_ranges[n_th_vector]), n) <<
' '<< data_vectors(std::get<0>(vector_data_ranges[n_th_vector])+1, n) <<
' '<< data_vectors(std::get<0>(vector_data_ranges[n_th_vector])+2, n)
5136 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
5137 if (data_set_written[data_set] ==
false)
5140 << data_names[data_set]
5143 <<
"LOOKUP_TABLE default" 5145 std::copy (data_vectors[data_set].begin(),
5146 data_vectors[data_set].end(),
5147 std::ostream_iterator<double>(out,
" "));
5164 out <<
"<?xml version=\"1.0\" ?> \n";
5166 out <<
"# vtk DataFile Version 3.0" 5168 <<
"#This file was generated by the deal.II library";
5177 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
5178 #ifdef DEAL_II_WITH_ZLIB 5179 out <<
" compressor=\"vtkZLibDataCompressor\"";
5181 #ifdef DEAL_II_WORDS_BIGENDIAN 5182 out <<
" byte_order=\"BigEndian\"";
5184 out <<
" byte_order=\"LittleEndian\"";
5188 out <<
"<UnstructuredGrid>";
5197 out <<
" </UnstructuredGrid>\n";
5198 out <<
"</VTKFile>\n";
5203 template <
int dim,
int spacedim>
5206 const std::vector<std::string> &data_names,
5207 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
5212 write_vtu_main (patches, data_names, vector_data_ranges, flags, out);
5219 template <
int dim,
int spacedim>
5221 const std::vector<std::string> &data_names,
5222 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
5228 #ifndef DEAL_II_WITH_MPI 5244 if (patches.size() == 0)
5249 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n" 5251 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n" 5253 <<
" <PointData Scalars=\"scalars\">\n";
5254 std::vector<bool> data_set_written (data_names.size(),
false);
5255 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5259 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5260 i<=std::get<1>(vector_data_ranges[n_th_vector]);
5262 data_set_written[i] =
true;
5269 out <<
" <DataArray type=\"Float32\" Name=\"";
5271 if (std::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5272 out << std::get<2>(vector_data_ranges[n_th_vector]);
5275 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5276 i<std::get<1>(vector_data_ranges[n_th_vector]);
5278 out << data_names[i] <<
"__";
5279 out << data_names[std::get<1>(vector_data_ranges[n_th_vector])];
5282 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5285 for (
unsigned int data_set=0; data_set<data_names.size(); ++data_set)
5286 if (data_set_written[data_set] ==
false)
5288 out <<
" <DataArray type=\"Float32\" Name=\"" 5289 << data_names[data_set]
5290 <<
"\"></DataArray>\n";
5293 out <<
" </PointData>\n";
5294 out <<
"</Piece>\n";
5309 n_metadata = ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0)
5311 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5313 out <<
"<FieldData>\n";
5315 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5317 out <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">" 5319 <<
"</DataArray>\n";
5321 if (flags.
time != std::numeric_limits<double>::min())
5323 out <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">" 5325 <<
"</DataArray>\n";
5329 out <<
"</FieldData>\n";
5333 VtuStream vtu_out(out, flags);
5335 const unsigned int n_data_sets = data_names.size();
5340 if (patches[0].points_are_available)
5349 #ifdef DEAL_II_WITH_ZLIB 5350 const char *ascii_or_binary =
"binary";
5352 const char *ascii_or_binary =
"ascii";
5358 unsigned int n_nodes;
5359 unsigned int n_cells;
5360 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
5384 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
5386 = &write_gmv_reorder_data_vectors<dim,spacedim,float>;
5398 out <<
"<Piece NumberOfPoints=\"" << n_nodes
5399 <<
"\" NumberOfCells=\"" << n_cells <<
"\" >\n";
5400 out <<
" <Points>\n";
5401 out <<
" <DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"" 5402 << ascii_or_binary <<
"\">\n";
5403 write_nodes(patches, vtu_out);
5404 out <<
" </DataArray>\n";
5405 out <<
" </Points>\n\n";
5408 out <<
" <Cells>\n";
5409 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"" 5410 << ascii_or_binary <<
"\">\n";
5411 write_cells(patches, vtu_out);
5412 out <<
" </DataArray>\n";
5418 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\"" 5419 << ascii_or_binary <<
"\">\n";
5421 std::vector<int32_t> offsets (n_cells);
5422 for (
unsigned int i=0; i<n_cells; ++i)
5426 out <<
" </DataArray>\n";
5431 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\"" 5432 << ascii_or_binary <<
"\">\n";
5438 #ifdef DEAL_II_WITH_ZLIB 5439 std::vector<uint8_t> cell_types (n_cells,
5440 static_cast<uint8_t>(vtk_cell_type[dim]));
5442 std::vector<unsigned int> cell_types (n_cells,
5443 vtk_cell_type[dim]);
5446 vtu_out << cell_types;
5449 out <<
" </DataArray>\n";
5450 out <<
" </Cells>\n";
5459 reorder_task.
join ();
5467 out <<
" <PointData Scalars=\"scalars\">\n";
5473 std::vector<bool> data_set_written (n_data_sets,
false);
5474 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5476 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) >=
5477 std::get<0>(vector_data_ranges[n_th_vector]),
5478 ExcLowerRange (std::get<1>(vector_data_ranges[n_th_vector]),
5479 std::get<0>(vector_data_ranges[n_th_vector])));
5480 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
5481 ExcIndexRange (std::get<1>(vector_data_ranges[n_th_vector]),
5483 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) + 1
5484 - std::get<0>(vector_data_ranges[n_th_vector]) <= 3,
5485 ExcMessage (
"Can't declare a vector with more than 3 components " 5490 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5491 i<=std::get<1>(vector_data_ranges[n_th_vector]);
5493 data_set_written[i] =
true;
5500 out <<
" <DataArray type=\"Float32\" Name=\"";
5502 if (std::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5503 out << std::get<2>(vector_data_ranges[n_th_vector]);
5506 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5507 i<std::get<1>(vector_data_ranges[n_th_vector]);
5509 out << data_names[i] <<
"__";
5510 out << data_names[std::get<1>(vector_data_ranges[n_th_vector])];
5513 out <<
"\" NumberOfComponents=\"3\" format=\"" 5514 << ascii_or_binary <<
"\">\n";
5519 std::vector<float> data;
5520 data.reserve (n_nodes*dim);
5522 for (
unsigned int n=0; n<n_nodes; ++n)
5524 switch (std::get<1>(vector_data_ranges[n_th_vector]) -
5525 std::get<0>(vector_data_ranges[n_th_vector]))
5528 data.push_back (data_vectors(std::get<0>(vector_data_ranges[n_th_vector]), n));
5534 data.push_back (data_vectors(std::get<0>(vector_data_ranges[n_th_vector]), n));
5535 data.push_back (data_vectors(std::get<0>(vector_data_ranges[n_th_vector])+1, n));
5539 data.push_back (data_vectors(std::get<0>(vector_data_ranges[n_th_vector]), n));
5540 data.push_back (data_vectors(std::get<0>(vector_data_ranges[n_th_vector])+1, n));
5541 data.push_back (data_vectors(std::get<0>(vector_data_ranges[n_th_vector])+2, n));
5555 out <<
" </DataArray>\n";
5559 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
5560 if (data_set_written[data_set] ==
false)
5562 out <<
" <DataArray type=\"Float32\" Name=\"" 5563 << data_names[data_set]
5565 << ascii_or_binary <<
"\">\n";
5567 std::vector<float> data (data_vectors[data_set].begin(),
5568 data_vectors[data_set].end());
5570 out <<
" </DataArray>\n";
5573 out <<
" </PointData>\n";
5576 out <<
" </Piece>\n";
5590 const std::vector<std::string> &piece_names,
5591 const std::vector<std::string> &data_names,
5592 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges)
5596 const unsigned int n_data_sets = data_names.size();
5598 out <<
"<?xml version=\"1.0\"?>\n";
5601 out <<
"#This file was generated by the deal.II library" 5606 out <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
5607 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
5608 out <<
" <PPointData Scalars=\"scalars\">\n";
5612 std::vector<bool> data_set_written (n_data_sets,
false);
5613 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5615 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) >=
5616 std::get<0>(vector_data_ranges[n_th_vector]),
5617 ExcLowerRange (std::get<1>(vector_data_ranges[n_th_vector]),
5618 std::get<0>(vector_data_ranges[n_th_vector])));
5619 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
5620 ExcIndexRange (std::get<1>(vector_data_ranges[n_th_vector]),
5622 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) + 1
5623 - std::get<0>(vector_data_ranges[n_th_vector]) <= 3,
5624 ExcMessage (
"Can't declare a vector with more than 3 components " 5629 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5630 i<=std::get<1>(vector_data_ranges[n_th_vector]);
5632 data_set_written[i] =
true;
5639 out <<
" <PDataArray type=\"Float32\" Name=\"";
5641 if (std::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5642 out << std::get<2>(vector_data_ranges[n_th_vector]);
5645 for (
unsigned int i=std::get<0>(vector_data_ranges[n_th_vector]);
5646 i<std::get<1>(vector_data_ranges[n_th_vector]);
5648 out << data_names[i] <<
"__";
5649 out << data_names[std::get<1>(vector_data_ranges[n_th_vector])];
5652 out <<
"\" NumberOfComponents=\"3\" format=\"ascii\"/>\n";
5655 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
5656 if (data_set_written[data_set] ==
false)
5658 out <<
" <PDataArray type=\"Float32\" Name=\"" 5659 << data_names[data_set]
5660 <<
"\" format=\"ascii\"/>\n";
5663 out <<
" </PPointData>\n";
5665 out <<
" <PPoints>\n";
5666 out <<
" <PDataArray type=\"Float32\" NumberOfComponents=\"3\"/>\n";
5667 out <<
" </PPoints>\n";
5669 for (
unsigned int i=0; i<piece_names.size(); ++i)
5670 out <<
" <Piece Source=\"" << piece_names[i] <<
"\"/>\n";
5672 out <<
" </PUnstructuredGrid>\n";
5673 out <<
"</VTKFile>\n";
5685 const std::vector<std::pair<double,std::string> > ×_and_names)
5689 out <<
"<?xml version=\"1.0\"?>\n";
5692 out <<
"#This file was generated by the deal.II library" 5697 out <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
5698 out <<
" <Collection>\n";
5700 std::streamsize ss = out.precision();
5703 for (
unsigned int i=0; i<times_and_names.size(); ++i)
5704 out <<
" <DataSet timestep=\"" << times_and_names[i].first
5705 <<
"\" group=\"\" part=\"0\" file=\"" << times_and_names[i].second
5708 out <<
" </Collection>\n";
5709 out <<
"</VTKFile>\n";
5721 const std::vector<std::string> &piece_names)
5723 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
5724 for (
unsigned int i=0; i<piece_names.size(); ++i)
5725 out << piece_names[i] <<
'\n';
5734 const std::vector<std::vector<std::string> > &piece_names)
5738 if (piece_names.size() == 0)
5741 const double nblocks = piece_names[0].size();
5742 Assert(nblocks > 0,
ExcMessage(
"piece_names should be a vector of nonempty vectors.") )
5744 out <<
"!NBLOCKS " << nblocks <<
'\n';
5745 for (std::vector<std::vector<std::string> >::const_iterator domain = piece_names.begin(); domain != piece_names.end(); ++domain)
5747 Assert(domain->size() == nblocks,
ExcMessage(
"piece_names should be a vector of equal sized vectors.") )
5748 for (std::vector<std::string>::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain)
5749 out << *subdomain <<
'\n';
5759 const std::vector<std::pair<
double,std::vector<std::string> > > ×_and_piece_names)
5763 if (times_and_piece_names.size() == 0)
5766 const double nblocks = times_and_piece_names[0].second.size();
5767 Assert(nblocks > 0,
ExcMessage(
"time_and_piece_names should contain nonempty vectors of filenames for every timestep.") )
5769 for (std::vector<std::pair<
double,std::vector<std::string> > >::const_iterator domain = times_and_piece_names.begin();
5770 domain != times_and_piece_names.end(); ++domain)
5771 out <<
"!TIME " << domain->first <<
'\n';
5773 out <<
"!NBLOCKS " << nblocks <<
'\n';
5774 for (std::vector<std::pair<
double,std::vector<std::string> > >::const_iterator domain = times_and_piece_names.begin();
5775 domain != times_and_piece_names.end(); ++domain)
5777 Assert(domain->second.size() == nblocks,
ExcMessage(
"piece_names should be a vector of equal sized vectors.") )
5778 for (std::vector<std::string>::const_iterator subdomain = domain->second.begin(); subdomain != domain->second.end(); ++subdomain)
5779 out << *subdomain <<
'\n';
5787 template <
int dim,
int spacedim>
5788 void write_svg (
const std::vector<Patch<dim,spacedim> > &,
5789 const std::vector<std::string> &,
5790 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
5797 template <
int spacedim>
5799 const std::vector<std::string> &,
5800 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &,
5805 const unsigned int height = flags.
height;
5806 unsigned int width = flags.
width;
5809 unsigned int margin_in_percent = 0;
5810 if (flags.
margin) margin_in_percent = 5;
5814 double x_dimension, y_dimension, z_dimension;
5816 typename std::vector<Patch<dim,spacedim> >::const_iterator patch = patches.begin();
5818 unsigned int n_subdivisions = patch->n_subdivisions;
5819 unsigned int n = n_subdivisions + 1;
5820 const unsigned int d1 = 1;
5821 const unsigned int d2 = n;
5827 Point<2> projection_decompositions[4];
5829 compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
5832 patch->data.n_rows() == 0,
5835 double x_min = projected_point[0];
5836 double x_max = x_min;
5837 double y_min = projected_point[1];
5838 double y_max = y_min;
5839 double z_min = patch->data.n_rows() != 0 ? patch->data(flags.
height_vector,0) : 0;
5840 double z_max = z_min;
5843 for (; patch != patches.end(); ++patch)
5845 n_subdivisions = patch->n_subdivisions;
5846 n = n_subdivisions + 1;
5848 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5850 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5852 compute_node(projected_points[0], &*patch, i1, i2, 0, n_subdivisions);
5853 compute_node(projected_points[1], &*patch, i1+1, i2, 0, n_subdivisions);
5854 compute_node(projected_points[2], &*patch, i1, i2+1, 0, n_subdivisions);
5855 compute_node(projected_points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5857 x_min = std::min(x_min, (
double)projected_points[0][0]);
5858 x_min = std::min(x_min, (
double)projected_points[1][0]);
5859 x_min = std::min(x_min, (
double)projected_points[2][0]);
5860 x_min = std::min(x_min, (
double)projected_points[3][0]);
5862 x_max = std::max(x_max, (
double)projected_points[0][0]);
5863 x_max = std::max(x_max, (
double)projected_points[1][0]);
5864 x_max = std::max(x_max, (
double)projected_points[2][0]);
5865 x_max = std::max(x_max, (
double)projected_points[3][0]);
5867 y_min = std::min(y_min, (
double)projected_points[0][1]);
5868 y_min = std::min(y_min, (
double)projected_points[1][1]);
5869 y_min = std::min(y_min, (
double)projected_points[2][1]);
5870 y_min = std::min(y_min, (
double)projected_points[3][1]);
5872 y_max = std::max(y_max, (
double)projected_points[0][1]);
5873 y_max = std::max(y_max, (
double)projected_points[1][1]);
5874 y_max = std::max(y_max, (
double)projected_points[2][1]);
5875 y_max = std::max(y_max, (
double)projected_points[3][1]);
5878 patch->data.n_rows() == 0,
5881 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, i1*d1 + i2*d2));
5882 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + i2*d2));
5883 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, i1*d1 + (i2+1)*d2));
5884 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + (i2+1)*d2));
5886 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, i1*d1 + i2*d2));
5887 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + i2*d2));
5888 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, i1*d1 + (i2+1)*d2));
5889 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + (i2+1)*d2));
5894 x_dimension = x_max - x_min;
5895 y_dimension = y_max - y_min;
5896 z_dimension = z_max - z_min;
5903 float camera_focus = 0;
5906 camera_position[0] = 0.;
5907 camera_position[1] = 0.;
5908 camera_position[2] = z_min + 2. * z_dimension;
5910 camera_direction[0] = 0.;
5911 camera_direction[1] = 0.;
5912 camera_direction[2] = - 1.;
5914 camera_horizontal[0] = 1.;
5915 camera_horizontal[1] = 0.;
5916 camera_horizontal[2] = 0.;
5918 camera_focus = .5 * z_dimension;
5924 const float angle_factor = 3.14159265f / 180.f;
5927 camera_position_temp[1] = std::cos(angle_factor * flags.polar_angle) * camera_position[1] - std::sin(angle_factor * flags.polar_angle) * camera_position[2];
5928 camera_position_temp[2] = std::sin(angle_factor * flags.polar_angle) * camera_position[1] + std::cos(angle_factor * flags.polar_angle) * camera_position[2];
5930 camera_direction_temp[1] = std::cos(angle_factor * flags.polar_angle) * camera_direction[1] - std::sin(angle_factor * flags.polar_angle) * camera_direction[2];
5931 camera_direction_temp[2] = std::sin(angle_factor * flags.polar_angle) * camera_direction[1] + std::cos(angle_factor * flags.polar_angle) * camera_direction[2];
5933 camera_horizontal_temp[1] = std::cos(angle_factor * flags.polar_angle) * camera_horizontal[1] - std::sin(angle_factor * flags.polar_angle) * camera_horizontal[2];
5934 camera_horizontal_temp[2] = std::sin(angle_factor * flags.polar_angle) * camera_horizontal[1] + std::cos(angle_factor * flags.polar_angle) * camera_horizontal[2];
5936 camera_position[1] = camera_position_temp[1];
5937 camera_position[2] = camera_position_temp[2];
5939 camera_direction[1] = camera_direction_temp[1];
5940 camera_direction[2] = camera_direction_temp[2];
5942 camera_horizontal[1] = camera_horizontal_temp[1];
5943 camera_horizontal[2] = camera_horizontal_temp[2];
5946 camera_position_temp[0] = std::cos(angle_factor * flags.
azimuth_angle) * camera_position[0] - std::sin(angle_factor * flags.
azimuth_angle) * camera_position[1];
5947 camera_position_temp[1] = std::sin(angle_factor * flags.
azimuth_angle) * camera_position[0] + std::cos(angle_factor * flags.
azimuth_angle) * camera_position[1];
5949 camera_direction_temp[0] = std::cos(angle_factor * flags.
azimuth_angle) * camera_direction[0] - std::sin(angle_factor * flags.
azimuth_angle) * camera_direction[1];
5950 camera_direction_temp[1] = std::sin(angle_factor * flags.
azimuth_angle) * camera_direction[0] + std::cos(angle_factor * flags.
azimuth_angle) * camera_direction[1];
5952 camera_horizontal_temp[0] = std::cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] - std::sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5953 camera_horizontal_temp[1] = std::sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] + std::cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5955 camera_position[0] = camera_position_temp[0];
5956 camera_position[1] = camera_position_temp[1];
5958 camera_direction[0] = camera_direction_temp[0];
5959 camera_direction[1] = camera_direction_temp[1];
5961 camera_horizontal[0] = camera_horizontal_temp[0];
5962 camera_horizontal[1] = camera_horizontal_temp[1];
5965 camera_position[0] = x_min + .5 * x_dimension;
5966 camera_position[1] = y_min + .5 * y_dimension;
5968 camera_position[0] += (z_min + 2. * z_dimension) * std::sin(angle_factor * flags.polar_angle) * std::sin(angle_factor * flags.
azimuth_angle);
5969 camera_position[1] -= (z_min + 2. * z_dimension) * std::sin(angle_factor * flags.polar_angle) * std::cos(angle_factor * flags.
azimuth_angle);
5973 double x_min_perspective, y_min_perspective;
5974 double x_max_perspective, y_max_perspective;
5975 double x_dimension_perspective, y_dimension_perspective;
5977 patch = patches.begin();
5979 n_subdivisions = patch->n_subdivisions;
5980 n = n_subdivisions + 1;
5984 compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
5987 patch->data.n_rows() == 0,
5990 point[0] = projected_point[0];
5991 point[1] = projected_point[1];
5992 point[2] = patch->data.n_rows() != 0 ? patch->data(flags.
height_vector, 0) : 0;
5994 projection_decomposition = svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
5996 x_min_perspective = projection_decomposition[0];
5997 x_max_perspective = projection_decomposition[0];
5998 y_min_perspective = projection_decomposition[1];
5999 y_max_perspective = projection_decomposition[1];
6002 for (; patch != patches.end(); ++patch)
6004 n_subdivisions = patch->n_subdivisions;
6005 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6007 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6012 compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
6013 compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
6014 compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
6015 compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
6018 patch->data.n_rows() == 0,
6021 vertices[0][0] = projected_vertices[0][0];
6022 vertices[0][1] = projected_vertices[0][1];
6023 vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
6025 vertices[1][0] = projected_vertices[1][0];
6026 vertices[1][1] = projected_vertices[1][1];
6027 vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
6029 vertices[2][0] = projected_vertices[2][0];
6030 vertices[2][1] = projected_vertices[2][1];
6031 vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
6033 vertices[3][0] = projected_vertices[3][0];
6034 vertices[3][1] = projected_vertices[3][1];
6035 vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
6037 projection_decompositions[0] = svg_project_point(vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
6038 projection_decompositions[1] = svg_project_point(vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
6039 projection_decompositions[2] = svg_project_point(vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
6040 projection_decompositions[3] = svg_project_point(vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
6042 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[0][0]);
6043 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[1][0]);
6044 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[2][0]);
6045 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[3][0]);
6047 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[0][0]);
6048 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[1][0]);
6049 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[2][0]);
6050 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[3][0]);
6052 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[0][1]);
6053 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[1][1]);
6054 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[2][1]);
6055 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[3][1]);
6057 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[0][1]);
6058 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[1][1]);
6059 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[2][1]);
6060 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[3][1]);
6065 x_dimension_perspective = x_max_perspective - x_min_perspective;
6066 y_dimension_perspective = y_max_perspective - y_min_perspective;
6068 std::multiset<SvgCell> cells;
6071 for (patch = patches.begin(); patch != patches.end(); ++patch)
6073 n_subdivisions = patch->n_subdivisions;
6075 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
6077 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
6082 compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
6083 compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
6084 compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
6085 compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
6088 patch->data.n_rows() == 0,
6091 cell.vertices[0][0] = projected_vertices[0][0];
6092 cell.vertices[0][1] = projected_vertices[0][1];
6093 cell.vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
6095 cell.vertices[1][0] = projected_vertices[1][0];
6096 cell.vertices[1][1] = projected_vertices[1][1];
6097 cell.vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
6099 cell.vertices[2][0] = projected_vertices[2][0];
6100 cell.vertices[2][1] = projected_vertices[2][1];
6101 cell.vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
6103 cell.vertices[3][0] = projected_vertices[3][0];
6104 cell.vertices[3][1] = projected_vertices[3][1];
6105 cell.vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
6107 cell.projected_vertices[0] = svg_project_point(cell.vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
6108 cell.projected_vertices[1] = svg_project_point(cell.vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
6109 cell.projected_vertices[2] = svg_project_point(cell.vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
6110 cell.projected_vertices[3] = svg_project_point(cell.vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
6112 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] + cell.vertices[2] + cell.vertices[3]);
6113 cell.projected_center = svg_project_point(cell.center, camera_position, camera_direction, camera_horizontal, camera_focus);
6115 cell.depth = cell.center.distance(camera_position);
6125 width =
static_cast<unsigned int>(.5 + height * (x_dimension_perspective / y_dimension_perspective));
6126 unsigned int additional_width = 0;
6128 if (flags.
draw_colorbar) additional_width =
static_cast<unsigned int>(.5 + height * .3);
6131 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\"" << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" <<
'\n' 6132 <<
" <rect width=\"" << width + additional_width <<
"\" height=\"" << height <<
"\" style=\"fill:white\"/>" <<
'\n' <<
'\n';
6134 unsigned int triangle_counter = 0;
6137 for (
typename std::multiset<SvgCell>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell)
6141 for (
unsigned int triangle_index = 0; triangle_index < 4; triangle_index++)
6143 switch (triangle_index)
6146 points3d_triangle[0] = cell->vertices[0], points3d_triangle[1] = cell->vertices[1], points3d_triangle[2] = cell->center;
6149 points3d_triangle[0] = cell->vertices[1], points3d_triangle[1] = cell->vertices[3], points3d_triangle[2] = cell->center;
6152 points3d_triangle[0] = cell->vertices[3], points3d_triangle[1] = cell->vertices[2], points3d_triangle[2] = cell->center;
6155 points3d_triangle[0] = cell->vertices[2], points3d_triangle[1] = cell->vertices[0], points3d_triangle[2] = cell->center;
6161 Point<6> gradient_param = svg_get_gradient_parameters(points3d_triangle);
6163 double start_h = .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
6164 double stop_h = .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
6166 unsigned int start_r = 0;
6167 unsigned int start_g = 0;
6168 unsigned int start_b = 0;
6170 unsigned int stop_r = 0;
6171 unsigned int stop_g = 0;
6172 unsigned int stop_b = 0;
6174 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6175 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6177 double start_f = start_h * 6. - start_i;
6178 double start_q = 1. - start_f;
6180 double stop_f = stop_h * 6. - stop_i;
6181 double stop_q = 1. - stop_f;
6183 switch (start_i % 6)
6186 start_r = 255, start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6189 start_r =
static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
6192 start_g = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6195 start_g =
static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
6198 start_r =
static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
6201 start_r = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6210 stop_r = 255, stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6213 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
6216 stop_g = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6219 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
6222 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
6225 stop_r = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6231 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
6233 gradient_start_point_3d[0] = gradient_param[0];
6234 gradient_start_point_3d[1] = gradient_param[1];
6235 gradient_start_point_3d[2] = gradient_param[4];
6237 gradient_stop_point_3d[0] = gradient_param[2];
6238 gradient_stop_point_3d[1] = gradient_param[3];
6239 gradient_stop_point_3d[2] = gradient_param[5];
6241 Point<2> gradient_start_point = svg_project_point(gradient_start_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
6242 Point<2> gradient_stop_point = svg_project_point(gradient_stop_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
6245 out <<
" <linearGradient id=\"" << triangle_counter <<
"\" gradientUnits=\"userSpaceOnUse\" " 6247 <<
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))
6250 <<
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))
6253 <<
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))
6256 <<
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))
6259 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n' 6260 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n' 6261 <<
" </linearGradient>" <<
'\n';
6264 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
6265 double x3 = cell->projected_center[0];
6266 double y3 = cell->projected_center[1];
6268 switch (triangle_index)
6271 x1 = cell->projected_vertices[0][0], y1 = cell->projected_vertices[0][1], x2 = cell->projected_vertices[1][0], y2 = cell->projected_vertices[1][1];
6274 x1 = cell->projected_vertices[1][0], y1 = cell->projected_vertices[1][1], x2 = cell->projected_vertices[3][0], y2 = cell->projected_vertices[3][1];
6277 x1 = cell->projected_vertices[3][0], y1 = cell->projected_vertices[3][1], x2 = cell->projected_vertices[2][0], y2 = cell->projected_vertices[2][1];
6280 x1 = cell->projected_vertices[2][0], y1 = cell->projected_vertices[2][1], x2 = cell->projected_vertices[0][0], y2 = cell->projected_vertices[0][1];
6286 out <<
" <path d=\"M " 6287 <<
static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6289 <<
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))
6291 <<
static_cast<unsigned int>(.5 + ((x2 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6293 <<
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))
6295 <<
static_cast<unsigned int>(.5 + ((x3 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6297 <<
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))
6299 <<
static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
6301 <<
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))
6302 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter <<
"); stroke-width:" << flags.line_thickness <<
"\"/>" <<
'\n';
6312 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
6314 unsigned int element_height =
static_cast<unsigned int>(((height/100.) * (71. - 2.*margin_in_percent)) / 4);
6315 unsigned int element_width =
static_cast<unsigned int>(.5 + (height/100.) * 2.5);
6317 additional_width = 0;
6318 if (!flags.
margin) additional_width =
static_cast<unsigned int>(.5 + (height/100.) * 2.5);
6320 for (
unsigned int index = 0; index < 4; index++)
6322 double start_h = .667 - ((index+1) / 4.) * .667;
6323 double stop_h = .667 - (index / 4.) * .667;
6325 unsigned int start_r = 0;
6326 unsigned int start_g = 0;
6327 unsigned int start_b = 0;
6329 unsigned int stop_r = 0;
6330 unsigned int stop_g = 0;
6331 unsigned int stop_b = 0;
6333 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
6334 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
6336 double start_f = start_h * 6. - start_i;
6337 double start_q = 1. - start_f;
6339 double stop_f = stop_h * 6. - stop_i;
6340 double stop_q = 1. - stop_f;
6342 switch (start_i % 6)
6345 start_r = 255, start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
6348 start_r =
static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
6351 start_g = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
6354 start_g =
static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
6357 start_r =
static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
6360 start_r = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
6369 stop_r = 255, stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
6372 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
6375 stop_g = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
6378 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
6381 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
6384 stop_r = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
6391 out <<
" <linearGradient id=\"colorbar_" << index <<
"\" gradientUnits=\"userSpaceOnUse\" " 6392 <<
"x1=\"" << width + additional_width <<
"\" " 6393 <<
"y1=\"" <<
static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height <<
"\" " 6394 <<
"x2=\"" << width + additional_width <<
"\" " 6395 <<
"y2=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (4-index) * element_height <<
"\"" 6397 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n' 6398 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n' 6399 <<
" </linearGradient>" <<
'\n';
6403 <<
" x=\"" << width + additional_width
6404 <<
"\" y=\"" <<
static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height
6405 <<
"\" width=\"" << element_width
6406 <<
"\" height=\"" << element_height
6407 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_" << index <<
")\"/>" <<
'\n';
6410 for (
unsigned int index = 0; index < 5; index++)
6412 out <<
" <text x=\"" << width + additional_width +
static_cast<unsigned int>(1.5 * element_width)
6413 <<
"\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29) + (4.-index) * element_height + 30.) <<
"\"" 6414 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
6416 if (index == 0 || index == 4) out <<
"; font-weight:bold";
6418 out <<
"\">" << (float)(((
int)((z_min + index * (z_dimension / 4.))*10000))/10000.);
6420 if (index == 4) out <<
" max";
6421 if (index == 0) out <<
" min";
6423 out <<
"</text>" <<
'\n';
6428 out <<
'\n' <<
"</svg>";
6435 template <
int dim,
int spacedim>
6438 const std::vector<std::string> &data_names,
6439 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
6450 out << dim <<
' ' << spacedim <<
'\n';
6453 out <<
"[deal.II intermediate format graphics data]" <<
'\n' 6454 <<
"[written by " << DEAL_II_PACKAGE_NAME <<
" " << DEAL_II_PACKAGE_VERSION <<
"]" <<
'\n' 6455 <<
"[Version: " << Deal_II_IntermediateFlags::format_version <<
"]" <<
'\n';
6457 out << data_names.size() <<
'\n';
6458 for (
unsigned int i=0; i<data_names.size(); ++i)
6459 out << data_names[i] <<
'\n';
6461 out << patches.size() <<
'\n';
6462 for (
unsigned int i=0; i<patches.size(); ++i)
6463 out << patches[i] <<
'\n';
6465 out << vector_data_ranges.size() <<
'\n';
6466 for (
unsigned int i=0; i<vector_data_ranges.size(); ++i)
6467 out << std::get<0>(vector_data_ranges[i]) <<
' ' 6468 << std::get<1>(vector_data_ranges[i]) <<
'\n' 6469 << std::get<2>(vector_data_ranges[i]) <<
'\n';
6479 std::pair<unsigned int, unsigned int>
6484 unsigned int dim, spacedim;
6485 input >> dim >> spacedim;
6487 return std::make_pair (dim, spacedim);
6497 template <
int dim,
int spacedim>
6499 : default_subdivisions(1),
6505 template <
int dim,
int spacedim>
6509 get_vector_data_ranges(),
6515 template <
int dim,
int spacedim>
6519 get_vector_data_ranges(),
6525 template <
int dim,
int spacedim>
6529 get_vector_data_ranges(),
6530 gnuplot_flags, out);
6535 template <
int dim,
int spacedim>
6539 get_vector_data_ranges(),
6545 template <
int dim,
int spacedim>
6549 get_vector_data_ranges(),
6555 template <
int dim,
int spacedim>
6559 get_vector_data_ranges(),
6565 template <
int dim,
int spacedim>
6569 get_vector_data_ranges(),
6570 tecplot_flags, out);
6575 template <
int dim,
int spacedim>
6579 get_vector_data_ranges(),
6580 tecplot_flags, out);
6585 template <
int dim,
int spacedim>
6589 get_vector_data_ranges(),
6593 template <
int dim,
int spacedim>
6597 get_vector_data_ranges(),
6601 template <
int dim,
int spacedim>
6605 get_vector_data_ranges(),
6609 template <
int dim,
int spacedim>
6612 #ifndef DEAL_II_WITH_MPI 6616 std::ofstream f(filename);
6621 int ierr = MPI_Comm_rank(comm, &myrank);
6623 ierr = MPI_Comm_size(comm, &nproc);
6627 ierr = MPI_Info_create(&info);
6630 ierr = MPI_File_open(comm, const_cast<char *>(filename),
6631 MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
6634 ierr = MPI_File_set_size(fh, 0);
6638 ierr = MPI_Barrier(comm);
6640 ierr = MPI_Info_free(&info);
6643 unsigned int header_size;
6648 std::stringstream ss;
6650 header_size = ss.str().size();
6651 ierr = MPI_File_write(fh, const_cast<char *>(ss.str().c_str()), header_size,
6652 MPI_CHAR, MPI_STATUS_IGNORE);
6656 ierr = MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0, comm);
6659 ierr = MPI_File_seek_shared( fh, header_size, MPI_SEEK_SET );
6662 std::stringstream ss;
6664 get_vector_data_ranges(),
6666 ierr = MPI_File_write_ordered(fh, const_cast<char *>(ss.str().c_str()),
6667 ss.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
6674 std::stringstream ss;
6676 unsigned int footer_size = ss.str().size();
6677 ierr = MPI_File_write_shared(fh, const_cast<char *>(ss.str().c_str()),
6678 footer_size, MPI_CHAR, MPI_STATUS_IGNORE);
6681 ierr = MPI_File_close( &fh );
6687 template <
int dim,
int spacedim>
6690 const std::vector<std::string> &piece_names)
const 6694 get_dataset_names(),
6695 get_vector_data_ranges());
6700 template <
int dim,
int spacedim>
6705 get_vector_data_ranges(),
6706 deal_II_intermediate_flags, out);
6710 template <
int dim,
int spacedim>
6713 const std::string &h5_filename,
const double cur_time, MPI_Comm comm)
const 6715 return create_xdmf_entry(data_filter, h5_filename, h5_filename, cur_time, comm);
6720 template <
int dim,
int spacedim>
6723 const std::string &h5_mesh_filename,
6724 const std::string &h5_solution_filename,
6725 const double cur_time,
6726 MPI_Comm comm)
const 6728 unsigned int local_node_cell_count[2], global_node_cell_count[2];
6731 #ifndef DEAL_II_WITH_HDF5 6736 (void)h5_mesh_filename;
6737 (void)h5_solution_filename;
6742 AssertThrow(spacedim == 2 || spacedim == 3,
ExcMessage (
"XDMF only supports 2 or 3 space dimensions."));
6744 local_node_cell_count[0] = data_filter.
n_nodes();
6745 local_node_cell_count[1] = data_filter.
n_cells();
6748 #ifdef DEAL_II_WITH_MPI 6749 int ierr = MPI_Comm_rank(comm, &myrank);
6751 ierr = MPI_Allreduce(local_node_cell_count, global_node_cell_count, 2, MPI_UNSIGNED, MPI_SUM, comm);
6756 global_node_cell_count[0] = local_node_cell_count[0];
6757 global_node_cell_count[1] = local_node_cell_count[1];
6763 XDMFEntry entry(h5_mesh_filename, h5_solution_filename, cur_time, global_node_cell_count[0], global_node_cell_count[1], dim, spacedim);
6764 unsigned int n_data_sets = data_filter.
n_data_sets();
6768 for (i=0; i<n_data_sets; ++i)
6781 template <
int dim,
int spacedim>
6784 const std::string &filename,
6785 MPI_Comm comm)
const 6789 #ifdef DEAL_II_WITH_MPI 6790 const int ierr = MPI_Comm_rank(comm, &myrank);
6800 std::ofstream xdmf_file(filename.c_str());
6801 std::vector<XDMFEntry>::const_iterator it;
6803 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
6804 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
6805 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
6806 xdmf_file <<
" <Domain>\n";
6807 xdmf_file <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
6810 for (it=entries.begin(); it!=entries.end(); ++it)
6811 xdmf_file << it->get_xdmf_content(3);
6813 xdmf_file <<
" </Grid>\n";
6814 xdmf_file <<
" </Domain>\n";
6815 xdmf_file <<
"</Xdmf>\n";
6827 template <
int dim,
int spacedim>
6832 get_vector_data_ranges(),
6836 template <
int dim,
int spacedim>
6838 const std::vector<std::string> &data_names,
6839 const std::vector<std::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
6842 const unsigned int n_data_sets = data_names.size();
6843 unsigned int n_node, n_cell;
6847 #ifndef DEAL_II_WITH_MPI 6864 compute_sizes<dim,spacedim>(patches, n_node, n_cell);
6867 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
6871 write_nodes(patches, filtered_data);
6872 write_cells(patches, filtered_data);
6875 reorder_task.join ();
6881 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
6882 std::string vector_name;
6883 for (n_th_vector=0,data_set=0; data_set<n_data_sets;)
6886 while (n_th_vector < vector_data_ranges.size() && std::get<0>(vector_data_ranges[n_th_vector]) < data_set) n_th_vector++;
6889 if (n_th_vector < vector_data_ranges.size() && std::get<0>(vector_data_ranges[n_th_vector]) == data_set)
6892 pt_data_vector_dim = std::get<1>(vector_data_ranges[n_th_vector]) - std::get<0>(vector_data_ranges[n_th_vector])+1;
6895 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) >= std::get<0>(vector_data_ranges[n_th_vector]),
6896 ExcLowerRange (std::get<1>(vector_data_ranges[n_th_vector]), std::get<0>(vector_data_ranges[n_th_vector])));
6897 AssertThrow (std::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
6898 ExcIndexRange (std::get<1>(vector_data_ranges[n_th_vector]), 0, n_data_sets));
6905 if (std::get<2>(vector_data_ranges[n_th_vector]) !=
"")
6907 vector_name = std::get<2>(vector_data_ranges[n_th_vector]);
6912 for (i=std::get<0>(vector_data_ranges[n_th_vector]); i<std::get<1>(vector_data_ranges[n_th_vector]); ++i)
6913 vector_name += data_names[i] +
"__";
6914 vector_name += data_names[std::get<1>(vector_data_ranges[n_th_vector])];
6920 pt_data_vector_dim = 1;
6921 vector_name = data_names[data_set];
6925 filtered_data.
write_data_set(vector_name, pt_data_vector_dim, data_set, data_vectors);
6928 data_set += pt_data_vector_dim;
6934 template <
int dim,
int spacedim>
6937 const std::string &filename, MPI_Comm comm)
const 6944 template <
int dim,
int spacedim>
6947 const bool write_mesh_file,
const std::string &mesh_filename,
const std::string &solution_filename, MPI_Comm comm)
const 6954 template <
int dim,
int spacedim>
6957 const std::string &filename,
6965 template <
int dim,
int spacedim>
6968 const bool write_mesh_file,
6969 const std::string &mesh_filename,
6970 const std::string &solution_filename,
6975 ExcMessage(
"DataOutBase was asked to write HDF5 output for a space dimension of 1. " 6976 "HDF5 only supports datasets that live in 2 or 3 dimensions."));
6980 #ifndef DEAL_II_WITH_HDF5 6984 (void)write_mesh_file;
6985 (void)mesh_filename;
6986 (void)solution_filename;
6990 #ifndef DEAL_II_WITH_MPI 7001 hid_t h5_mesh_file_id=-1, h5_solution_file_id, file_plist_id, plist_id;
7002 hid_t node_dataspace, node_dataset, node_file_dataspace, node_memory_dataspace;
7003 hid_t cell_dataspace, cell_dataset, cell_file_dataspace, cell_memory_dataspace;
7004 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace, pt_data_memory_dataspace;
7006 unsigned int local_node_cell_count[2], global_node_cell_count[2], global_node_cell_offsets[2];
7007 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
7008 std::vector<double> node_data_vec;
7009 std::vector<unsigned int> cell_data_vec;
7012 #ifndef H5_HAVE_PARALLEL 7013 # ifdef DEAL_II_WITH_MPI 7015 ierr = MPI_Comm_size(comm, &world_size);
7018 ExcMessage (
"Serial HDF5 output on multiple processes is not yet supported."));
7022 local_node_cell_count[0] = data_filter.
n_nodes();
7023 local_node_cell_count[1] = data_filter.
n_cells();
7026 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
7029 #ifdef DEAL_II_WITH_MPI 7030 #ifdef H5_HAVE_PARALLEL 7032 status = H5Pset_fapl_mpio(file_plist_id, comm, MPI_INFO_NULL);
7039 #ifdef DEAL_II_WITH_MPI 7040 ierr = MPI_Allreduce(local_node_cell_count, global_node_cell_count, 2, MPI_UNSIGNED, MPI_SUM, comm);
7042 ierr = MPI_Scan(local_node_cell_count, global_node_cell_offsets, 2, MPI_UNSIGNED, MPI_SUM, comm);
7044 global_node_cell_offsets[0] -= local_node_cell_count[0];
7045 global_node_cell_offsets[1] -= local_node_cell_count[1];
7047 global_node_cell_count[0] = local_node_cell_count[0];
7048 global_node_cell_count[1] = local_node_cell_count[1];
7049 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
7053 plist_id = H5Pcreate(H5P_DATASET_XFER);
7055 #ifdef DEAL_II_WITH_MPI 7056 #ifdef H5_HAVE_PARALLEL 7057 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
7062 if (write_mesh_file)
7065 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
7070 node_ds_dim[0] = global_node_cell_count[0];
7071 node_ds_dim[1] = (spacedim<2) ? 2 : spacedim;
7072 node_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
7075 cell_ds_dim[0] = global_node_cell_count[1];
7077 cell_dataspace = H5Screate_simple(2, cell_ds_dim,
nullptr);
7081 #if H5Gcreate_vers == 1 7082 node_dataset = H5Dcreate(h5_mesh_file_id,
"nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT);
7084 node_dataset = H5Dcreate(h5_mesh_file_id,
"nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
7087 #if H5Gcreate_vers == 1 7088 cell_dataset = H5Dcreate(h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
7090 cell_dataset = H5Dcreate(h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
7095 status = H5Sclose(node_dataspace);
7097 status = H5Sclose(cell_dataspace);
7102 count[0] = local_node_cell_count[0];
7103 count[1] = (spacedim<2) ? 2 : spacedim;
7105 offset[0] = global_node_cell_offsets[0];
7108 node_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7112 node_file_dataspace = H5Dget_space(node_dataset);
7114 status = H5Sselect_hyperslab(node_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7118 count[0] = local_node_cell_count[1];
7120 offset[0] = global_node_cell_offsets[1];
7122 cell_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7125 cell_file_dataspace = H5Dget_space(cell_dataset);
7127 status = H5Sselect_hyperslab(cell_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7132 status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, node_data_vec.data());
7134 node_data_vec.clear();
7137 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
7138 status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, cell_data_vec.data());
7140 cell_data_vec.clear();
7143 status = H5Sclose(node_file_dataspace);
7145 status = H5Sclose(cell_file_dataspace);
7149 status = H5Sclose(node_memory_dataspace);
7151 status = H5Sclose(cell_memory_dataspace);
7155 status = H5Dclose(node_dataset);
7157 status = H5Dclose(cell_dataset);
7161 if (mesh_filename != solution_filename)
7163 status = H5Fclose(h5_mesh_file_id);
7169 if (mesh_filename == solution_filename && write_mesh_file)
7171 h5_solution_file_id = h5_mesh_file_id;
7176 h5_solution_file_id = H5Fcreate(solution_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
7185 std::string vector_name;
7194 node_ds_dim[0] = global_node_cell_count[0];
7195 node_ds_dim[1] = pt_data_vector_dim;
7196 pt_data_dataspace = H5Screate_simple(2, node_ds_dim,
nullptr);
7199 #if H5Gcreate_vers == 1 7200 pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT);
7202 pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
7207 count[0] = local_node_cell_count[0];
7208 count[1] = pt_data_vector_dim;
7209 offset[0] = global_node_cell_offsets[0];
7211 pt_data_memory_dataspace = H5Screate_simple(2, count,
nullptr);
7215 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
7217 status = H5Sselect_hyperslab(pt_data_file_dataspace, H5S_SELECT_SET, offset,
nullptr, count,
nullptr);
7221 status = H5Dwrite(pt_data_dataset, H5T_NATIVE_DOUBLE, pt_data_memory_dataspace, pt_data_file_dataspace, plist_id, data_filter.
get_data_set(i));
7225 status = H5Sclose(pt_data_dataspace);
7227 status = H5Sclose(pt_data_memory_dataspace);
7229 status = H5Sclose(pt_data_file_dataspace);
7232 status = H5Dclose(pt_data_dataset);
7237 status = H5Pclose(file_plist_id);
7241 status = H5Pclose(plist_id);
7245 status = H5Fclose(h5_solution_file_id);
7252 template <
int dim,
int spacedim>
7259 output_format = default_fmt;
7261 switch (output_format)
7275 write_gnuplot (out);
7291 write_tecplot (out);
7295 write_tecplot_binary (out);
7311 write_deal_II_intermediate (out);
7321 template <
int dim,
int spacedim>
7329 template <
int dim,
int spacedim>
7330 template <
typename FlagType>
7336 if (
typeid(flags) ==
typeid(dx_flags))
7338 else if (
typeid(flags) ==
typeid(ucd_flags))
7340 else if (
typeid(flags) ==
typeid(povray_flags))
7342 else if (
typeid(flags) ==
typeid(eps_flags))
7344 else if (
typeid(flags) ==
typeid(gmv_flags))
7346 else if (
typeid(flags) ==
typeid(tecplot_flags))
7348 else if (
typeid(flags) ==
typeid(vtk_flags))
7350 else if (
typeid(flags) ==
typeid(svg_flags))
7352 else if (
typeid(flags) ==
typeid(gnuplot_flags))
7354 else if (
typeid(flags) ==
typeid(deal_II_intermediate_flags))
7362 template <
int dim,
int spacedim>
7375 template <
int dim,
int spacedim>
7381 "A name for the output format to be used");
7383 "Number of subdivisions of each mesh cell");
7425 template <
int dim,
int spacedim>
7429 const std::string &output_name = prm.
get (
"Output format");
7431 default_subdivisions = prm.
get_integer (
"Subdivisions");
7434 dx_flags.parse_parameters (prm);
7438 ucd_flags.parse_parameters (prm);
7442 gnuplot_flags.parse_parameters (prm);
7446 povray_flags.parse_parameters (prm);
7450 eps_flags.parse_parameters (prm);
7454 gmv_flags.parse_parameters (prm);
7458 tecplot_flags.parse_parameters (prm);
7462 vtk_flags.parse_parameters (prm);
7466 deal_II_intermediate_flags.parse_parameters (prm);
7472 template <
int dim,
int spacedim>
7476 return (
sizeof (default_fmt) +
7491 template <
int dim,
int spacedim>
7492 std::vector<std::tuple<unsigned int, unsigned int, std::string> >
7495 return std::vector<std::tuple<unsigned int, unsigned int, std::string> >();
7499 template <
int dim,
int spacedim>
7508 std::set<std::string> all_names;
7510 const std::vector<std::tuple<unsigned int, unsigned int, std::string> >
7511 ranges = this->get_vector_data_ranges();
7512 const std::vector<std::string> data_names = this->get_dataset_names();
7513 const unsigned int n_data_sets = data_names.size();
7514 std::vector<bool> data_set_written (n_data_sets,
false);
7516 for (
unsigned int n_th_vector=0; n_th_vector<ranges.size(); ++n_th_vector)
7518 const std::string &name = std::get<2>(ranges[n_th_vector]);
7521 Assert(all_names.find(name) == all_names.end(),
7522 ExcMessage(
"Error: names of fields in DataOut need to be unique, " 7523 "but '" + name +
"' is used more than once."));
7524 all_names.insert(name);
7525 for (
unsigned int i=std::get<0>(ranges[n_th_vector]);
7526 i<=std::get<1>(ranges[n_th_vector]);
7528 data_set_written[i] =
true;
7532 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
7533 if (data_set_written[data_set] ==
false)
7535 const std::string &name = data_names[data_set];
7536 Assert(all_names.find(name) == all_names.end(),
7537 ExcMessage(
"Error: names of fields in DataOut need to be unique, " 7538 "but '" + name +
"' is used more than once."));
7539 all_names.insert(name);
7549 template <
int dim,
int spacedim>
7557 std::vector<typename ::DataOutBase::Patch<dim,spacedim> >
7562 std::vector<std::string> tmp;
7563 tmp.swap (dataset_names);
7566 std::vector<std::tuple<unsigned int, unsigned int, std::string> > tmp;
7567 tmp.swap (vector_data_ranges);
7579 std::pair<unsigned int, unsigned int>
7583 (dimension_info.second == spacedim),
7584 ExcIncompatibleDimensions (dimension_info.first, dim,
7585 dimension_info.second, spacedim));
7594 getline (in, header);
7596 std::ostringstream s;
7597 s <<
"[deal.II intermediate format graphics data]";
7599 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7603 getline (in, header);
7605 std::ostringstream s;
7606 s <<
"[written by " << DEAL_II_PACKAGE_NAME <<
" " << DEAL_II_PACKAGE_VERSION <<
"]";
7608 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7612 getline (in, header);
7614 std::ostringstream s;
7617 Assert (header == s.str(),
7618 ExcMessage(
"Invalid or incompatible file format. Intermediate format " 7619 "files can only be read by the same deal.II version as they " 7620 "are written by."));
7624 unsigned int n_datasets;
7626 dataset_names.resize (n_datasets);
7627 for (
unsigned int i=0; i<n_datasets; ++i)
7628 in >> dataset_names[i];
7630 unsigned int n_patches;
7632 patches.resize (n_patches);
7633 for (
unsigned int i=0; i<n_patches; ++i)
7636 unsigned int n_vector_data_ranges;
7637 in >> n_vector_data_ranges;
7638 vector_data_ranges.resize (n_vector_data_ranges);
7639 for (
unsigned int i=0; i<n_vector_data_ranges; ++i)
7641 in >> std::get<0>(vector_data_ranges[i])
7642 >> std::get<1>(vector_data_ranges[i]);
7655 std::get<2>(vector_data_ranges[i]) = name;
7663 template <
int dim,
int spacedim>
7668 typedef typename ::DataOutBase::Patch<dim,spacedim> Patch;
7671 const std::vector<Patch> &source_patches = source.
get_patches ();
7681 Assert (get_vector_data_ranges().size() ==
7683 ExcMessage (
"Both sources need to declare the same components " 7685 for (
unsigned int i=0; i<get_vector_data_ranges().size(); ++i)
7687 Assert (std::get<0>(get_vector_data_ranges()[i]) ==
7689 ExcMessage (
"Both sources need to declare the same components " 7691 Assert (std::get<1>(get_vector_data_ranges()[i]) ==
7693 ExcMessage (
"Both sources need to declare the same components " 7695 Assert (std::get<2>(get_vector_data_ranges()[i]) ==
7697 ExcMessage (
"Both sources need to declare the same components " 7702 Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
7704 Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
7706 Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
7713 const unsigned int old_n_patches = patches.size();
7714 patches.insert (patches.end(),
7715 source_patches.begin(),
7716 source_patches.end());
7719 for (
unsigned int i=old_n_patches; i<patches.size(); ++i)
7720 patches[i].patch_index += old_n_patches;
7723 for (
unsigned int i=old_n_patches; i<patches.size(); ++i)
7724 for (
unsigned int n=0; n<GeometryInfo<dim>::faces_per_cell; ++n)
7726 patches[i].neighbors[n] += old_n_patches;
7731 template <
int dim,
int spacedim>
7732 const std::vector<typename ::DataOutBase::Patch<dim,spacedim> > &
7740 template <
int dim,
int spacedim>
7741 std::vector<std::string>
7744 return dataset_names;
7749 template <
int dim,
int spacedim>
7750 std::vector<std::tuple<unsigned int, unsigned int, std::string> >
7753 return vector_data_ranges;
7763 h5_sol_filename(
""),
7764 h5_mesh_filename(
""),
7766 num_nodes(
numbers::invalid_unsigned_int),
7767 num_cells(
numbers::invalid_unsigned_int),
7768 dimension(
numbers::invalid_unsigned_int),
7769 space_dimension(
numbers::invalid_unsigned_int)
7776 const unsigned int nodes,
7777 const unsigned int cells,
7778 const unsigned int dim)
7792 const std::string &solution_filename,
7794 const unsigned int nodes,
7795 const unsigned int cells,
7796 const unsigned int dim)
7810 const std::string &solution_filename,
7812 const unsigned int nodes,
7813 const unsigned int cells,
7814 const unsigned int dim,
7815 const unsigned int spacedim)
7818 h5_sol_filename(solution_filename),
7819 h5_mesh_filename(mesh_filename),
7824 space_dimension(spacedim)
7842 std::string indent(
const unsigned int indent_level)
7844 std::string res =
"";
7845 for (
unsigned int i=0; i<indent_level; ++i)
7858 std::stringstream ss;
7859 ss << indent(indent_level+0) <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
7860 ss << indent(indent_level+1) <<
"<Time Value=\"" <<
entry_time <<
"\"/>\n";
7861 ss << indent(indent_level+1) <<
"<Geometry GeometryType=\"" << (
space_dimension <= 2 ?
"XY" :
"XYZ" ) <<
"\">\n";
7864 ss << indent(indent_level+2) <<
"</DataItem>\n";
7865 ss << indent(indent_level+1) <<
"</Geometry>\n";
7870 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"" <<
"Polyvertex" <<
"\" NumberOfElements=\"" <<
num_cells <<
"\" NodesPerElement=\"1\">\n";
7872 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"" <<
"Polyline" <<
"\" NumberOfElements=\"" <<
num_cells <<
"\" NodesPerElement=\"2\">\n";
7874 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"" <<
"Quadrilateral"<<
"\" NumberOfElements=\"" <<
num_cells <<
"\">\n";
7876 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"" <<
"Hexahedron" <<
"\" NumberOfElements=\"" <<
num_cells <<
"\">\n";
7878 ss << indent(indent_level+2) <<
"<DataItem Dimensions=\"" <<
num_cells <<
" " << (1 <<
dimension) <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
7880 ss << indent(indent_level+2) <<
"</DataItem>\n";
7881 ss << indent(indent_level+1) <<
"</Topology>\n";
7886 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\"" <<
num_nodes <<
"\">\n";
7887 ss << indent(indent_level+1) <<
"</Topology>\n";
7890 for (std::map<std::string, unsigned int>::const_iterator it=
attribute_dims.begin();
7893 ss << indent(indent_level+1) <<
"<Attribute Name=\"" << it->first <<
"\" AttributeType=\"" << (it->second > 1 ?
"Vector" :
"Scalar") <<
"\" Center=\"Node\">\n";
7895 ss << indent(indent_level+2) <<
"<DataItem Dimensions=\"" <<
num_nodes <<
" " << (it->second > 1 ? 3 : 1) <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
7896 ss << indent(indent_level+3) <<
h5_sol_filename <<
":/" << it->first <<
"\n";
7897 ss << indent(indent_level+2) <<
"</DataItem>\n";
7898 ss << indent(indent_level+1) <<
"</Attribute>\n";
7901 ss << indent(indent_level+0) <<
"</Grid>\n";
7910 template <
int dim,
int spacedim>
7916 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]" 7921 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
7925 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
7934 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
7935 for (
unsigned int i=0; i<patch.
data.n_rows(); ++i)
7936 for (
unsigned int j=0; j<patch.
data.n_cols(); ++j)
7937 out << patch.
data[i][j] <<
' ';
7945 template <
int dim,
int spacedim>
7960 getline (in, header);
7961 while ((header.size() != 0) &&
7962 (header[header.size()-1] ==
' '))
7963 header.erase(header.size()-1);
7965 while ((header ==
"") && in);
7967 std::ostringstream s;
7968 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
7970 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7975 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
7978 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
7985 unsigned int n_rows, n_cols;
7986 in >> n_rows >> n_cols;
7988 for (
unsigned int i=0; i<patch.
data.n_rows(); ++i)
7989 for (
unsigned int j=0; j<patch.
data.n_cols(); ++j)
7990 in >> patch.
data[i][j];
8001 #include "data_out_base.inst" 8003 DEAL_II_NAMESPACE_CLOSE
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
unsigned int space_dimension
Map3DPoint existing_points
static ::ExceptionBase & ExcIncompatiblePatchLists()
unsigned int height_vector
void write_vtu_footer(std::ostream &out)
static void declare_parameters(ParameterHandler &prm)
#define DeclException2(Exception2, type1, type2, outsequence)
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
#define AssertDimension(dim1, dim2)
void parse_parameters(const ParameterHandler &prm)
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 swap(TableBase< N, T > &v)
void set_flags(const FlagType &flags)
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const
void write_data_set(const std::string &name, const unsigned int dimension, const unsigned int set_num, const Table< 2, double > &data_vectors)
std::map< unsigned int, unsigned int > filtered_cells
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)
Task< RT > new_task(const std::function< RT()> &function)
Point< spacedim > point(const gp_Pnt &p, const double &tolerance=1e-10)
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
void parse_parameters(const ParameterHandler &prm)
void swap(Patch< dim, spacedim > &other_patch)
void merge(const DataOutReader< dim, spacedim > &other)
std::string get(const std::string &entry_string) const
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)
ZlibCompressionLevel compression_level
static ::ExceptionBase & ExcNotInitialized()
void write_svg(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const SvgFlags &flags, std::ostream &out)
#define AssertThrow(cond, exc)
void write_dx(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const DXFlags &flags, std::ostream &out)
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
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
unsigned int get_data_set_dim(const unsigned int set_num) const
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
std::vector< unsigned int > data_set_dims
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
std::string get_xdmf_content(const unsigned int indent_level) const
bool filter_duplicate_vertices
std::vector< std::vector< double > > data_sets
static void declare_parameters(ParameterHandler &prm)
void fill_cell_data(const unsigned int local_node_offset, std::vector< unsigned int > &cell_data) const
std::map< std::string, unsigned int > attribute_dims
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void parse_parameters(ParameterHandler &prm)
Point< spacedim > vertices[1]
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 write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const TecplotFlags &flags, std::ostream &out)
void enter_subsection(const std::string &subsection)
static ::ExceptionBase & ExcNoPatches()
static ::ExceptionBase & ExcIncompatibleDatasetNames()
DataOutBase::DataOutFilterFlags flags
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)
void write_tecplot_binary(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_point(const unsigned int index, const Point< dim > &p)
double get_double(const std::string &entry_name) const
unsigned int n_cells() const
std::size_t memory_consumption() const
TecplotFlags(const char *tecplot_binary_file_name=nullptr, const char *zone_name=nullptr, const double solution_time=-1.0)
T sum(const T &t, const MPI_Comm &mpi_communicator)
std::vector< std::string > data_set_names
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)
#define Assert(cond, exc)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const GnuplotFlags &flags, std::ostream &out)
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 write_cell(const unsigned int index, const unsigned int start, const unsigned int d1, const unsigned int d2, const unsigned int d3)
void write_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const UcdFlags &flags, std::ostream &out)
void read(std::istream &in)
bool points_are_available
OutputFormat parse_output_format(const std::string &format_name)
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, MPI_Comm comm) const
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
bool get_bool(const std::string &entry_name) const
void parse_parameters(const ParameterHandler &prm)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
std::string h5_sol_filename
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
void parse_parameters(const ParameterHandler &prm)
static ::ExceptionBase & ExcLowerRange(int arg1, int arg2)
std::string h5_mesh_filename
void fill_node_data(std::vector< double > &node_data) const
void write_gmv(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const GmvFlags &flags, std::ostream &out)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static void declare_parameters(ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
bool operator==(const Patch &patch) const
void write_eps(std::ostream &out) const
void swap(Vector< Number > &u, Vector< Number > &v)
void write_deal_II_intermediate(std::ostream &out) const
static void declare_parameters(ParameterHandler &prm)
void write_povray(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const PovrayFlags &flags, std::ostream &out)
static const unsigned int no_neighbor
std::size_t memory_consumption() const
size_type size(const unsigned int i) const
#define AssertThrowMPI(error_code)
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
const double * get_data_set(const unsigned int set_num) const
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
PovrayFlags(const bool smooth=false, const bool bicubic_patch=false, const bool external_data=false)
void internal_add_cell(const unsigned int cell_index, const unsigned int pt_index)
unsigned int color_vector
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges)
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()
std::ostream & operator<<(std::ostream &out, const SymmetricTensor< 2, dim, Number > &t)
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
void write_dx(std::ostream &out) const
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const EpsFlags &flags, std::ostream &out)
std::string get_data_set_name(const unsigned int set_num) const
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
virtual std::vector< std::string > get_dataset_names() const
std::size_t memory_consumption() const
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, DataOutFilter &filtered_data)
std::map< unsigned int, unsigned int > filtered_points
bool points_are_available
void write_gnuplot(std::ostream &out) const
void write_vtu(std::ostream &out) const
UcdFlags(const bool write_preamble=false)
void parse_parameters(const ParameterHandler &prm)
std::string get_output_format_names()
unsigned int height_vector
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
unsigned int vertices_per_cell
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
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