34 #include <deal.II/base/data_out_base.h> 35 #include <deal.II/base/utilities.h> 36 #include <deal.II/base/parameter_handler.h> 37 #include <deal.II/base/thread_management.h> 38 #include <deal.II/base/memory_consumption.h> 39 #include <deal.II/base/std_cxx11/shared_ptr.h> 40 #include <deal.II/base/mpi.h> 54 #ifdef DEAL_II_WITH_ZLIB 58 #ifdef DEAL_II_WITH_HDF5 62 DEAL_II_NAMESPACE_OPEN
70 std::string, std::string,
71 <<
"Unexpected input: expected line\n <" 80 #ifdef DEAL_II_WITH_ZLIB 91 step_A, step_B, step_C
96 base64_encodestep step;
100 void base64_init_encodestate(base64_encodestate *state_in)
102 state_in->step = step_A;
103 state_in->result = 0;
107 char base64_encode_value(
char value_in)
109 static const char *encoding
110 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
111 if (value_in > 63)
return '=';
112 return encoding[(int)value_in];
115 int base64_encode_block(
const char *plaintext_in,
118 base64_encodestate *state_in)
120 const char *plainchar = plaintext_in;
121 const char *
const plaintextend = plaintext_in + length_in;
122 char *codechar = code_out;
126 result = state_in->result;
128 switch (state_in->step)
133 if (plainchar == plaintextend)
135 state_in->result = result;
136 state_in->step = step_A;
137 return codechar - code_out;
139 fragment = *plainchar++;
140 result = (fragment & 0x0fc) >> 2;
141 *codechar++ = base64_encode_value(result);
142 result = (fragment & 0x003) << 4;
144 if (plainchar == plaintextend)
146 state_in->result = result;
147 state_in->step = step_B;
148 return codechar - code_out;
150 fragment = *plainchar++;
151 result |= (fragment & 0x0f0) >> 4;
152 *codechar++ = base64_encode_value(result);
153 result = (fragment & 0x00f) << 2;
155 if (plainchar == plaintextend)
157 state_in->result = result;
158 state_in->step = step_C;
159 return codechar - code_out;
161 fragment = *plainchar++;
162 result |= (fragment & 0x0c0) >> 6;
163 *codechar++ = base64_encode_value(result);
164 result = (fragment & 0x03f) >> 0;
165 *codechar++ = base64_encode_value(result);
169 return codechar - code_out;
172 int base64_encode_blockend(
char *code_out, base64_encodestate *state_in)
174 char *codechar = code_out;
176 switch (state_in->step)
179 *codechar++ = base64_encode_value(state_in->result);
184 *codechar++ = base64_encode_value(state_in->result);
192 return codechar - code_out;
206 encode_block (
const char *data,
209 base64::base64_encodestate state;
210 base64::base64_init_encodestate(&state);
212 char *encoded_data =
new char[2*data_size+1];
214 const int encoded_length_data
215 = base64::base64_encode_block (data, data_size,
216 encoded_data, &state);
217 base64::base64_encode_blockend (encoded_data + encoded_length_data,
232 case (DataOutBase::VtkFlags::no_compression):
233 return Z_NO_COMPRESSION;
234 case (DataOutBase::VtkFlags::best_speed):
236 case (DataOutBase::VtkFlags::best_compression):
237 return Z_BEST_COMPRESSION;
238 case (DataOutBase::VtkFlags::default_compression):
239 return Z_DEFAULT_COMPRESSION;
241 Assert(
false, ExcNotImplemented());
242 return Z_NO_COMPRESSION;
252 template <
typename T>
253 void write_compressed_block (
const std::vector<T> &data,
255 std::ostream &output_stream)
257 if (data.size() != 0)
261 uLongf compressed_data_length
262 = compressBound (data.size() *
sizeof(T));
263 char *compressed_data =
new char[compressed_data_length];
264 int err = compress2 ((Bytef *) compressed_data,
265 &compressed_data_length,
266 (
const Bytef *) &data[0],
267 data.size() *
sizeof(T),
270 Assert (err == Z_OK, ExcInternalError());
273 const uint32_t compression_header[4]
275 (uint32_t)(data.size() *
sizeof(T)),
276 (uint32_t)(data.size() *
sizeof(T)),
277 (uint32_t)compressed_data_length
280 char *encoded_header = encode_block ((
char *)&compression_header[0],
281 4 *
sizeof(compression_header[0]));
282 output_stream << encoded_header;
283 delete[] encoded_header;
287 char *encoded_data = encode_block (compressed_data,
288 compressed_data_length);
289 delete[] compressed_data;
291 output_stream << encoded_data;
292 delete[] encoded_data;
339 bool operator < (
const SvgCell &)
const;
342 bool SvgCell::operator < (
const SvgCell &e)
const 346 return depth > e.depth;
381 bool operator < (
const EpsCell2d &)
const;
395 template <
int dim,
int spacedim>
397 write_gmv_reorder_data_vectors (
const std::vector<Patch<dim,spacedim> > &patches,
411 const unsigned int n_data_sets
412 =patches[0].points_are_available ? (patches[0].data.n_rows() - spacedim) : patches[0].data.n_rows();
414 Assert (data_vectors.
size()[0] == n_data_sets,
418 unsigned int next_value = 0;
419 for (
typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
420 patch != patches.end(); ++patch)
422 const unsigned int n_subdivisions = patch->n_subdivisions;
423 (void)n_subdivisions;
425 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
426 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
427 ExcDimensionMismatch (patch->points_are_available
429 (n_data_sets + spacedim)
432 patch->data.n_rows()));
433 Assert ((n_data_sets == 0)
435 (patch->data.n_cols() == Utilities::fixed_power<dim>(n_subdivisions+1)),
436 ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1));
438 for (
unsigned int i=0; i<patch->data.n_cols(); ++i, ++next_value)
439 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
440 data_vectors[data_set][next_value] = patch->data(data_set,i);
443 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
444 Assert (data_vectors[data_set].size() == next_value,
457 Map3DPoint::const_iterator it;
458 unsigned int internal_ind;
461 for (
int d=0; d<3; ++d) int_pt(d) = (d < dim ? p(d) : 0);
463 it = existing_points.find(int_pt);
466 if (it == existing_points.end() || !flags.filter_duplicate_vertices)
468 internal_ind = existing_points.size();
469 existing_points.insert(std::make_pair(int_pt, internal_ind));
473 internal_ind = it->second;
476 filtered_points[index] = internal_ind;
481 filtered_cells[cell_index] = filtered_points[pt_index];
486 Map3DPoint::const_iterator it;
488 node_data.resize(existing_points.size()*node_dim);
490 for (it=existing_points.begin(); it!=existing_points.end(); ++it)
492 for (
int d=0; d<node_dim; ++d) node_data[node_dim*it->second+d] = it->first(d);
498 std::map<unsigned int, unsigned int>::const_iterator it;
500 cell_data.resize(filtered_cells.size());
502 for (it=filtered_cells.begin(); it!=filtered_cells.end(); ++it)
504 cell_data[it->first] = it->second+local_node_offset;
518 n_cell_verts = GeometryInfo<dim>::vertices_per_cell;
519 internal_add_cell(base_entry+0, start);
520 internal_add_cell(base_entry+1, start+d1);
523 internal_add_cell(base_entry+2, start+d2+d1);
524 internal_add_cell(base_entry+3, start+d2);
527 internal_add_cell(base_entry+4, start+d3);
528 internal_add_cell(base_entry+5, start+d3+d1);
529 internal_add_cell(base_entry+6, start+d3+d2+d1);
530 internal_add_cell(base_entry+7, start+d3+d2);
537 unsigned int num_verts = existing_points.size();
538 unsigned int i, r, d, new_dim;
541 if (flags.xdmf_hdf5_output && dimension != 1) new_dim = 3;
542 else new_dim = dimension;
545 data_set_names.push_back(name);
546 data_set_dims.push_back(new_dim);
547 data_sets.push_back(std::vector<double>(new_dim*num_verts));
550 for (i=0; i<filtered_points.size(); ++i)
552 for (d=0; d<new_dim; ++d)
554 r = filtered_points[i];
555 if (d < dimension) data_sets.back()[r*new_dim+d] = data_vectors(set_num+d, i);
556 else data_sets.back()[r*new_dim+d] = 0;
568 const char *gmv_cell_type[4] =
570 "",
"line 2",
"quad 4",
"hex 8" 573 const char *ucd_cell_type[4] =
575 "",
"line",
"quad",
"hex" 578 const char *tecplot_cell_type[4] =
580 "",
"lineseg",
"quadrilateral",
"brick" 583 #ifdef DEAL_II_HAVE_TECPLOT 584 const unsigned int tecplot_binary_cell_type[4] =
594 const unsigned int vtk_cell_type[5] =
596 0, 3, 9, 12,
static_cast<unsigned int>(-1)
609 template <
int dim,
int spacedim>
615 const unsigned int xstep,
616 const unsigned int ystep,
617 const unsigned int zstep,
618 const unsigned int n_subdivisions)
622 unsigned int point_no=0;
627 Assert (zstep<n_subdivisions+1, ExcIndexRange(zstep,0,n_subdivisions+1));
628 point_no+=(n_subdivisions+1)*(n_subdivisions+1)*zstep;
630 Assert (ystep<n_subdivisions+1, ExcIndexRange(ystep,0,n_subdivisions+1));
631 point_no+=(n_subdivisions+1)*ystep;
633 Assert (xstep<n_subdivisions+1, ExcIndexRange(xstep,0,n_subdivisions+1));
640 Assert (
false, ExcNotImplemented());
642 for (
unsigned int d=0; d<spacedim; ++d)
643 node[d]=patch->
data(patch->
data.
size(0)-spacedim+d,point_no);
648 const double stepsize=1./n_subdivisions,
649 xfrac=xstep*stepsize;
654 const double yfrac=ystep*stepsize;
656 node += ((patch->
vertices[3] * xfrac) + (patch->
vertices[2] * (1-xfrac))) * yfrac;
659 const double zfrac=zstep*stepsize;
672 template<
int dim,
int spacedim>
676 unsigned int &n_nodes,
677 unsigned int &n_cells)
682 patch!=patches.end(); ++patch)
694 template<
typename FlagsType>
701 StreamBase (std::ostream &stream,
702 const FlagsType &flags)
714 void write_point (
const unsigned int,
718 "reimplement this function if you want to call " 727 void flush_points () {}
735 void write_cell (
const unsigned int ,
742 "reimplement this function if you want to call " 752 void flush_cells () {}
758 template <
typename T>
771 unsigned int selected_component;
778 std::ostream &stream;
783 const FlagsType flags;
792 class DXStream :
public StreamBase<DataOutBase::DXFlags>
795 DXStream (std::ostream &stream,
799 void write_point (
const unsigned int index,
813 void write_cell (
const unsigned int index,
814 const unsigned int start,
815 const unsigned int x_offset,
816 const unsigned int y_offset,
817 const unsigned int z_offset);
829 template<
typename data>
830 void write_dataset (
const unsigned int index,
831 const std::vector<data> &values);
840 class GmvStream :
public StreamBase<DataOutBase::GmvFlags>
843 GmvStream (std::ostream &stream,
847 void write_point (
const unsigned int index,
861 void write_cell (
const unsigned int index,
862 const unsigned int start,
863 const unsigned int x_offset,
864 const unsigned int y_offset,
865 const unsigned int z_offset);
874 class TecplotStream :
public StreamBase<DataOutBase::TecplotFlags>
877 TecplotStream (std::ostream &stream,
881 void write_point (
const unsigned int index,
895 void write_cell (
const unsigned int index,
896 const unsigned int start,
897 const unsigned int x_offset,
898 const unsigned int y_offset,
899 const unsigned int z_offset);
908 class UcdStream :
public StreamBase<DataOutBase::UcdFlags>
911 UcdStream (std::ostream &stream,
915 void write_point (
const unsigned int index,
933 void write_cell (
const unsigned int index,
934 const unsigned int start,
935 const unsigned int x_offset,
936 const unsigned int y_offset,
937 const unsigned int z_offset);
949 template<
typename data>
950 void write_dataset (
const unsigned int index,
951 const std::vector<data> &values);
960 class VtkStream :
public StreamBase<DataOutBase::VtkFlags>
963 VtkStream (std::ostream &stream,
967 void write_point (
const unsigned int index,
981 void write_cell (
const unsigned int index,
982 const unsigned int start,
983 const unsigned int x_offset,
984 const unsigned int y_offset,
985 const unsigned int z_offset);
989 class VtuStream :
public StreamBase<DataOutBase::VtkFlags>
992 VtuStream (std::ostream &stream,
996 void write_point (
const unsigned int index,
999 void flush_points ();
1012 void write_cell (
const unsigned int index,
1013 const unsigned int start,
1014 const unsigned int x_offset,
1015 const unsigned int y_offset,
1016 const unsigned int z_offset);
1018 void flush_cells ();
1020 template <
typename T>
1034 template <
typename T>
1035 std::ostream &operator<< (const std::vector<T> &);
1050 std::vector<double> vertices;
1051 std::vector<int32_t> cells;
1057 DXStream::DXStream (std::ostream &out,
1060 StreamBase<DataOutBase::DXFlags> (out, f)
1066 DXStream::write_point (
const unsigned int,
1069 if (flags.coordinates_binary)
1072 for (
unsigned int d=0; d<dim; ++d)
1074 stream.write(reinterpret_cast<const char *>(data),
1075 dim *
sizeof(*data));
1079 for (
unsigned int d=0; d<dim; ++d)
1080 stream << p(d) <<
'\t';
1089 DXStream::write_cell (
unsigned int,
1097 nodes[GeometryInfo<dim>::dx_to_deal[1]] = start+d1;
1101 nodes[GeometryInfo<dim>::dx_to_deal[2]] = start+d2;
1102 nodes[GeometryInfo<dim>::dx_to_deal[3]] = start+d2+d1;
1106 nodes[GeometryInfo<dim>::dx_to_deal[4]] = start+d3;
1107 nodes[GeometryInfo<dim>::dx_to_deal[5]] = start+d3+d1;
1108 nodes[GeometryInfo<dim>::dx_to_deal[6]] = start+d3+d2;
1109 nodes[GeometryInfo<dim>::dx_to_deal[7]] = start+d3+d2+d1;
1113 if (flags.int_binary)
1114 stream.write(reinterpret_cast<const char *>(nodes),
1115 (1<<dim) *
sizeof(*nodes));
1118 const unsigned int final = (1<<dim) - 1;
1119 for (
unsigned int i=0; i<final ; ++i)
1120 stream << nodes[i] <<
'\t';
1121 stream << nodes[
final] <<
'\n';
1127 template<
typename data>
1130 DXStream::write_dataset (
const unsigned int,
1131 const std::vector<data> &values)
1133 if (flags.data_binary)
1135 stream.write(reinterpret_cast<const char *>(&values[0]),
1136 values.size()*
sizeof(data));
1140 for (
unsigned int i=0; i<values.size(); ++i)
1141 stream <<
'\t' << values[i];
1150 GmvStream::GmvStream (std::ostream &out,
1153 StreamBase<DataOutBase::GmvFlags> (out, f)
1159 GmvStream::write_point (
const unsigned int,
1163 ExcNotInitialized());
1164 stream << p(selected_component) <<
' ';
1171 GmvStream::write_cell (
unsigned int,
1179 const unsigned int start=s+1;
1180 stream << gmv_cell_type[dim] <<
'\n';
1182 stream << start <<
'\t' 1186 stream <<
'\t' << start+d2+d1
1187 <<
'\t' << start+d2;
1190 stream <<
'\t' << start+d3
1191 <<
'\t' << start+d3+d1
1192 <<
'\t' << start+d3+d2+d1
1193 <<
'\t' << start+d3+d2;
1201 TecplotStream::TecplotStream (std::ostream &out,
1204 StreamBase<DataOutBase::TecplotFlags> (out, f)
1210 TecplotStream::write_point (
const unsigned int,
1214 ExcNotInitialized());
1215 stream << p(selected_component) <<
'\n';
1222 TecplotStream::write_cell (
unsigned int,
1228 const unsigned int start = s+1;
1230 stream << start <<
'\t' 1234 stream <<
'\t' << start+d2+d1
1235 <<
'\t' << start+d2;
1238 stream <<
'\t' << start+d3
1239 <<
'\t' << start+d3+d1
1240 <<
'\t' << start+d3+d2+d1
1241 <<
'\t' << start+d3+d2;
1249 UcdStream::UcdStream (std::ostream &out,
1252 StreamBase<DataOutBase::UcdFlags> (out, f)
1258 UcdStream::write_point (
const unsigned int index,
1264 for (
unsigned int i=0; i<dim; ++i)
1265 stream << p(i) <<
' ';
1267 for (
unsigned int i=dim; i<3; ++i)
1276 UcdStream::write_cell (
unsigned int index,
1284 nodes[GeometryInfo<dim>::ucd_to_deal[1]] = start+d1;
1288 nodes[GeometryInfo<dim>::ucd_to_deal[2]] = start+d2;
1289 nodes[GeometryInfo<dim>::ucd_to_deal[3]] = start+d2+d1;
1293 nodes[GeometryInfo<dim>::ucd_to_deal[4]] = start+d3;
1294 nodes[GeometryInfo<dim>::ucd_to_deal[5]] = start+d3+d1;
1295 nodes[GeometryInfo<dim>::ucd_to_deal[6]] = start+d3+d2;
1296 nodes[GeometryInfo<dim>::ucd_to_deal[7]] = start+d3+d2+d1;
1303 stream << index+1 <<
"\t0 " << ucd_cell_type[dim];
1304 const unsigned int final = (1<<dim);
1305 for (
unsigned int i=0; i<final ; ++i)
1306 stream <<
'\t' << nodes[i]+1;
1312 template<
typename data>
1315 UcdStream::write_dataset (
const unsigned int index,
1316 const std::vector<data> &values)
1319 for (
unsigned int i=0; i<values.size(); ++i)
1320 stream <<
'\t' << values[i];
1328 VtkStream::VtkStream (std::ostream &out,
1331 StreamBase<DataOutBase::VtkFlags> (out, f)
1337 VtkStream::write_point (
const unsigned int,
1343 for (
unsigned int i=dim; i<3; ++i)
1352 VtkStream::write_cell (
unsigned int,
1358 stream << GeometryInfo<dim>::vertices_per_cell <<
'\t' 1363 stream <<
'\t' << start+d2+d1
1364 <<
'\t' << start+d2;
1367 stream <<
'\t' << start+d3
1368 <<
'\t' << start+d3+d1
1369 <<
'\t' << start+d3+d2+d1
1370 <<
'\t' << start+d3+d2;
1378 VtuStream::VtuStream (std::ostream &out,
1381 StreamBase<DataOutBase::VtkFlags> (out, f)
1387 VtuStream::write_point (
const unsigned int,
1390 #if !defined(DEAL_II_WITH_ZLIB) 1394 for (
unsigned int i=dim; i<3; ++i)
1401 for (
unsigned int i=0; i<dim; ++i)
1402 vertices.push_back(p[i]);
1403 for (
unsigned int i=dim; i<3; ++i)
1404 vertices.push_back(0);
1410 VtuStream::flush_points ()
1412 #ifdef DEAL_II_WITH_ZLIB 1416 *
this << vertices <<
'\n';
1424 VtuStream::write_cell (
unsigned int,
1430 #if !defined(DEAL_II_WITH_ZLIB) 1431 stream << start <<
'\t' 1435 stream <<
'\t' << start+d2+d1
1436 <<
'\t' << start+d2;
1439 stream <<
'\t' << start+d3
1440 <<
'\t' << start+d3+d1
1441 <<
'\t' << start+d3+d2+d1
1442 <<
'\t' << start+d3+d2;
1447 cells.push_back (start);
1448 cells.push_back (start+d1);
1451 cells.push_back (start+d2+d1);
1452 cells.push_back (start+d2);
1455 cells.push_back (start+d3);
1456 cells.push_back (start+d3+d1);
1457 cells.push_back (start+d3+d2+d1);
1458 cells.push_back (start+d3+d2);
1467 VtuStream::flush_cells ()
1469 #ifdef DEAL_II_WITH_ZLIB 1473 *
this << cells <<
'\n';
1479 template <
typename T>
1481 VtuStream::operator<< (const std::vector<T> &data)
1483 #ifdef DEAL_II_WITH_ZLIB 1487 write_compressed_block (data, flags, stream);
1489 for (
unsigned int i=0; i<data.size(); ++i)
1490 stream << data[i] <<
' ';
1501 template <
int dim,
int spacedim>
1504 const unsigned int Deal_II_IntermediateFlags::format_version = 3;
1508 template <
int dim,
int spacedim>
1512 template <
int dim,
int spacedim>
1515 patch_index(no_neighbor),
1517 points_are_available(false)
1523 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
1524 neighbors[i] = no_neighbor;
1526 Assert (dim<=spacedim, ExcIndexRange(dim,0,spacedim));
1527 Assert (spacedim<=3, ExcNotImplemented());
1532 template <
int dim,
int spacedim>
1537 const double epsilon=3e-16;
1538 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1539 if (vertices[i].distance(patch.
vertices[i]) > epsilon)
1542 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
1555 if (data.n_rows() != patch.
data.n_rows())
1558 if (data.n_cols() != patch.
data.n_cols())
1561 for (
unsigned int i=0; i<data.n_rows(); ++i)
1562 for (
unsigned int j=0; j<data.n_cols(); ++j)
1563 if (data[i][j] != patch.
data[i][j])
1571 template <
int dim,
int spacedim>
1575 return (
sizeof(vertices) /
sizeof(vertices[0]) *
1587 template <
int dim,
int spacedim>
1591 std::swap (vertices, other_patch.
vertices);
1592 std::swap (neighbors, other_patch.
neighbors);
1595 data.swap (other_patch.
data);
1601 UcdFlags::UcdFlags (
const bool write_preamble)
1603 write_preamble (write_preamble)
1609 const bool bicubic_patch,
1610 const bool external_data)
1613 bicubic_patch(bicubic_patch),
1614 external_data(external_data)
1619 const bool xdmf_hdf5_output) :
1620 filter_duplicate_vertices(filter_duplicate_vertices),
1621 xdmf_hdf5_output(xdmf_hdf5_output)
1629 "Whether to remove duplicate vertex values.");
1632 "Whether the data will be used in an XDMF/HDF5 combination.");
1646 const bool int_binary,
1647 const bool coordinates_binary,
1648 const bool data_binary)
1650 write_neighbors(write_neighbors),
1651 int_binary(int_binary),
1652 coordinates_binary(coordinates_binary),
1653 data_binary(data_binary),
1662 "A boolean field indicating whether neighborship " 1663 "information between cells is to be written to the " 1664 "OpenDX output file");
1667 "Output format of integer numbers, which is " 1668 "either a text representation (ascii) or binary integer " 1669 "values of 32 or 64 bits length");
1672 "Output format of vertex coordinates, which is " 1673 "either a text representation (ascii) or binary " 1674 "floating point values of 32 or 64 bits length");
1677 "Output format of data values, which is " 1678 "either a text representation (ascii) or binary " 1679 "floating point values of 32 or 64 bits length");
1696 "A flag indicating whether a comment should be " 1697 "written to the beginning of the output file " 1698 "indicating date and time of creation as well " 1699 "as the creating program");
1706 write_preamble = prm.
get_bool (
"Write preamble");
1712 const int azimuth_angle,
1713 const int polar_angle,
1714 const unsigned int line_thickness,
1716 const bool draw_colorbar)
1720 height_vector(height_vector),
1721 azimuth_angle(azimuth_angle),
1722 polar_angle(polar_angle),
1723 line_thickness(line_thickness),
1725 draw_colorbar(draw_colorbar)
1734 "A flag indicating whether POVRAY should use smoothed " 1735 "triangles instead of the usual ones");
1738 "Whether POVRAY should use bicubic patches");
1741 "Whether camera and lighting information should " 1742 "be put into an external file \"data.inc\" or into " 1743 "the POVRAY input file");
1750 smooth = prm.
get_bool (
"Use smooth triangles");
1751 bicubic_patch = prm.
get_bool (
"Use bicubic patches");
1752 external_data = prm.
get_bool (
"Include external file");
1758 const unsigned int color_vector,
1760 const unsigned int size,
1761 const double line_width,
1762 const double azimut_angle,
1763 const double turn_angle,
1764 const double z_scaling,
1765 const bool draw_mesh,
1766 const bool draw_cells,
1767 const bool shade_cells,
1768 const ColorFunction color_function)
1770 height_vector(height_vector),
1771 color_vector(color_vector),
1772 size_type(size_type),
1774 line_width(line_width),
1775 azimut_angle(azimut_angle),
1776 turn_angle(turn_angle),
1777 z_scaling(z_scaling),
1778 draw_mesh(draw_mesh),
1779 draw_cells(draw_cells),
1780 shade_cells(shade_cells),
1781 color_function(color_function)
1820 double sum = xmax+ xmin;
1821 double sum13 = xmin+3*xmax;
1822 double sum22 = 2*xmin+2*xmax;
1823 double sum31 = 3*xmin+ xmax;
1824 double dif = xmax-xmin;
1825 double rezdif = 1.0/dif;
1831 else if (x<(sum22)/4)
1833 else if (x<(sum13)/4)
1844 rgb_values.green = 0;
1845 rgb_values.blue = (x-xmin)*4.*rezdif;
1849 rgb_values.green = (4*x-3*xmin-xmax)*rezdif;
1850 rgb_values.blue = (sum22-4.*x)*rezdif;
1853 rgb_values.red = (4*x-2*sum)*rezdif;
1854 rgb_values.green = (xmin+3*xmax-4*x)*rezdif;
1855 rgb_values.blue = 0;
1859 rgb_values.green = (4*x-xmin-3*xmax)*rezdif;
1860 rgb_values.blue = (4.*x-sum13)*rezdif;
1866 rgb_values.red = rgb_values.green = rgb_values.blue = 1;
1879 rgb_values.red = rgb_values.blue = rgb_values.green
1880 = (x-xmin)/(xmax-xmin);
1892 rgb_values.red = rgb_values.blue = rgb_values.green
1893 = 1-(x-xmin)/(xmax-xmin);
1899 bool EpsCell2d::operator < (
const EpsCell2d &e)
const 1903 return depth > e.depth;
1912 "Number of the input vector that is to be used to " 1913 "generate height information");
1916 "Number of the input vector that is to be used to " 1917 "generate color information");
1920 "Whether width or height should be scaled to match " 1922 prm.
declare_entry (
"Size (width or height) in eps units",
"300",
1924 "The size (width or height) to which the eps output " 1925 "file is to be scaled");
1928 "The width in which the postscript renderer is to " 1932 "Angle of the viewing position against the vertical " 1936 "Angle of the viewing direction against the y-axis");
1939 "Scaling for the z-direction relative to the scaling " 1940 "used in x- and y-directions");
1943 "Whether the mesh lines, or only the surface should be " 1947 "Whether only the mesh lines, or also the interior of " 1948 "cells should be plotted. If this flag is false, then " 1949 "one can see through the mesh");
1950 prm.
declare_entry (
"Color shading of interior of cells",
"true",
1952 "Whether the interior of cells shall be shaded");
1955 "Name of a color function used to colorize mesh lines " 1956 "and/or cell interiors");
1965 if (prm.
get (
"Scale to width or height") ==
"width")
1977 if (prm.
get(
"Color function") ==
"default")
1979 else if (prm.
get(
"Color function") ==
"grey scale")
1981 else if (prm.
get(
"Color function") ==
"reverse grey scale")
1988 Assert (
false, ExcInternalError());
1995 const char *zone_name,
1996 const double solution_time)
1998 tecplot_binary_file_name(tecplot_binary_file_name),
1999 zone_name(zone_name),
2000 solution_time (solution_time)
2008 return sizeof(*this)
2016 const unsigned int cycle,
2017 const bool print_date_and_time,
2022 print_date_and_time (print_date_and_time),
2023 compression_level (compression_level)
2031 if (format_name ==
"none")
2034 if (format_name ==
"dx")
2037 if (format_name ==
"ucd")
2040 if (format_name ==
"gnuplot")
2043 if (format_name ==
"povray")
2046 if (format_name ==
"eps")
2049 if (format_name ==
"gmv")
2052 if (format_name ==
"tecplot")
2055 if (format_name ==
"tecplot_binary")
2058 if (format_name ==
"vtk")
2061 if (format_name ==
"vtu")
2064 if (format_name ==
"deal.II intermediate")
2067 if (format_name ==
"hdf5")
2071 ExcMessage (
"The given file format name is not recognized: <" 2072 + format_name +
">"));
2083 return "none|dx|ucd|gnuplot|povray|eps|gmv|tecplot|tecplot_binary|vtk|vtu|hdf5|svg|deal.II intermediate";
2091 switch (output_format)
2122 Assert (
false, ExcNotImplemented());
2130 template <
int dim,
int spacedim,
typename StreamType>
2135 Assert (dim<=3, ExcNotImplemented());
2136 unsigned int count = 0;
2143 patch=patches.begin();
2144 patch!=patches.end(); ++patch)
2146 const unsigned int n_subdivisions = patch->n_subdivisions;
2147 const unsigned int n = n_subdivisions+1;
2152 const unsigned int n1 = (dim>0) ? n : 1;
2153 const unsigned int n2 = (dim>1) ? n : 1;
2154 const unsigned int n3 = (dim>2) ? n : 1;
2156 for (
unsigned int i3=0; i3<n3; ++i3)
2157 for (
unsigned int i2=0; i2<n2; ++i2)
2158 for (
unsigned int i1=0; i1<n1; ++i1)
2160 compute_node(node, &*patch,
2165 out.write_point(count++, node);
2168 out.flush_points ();
2171 template <
int dim,
int spacedim,
typename StreamType>
2176 Assert (dim<=3, ExcNotImplemented());
2177 unsigned int count = 0;
2178 unsigned int first_vertex_of_patch = 0;
2183 patch=patches.begin();
2184 patch!=patches.end(); ++patch)
2186 const unsigned int n_subdivisions = patch->n_subdivisions;
2187 const unsigned int n = n_subdivisions+1;
2189 const unsigned int n1 = (dim>0) ? n_subdivisions : 1;
2190 const unsigned int n2 = (dim>1) ? n_subdivisions : 1;
2191 const unsigned int n3 = (dim>2) ? n_subdivisions : 1;
2193 unsigned int d1 = 1;
2194 unsigned int d2 = n;
2195 unsigned int d3 = n*n;
2196 for (
unsigned int i3=0; i3<n3; ++i3)
2197 for (
unsigned int i2=0; i2<n2; ++i2)
2198 for (
unsigned int i1=0; i1<n1; ++i1)
2200 const unsigned int offset = first_vertex_of_patch+i3*d3+i2*d2+i1*d1;
2202 out.template write_cell<dim>(count++, offset, d1, d2, d3);
2206 first_vertex_of_patch += Utilities::fixed_power<dim>(n_subdivisions+1);
2213 template <
int dim,
int spacedim,
class StreamType>
2217 unsigned int n_data_sets,
2218 const bool double_precision,
2221 Assert (dim<=3, ExcNotImplemented());
2222 unsigned int count = 0;
2226 patch != patches.end(); ++patch)
2228 const unsigned int n_subdivisions = patch->n_subdivisions;
2229 const unsigned int n = n_subdivisions+1;
2231 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
2232 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
2233 ExcDimensionMismatch (patch->points_are_available
2235 (n_data_sets + spacedim)
2238 patch->data.n_rows()));
2239 Assert (patch->data.n_cols() == Utilities::fixed_power<dim>(n),
2240 ExcInvalidDatasetSize (patch->data.n_cols(), n));
2242 std::vector<float> floats(n_data_sets);
2243 std::vector<double> doubles(n_data_sets);
2247 for (
unsigned int i=0; i<Utilities::fixed_power<dim>(n); ++i, ++count)
2248 if (double_precision)
2250 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2251 doubles[data_set] = patch->data(data_set, i);
2252 out.write_dataset(count, doubles);
2256 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2257 floats[data_set] = patch->data(data_set, i);
2258 out.write_dataset(count, floats);
2278 camera_vertical[0] = camera_horizontal[1] * camera_direction[2] - camera_horizontal[2] * camera_direction[1];
2279 camera_vertical[1] = camera_horizontal[2] * camera_direction[0] - camera_horizontal[0] * camera_direction[2];
2280 camera_vertical[2] = camera_horizontal[0] * camera_direction[1] - camera_horizontal[1] * camera_direction[0];
2284 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];
2287 projection[0] = camera_position[0] + phi * (point[0] - camera_position[0]);
2288 projection[1] = camera_position[1] + phi * (point[1] - camera_position[1]);
2289 projection[2] = camera_position[2] + phi * (point[2] - camera_position[2]);
2292 projection_decomposition[0] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_horizontal[0];
2293 projection_decomposition[0] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_horizontal[1];
2294 projection_decomposition[0] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_horizontal[2];
2296 projection_decomposition[1] = (projection[0] - camera_position[0] - camera_focus * camera_direction[0]) * camera_vertical[0];
2297 projection_decomposition[1] += (projection[1] - camera_position[1] - camera_focus * camera_direction[1]) * camera_vertical[1];
2298 projection_decomposition[1] += (projection[2] - camera_position[2] - camera_focus * camera_direction[2]) * camera_vertical[2];
2300 return projection_decomposition;
2313 for (
int i = 0; i < 2; ++i)
2315 for (
int j = 0; j < 2-i; ++j)
2317 if (points[j][2] > points[j + 1][2])
2320 points[j] = points[j+1];
2328 v_inter = points[1];
2335 A[0][0] = v_max[0] - v_min[0];
2336 A[0][1] = v_inter[0] - v_min[0];
2337 A[1][0] = v_max[1] - v_min[1];
2338 A[1][1] = v_inter[1] - v_min[1];
2344 bool col_change =
false;
2353 double temp = A[1][0];
2358 for (
unsigned int k = 0; k < 1; k++)
2360 for (
unsigned int i = k+1; i < 2; i++)
2362 x = A[i][k] / A[k][k];
2364 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2366 b[i] = b[i] - b[k]*x;
2371 b[1] = b[1] / A[1][1];
2373 for (
int i = 0; i >= 0; i--)
2377 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
2379 b[i] = sum / A[i][i];
2389 double c = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) + v_min[2];
2392 A[0][0] = v_max[0] - v_min[0];
2393 A[0][1] = v_inter[0] - v_min[0];
2394 A[1][0] = v_max[1] - v_min[1];
2395 A[1][1] = v_inter[1] - v_min[1];
2397 b[0] = 1.0 - v_min[0];
2409 double temp = A[1][0];
2414 for (
unsigned int k = 0; k < 1; k++)
2416 for (
unsigned int i = k+1; i < 2; i++)
2418 x = A[i][k] / A[k][k];
2420 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2422 b[i] = b[i] - b[k] * x;
2427 b[1]=b[1] / A[1][1];
2429 for (
int i = 0; i >= 0; i--)
2433 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j]*b[j];
2435 b[i] = sum / A[i][i];
2445 gradient[0] = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2448 A[0][0] = v_max[0] - v_min[0];
2449 A[0][1] = v_inter[0] - v_min[0];
2450 A[1][0] = v_max[1] - v_min[1];
2451 A[1][1] = v_inter[1] - v_min[1];
2454 b[1] = 1.0 - v_min[1];
2465 double temp = A[1][0];
2470 for (
unsigned int k = 0; k < 1; k++)
2472 for (
unsigned int i = k+1; i < 2; i++)
2474 x = A[i][k] / A[k][k];
2476 for (
unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
2478 b[i] = b[i] - b[k] * x;
2482 b[1] = b[1] / A[1][1];
2484 for (
int i = 0; i >= 0; i--)
2488 for (
unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
2490 b[i] = sum / A[i][i];
2500 gradient[1] = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
2503 double gradient_norm = sqrt(pow(gradient[0], 2.0) + pow(gradient[1], 2.0));
2504 gradient[0] /= gradient_norm;
2505 gradient[1] /= gradient_norm;
2507 double lambda = - gradient[0] * (v_min[0] - v_max[0]) - gradient[1] * (v_min[1] - v_max[1]);
2511 gradient_parameters[0] = v_min[0];
2512 gradient_parameters[1] = v_min[1];
2514 gradient_parameters[2] = v_min[0] + lambda * gradient[0];
2515 gradient_parameters[3] = v_min[1] + lambda * gradient[1];
2517 gradient_parameters[4] = v_min[2];
2518 gradient_parameters[5] = v_max[2];
2520 return gradient_parameters;
2526 template <
int dim,
int spacedim>
2528 const std::vector<std::string> &data_names,
2529 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
2535 #ifndef DEAL_II_WITH_MPI 2549 Assert (patches.size() > 0, ExcNoPatches());
2551 if (patches.size() == 0)
2555 const unsigned int n_data_sets = data_names.size();
2557 UcdStream ucd_out(out, flags);
2561 unsigned int n_nodes;
2562 unsigned int n_cells;
2563 compute_sizes<dim,spacedim> (patches, n_nodes, n_cells);
2568 out <<
"# This file was generated by the deal.II library." <<
'\n' 2572 <<
"# For a description of the UCD format see the AVS Developer's guide." 2578 out << n_nodes <<
' ' 2580 << n_data_sets <<
' ' 2585 write_nodes(patches, ucd_out);
2588 write_cells(patches, ucd_out);
2593 if (n_data_sets != 0)
2595 out << n_data_sets <<
" ";
2596 for (
unsigned int i=0; i<n_data_sets; ++i)
2601 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
2602 out << data_names[data_set]
2606 write_data(patches, n_data_sets,
true, ucd_out);
2617 template <
int dim,
int spacedim>
2619 const std::vector<std::string> &data_names,
2620 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
2626 #ifndef DEAL_II_WITH_MPI 2640 Assert (patches.size() > 0, ExcNoPatches());
2642 if (patches.size() == 0)
2646 DXStream dx_out(out, flags);
2650 unsigned int offset = 0;
2652 const unsigned int n_data_sets = data_names.size();
2656 unsigned int n_nodes;
2657 unsigned int n_cells;
2658 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
2662 out <<
"object \"vertices\" class array type float rank 1 shape " << spacedim
2663 <<
" items " << n_nodes;
2667 out <<
" lsb ieee data 0" <<
'\n';
2668 offset += n_nodes * spacedim *
sizeof(float);
2672 out <<
" data follows" <<
'\n';
2673 write_nodes(patches, dx_out);
2681 out <<
"object \"cells\" class array type int rank 1 shape " 2683 <<
" items " << n_cells;
2687 out <<
" lsb binary data " << offset <<
'\n';
2688 offset += n_cells *
sizeof (int);
2692 out <<
" data follows" <<
'\n';
2693 write_cells(patches, dx_out);
2698 out <<
"attribute \"element type\" string \"";
2699 if (dim==1) out <<
"lines";
2700 if (dim==2) out <<
"quads";
2701 if (dim==3) out <<
"cubes";
2703 <<
"attribute \"ref\" string \"positions\"" <<
'\n';
2710 out <<
"object \"neighbors\" class array type int rank 1 shape " 2712 <<
" items " << n_cells
2716 patch=patches.begin();
2717 patch!=patches.end(); ++patch)
2719 const unsigned int n = patch->n_subdivisions;
2720 const unsigned int n1 = (dim>0) ? n : 1;
2721 const unsigned int n2 = (dim>1) ? n : 1;
2722 const unsigned int n3 = (dim>2) ? n : 1;
2723 unsigned int cells_per_patch = Utilities::fixed_power<dim>(n);
2724 unsigned int dx = 1;
2725 unsigned int dy = n;
2726 unsigned int dz = n*n;
2728 const unsigned int patch_start = patch->patch_index * cells_per_patch;
2730 for (
unsigned int i3=0; i3<n3; ++i3)
2731 for (
unsigned int i2=0; i2<n2; ++i2)
2732 for (
unsigned int i1=0; i1<n1; ++i1)
2734 const unsigned int nx = i1*
dx;
2735 const unsigned int ny = i2*dy;
2736 const unsigned int nz = i3*dz;
2744 const unsigned int nn = patch->neighbors[0];
2746 if (nn != patch->no_neighbor)
2747 out << (nn*cells_per_patch+ny+nz+dx*(n-1));
2754 << patch_start+nx-dx+ny+nz;
2761 const unsigned int nn = patch->neighbors[1];
2763 if (nn != patch->no_neighbor)
2764 out << (nn*cells_per_patch+ny+nz);
2771 << patch_start+nx+dx+ny+nz;
2778 const unsigned int nn = patch->neighbors[2];
2780 if (nn != patch->no_neighbor)
2781 out << (nn*cells_per_patch+nx+nz+dy*(n-1));
2788 << patch_start+nx+ny-dy+nz;
2793 const unsigned int nn = patch->neighbors[3];
2795 if (nn != patch->no_neighbor)
2796 out << (nn*cells_per_patch+nx+nz);
2803 << patch_start+nx+ny+dy+nz;
2811 const unsigned int nn = patch->neighbors[4];
2813 if (nn != patch->no_neighbor)
2814 out << (nn*cells_per_patch+nx+ny+dz*(n-1));
2821 << patch_start+nx+ny+nz-dz;
2826 const unsigned int nn = patch->neighbors[5];
2828 if (nn != patch->no_neighbor)
2829 out << (nn*cells_per_patch+nx+ny);
2836 << patch_start+nx+ny+nz+dz;
2844 if (n_data_sets != 0)
2846 out <<
"object \"data\" class array type float rank 1 shape " 2848 <<
" items " << n_nodes;
2852 out <<
" lsb ieee data " << offset <<
'\n';
2853 offset += n_data_sets * n_nodes * ((flags.
data_double)
2859 out <<
" data follows" <<
'\n';
2860 write_data(patches, n_data_sets, flags.
data_double, dx_out);
2864 out <<
"attribute \"dep\" string \"positions\"" <<
'\n';
2868 out <<
"object \"data\" class constantarray type float rank 0 items " << n_nodes <<
" data follows" 2869 <<
'\n' <<
'0' <<
'\n';
2874 out <<
"object \"deal data\" class field" <<
'\n' 2875 <<
"component \"positions\" value \"vertices\"" <<
'\n' 2876 <<
"component \"connections\" value \"cells\"" <<
'\n' 2877 <<
"component \"data\" value \"data\"" <<
'\n';
2880 out <<
"component \"neighbors\" value \"neighbors\"" <<
'\n';
2883 out <<
"attribute \"created\" string \"" 2889 out <<
"end" <<
'\n';
2892 write_nodes(patches, dx_out);
2894 write_cells(patches, dx_out);
2896 write_data(patches, n_data_sets, flags.
data_double, dx_out);
2908 template <
int dim,
int spacedim>
2910 const std::vector<std::string> &data_names,
2911 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
2917 #ifndef DEAL_II_WITH_MPI 2931 Assert (patches.size() > 0, ExcNoPatches());
2933 if (patches.size() == 0)
2937 const unsigned int n_data_sets = data_names.size();
2941 out <<
"# This file was generated by the deal.II library." <<
'\n' 2945 <<
"# For a description of the GNUPLOT format see the GNUPLOT manual." 2959 out <<
"<x> <y> <z> ";
2963 Assert (
false, ExcNotImplemented());
2966 for (
unsigned int i=0; i<data_names.size(); ++i)
2967 out <<
'<' << data_names[i] <<
"> ";
2974 patch != patches.end(); ++patch)
2976 const unsigned int n_subdivisions = patch->n_subdivisions;
2977 const unsigned int n = n_subdivisions+1;
2979 const unsigned int n1 = (dim>0) ? n : 1;
2980 const unsigned int n2 = (dim>1) ? n : 1;
2981 const unsigned int n3 = (dim>2) ? n : 1;
2982 unsigned int d1 = 1;
2983 unsigned int d2 = n;
2984 unsigned int d3 = n*n;
2986 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
2987 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
2988 ExcDimensionMismatch (patch->points_are_available
2990 (n_data_sets + spacedim)
2993 patch->data.n_rows()));
2994 Assert (patch->data.n_cols() == Utilities::fixed_power<dim>(n),
2995 ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1));
3001 for (
unsigned int i2=0; i2<n2; ++i2)
3003 for (
unsigned int i1=0; i1<n1; ++i1)
3007 compute_node(node, &*patch, i1, i2, 0, n_subdivisions);
3010 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3011 out << patch->data(data_set,i1*d1+i2*d2) <<
' ';
3030 for (
unsigned int i3=0; i3<n3; ++i3)
3031 for (
unsigned int i2=0; i2<n2; ++i2)
3032 for (
unsigned int i1=0; i1<n1; ++i1)
3036 compute_node(this_point, &*patch, i1, i2, i3, n_subdivisions);
3039 if (i1 < n_subdivisions)
3044 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3046 << patch->data(data_set,i1*d1+i2*d2+i3*d3);
3051 compute_node(node, &*patch, i1+1, i2, i3, n_subdivisions);
3054 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3056 << patch->data(data_set,(i1+1)*d1+i2*d2+i3*d3);
3066 if (i2 < n_subdivisions)
3071 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3073 << patch->data(data_set, i1*d1+i2*d2+i3*d3);
3078 compute_node(node, &*patch, i1, i2+1, i3, n_subdivisions);
3081 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3083 << patch->data(data_set,i1*d1+(i2+1)*d2+i3*d3);
3093 if (i3 < n_subdivisions)
3098 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3100 << patch->data(data_set,i1*d1+i2*d2+i3*d3);
3105 compute_node(node, &*patch, i1, i2, i3+1, n_subdivisions);
3108 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3110 << patch->data(data_set,i1*d1+i2*d2+(i3+1)*d3);
3120 Assert (
false, ExcNotImplemented());
3131 template <
int dim,
int spacedim>
3133 const std::vector<std::string> &data_names,
3134 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3140 #ifndef DEAL_II_WITH_MPI 3154 Assert (patches.size() > 0, ExcNoPatches());
3156 if (patches.size() == 0)
3159 Assert (dim==2, ExcNotImplemented());
3160 Assert (spacedim==2, ExcNotImplemented());
3162 const unsigned int n_data_sets = data_names.size();
3167 out <<
"/* This file was generated by the deal.II library." <<
'\n' 3171 <<
" For a description of the POVRAY format see the POVRAY manual." 3176 out <<
"#include \"colors.inc\" " <<
'\n' 3177 <<
"#include \"textures.inc\" " <<
'\n';
3183 out <<
"#include \"data.inc\" " <<
'\n';
3188 <<
"camera {" <<
'\n' 3189 <<
" location <1,4,-7>" <<
'\n' 3190 <<
" look_at <0,0,0>" <<
'\n' 3191 <<
" angle 30" <<
'\n' 3196 <<
"light_source {" <<
'\n' 3197 <<
" <1,4,-7>" <<
'\n' 3198 <<
" color Grey" <<
'\n' 3201 <<
"light_source {" <<
'\n' 3202 <<
" <0,20,0>" <<
'\n' 3203 <<
" color White" <<
'\n' 3209 Assert(patches.size()>0, ExcInternalError());
3210 double hmin=patches[0].data(0,0);
3211 double hmax=patches[0].data(0,0);
3214 patch != patches.end(); ++patch)
3216 const unsigned int n_subdivisions = patch->n_subdivisions;
3218 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
3219 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
3220 ExcDimensionMismatch (patch->points_are_available
3222 (n_data_sets + spacedim)
3225 patch->data.n_rows()));
3226 Assert (patch->data.n_cols() == Utilities::fixed_power<dim>(n_subdivisions+1),
3227 ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1));
3229 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
3230 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
3232 const int dl = i*(n_subdivisions+1)+j;
3233 if (patch->data(0,dl)<hmin)
3234 hmin=patch->data(0,dl);
3235 if (patch->data(0,dl)>hmax)
3236 hmax=patch->data(0,dl);
3240 out <<
"#declare HMIN=" << hmin <<
";" <<
'\n' 3241 <<
"#declare HMAX=" << hmax <<
";" <<
'\n' <<
'\n';
3247 out <<
"#declare Tex=texture{" <<
'\n' 3248 <<
" pigment {" <<
'\n' 3249 <<
" gradient y" <<
'\n' 3250 <<
" scale y*(HMAX-HMIN)*" << 0.1 <<
'\n' 3251 <<
" color_map {" <<
'\n' 3252 <<
" [0.00 color Light_Purple] " <<
'\n' 3253 <<
" [0.95 color Light_Purple] " <<
'\n' 3254 <<
" [1.00 color White] " <<
'\n' 3255 <<
"} } }" <<
'\n' <<
'\n';
3262 <<
"mesh {" <<
'\n';
3267 patch != patches.end(); ++patch)
3269 const unsigned int n_subdivisions = patch->n_subdivisions;
3270 const unsigned int n = n_subdivisions+1;
3271 const unsigned int d1=1;
3272 const unsigned int d2=n;
3274 Assert ((patch->data.n_rows() == n_data_sets && !patch->points_are_available) ||
3275 (patch->data.n_rows() == n_data_sets+spacedim && patch->points_are_available),
3276 ExcDimensionMismatch (patch->points_are_available
3278 (n_data_sets + spacedim)
3281 patch->data.n_rows()));
3282 Assert (patch->data.n_cols() == Utilities::fixed_power<dim>(n),
3283 ExcInvalidDatasetSize (patch->data.n_cols(), n_subdivisions+1));
3286 std::vector<Point<spacedim> > ver(n*n);
3288 for (
unsigned int i2=0; i2<n; ++i2)
3289 for (
unsigned int i1=0; i1<n; ++i1)
3293 compute_node(ver[i1*d1+i2*d2], &*patch, i1, i2, 0, n_subdivisions);
3301 std::vector<Point<3> > nrml;
3319 for (
unsigned int i=0; i<n; ++i)
3320 for (
unsigned int j=0; j<n; ++j)
3322 const unsigned int il = (i==0) ? i : (i-1);
3323 const unsigned int ir = (i==n_subdivisions) ? i : (i+1);
3324 const unsigned int jl = (j==0) ? j : (j-1);
3325 const unsigned int jr = (j==n_subdivisions) ? j : (j+1);
3327 h1(0)=ver[ir*d1+j*d2](0) - ver[il*d1+j*d2](0);
3328 h1(1)=patch->data(0,ir*d1+j*d2)-
3329 patch->data(0,il*d1+j*d2);
3330 h1(2)=ver[ir*d1+j*d2](1) - ver[il*d1+j*d2](1);
3332 h2(0)=ver[i*d1+jr*d2](0) - ver[i*d1+jl*d2](0);
3333 h2(1)=patch->data(0,i*d1+jr*d2)-
3334 patch->data(0,i*d1+jl*d2);
3335 h2(2)=ver[i*d1+jr*d2](1) - ver[i*d1+jl*d2](1);
3337 nrml[i*d1+j*d2](0)=h1(1)*h2(2)-h1(2)*h2(1);
3338 nrml[i*d1+j*d2](1)=h1(2)*h2(0)-h1(0)*h2(2);
3339 nrml[i*d1+j*d2](2)=h1(0)*h2(1)-h1(1)*h2(0);
3342 double norm=std::sqrt(
3343 std::pow(nrml[i*d1+j*d2](0),2.)+
3344 std::pow(nrml[i*d1+j*d2](1),2.)+
3345 std::pow(nrml[i*d1+j*d2](2),2.));
3347 if (nrml[i*d1+j*d2](1)<0)
3350 for (
unsigned int k=0; k<3; ++k)
3351 nrml[i*d1+j*d2](k)/=norm;
3356 for (
unsigned int i=0; i<n_subdivisions; ++i)
3357 for (
unsigned int j=0; j<n_subdivisions; ++j)
3360 const int dl = i*d1+j*d2;
3366 out <<
"smooth_triangle {" <<
'\n' <<
"\t<" 3367 << ver[dl](0) <<
"," 3368 << patch->data(0,dl) <<
"," 3369 << ver[dl](1) <<
">, <" 3370 << nrml[dl](0) <<
", " 3371 << nrml[dl](1) <<
", " 3375 << ver[dl+d1](0) <<
"," 3376 << patch->data(0,dl+d1) <<
"," 3377 << ver[dl+d1](1) <<
">, <" 3378 << nrml[dl+d1](0) <<
", " 3379 << nrml[dl+d1](1) <<
", " 3383 << ver[dl+d1+d2](0) <<
"," 3384 << patch->data(0,dl+d1+d2) <<
"," 3385 << ver[dl+d1+d2](1) <<
">, <" 3386 << nrml[dl+d1+d2](0) <<
", " 3387 << nrml[dl+d1+d2](1) <<
", " 3388 << nrml[dl+d1+d2](2)
3392 out <<
"smooth_triangle {" <<
'\n' <<
"\t<" 3393 << ver[dl](0) <<
"," 3394 << patch->data(0,dl) <<
"," 3395 << ver[dl](1) <<
">, <" 3396 << nrml[dl](0) <<
", " 3397 << nrml[dl](1) <<
", " 3401 << ver[dl+d1+d2](0) <<
"," 3402 << patch->data(0,dl+d1+d2) <<
"," 3403 << ver[dl+d1+d2](1) <<
">, <" 3404 << nrml[dl+d1+d2](0) <<
", " 3405 << nrml[dl+d1+d2](1) <<
", " 3406 << nrml[dl+d1+d2](2)
3409 << ver[dl+d2](0) <<
"," 3410 << patch->data(0,dl+d2) <<
"," 3411 << ver[dl+d2](1) <<
">, <" 3412 << nrml[dl+d2](0) <<
", " 3413 << nrml[dl+d2](1) <<
", " 3421 out <<
"triangle {" <<
'\n' <<
"\t<" 3422 << ver[dl](0) <<
"," 3423 << patch->data(0,dl) <<
"," 3424 << ver[dl](1) <<
">," <<
'\n';
3426 << ver[dl+d1](0) <<
"," 3427 << patch->data(0,dl+d1) <<
"," 3428 << ver[dl+d1](1) <<
">," <<
'\n';
3430 << ver[dl+d1+d2](0) <<
"," 3431 << patch->data(0,dl+d1+d2) <<
"," 3432 << ver[dl+d1+d2](1) <<
">}" <<
'\n';
3435 out <<
"triangle {" <<
'\n' <<
"\t<" 3436 << ver[dl](0) <<
"," 3437 << patch->data(0,dl) <<
"," 3438 << ver[dl](1) <<
">," <<
'\n';
3440 << ver[dl+d1+d2](0) <<
"," 3441 << patch->data(0,dl+d1+d2) <<
"," 3442 << ver[dl+d1+d2](1) <<
">," <<
'\n';
3444 << ver[dl+d2](0) <<
"," 3445 << patch->data(0,dl+d2) <<
"," 3446 << ver[dl+d2](1) <<
">}" <<
'\n';
3453 Assert (n_subdivisions==3, ExcDimensionMismatch(n_subdivisions,3));
3455 <<
"bicubic_patch {" <<
'\n' 3456 <<
" type 0" <<
'\n' 3457 <<
" flatness 0" <<
'\n' 3458 <<
" u_steps 0" <<
'\n' 3459 <<
" v_steps 0" <<
'\n';
3460 for (
int i=0; i<16; ++i)
3462 out <<
"\t<" << ver[i](0) <<
"," << patch->data(0,i) <<
"," << ver[i](1) <<
">";
3463 if (i!=15) out <<
",";
3466 out <<
" texture {Tex}" <<
'\n' 3474 out <<
" texture {Tex}" <<
'\n' 3488 template <
int dim,
int spacedim>
3490 const std::vector<std::string> &,
3491 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3500 template <
int spacedim>
3502 const std::vector<std::string> &,
3503 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3509 #ifndef DEAL_II_WITH_MPI 3523 Assert (patches.size() > 0, ExcNoPatches());
3525 if (patches.size() == 0)
3529 const unsigned int old_precision = out.precision();
3542 std::multiset<EpsCell2d> cells;
3551 double min_color_value=0, max_color_value=0;
3556 double heights[4] = { 0, 0, 0, 0 };
3563 for (
typename std::vector<
Patch<2,spacedim> >::const_iterator patch=patches.begin();
3564 patch!=patches.end(); ++patch)
3566 const unsigned int n_subdivisions = patch->n_subdivisions;
3567 const unsigned int n = n_subdivisions+1;
3568 const unsigned int d1 = 1;
3569 const unsigned int d2 = n;
3571 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
3572 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
3575 compute_node(points[0], &*patch, i1, i2, 0, n_subdivisions);
3576 compute_node(points[1], &*patch, i1+1, i2, 0, n_subdivisions);
3577 compute_node(points[2], &*patch, i1, i2+1, 0, n_subdivisions);
3578 compute_node(points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
3584 patch->data.n_rows() == 0,
3586 patch->data.n_rows()));
3587 heights[0] = patch->data.n_rows() != 0 ?
3590 heights[1] = patch->data.n_rows() != 0 ?
3593 heights[2] = patch->data.n_rows() != 0 ?
3596 heights[3] = patch->data.n_rows() != 0 ?
3603 for (
unsigned int i=0; i<4; ++i)
3604 heights[i] = points[i](2);
3607 Assert(
false, ExcNotImplemented());
3632 const double cx = -std::cos(pi-flags.
azimut_angle * 2*pi / 360.),
3633 cz = -std::cos(flags.
turn_angle * 2*pi / 360.),
3635 sz = std::sin(flags.
turn_angle * 2*pi / 360.);
3636 for (
unsigned int vertex=0; vertex<4; ++vertex)
3638 const double x = points[vertex](0),
3639 y = points[vertex](1),
3640 z = -heights[vertex];
3642 eps_cell.vertices[vertex](0) = - cz*x+ sz*y;
3643 eps_cell.vertices[vertex](1) = -cx*sz*x-cx*cz*y-sx*z;
3665 = (points[0] + points[1] + points[2] + points[3]) / 4;
3666 const double center_height
3667 = -(heights[0] + heights[1] + heights[2] + heights[3]) / 4;
3671 eps_cell.depth = -sx*sz*center_point(0)
3672 -sx*cz*center_point(1)
3678 patch->data.n_rows() == 0,
3680 patch->data.n_rows()));
3681 const double color_values[4]
3682 = { patch->data.n_rows() != 0 ?
3685 patch->data.n_rows() != 0 ?
3686 patch->data(flags.
color_vector,(i1+1)*d1 + i2 *d2) : 1,
3688 patch->data.n_rows() != 0 ?
3689 patch->data(flags.
color_vector,i1 *d1 + (i2+1)*d2) : 1,
3691 patch->data.n_rows() != 0 ?
3692 patch->data(flags.
color_vector,(i1+1)*d1 + (i2+1)*d2) : 1
3697 eps_cell.color_value = (color_values[0] +
3700 color_values[2]) / 4;
3704 if (patch == patches.begin())
3705 min_color_value = max_color_value = eps_cell.color_value;
3708 min_color_value = (min_color_value < eps_cell.color_value ?
3709 min_color_value : eps_cell.color_value);
3710 max_color_value = (max_color_value > eps_cell.color_value ?
3711 max_color_value : eps_cell.color_value);
3716 cells.insert (eps_cell);
3723 double x_min = cells.begin()->vertices[0](0);
3724 double x_max = x_min;
3725 double y_min = cells.begin()->vertices[0](1);
3726 double y_max = y_min;
3728 for (
typename std::multiset<EpsCell2d>::const_iterator
3730 cell!=cells.end(); ++cell)
3731 for (
unsigned int vertex=0; vertex<4; ++vertex)
3733 x_min = std::min (x_min, cell->vertices[vertex](0));
3734 x_max = std::max (x_max, cell->vertices[vertex](0));
3735 y_min = std::min (y_min, cell->vertices[vertex](1));
3736 y_max = std::max (y_max, cell->vertices[vertex](1));
3744 const double scale = (flags.size /
3749 const Point<2> offset(x_min, y_min);
3754 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n' 3755 <<
"%%Title: deal.II Output" <<
'\n' 3756 <<
"%%Creator: the deal.II library" <<
'\n' 3757 <<
"%%Creation Date: " 3761 <<
"%%BoundingBox: " 3765 <<
static_cast<unsigned int>( (x_max-x_min) * scale + 0.5)
3767 <<
static_cast<unsigned int>( (y_max-y_min) * scale + 0.5)
3778 out <<
"/m {moveto} bind def" <<
'\n' 3779 <<
"/l {lineto} bind def" <<
'\n' 3780 <<
"/s {setrgbcolor} bind def" <<
'\n' 3781 <<
"/sg {setgray} bind def" <<
'\n' 3782 <<
"/lx {lineto closepath stroke} bind def" <<
'\n' 3783 <<
"/lf {lineto closepath fill} bind def" <<
'\n';
3785 out <<
"%%EndProlog" <<
'\n' 3788 out << flags.line_width <<
" setlinewidth" <<
'\n';
3794 out << std::setprecision (5);
3811 if (max_color_value == min_color_value)
3812 max_color_value = min_color_value+1;
3819 for (
typename std::multiset<EpsCell2d>::const_iterator
3821 cell!=cells.end(); ++cell)
3823 if (flags.draw_cells)
3825 if (flags.shade_cells)
3828 = (*flags.color_function) (cell->color_value,
3834 out << rgb_values.red <<
" sg ";
3836 out << rgb_values.red <<
' ' 3837 << rgb_values.green <<
' ' 3838 << rgb_values.blue <<
" s ";
3843 out << (cell->vertices[0]-offset) * scale <<
" m " 3844 << (cell->vertices[1]-offset) * scale <<
" l " 3845 << (cell->vertices[3]-offset) * scale <<
" l " 3846 << (cell->vertices[2]-offset) * scale <<
" lf" 3850 if (flags.draw_mesh)
3852 << (cell->vertices[0]-offset) * scale <<
" m " 3853 << (cell->vertices[1]-offset) * scale <<
" l " 3854 << (cell->vertices[3]-offset) * scale <<
" l " 3855 << (cell->vertices[2]-offset) * scale <<
" lx" 3858 out <<
"showpage" <<
'\n';
3861 out << std::setprecision(old_precision);
3869 template <
int dim,
int spacedim>
3871 const std::vector<std::string> &data_names,
3872 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
3876 Assert(dim<=3, ExcNotImplemented());
3879 #ifndef DEAL_II_WITH_MPI 3893 Assert (patches.size() > 0, ExcNoPatches());
3895 if (patches.size() == 0)
3899 GmvStream gmv_out(out, flags);
3900 const unsigned int n_data_sets = data_names.size();
3905 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
3906 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
3907 ExcDimensionMismatch (patches[0].points_are_available
3909 (n_data_sets + spacedim)
3912 patches[0].data.n_rows()));
3916 out <<
"gmvinput ascii" 3922 unsigned int n_nodes;
3923 unsigned int n_cells;
3924 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
3948 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
3950 = &write_gmv_reorder_data_vectors<dim,spacedim>;
3960 out <<
"nodes " << n_nodes <<
'\n';
3961 for (
unsigned int d=0; d<spacedim; ++d)
3963 gmv_out.selected_component = d;
3964 write_nodes(patches, gmv_out);
3969 for (
unsigned int d=spacedim; d<3; ++d)
3971 for (
unsigned int i=0; i<n_nodes; ++i)
3979 out <<
"cells " << n_cells <<
'\n';
3980 write_cells(patches, gmv_out);
3984 out <<
"variable" <<
'\n';
3989 reorder_task.
join ();
3995 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
3997 out << data_names[data_set] <<
" 1" <<
'\n';
3998 std::copy (data_vectors[data_set].begin(),
3999 data_vectors[data_set].end(),
4000 std::ostream_iterator<double>(out,
" "));
4008 out <<
"endvars" <<
'\n';
4024 template <
int dim,
int spacedim>
4026 const std::vector<std::string> &data_names,
4027 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
4033 #ifndef DEAL_II_WITH_MPI 4047 Assert (patches.size() > 0, ExcNoPatches());
4049 if (patches.size() == 0)
4053 TecplotStream tecplot_out(out, flags);
4055 const unsigned int n_data_sets = data_names.size();
4060 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4061 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4062 ExcDimensionMismatch (patches[0].points_are_available
4064 (n_data_sets + spacedim)
4067 patches[0].data.n_rows()));
4071 unsigned int n_nodes;
4072 unsigned int n_cells;
4073 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4078 out <<
"# This file was generated by the deal.II library." <<
'\n' 4082 <<
"# For a description of the Tecplot format see the Tecplot documentation." 4087 out <<
"Variables=";
4095 out <<
"\"x\", \"y\"";
4098 out <<
"\"x\", \"y\", \"z\"";
4101 Assert (
false, ExcNotImplemented());
4104 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4105 out <<
", \"" << data_names[data_set] <<
"\"";
4111 out <<
"t=\"" << flags.
zone_name <<
"\" ";
4114 out <<
"strandid=1, solutiontime=" << flags.
solution_time <<
", ";
4116 out <<
"f=feblock, n=" << n_nodes <<
", e=" << n_cells
4117 <<
", et=" << tecplot_cell_type[dim] <<
'\n';
4145 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4147 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4156 for (
unsigned int d=0; d<spacedim; ++d)
4158 tecplot_out.selected_component = d;
4159 write_nodes(patches, tecplot_out);
4170 reorder_task.
join ();
4173 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4175 std::copy (data_vectors[data_set].begin(),
4176 data_vectors[data_set].end(),
4177 std::ostream_iterator<double>(out,
"\n"));
4181 write_cells(patches, tecplot_out);
4196 #ifdef DEAL_II_HAVE_TECPLOT 4203 TecplotMacros(
const unsigned int n_nodes = 0,
4204 const unsigned int n_vars = 0,
4205 const unsigned int n_cells = 0,
4206 const unsigned int n_vert = 0);
4208 float &nd(
const unsigned int i,
const unsigned int j);
4209 int &cd(
const unsigned int i,
const unsigned int j);
4210 std::vector<float> nodalData;
4211 std::vector<int> connData;
4213 unsigned int n_nodes;
4214 unsigned int n_vars;
4215 unsigned int n_cells;
4216 unsigned int n_vert;
4221 TecplotMacros::TecplotMacros(
const unsigned int n_nodes,
4222 const unsigned int n_vars,
4223 const unsigned int n_cells,
4224 const unsigned int n_vert)
4231 nodalData.resize(n_nodes*n_vars);
4232 connData.resize(n_cells*n_vert);
4238 TecplotMacros::~TecplotMacros()
4244 float &TecplotMacros::nd (
const unsigned int i,
4245 const unsigned int j)
4247 return nodalData[i*n_nodes+j];
4253 int &TecplotMacros::cd (
const unsigned int i,
4254 const unsigned int j)
4256 return connData[i+j*n_vert];
4267 template <
int dim,
int spacedim>
4269 const std::vector<std::string> &data_names,
4270 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4275 #ifndef DEAL_II_HAVE_TECPLOT 4280 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4289 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4300 if (file_name == NULL)
4307 " file through the TecplotFlags interface."));
4308 write_tecplot (patches, data_names, vector_data_ranges, flags, out);
4315 #ifndef DEAL_II_WITH_MPI 4329 Assert (patches.size() > 0, ExcNoPatches());
4331 if (patches.size() == 0)
4335 const unsigned int n_data_sets = data_names.size();
4340 Assert ((patches[0].data.n_rows() == n_data_sets && !patches[0].points_are_available) ||
4341 (patches[0].data.n_rows() == n_data_sets+spacedim && patches[0].points_are_available),
4342 ExcDimensionMismatch (patches[0].points_are_available
4344 (n_data_sets + spacedim)
4347 patches[0].data.n_rows()));
4351 unsigned int n_nodes;
4352 unsigned int n_cells;
4353 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4356 const unsigned int vars_per_node = (spacedim+n_data_sets),
4359 TecplotMacros tm(n_nodes, vars_per_node, n_cells, nodes_per_cell);
4363 cell_type = tecplot_binary_cell_type[dim];
4365 std::string tec_var_names;
4369 tec_var_names =
"x y";
4372 tec_var_names =
"x y z";
4375 Assert(
false, ExcNotImplemented());
4378 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4380 tec_var_names +=
" ";
4381 tec_var_names += data_names[data_set];
4406 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4408 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4415 for (
unsigned int d=1; d<=spacedim; ++d)
4417 unsigned int entry=0;
4420 patch!=patches.end(); ++patch)
4422 const unsigned int n_subdivisions = patch->n_subdivisions;
4428 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
4429 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
4431 const double x_frac = i * 1./n_subdivisions,
4432 y_frac = j * 1./n_subdivisions;
4434 tm.nd((d-1),entry) =
static_cast<float>(
4435 (((patch->vertices[1](d-1) * x_frac) +
4436 (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
4437 ((patch->vertices[3](d-1) * x_frac) +
4438 (patch->vertices[2](d-1) * (1-x_frac))) * y_frac)
4447 for (
unsigned int j=0; j<n_subdivisions+1; ++j)
4448 for (
unsigned int k=0; k<n_subdivisions+1; ++k)
4449 for (
unsigned int i=0; i<n_subdivisions+1; ++i)
4451 const double x_frac = i * 1./n_subdivisions,
4452 y_frac = k * 1./n_subdivisions,
4453 z_frac = j * 1./n_subdivisions;
4457 tm.nd((d-1),entry) =
static_cast<float>(
4458 ((((patch->vertices[1](d-1) * x_frac) +
4459 (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
4460 ((patch->vertices[3](d-1) * x_frac) +
4461 (patch->vertices[2](d-1) * (1-x_frac))) * y_frac) * (1-z_frac) +
4462 (((patch->vertices[5](d-1) * x_frac) +
4463 (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) +
4464 ((patch->vertices[7](d-1) * x_frac) +
4465 (patch->vertices[6](d-1) * (1-x_frac))) * y_frac) * z_frac)
4473 Assert (
false, ExcNotImplemented());
4482 reorder_task.
join ();
4485 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4486 for (
unsigned int entry=0; entry<data_vectors[data_set].
size(); entry++)
4487 tm.nd((spacedim+data_set),entry) =
static_cast<float>(data_vectors[data_set][entry]);
4495 unsigned int first_vertex_of_patch = 0;
4496 unsigned int elem=0;
4499 patch!=patches.end(); ++patch)
4501 const unsigned int n_subdivisions = patch->n_subdivisions;
4502 const unsigned int n = n_subdivisions+1;
4503 const unsigned int d1=1;
4504 const unsigned int d2=n;
4505 const unsigned int d3=n*n;
4512 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
4513 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
4515 tm.cd(0,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+1;
4516 tm.cd(1,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+1;
4517 tm.cd(2,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+1;
4518 tm.cd(3,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+1;
4527 for (
unsigned int i3=0; i3<n_subdivisions; ++i3)
4528 for (
unsigned int i2=0; i2<n_subdivisions; ++i2)
4529 for (
unsigned int i1=0; i1<n_subdivisions; ++i1)
4534 tm.cd(0,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+(i3 )*d3+1;
4535 tm.cd(1,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+(i3 )*d3+1;
4536 tm.cd(2,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+(i3 )*d3+1;
4537 tm.cd(3,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+(i3 )*d3+1;
4538 tm.cd(4,elem) = first_vertex_of_patch+(i1 )*d1+(i2 )*d2+(i3+1)*d3+1;
4539 tm.cd(5,elem) = first_vertex_of_patch+(i1+1)*d1+(i2 )*d2+(i3+1)*d3+1;
4540 tm.cd(6,elem) = first_vertex_of_patch+(i1+1)*d1+(i2+1)*d2+(i3+1)*d3+1;
4541 tm.cd(7,elem) = first_vertex_of_patch+(i1 )*d1+(i2+1)*d2+(i3+1)*d3+1;
4549 Assert (
false, ExcNotImplemented());
4555 first_vertex_of_patch += Utilities::fixed_power<dim>(n);
4561 num_nodes =
static_cast<int>(n_nodes),
4562 num_cells = static_cast<int>(n_cells);
4564 char dot[2] = {
'.', 0};
4571 char *var_names=
const_cast<char *
> (tec_var_names.c_str());
4572 ierr = TECINI (NULL,
4579 Assert (ierr == 0, ExcErrorOpeningTecplotFile(file_name));
4581 char FEBLOCK[] = {
'F',
'E',
'B',
'L',
'O',
'C',
'K',0};
4582 ierr = TECZNE (NULL,
4589 Assert (ierr == 0, ExcTecplotAPIError());
4591 int total = (vars_per_node*num_nodes);
4593 ierr = TECDAT (&total,
4597 Assert (ierr == 0, ExcTecplotAPIError());
4599 ierr = TECNOD (&tm.connData[0]);
4601 Assert (ierr == 0, ExcTecplotAPIError());
4605 Assert (ierr == 0, ExcTecplotAPIError());
4612 template <
int dim,
int spacedim>
4615 const std::vector<std::string> &data_names,
4616 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4622 #ifndef DEAL_II_WITH_MPI 4636 Assert (patches.size() > 0, ExcNoPatches());
4638 if (patches.size() == 0)
4642 VtkStream vtk_out(out, flags);
4644 const unsigned int n_data_sets = data_names.size();
4647 if (patches[0].points_are_available)
4659 out <<
"# vtk DataFile Version 3.0" 4661 <<
"#This file was generated by the deal.II library";
4673 out <<
"DATASET UNSTRUCTURED_GRID\n" 4682 n_metadata = ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0)
4684 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
4686 out <<
"FIELD FieldData " << n_metadata <<
"\n";
4688 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
4690 out <<
"CYCLE 1 1 int\n" 4691 << flags.
cycle <<
"\n";
4693 if (flags.
time != std::numeric_limits<double>::min())
4695 out <<
"TIME 1 1 double\n" 4696 << flags.
time <<
"\n";
4702 unsigned int n_nodes;
4703 unsigned int n_cells;
4704 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
4728 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
4730 = &write_gmv_reorder_data_vectors<dim,spacedim>;
4740 out <<
"POINTS " << n_nodes <<
" double" <<
'\n';
4741 write_nodes(patches, vtk_out);
4745 out <<
"CELLS " << n_cells <<
' ' 4748 write_cells(patches, vtk_out);
4753 out <<
"CELL_TYPES " << n_cells <<
'\n';
4754 for (
unsigned int i=0; i<n_cells; ++i)
4755 out <<
' ' << vtk_cell_type[dim];
4763 reorder_task.
join ();
4771 out <<
"POINT_DATA " << n_nodes
4778 std::vector<bool> data_set_written (n_data_sets,
false);
4779 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
4781 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
4782 std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
4783 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
4784 std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
4785 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
4786 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
4788 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
4789 - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
4790 ExcMessage (
"Can't declare a vector with more than 3 components " 4794 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4795 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
4797 data_set_written[i] =
true;
4806 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
4807 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
4810 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4811 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
4813 out << data_names[i] <<
"__";
4814 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
4823 for (
unsigned int n=0; n<n_nodes; ++n)
4825 switch (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) -
4826 std_cxx11::get<0>(vector_data_ranges[n_th_vector]))
4829 out << data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n) <<
" 0 0" 4834 out << data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n) <<
' '<< data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n) <<
" 0" 4838 out << data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n) <<
' '<< data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n) <<
' '<< data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+2, n)
4849 Assert (
false, ExcInternalError());
4855 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
4856 if (data_set_written[data_set] ==
false)
4859 << data_names[data_set]
4862 <<
"LOOKUP_TABLE default" 4864 std::copy (data_vectors[data_set].begin(),
4865 data_vectors[data_set].end(),
4866 std::ostream_iterator<double>(out,
" "));
4883 out <<
"<?xml version=\"1.0\" ?> \n";
4885 out <<
"# vtk DataFile Version 3.0" 4887 <<
"#This file was generated by the deal.II library";
4896 out <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
4897 #ifdef DEAL_II_WITH_ZLIB 4898 out <<
" compressor=\"vtkZLibDataCompressor\"";
4900 #ifdef DEAL_II_WORDS_BIGENDIAN 4901 out <<
" byte_order=\"BigEndian\"";
4903 out <<
" byte_order=\"LittleEndian\"";
4907 out <<
"<UnstructuredGrid>";
4916 out <<
" </UnstructuredGrid>\n";
4917 out <<
"</VTKFile>\n";
4922 template <
int dim,
int spacedim>
4925 const std::vector<std::string> &data_names,
4926 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4931 write_vtu_main (patches, data_names, vector_data_ranges, flags, out);
4938 template <
int dim,
int spacedim>
4940 const std::vector<std::string> &data_names,
4941 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
4947 #ifndef DEAL_II_WITH_MPI 4961 Assert (patches.size() > 0, ExcNoPatches());
4963 if (patches.size() == 0)
4968 out <<
"<Piece NumberOfPoints=\"0\" NumberOfCells=\"0\" >\n" 4970 <<
"<DataArray type=\"UInt8\" Name=\"types\"></DataArray>\n" 4972 <<
" <PointData Scalars=\"scalars\">\n";
4973 std::vector<bool> data_set_written (data_names.size(),
false);
4974 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
4978 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4979 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
4981 data_set_written[i] =
true;
4988 out <<
" <DataArray type=\"Float64\" Name=\"";
4990 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
4991 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
4994 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
4995 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
4997 out << data_names[i] <<
"__";
4998 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
5001 out <<
"\" NumberOfComponents=\"3\"></DataArray>\n";
5004 for (
unsigned int data_set=0; data_set<data_names.size(); ++data_set)
5005 if (data_set_written[data_set] ==
false)
5007 out <<
" <DataArray type=\"Float64\" Name=\"" 5008 << data_names[data_set]
5009 <<
"\"></DataArray>\n";
5012 out <<
" </PointData>\n";
5013 out <<
"</Piece>\n";
5028 n_metadata = ((flags.
cycle != std::numeric_limits<unsigned int>::min() ? 1 : 0)
5030 (flags.
time != std::numeric_limits<double>::min() ? 1 : 0));
5032 out <<
"<FieldData>\n";
5034 if (flags.
cycle != std::numeric_limits<unsigned int>::min())
5036 out <<
"<DataArray type=\"Float32\" Name=\"CYCLE\" NumberOfTuples=\"1\" format=\"ascii\">" 5038 <<
"</DataArray>\n";
5040 if (flags.
time != std::numeric_limits<double>::min())
5042 out <<
"<DataArray type=\"Float32\" Name=\"TIME\" NumberOfTuples=\"1\" format=\"ascii\">" 5044 <<
"</DataArray>\n";
5048 out <<
"</FieldData>\n";
5052 VtuStream vtu_out(out, flags);
5054 const unsigned int n_data_sets = data_names.size();
5059 if (patches[0].points_are_available)
5068 #ifdef DEAL_II_WITH_ZLIB
5069 const char *ascii_or_binary =
"binary";
5071 const char *ascii_or_binary =
"ascii";
5077 unsigned int n_nodes;
5078 unsigned int n_cells;
5079 compute_sizes<dim,spacedim>(patches, n_nodes, n_cells);
5103 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
5105 = &write_gmv_reorder_data_vectors<dim,spacedim>;
5117 out <<
"<Piece NumberOfPoints=\"" << n_nodes
5118 <<
"\" NumberOfCells=\"" << n_cells <<
"\" >\n";
5119 out <<
" <Points>\n";
5120 out <<
" <DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"" 5121 << ascii_or_binary <<
"\">\n";
5122 write_nodes(patches, vtu_out);
5123 out <<
" </DataArray>\n";
5124 out <<
" </Points>\n\n";
5127 out <<
" <Cells>\n";
5128 out <<
" <DataArray type=\"Int32\" Name=\"connectivity\" format=\"" 5129 << ascii_or_binary <<
"\">\n";
5130 write_cells(patches, vtu_out);
5131 out <<
" </DataArray>\n";
5137 out <<
" <DataArray type=\"Int32\" Name=\"offsets\" format=\"" 5138 << ascii_or_binary <<
"\">\n";
5140 std::vector<int32_t> offsets (n_cells);
5141 for (
unsigned int i=0; i<n_cells; ++i)
5145 out <<
" </DataArray>\n";
5150 out <<
" <DataArray type=\"UInt8\" Name=\"types\" format=\"" 5151 << ascii_or_binary <<
"\">\n";
5157 #ifdef DEAL_II_WITH_ZLIB 5158 std::vector<uint8_t> cell_types (n_cells,
5159 static_cast<uint8_t>(vtk_cell_type[dim]));
5161 std::vector<unsigned int> cell_types (n_cells,
5162 vtk_cell_type[dim]);
5165 vtu_out << cell_types;
5168 out <<
" </DataArray>\n";
5169 out <<
" </Cells>\n";
5178 reorder_task.
join ();
5186 out <<
" <PointData Scalars=\"scalars\">\n";
5192 std::vector<bool> data_set_written (n_data_sets,
false);
5193 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
5195 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
5196 std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
5197 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
5198 std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
5199 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
5200 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
5202 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
5203 - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
5204 ExcMessage (
"Can't declare a vector with more than 3 components " 5209 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5210 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5212 data_set_written[i] =
true;
5219 out <<
" <DataArray type=\"Float64\" Name=\"";
5221 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
5222 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
5225 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
5226 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
5228 out << data_names[i] <<
"__";
5229 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
5232 out <<
"\" NumberOfComponents=\"3\" format=\"" 5233 << ascii_or_binary <<
"\">\n";
5238 std::vector<double> data;
5239 data.reserve (n_nodes*dim);
5241 for (
unsigned int n=0; n<n_nodes; ++n)
5243 switch (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) -
5244 std_cxx11::get<0>(vector_data_ranges[n_th_vector]))
5247 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n));
5253 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n));
5254 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n));
5258 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector]), n));
5259 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1, n));
5260 data.push_back (data_vectors(std_cxx11::get<0>(vector_data_ranges[n_th_vector])+2, n));
5270 Assert (
false, ExcInternalError());
5274 out <<
" </DataArray>\n";
5278 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
5279 if (data_set_written[data_set] ==
false)
5281 out <<
" <DataArray type=\"Float64\" Name=\"" 5282 << data_names[data_set]
5284 << ascii_or_binary <<
"\">\n";
5286 std::vector<double> data (data_vectors[data_set].begin(),
5287 data_vectors[data_set].end());
5289 out <<
" </DataArray>\n";
5292 out <<
" </PointData>\n";
5295 out <<
" </Piece>\n";
5306 template <
int dim,
int spacedim>
5308 const std::vector<std::string> &,
5309 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
5313 Assert (
false, ExcNotImplemented());
5316 template <
int spacedim>
5318 const std::vector<std::string> &,
5319 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &,
5324 const unsigned int height = flags.
height;
5325 unsigned int width = flags.
width;
5328 unsigned int margin_in_percent = 0;
5329 if (flags.
margin) margin_in_percent = 5;
5333 double x_dimension, y_dimension, z_dimension;
5335 typename std::vector<Patch<dim,spacedim> >::const_iterator patch = patches.begin();
5337 unsigned int n_subdivisions = patch->n_subdivisions;
5338 unsigned int n = n_subdivisions + 1;
5339 const unsigned int d1 = 1;
5340 const unsigned int d2 = n;
5346 Point<2> projection_decompositions[4];
5348 compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
5351 patch->data.n_rows() == 0,
5352 ExcIndexRange (flags.
height_vector, 0, patch->data.n_rows()));
5354 double x_min = projected_point[0];
5355 double x_max = x_min;
5356 double y_min = projected_point[1];
5357 double y_max = y_min;
5358 double z_min = patch->data.n_rows() != 0 ? patch->data(flags.
height_vector,0) : 0;
5359 double z_max = z_min;
5362 for (; patch != patches.end(); ++patch)
5364 n_subdivisions = patch->n_subdivisions;
5365 n = n_subdivisions + 1;
5367 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5369 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5371 compute_node(projected_points[0], &*patch, i1, i2, 0, n_subdivisions);
5372 compute_node(projected_points[1], &*patch, i1+1, i2, 0, n_subdivisions);
5373 compute_node(projected_points[2], &*patch, i1, i2+1, 0, n_subdivisions);
5374 compute_node(projected_points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5376 x_min = std::min(x_min, (
double)projected_points[0][0]);
5377 x_min = std::min(x_min, (
double)projected_points[1][0]);
5378 x_min = std::min(x_min, (
double)projected_points[2][0]);
5379 x_min = std::min(x_min, (
double)projected_points[3][0]);
5381 x_max = std::max(x_max, (
double)projected_points[0][0]);
5382 x_max = std::max(x_max, (
double)projected_points[1][0]);
5383 x_max = std::max(x_max, (
double)projected_points[2][0]);
5384 x_max = std::max(x_max, (
double)projected_points[3][0]);
5386 y_min = std::min(y_min, (
double)projected_points[0][1]);
5387 y_min = std::min(y_min, (
double)projected_points[1][1]);
5388 y_min = std::min(y_min, (
double)projected_points[2][1]);
5389 y_min = std::min(y_min, (
double)projected_points[3][1]);
5391 y_max = std::max(y_max, (
double)projected_points[0][1]);
5392 y_max = std::max(y_max, (
double)projected_points[1][1]);
5393 y_max = std::max(y_max, (
double)projected_points[2][1]);
5394 y_max = std::max(y_max, (
double)projected_points[3][1]);
5397 patch->data.n_rows() == 0,
5398 ExcIndexRange (flags.
height_vector, 0, patch->data.n_rows()));
5400 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, i1*d1 + i2*d2));
5401 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + i2*d2));
5402 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, i1*d1 + (i2+1)*d2));
5403 z_min = std::min(z_min, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + (i2+1)*d2));
5405 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, i1*d1 + i2*d2));
5406 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + i2*d2));
5407 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, i1*d1 + (i2+1)*d2));
5408 z_max = std::max(z_max, (
double)patch->data(flags.
height_vector, (i1+1)*d1 + (i2+1)*d2));
5413 x_dimension = x_max - x_min;
5414 y_dimension = y_max - y_min;
5415 z_dimension = z_max - z_min;
5422 float camera_focus = 0;
5425 camera_position[0] = 0.;
5426 camera_position[1] = 0.;
5427 camera_position[2] = z_min + 2. * z_dimension;
5429 camera_direction[0] = 0.;
5430 camera_direction[1] = 0.;
5431 camera_direction[2] = - 1.;
5433 camera_horizontal[0] = 1.;
5434 camera_horizontal[1] = 0.;
5435 camera_horizontal[2] = 0.;
5437 camera_focus = .5 * z_dimension;
5443 const float angle_factor = 3.14159265f / 180.f;
5446 camera_position_temp[1] = cos(angle_factor * flags.polar_angle) * camera_position[1] - sin(angle_factor * flags.polar_angle) * camera_position[2];
5447 camera_position_temp[2] = sin(angle_factor * flags.polar_angle) * camera_position[1] + cos(angle_factor * flags.polar_angle) * camera_position[2];
5449 camera_direction_temp[1] = cos(angle_factor * flags.polar_angle) * camera_direction[1] - sin(angle_factor * flags.polar_angle) * camera_direction[2];
5450 camera_direction_temp[2] = sin(angle_factor * flags.polar_angle) * camera_direction[1] + cos(angle_factor * flags.polar_angle) * camera_direction[2];
5452 camera_horizontal_temp[1] = cos(angle_factor * flags.polar_angle) * camera_horizontal[1] - sin(angle_factor * flags.polar_angle) * camera_horizontal[2];
5453 camera_horizontal_temp[2] = sin(angle_factor * flags.polar_angle) * camera_horizontal[1] + cos(angle_factor * flags.polar_angle) * camera_horizontal[2];
5455 camera_position[1] = camera_position_temp[1];
5456 camera_position[2] = camera_position_temp[2];
5458 camera_direction[1] = camera_direction_temp[1];
5459 camera_direction[2] = camera_direction_temp[2];
5461 camera_horizontal[1] = camera_horizontal_temp[1];
5462 camera_horizontal[2] = camera_horizontal_temp[2];
5465 camera_position_temp[0] = cos(angle_factor * flags.
azimuth_angle) * camera_position[0] - sin(angle_factor * flags.
azimuth_angle) * camera_position[1];
5466 camera_position_temp[1] = sin(angle_factor * flags.
azimuth_angle) * camera_position[0] + cos(angle_factor * flags.
azimuth_angle) * camera_position[1];
5468 camera_direction_temp[0] = cos(angle_factor * flags.
azimuth_angle) * camera_direction[0] - sin(angle_factor * flags.
azimuth_angle) * camera_direction[1];
5469 camera_direction_temp[1] = sin(angle_factor * flags.
azimuth_angle) * camera_direction[0] + cos(angle_factor * flags.
azimuth_angle) * camera_direction[1];
5471 camera_horizontal_temp[0] = cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] - sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5472 camera_horizontal_temp[1] = sin(angle_factor * flags.
azimuth_angle) * camera_horizontal[0] + cos(angle_factor * flags.
azimuth_angle) * camera_horizontal[1];
5474 camera_position[0] = camera_position_temp[0];
5475 camera_position[1] = camera_position_temp[1];
5477 camera_direction[0] = camera_direction_temp[0];
5478 camera_direction[1] = camera_direction_temp[1];
5480 camera_horizontal[0] = camera_horizontal_temp[0];
5481 camera_horizontal[1] = camera_horizontal_temp[1];
5484 camera_position[0] = x_min + .5 * x_dimension;
5485 camera_position[1] = y_min + .5 * y_dimension;
5487 camera_position[0] += (z_min + 2. * z_dimension) * sin(angle_factor * flags.polar_angle) * sin(angle_factor * flags.
azimuth_angle);
5488 camera_position[1] -= (z_min + 2. * z_dimension) * sin(angle_factor * flags.polar_angle) * cos(angle_factor * flags.
azimuth_angle);
5492 double x_min_perspective, y_min_perspective;
5493 double x_max_perspective, y_max_perspective;
5494 double x_dimension_perspective, y_dimension_perspective;
5496 patch = patches.begin();
5498 n_subdivisions = patch->n_subdivisions;
5499 n = n_subdivisions + 1;
5503 compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
5506 patch->data.n_rows() == 0,
5507 ExcIndexRange (flags.
height_vector, 0, patch->data.n_rows()));
5509 point[0] = projected_point[0];
5510 point[1] = projected_point[1];
5511 point[2] = patch->data.n_rows() != 0 ? patch->data(flags.
height_vector, 0) : 0;
5513 projection_decomposition = svg_project_point(point, camera_position, camera_direction, camera_horizontal, camera_focus);
5515 x_min_perspective = projection_decomposition[0];
5516 x_max_perspective = projection_decomposition[0];
5517 y_min_perspective = projection_decomposition[1];
5518 y_max_perspective = projection_decomposition[1];
5521 for (; patch != patches.end(); ++patch)
5523 n_subdivisions = patch->n_subdivisions;
5524 n = n_subdivisions + 1;
5526 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5528 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5533 compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
5534 compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
5535 compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
5536 compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5539 patch->data.n_rows() == 0,
5540 ExcIndexRange (flags.
height_vector, 0, patch->data.n_rows()));
5542 vertices[0][0] = projected_vertices[0][0];
5543 vertices[0][1] = projected_vertices[0][1];
5544 vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
5546 vertices[1][0] = projected_vertices[1][0];
5547 vertices[1][1] = projected_vertices[1][1];
5548 vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
5550 vertices[2][0] = projected_vertices[2][0];
5551 vertices[2][1] = projected_vertices[2][1];
5552 vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
5554 vertices[3][0] = projected_vertices[3][0];
5555 vertices[3][1] = projected_vertices[3][1];
5556 vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
5558 projection_decompositions[0] = svg_project_point(vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
5559 projection_decompositions[1] = svg_project_point(vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
5560 projection_decompositions[2] = svg_project_point(vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
5561 projection_decompositions[3] = svg_project_point(vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
5563 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[0][0]);
5564 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[1][0]);
5565 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[2][0]);
5566 x_min_perspective = std::min(x_min_perspective, (
double)projection_decompositions[3][0]);
5568 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[0][0]);
5569 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[1][0]);
5570 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[2][0]);
5571 x_max_perspective = std::max(x_max_perspective, (
double)projection_decompositions[3][0]);
5573 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[0][1]);
5574 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[1][1]);
5575 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[2][1]);
5576 y_min_perspective = std::min(y_min_perspective, (
double)projection_decompositions[3][1]);
5578 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[0][1]);
5579 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[1][1]);
5580 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[2][1]);
5581 y_max_perspective = std::max(y_max_perspective, (
double)projection_decompositions[3][1]);
5586 x_dimension_perspective = x_max_perspective - x_min_perspective;
5587 y_dimension_perspective = y_max_perspective - y_min_perspective;
5589 std::multiset<SvgCell> cells;
5592 for (patch = patches.begin(); patch != patches.end(); ++patch)
5594 n_subdivisions = patch->n_subdivisions;
5595 n = n_subdivisions + 1;
5597 for (
unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
5599 for (
unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
5604 compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
5605 compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
5606 compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
5607 compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
5610 patch->data.n_rows() == 0,
5611 ExcIndexRange (flags.
height_vector, 0, patch->data.n_rows()));
5613 cell.vertices[0][0] = projected_vertices[0][0];
5614 cell.vertices[0][1] = projected_vertices[0][1];
5615 cell.vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
5617 cell.vertices[1][0] = projected_vertices[1][0];
5618 cell.vertices[1][1] = projected_vertices[1][1];
5619 cell.vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
5621 cell.vertices[2][0] = projected_vertices[2][0];
5622 cell.vertices[2][1] = projected_vertices[2][1];
5623 cell.vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
5625 cell.vertices[3][0] = projected_vertices[3][0];
5626 cell.vertices[3][1] = projected_vertices[3][1];
5627 cell.vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
5629 cell.projected_vertices[0] = svg_project_point(cell.vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
5630 cell.projected_vertices[1] = svg_project_point(cell.vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
5631 cell.projected_vertices[2] = svg_project_point(cell.vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
5632 cell.projected_vertices[3] = svg_project_point(cell.vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
5634 cell.center = .25 * (cell.vertices[0] + cell.vertices[1] + cell.vertices[2] + cell.vertices[3]);
5635 cell.projected_center = svg_project_point(cell.center, camera_position, camera_direction, camera_horizontal, camera_focus);
5637 cell.depth = cell.center.distance(camera_position);
5647 width =
static_cast<unsigned int>(.5 + height * (x_dimension_perspective / y_dimension_perspective));
5648 unsigned int additional_width = 0;
5650 if (flags.
draw_colorbar) additional_width =
static_cast<unsigned int>(.5 + height * .3);
5653 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\"" << height <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" <<
'\n' 5654 <<
" <rect width=\"" << width + additional_width <<
"\" height=\"" << height <<
"\" style=\"fill:white\"/>" <<
'\n' <<
'\n';
5656 unsigned int triangle_counter = 0;
5659 for (
typename std::multiset<SvgCell>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell)
5663 for (
unsigned int triangle_index = 0; triangle_index < 4; triangle_index++)
5665 switch (triangle_index)
5668 points3d_triangle[0] = cell->vertices[0], points3d_triangle[1] = cell->vertices[1], points3d_triangle[2] = cell->center;
5671 points3d_triangle[0] = cell->vertices[1], points3d_triangle[1] = cell->vertices[3], points3d_triangle[2] = cell->center;
5674 points3d_triangle[0] = cell->vertices[3], points3d_triangle[1] = cell->vertices[2], points3d_triangle[2] = cell->center;
5677 points3d_triangle[0] = cell->vertices[2], points3d_triangle[1] = cell->vertices[0], points3d_triangle[2] = cell->center;
5683 Point<6> gradient_param = svg_get_gradient_parameters(points3d_triangle);
5685 double start_h = .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
5686 double stop_h = .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
5688 unsigned int start_r = 0;
5689 unsigned int start_g = 0;
5690 unsigned int start_b = 0;
5692 unsigned int stop_r = 0;
5693 unsigned int stop_g = 0;
5694 unsigned int stop_b = 0;
5696 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
5697 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
5699 double start_f = start_h * 6. - start_i;
5700 double start_q = 1. - start_f;
5702 double stop_f = stop_h * 6. - stop_i;
5703 double stop_q = 1. - stop_f;
5705 switch (start_i % 6)
5708 start_r = 255, start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
5711 start_r =
static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
5714 start_g = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
5717 start_g =
static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
5720 start_r =
static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
5723 start_r = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
5732 stop_r = 255, stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
5735 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
5738 stop_g = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
5741 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
5744 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
5747 stop_r = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
5753 Point<3> gradient_start_point_3d, gradient_stop_point_3d;
5755 gradient_start_point_3d[0] = gradient_param[0];
5756 gradient_start_point_3d[1] = gradient_param[1];
5757 gradient_start_point_3d[2] = gradient_param[4];
5759 gradient_stop_point_3d[0] = gradient_param[2];
5760 gradient_stop_point_3d[1] = gradient_param[3];
5761 gradient_stop_point_3d[2] = gradient_param[5];
5763 Point<2> gradient_start_point = svg_project_point(gradient_start_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
5764 Point<2> gradient_stop_point = svg_project_point(gradient_stop_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
5767 out <<
" <linearGradient id=\"" << triangle_counter <<
"\" gradientUnits=\"userSpaceOnUse\" " 5769 <<
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))
5772 <<
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))
5775 <<
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))
5778 <<
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))
5781 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n' 5782 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n' 5783 <<
" </linearGradient>" <<
'\n';
5786 double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
5787 double x3 = cell->projected_center[0];
5788 double y3 = cell->projected_center[1];
5790 switch (triangle_index)
5793 x1 = cell->projected_vertices[0][0], y1 = cell->projected_vertices[0][1], x2 = cell->projected_vertices[1][0], y2 = cell->projected_vertices[1][1];
5796 x1 = cell->projected_vertices[1][0], y1 = cell->projected_vertices[1][1], x2 = cell->projected_vertices[3][0], y2 = cell->projected_vertices[3][1];
5799 x1 = cell->projected_vertices[3][0], y1 = cell->projected_vertices[3][1], x2 = cell->projected_vertices[2][0], y2 = cell->projected_vertices[2][1];
5802 x1 = cell->projected_vertices[2][0], y1 = cell->projected_vertices[2][1], x2 = cell->projected_vertices[0][0], y2 = cell->projected_vertices[0][1];
5808 out <<
" <path d=\"M " 5809 <<
static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
5811 <<
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))
5813 <<
static_cast<unsigned int>(.5 + ((x2 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
5815 <<
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))
5817 <<
static_cast<unsigned int>(.5 + ((x3 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
5819 <<
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))
5821 <<
static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
5823 <<
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))
5824 <<
"\" style=\"stroke:black; fill:url(#" << triangle_counter <<
"); stroke-width:" << flags.line_thickness <<
"\"/>" <<
'\n';
5834 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
5836 unsigned int element_height =
static_cast<unsigned int>(((height/100.) * (71. - 2.*margin_in_percent)) / 4);
5837 unsigned int element_width =
static_cast<unsigned int>(.5 + (height/100.) * 2.5);
5839 additional_width = 0;
5840 if (!flags.
margin) additional_width =
static_cast<unsigned int>(.5 + (height/100.) * 2.5);
5842 for (
unsigned int index = 0; index < 4; index++)
5844 double start_h = .667 - ((index+1) / 4.) * .667;
5845 double stop_h = .667 - (index / 4.) * .667;
5847 unsigned int start_r = 0;
5848 unsigned int start_g = 0;
5849 unsigned int start_b = 0;
5851 unsigned int stop_r = 0;
5852 unsigned int stop_g = 0;
5853 unsigned int stop_b = 0;
5855 unsigned int start_i =
static_cast<unsigned int>(start_h * 6.);
5856 unsigned int stop_i =
static_cast<unsigned int>(stop_h * 6.);
5858 double start_f = start_h * 6. - start_i;
5859 double start_q = 1. - start_f;
5861 double stop_f = stop_h * 6. - stop_i;
5862 double stop_q = 1. - stop_f;
5864 switch (start_i % 6)
5867 start_r = 255, start_g =
static_cast<unsigned int>(.5 + 255. * start_f);
5870 start_r =
static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
5873 start_g = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_f);
5876 start_g =
static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
5879 start_r =
static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
5882 start_r = 255, start_b =
static_cast<unsigned int>(.5 + 255. * start_q);
5891 stop_r = 255, stop_g =
static_cast<unsigned int>(.5 + 255. * stop_f);
5894 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
5897 stop_g = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_f);
5900 stop_g =
static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
5903 stop_r =
static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
5906 stop_r = 255, stop_b =
static_cast<unsigned int>(.5 + 255. * stop_q);
5913 out <<
" <linearGradient id=\"colorbar_" << index <<
"\" gradientUnits=\"userSpaceOnUse\" " 5914 <<
"x1=\"" << width + additional_width <<
"\" " 5915 <<
"y1=\"" <<
static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height <<
"\" " 5916 <<
"x2=\"" << width + additional_width <<
"\" " 5917 <<
"y2=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (4-index) * element_height <<
"\"" 5919 <<
" <stop offset=\"0\" style=\"stop-color:rgb(" << start_r <<
"," << start_g <<
"," << start_b <<
")\"/>" <<
'\n' 5920 <<
" <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r <<
"," << stop_g <<
"," << stop_b <<
")\"/>" <<
'\n' 5921 <<
" </linearGradient>" <<
'\n';
5925 <<
" x=\"" << width + additional_width
5926 <<
"\" y=\"" <<
static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height
5927 <<
"\" width=\"" << element_width
5928 <<
"\" height=\"" << element_height
5929 <<
"\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_" << index <<
")\"/>" <<
'\n';
5932 for (
unsigned int index = 0; index < 5; index++)
5934 out <<
" <text x=\"" << width + additional_width +
static_cast<unsigned int>(1.5 * element_width)
5935 <<
"\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29) + (4.-index) * element_height + 30.) <<
"\"" 5936 <<
" style=\"text-anchor:start; font-size:80; font-family:Helvetica";
5938 if (index == 0 || index == 4) out <<
"; font-weight:bold";
5940 out <<
"\">" << (float)(((
int)((z_min + index * (z_dimension / 4.))*10000))/10000.);
5942 if (index == 4) out <<
" max";
5943 if (index == 0) out <<
" min";
5945 out <<
"</text>" <<
'\n';
5950 out <<
'\n' <<
"</svg>";
5957 template <
int dim,
int spacedim>
5960 const std::vector<std::string> &data_names,
5961 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
5972 out << dim <<
' ' << spacedim <<
'\n';
5975 out <<
"[deal.II intermediate format graphics data]" <<
'\n' 5976 <<
"[written by " << DEAL_II_PACKAGE_NAME <<
" " << DEAL_II_PACKAGE_VERSION <<
"]" <<
'\n' 5979 out << data_names.size() <<
'\n';
5980 for (
unsigned int i=0; i<data_names.size(); ++i)
5981 out << data_names[i] <<
'\n';
5983 out << patches.size() <<
'\n';
5984 for (
unsigned int i=0; i<patches.size(); ++i)
5985 out << patches[i] <<
'\n';
5987 out << vector_data_ranges.size() <<
'\n';
5988 for (
unsigned int i=0; i<vector_data_ranges.size(); ++i)
5989 out << std_cxx11::get<0>(vector_data_ranges[i]) <<
' ' 5990 << std_cxx11::get<1>(vector_data_ranges[i]) <<
'\n' 5991 << std_cxx11::get<2>(vector_data_ranges[i]) <<
'\n';
6001 std::pair<unsigned int, unsigned int>
6006 unsigned int dim, spacedim;
6007 input >> dim >> spacedim;
6009 return std::make_pair (dim, spacedim);
6019 template <
int dim,
int spacedim>
6021 : default_subdivisions(1)
6025 template <
int dim,
int spacedim>
6032 template <
int dim,
int spacedim>
6042 template <
int dim,
int spacedim>
6052 template <
int dim,
int spacedim>
6062 template <
int dim,
int spacedim>
6072 template <
int dim,
int spacedim>
6082 template <
int dim,
int spacedim>
6092 template <
int dim,
int spacedim>
6102 template <
int dim,
int spacedim>
6112 template <
int dim,
int spacedim>
6120 template <
int dim,
int spacedim>
6128 template <
int dim,
int spacedim>
6136 template <
int dim,
int spacedim>
6139 #ifndef DEAL_II_WITH_MPI 6143 std::ofstream f(filename);
6147 int myrank, nproc, err;
6148 MPI_Comm_rank(comm, &myrank);
6149 MPI_Comm_size(comm, &nproc);
6152 MPI_Info_create(&info);
6154 err = MPI_File_open(comm, const_cast<char *>(filename),
6155 MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
6159 MPI_File_set_size(fh, 0);
6163 MPI_Info_free(&info);
6165 unsigned int header_size;
6170 std::stringstream ss;
6172 header_size = ss.str().size();
6173 MPI_File_write(fh, const_cast<char *>(ss.str().c_str()), header_size, MPI_CHAR, MPI_STATUS_IGNORE);
6176 MPI_Bcast(&header_size, 1, MPI_UNSIGNED, 0, comm);
6178 MPI_File_seek_shared( fh, header_size, MPI_SEEK_SET );
6180 std::stringstream ss;
6184 MPI_File_write_ordered(fh, const_cast<char *>(ss.str().c_str()), ss.str().size(), MPI_CHAR, MPI_STATUS_IGNORE);
6190 std::stringstream ss;
6192 unsigned int footer_size = ss.str().size();
6193 MPI_File_write_shared(fh, const_cast<char *>(ss.str().c_str()), footer_size, MPI_CHAR, MPI_STATUS_IGNORE);
6195 MPI_File_close( &fh );
6200 template <
int dim,
int spacedim>
6204 const std::vector<std::pair<double,std::string> > ×_and_names)
const 6208 out <<
"<?xml version=\"1.0\"?>\n";
6211 out <<
"#This file was generated by the deal.II library" 6216 out <<
"<VTKFile type=\"Collection\" version=\"0.1\" ByteOrder=\"LittleEndian\">\n";
6217 out <<
" <Collection>\n";
6219 for (
unsigned int i=0; i<times_and_names.size(); ++i)
6220 out <<
" <DataSet timestep=\"" << times_and_names[i].first
6221 <<
"\" group=\"\" part=\"0\" file=\"" << times_and_names[i].second
6224 out <<
" </Collection>\n";
6225 out <<
"</VTKFile>\n";
6233 template <
int dim,
int spacedim>
6236 const std::vector<std::string> &piece_names)
const 6241 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > vector_data_ranges
6244 const unsigned int n_data_sets = data_names.size();
6246 out <<
"<?xml version=\"1.0\"?>\n";
6249 out <<
"#This file was generated by the deal.II library" 6254 out <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">\n";
6255 out <<
" <PUnstructuredGrid GhostLevel=\"0\">\n";
6256 out <<
" <PPointData Scalars=\"scalars\">\n";
6260 std::vector<bool> data_set_written (n_data_sets,
false);
6261 for (
unsigned int n_th_vector=0; n_th_vector<vector_data_ranges.size(); ++n_th_vector)
6263 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >=
6264 std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
6265 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
6266 std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
6267 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
6268 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]),
6270 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) + 1
6271 - std_cxx11::get<0>(vector_data_ranges[n_th_vector]) <= 3,
6272 ExcMessage (
"Can't declare a vector with more than 3 components " 6277 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
6278 i<=std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
6280 data_set_written[i] =
true;
6287 out <<
" <PDataArray type=\"Float64\" Name=\"";
6289 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
6290 out << std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
6293 for (
unsigned int i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]);
6294 i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]);
6296 out << data_names[i] <<
"__";
6297 out << data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
6300 out <<
"\" NumberOfComponents=\"3\" format=\"ascii\"/>\n";
6303 for (
unsigned int data_set=0; data_set<n_data_sets; ++data_set)
6304 if (data_set_written[data_set] ==
false)
6306 out <<
" <PDataArray type=\"Float64\" Name=\"" 6307 << data_names[data_set]
6308 <<
"\" format=\"ascii\"/>\n";
6311 out <<
" </PPointData>\n";
6313 out <<
" <PPoints>\n";
6314 out <<
" <PDataArray type=\"Float64\" NumberOfComponents=\"3\"/>\n";
6315 out <<
" </PPoints>\n";
6317 for (
unsigned int i=0; i<piece_names.size(); ++i)
6318 out <<
" <Piece Source=\"" << piece_names[i] <<
"\"/>\n";
6320 out <<
" </PUnstructuredGrid>\n";
6321 out <<
"</VTKFile>\n";
6331 template <
int dim,
int spacedim>
6334 const std::vector<std::string> &piece_names)
const 6336 out <<
"!NBLOCKS " << piece_names.size() <<
'\n';
6337 for (
unsigned int i=0; i<piece_names.size(); ++i)
6338 out << piece_names[i] <<
'\n';
6345 template <
int dim,
int spacedim>
6348 const std::vector<std::vector<std::string> > &piece_names)
const 6352 if (piece_names.size() == 0)
6355 const double nblocks = piece_names[0].size();
6356 Assert(nblocks > 0,
ExcMessage(
"piece_names should be a vector of nonempty vectors.") )
6358 out <<
"!NBLOCKS " << nblocks <<
'\n';
6359 for (std::vector<std::vector<std::string> >::const_iterator domain = piece_names.begin(); domain != piece_names.end(); ++domain)
6361 Assert(domain->size() == nblocks,
ExcMessage(
"piece_names should be a vector of equal sized vectors.") )
6362 for (std::vector<std::string>::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain)
6363 out << *subdomain <<
'\n';
6371 template <
int dim,
int spacedim>
6381 template <
int dim,
int spacedim>
6384 const std::string &h5_filename,
const double cur_time, MPI_Comm comm)
const 6386 return create_xdmf_entry(data_filter, h5_filename, h5_filename, cur_time, comm);
6391 template <
int dim,
int spacedim>
6394 const std::string &h5_mesh_filename,
6395 const std::string &h5_solution_filename,
6396 const double cur_time,
6397 MPI_Comm comm)
const 6399 unsigned int local_node_cell_count[2], global_node_cell_count[2];
6402 #ifndef DEAL_II_WITH_HDF5 6407 (void)h5_mesh_filename;
6408 (void)h5_solution_filename;
6415 local_node_cell_count[0] = data_filter.
n_nodes();
6416 local_node_cell_count[1] = data_filter.
n_cells();
6419 #ifdef DEAL_II_WITH_MPI 6420 MPI_Comm_rank(comm, &myrank);
6421 MPI_Allreduce(local_node_cell_count, global_node_cell_count, 2, MPI_UNSIGNED, MPI_SUM, comm);
6424 global_node_cell_count[0] = local_node_cell_count[0];
6425 global_node_cell_count[1] = local_node_cell_count[1];
6431 XDMFEntry entry(h5_mesh_filename, h5_solution_filename, cur_time, global_node_cell_count[0], global_node_cell_count[1], dim);
6432 unsigned int n_data_sets = data_filter.
n_data_sets();
6436 for (i=0; i<n_data_sets; ++i)
6449 template <
int dim,
int spacedim>
6452 const std::string &filename,
6453 MPI_Comm comm)
const 6457 #ifdef DEAL_II_WITH_MPI 6458 MPI_Comm_rank(comm, &myrank);
6467 std::ofstream xdmf_file(filename.c_str());
6468 std::vector<XDMFEntry>::const_iterator it;
6470 xdmf_file <<
"<?xml version=\"1.0\" ?>\n";
6471 xdmf_file <<
"<!DOCTYPE Xdmf SYSTEM \"Xdmf.dtd\" []>\n";
6472 xdmf_file <<
"<Xdmf Version=\"2.0\">\n";
6473 xdmf_file <<
" <Domain>\n";
6474 xdmf_file <<
" <Grid Name=\"CellTime\" GridType=\"Collection\" CollectionType=\"Temporal\">\n";
6477 for (it=entries.begin(); it!=entries.end(); ++it)
6478 xdmf_file << it->get_xdmf_content(3);
6480 xdmf_file <<
" </Grid>\n";
6481 xdmf_file <<
" </Domain>\n";
6482 xdmf_file <<
"</Xdmf>\n";
6495 std::stringstream ss;
6496 std::map<std::string, unsigned int>::const_iterator it;
6498 if (!valid)
return "";
6500 ss << indent(indent_level+0) <<
"<Grid Name=\"mesh\" GridType=\"Uniform\">\n";
6501 ss << indent(indent_level+1) <<
"<Time Value=\"" << entry_time <<
"\"/>\n";
6502 ss << indent(indent_level+1) <<
"<Geometry GeometryType=\"" << (dimension == 2 ?
"XY" :
"XYZ" ) <<
"\">\n";
6503 ss << indent(indent_level+2) <<
"<DataItem Dimensions=\"" << num_nodes <<
" " << dimension <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
6504 ss << indent(indent_level+3) << h5_mesh_filename <<
":/nodes\n";
6505 ss << indent(indent_level+2) <<
"</DataItem>\n";
6506 ss << indent(indent_level+1) <<
"</Geometry>\n";
6510 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"" << (dimension == 2 ?
"Quadrilateral" :
"Hexahedron") <<
"\" NumberOfElements=\"" << num_cells <<
"\">\n";
6511 ss << indent(indent_level+2) <<
"<DataItem Dimensions=\"" << num_cells <<
" " << (2 << (dimension-1)) <<
"\" NumberType=\"UInt\" Format=\"HDF\">\n";
6512 ss << indent(indent_level+3) << h5_mesh_filename <<
":/cells\n";
6513 ss << indent(indent_level+2) <<
"</DataItem>\n";
6514 ss << indent(indent_level+1) <<
"</Topology>\n";
6519 ss << indent(indent_level+1) <<
"<Topology TopologyType=\"Polyvertex\" NumberOfElements=\"" << num_nodes <<
"\">\n";
6520 ss << indent(indent_level+1) <<
"</Topology>\n";
6523 for (it=attribute_dims.begin(); it!=attribute_dims.end(); ++it)
6525 ss << indent(indent_level+1) <<
"<Attribute Name=\"" << it->first <<
"\" AttributeType=\"" << (it->second > 1 ?
"Vector" :
"Scalar") <<
"\" Center=\"Node\">\n";
6527 ss << indent(indent_level+2) <<
"<DataItem Dimensions=\"" << num_nodes <<
" " << (it->second > 1 ? 3 : 1) <<
"\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
6528 ss << indent(indent_level+3) << h5_sol_filename <<
":/" << it->first <<
"\n";
6529 ss << indent(indent_level+2) <<
"</DataItem>\n";
6530 ss << indent(indent_level+1) <<
"</Attribute>\n";
6533 ss << indent(indent_level+0) <<
"</Grid>\n";
6542 template <
int dim,
int spacedim>
6551 template <
int dim,
int spacedim>
6553 const std::vector<std::string> &data_names,
6554 const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
6557 const unsigned int n_data_sets = data_names.size();
6558 unsigned int n_node, n_cell;
6562 #ifndef DEAL_II_WITH_MPI 6576 Assert (patches.size() > 0, ExcNoPatches());
6579 compute_sizes<dim,spacedim>(patches, n_node, n_cell);
6582 void (*fun_ptr) (
const std::vector<Patch<dim,spacedim> > &,
Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
6586 write_nodes(patches, filtered_data);
6587 write_cells(patches, filtered_data);
6590 reorder_task.join ();
6596 unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
6597 std::string vector_name;
6598 for (n_th_vector=0,data_set=0; data_set<n_data_sets;)
6601 while (n_th_vector < vector_data_ranges.size() && std_cxx11::get<0>(vector_data_ranges[n_th_vector]) < data_set) n_th_vector++;
6604 if (n_th_vector < vector_data_ranges.size() && std_cxx11::get<0>(vector_data_ranges[n_th_vector]) == data_set)
6607 pt_data_vector_dim = std_cxx11::get<1>(vector_data_ranges[n_th_vector]) - std_cxx11::get<0>(vector_data_ranges[n_th_vector])+1;
6610 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) >= std_cxx11::get<0>(vector_data_ranges[n_th_vector]),
6611 ExcLowerRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]), std_cxx11::get<0>(vector_data_ranges[n_th_vector])));
6612 AssertThrow (std_cxx11::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
6613 ExcIndexRange (std_cxx11::get<1>(vector_data_ranges[n_th_vector]), 0, n_data_sets));
6620 if (std_cxx11::get<2>(vector_data_ranges[n_th_vector]) !=
"")
6622 vector_name = std_cxx11::get<2>(vector_data_ranges[n_th_vector]);
6627 for (i=std_cxx11::get<0>(vector_data_ranges[n_th_vector]); i<std_cxx11::get<1>(vector_data_ranges[n_th_vector]); ++i)
6628 vector_name += data_names[i] +
"__";
6629 vector_name += data_names[std_cxx11::get<1>(vector_data_ranges[n_th_vector])];
6635 pt_data_vector_dim = 1;
6636 vector_name = data_names[data_set];
6640 filtered_data.
write_data_set(vector_name, pt_data_vector_dim, data_set, data_vectors);
6643 data_set += pt_data_vector_dim;
6649 template <
int dim,
int spacedim>
6652 const std::string &filename, MPI_Comm comm)
const 6659 template <
int dim,
int spacedim>
6662 const bool write_mesh_file,
const std::string &mesh_filename,
const std::string &solution_filename, MPI_Comm comm)
const 6669 template <
int dim,
int spacedim>
6672 const std::string &filename,
6680 template <
int dim,
int spacedim>
6683 const bool write_mesh_file,
6684 const std::string &mesh_filename,
6685 const std::string &solution_filename,
6688 #ifndef DEAL_II_WITH_HDF5 6693 (void)write_mesh_file;
6694 (void)mesh_filename;
6695 (void)solution_filename;
6699 #ifndef DEAL_II_WITH_MPI 6715 hid_t h5_mesh_file_id=-1, h5_solution_file_id, file_plist_id, plist_id;
6716 hid_t node_dataspace, node_dataset, node_file_dataspace, node_memory_dataspace;
6717 hid_t cell_dataspace, cell_dataset, cell_file_dataspace, cell_memory_dataspace;
6718 hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace, pt_data_memory_dataspace;
6720 unsigned int local_node_cell_count[2], global_node_cell_count[2], global_node_cell_offsets[2];
6721 hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
6722 std::vector<double> node_data_vec;
6723 std::vector<unsigned int> cell_data_vec;
6726 #ifndef H5_HAVE_PARALLEL 6727 # ifdef DEAL_II_WITH_MPI 6729 MPI_Comm_size(comm, &world_size);
6731 ExcMessage (
"Serial HDF5 output on multiple processes is not yet supported."));
6735 local_node_cell_count[0] = data_filter.
n_nodes();
6736 local_node_cell_count[1] = data_filter.
n_cells();
6739 file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
6742 #ifdef DEAL_II_WITH_MPI 6743 #ifdef H5_HAVE_PARALLEL 6745 status = H5Pset_fapl_mpio(file_plist_id, comm, MPI_INFO_NULL);
6752 #ifdef DEAL_II_WITH_MPI 6753 MPI_Allreduce(local_node_cell_count, global_node_cell_count, 2, MPI_UNSIGNED, MPI_SUM, comm);
6754 MPI_Scan(local_node_cell_count, global_node_cell_offsets, 2, MPI_UNSIGNED, MPI_SUM, comm);
6755 global_node_cell_offsets[0] -= local_node_cell_count[0];
6756 global_node_cell_offsets[1] -= local_node_cell_count[1];
6758 global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
6762 plist_id = H5Pcreate(H5P_DATASET_XFER);
6764 #ifdef DEAL_II_WITH_MPI 6765 #ifdef H5_HAVE_PARALLEL 6766 status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
6771 if (write_mesh_file)
6774 h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
6778 node_ds_dim[0] = global_node_cell_count[0];
6779 node_ds_dim[1] = dim;
6780 node_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
6783 cell_ds_dim[0] = global_node_cell_count[1];
6785 cell_dataspace = H5Screate_simple(2, cell_ds_dim, NULL);
6789 #if H5Gcreate_vers == 1 6790 node_dataset = H5Dcreate(h5_mesh_file_id,
"nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT);
6792 node_dataset = H5Dcreate(h5_mesh_file_id,
"nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
6795 #if H5Gcreate_vers == 1 6796 cell_dataset = H5Dcreate(h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
6798 cell_dataset = H5Dcreate(h5_mesh_file_id,
"cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
6803 status = H5Sclose(node_dataspace);
6805 status = H5Sclose(cell_dataspace);
6809 count[0] = local_node_cell_count[0];
6811 offset[0] = global_node_cell_offsets[0];
6813 node_memory_dataspace = H5Screate_simple(2, count, NULL);
6817 node_file_dataspace = H5Dget_space(node_dataset);
6819 status = H5Sselect_hyperslab(node_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
6823 count[0] = local_node_cell_count[1];
6825 offset[0] = global_node_cell_offsets[1];
6827 cell_memory_dataspace = H5Screate_simple(2, count, NULL);
6830 cell_file_dataspace = H5Dget_space(cell_dataset);
6832 status = H5Sselect_hyperslab(cell_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
6837 status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, &node_data_vec[0]);
6839 node_data_vec.clear();
6842 data_filter.
fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
6843 status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, &cell_data_vec[0]);
6845 cell_data_vec.clear();
6848 status = H5Sclose(node_file_dataspace);
6850 status = H5Sclose(cell_file_dataspace);
6854 status = H5Sclose(node_memory_dataspace);
6856 status = H5Sclose(cell_memory_dataspace);
6860 status = H5Dclose(node_dataset);
6862 status = H5Dclose(cell_dataset);
6866 if (mesh_filename != solution_filename)
6868 status = H5Fclose(h5_mesh_file_id);
6874 if (mesh_filename == solution_filename && write_mesh_file)
6876 h5_solution_file_id = h5_mesh_file_id;
6881 h5_solution_file_id = H5Fcreate(solution_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
6889 unsigned int i, pt_data_vector_dim;
6890 std::string vector_name;
6899 node_ds_dim[0] = global_node_cell_count[0];
6900 node_ds_dim[1] = pt_data_vector_dim;
6901 pt_data_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
6904 #if H5Gcreate_vers == 1 6905 pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT);
6907 pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
6912 count[0] = local_node_cell_count[0];
6913 count[1] = pt_data_vector_dim;
6914 offset[0] = global_node_cell_offsets[0];
6916 pt_data_memory_dataspace = H5Screate_simple(2, count, NULL);
6917 AssertThrow(pt_data_memory_dataspace >= 0, ExcIO());
6920 pt_data_file_dataspace = H5Dget_space(pt_data_dataset);
6921 AssertThrow(pt_data_file_dataspace >= 0, ExcIO());
6922 status = H5Sselect_hyperslab(pt_data_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
6926 status = H5Dwrite(pt_data_dataset, H5T_NATIVE_DOUBLE, pt_data_memory_dataspace, pt_data_file_dataspace, plist_id, data_filter.
get_data_set(i));
6930 status = H5Sclose(pt_data_dataspace);
6932 status = H5Sclose(pt_data_memory_dataspace);
6934 status = H5Sclose(pt_data_file_dataspace);
6937 status = H5Dclose(pt_data_dataset);
6942 status = H5Pclose(file_plist_id);
6946 status = H5Pclose(plist_id);
6950 status = H5Fclose(h5_solution_file_id);
6958 template <
int dim,
int spacedim>
6967 switch (output_format)
7021 Assert (
false, ExcNotImplemented());
7027 template <
int dim,
int spacedim>
7035 template <
int dim,
int spacedim>
7036 template <
typename FlagType>
7042 if (
typeid(flags) ==
typeid(
dx_flags))
7044 else if (
typeid(flags) ==
typeid(
ucd_flags))
7048 else if (
typeid(flags) ==
typeid(
eps_flags))
7050 else if (
typeid(flags) ==
typeid(
gmv_flags))
7054 else if (
typeid(flags) ==
typeid(
vtk_flags))
7056 else if (
typeid(flags) ==
typeid(
svg_flags))
7061 Assert(
false, ExcNotImplemented());
7066 template <
int dim,
int spacedim>
7079 template <
int dim,
int spacedim>
7085 "A name for the output format to be used");
7087 "Number of subdivisions of each mesh cell");
7129 template <
int dim,
int spacedim>
7133 const std::string &output_name = prm.
get (
"Output format");
7176 template <
int dim,
int spacedim>
7195 template <
int dim,
int spacedim>
7196 std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
7199 return std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >();
7207 template <
int dim,
int spacedim>
7215 std::vector<typename ::DataOutBase::Patch<dim,spacedim> >
7220 std::vector<std::string> tmp;
7221 tmp.swap (dataset_names);
7224 std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> > tmp;
7225 tmp.swap (vector_data_ranges);
7237 std::pair<unsigned int, unsigned int>
7241 (dimension_info.second == spacedim),
7242 ExcIncompatibleDimensions (dimension_info.first, dim,
7243 dimension_info.second, spacedim));
7252 getline (in, header);
7254 std::ostringstream s;
7255 s <<
"[deal.II intermediate format graphics data]";
7257 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7261 getline (in, header);
7263 std::ostringstream s;
7264 s <<
"[written by " << DEAL_II_PACKAGE_NAME <<
" " << DEAL_II_PACKAGE_VERSION <<
"]";
7266 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7270 getline (in, header);
7272 std::ostringstream s;
7275 Assert (header == s.str(),
7276 ExcMessage(
"Invalid or incompatible file format. Intermediate format " 7277 "files can only be read by the same deal.II version as they " 7278 "are written by."));
7282 unsigned int n_datasets;
7284 dataset_names.resize (n_datasets);
7285 for (
unsigned int i=0; i<n_datasets; ++i)
7286 in >> dataset_names[i];
7288 unsigned int n_patches;
7290 patches.resize (n_patches);
7291 for (
unsigned int i=0; i<n_patches; ++i)
7294 unsigned int n_vector_data_ranges;
7295 in >> n_vector_data_ranges;
7296 vector_data_ranges.resize (n_vector_data_ranges);
7297 for (
unsigned int i=0; i<n_vector_data_ranges; ++i)
7299 in >> std_cxx11::get<0>(vector_data_ranges[i])
7300 >> std_cxx11::get<1>(vector_data_ranges[i]);
7313 std_cxx11::get<2>(vector_data_ranges[i]) = name;
7321 template <
int dim,
int spacedim>
7326 typedef typename ::DataOutBase::Patch<dim,spacedim> Patch;
7329 const std::vector<Patch> source_patches = source.
get_patches ();
7330 Assert (patches.size () != 0, ExcNoPatches ());
7331 Assert (source_patches.size () != 0, ExcNoPatches ());
7335 ExcIncompatibleDatasetNames());
7341 ExcMessage (
"Both sources need to declare the same components " 7347 ExcMessage (
"Both sources need to declare the same components " 7351 ExcMessage (
"Both sources need to declare the same components " 7355 ExcMessage (
"Both sources need to declare the same components " 7360 Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
7361 ExcIncompatiblePatchLists());
7362 Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
7363 ExcIncompatiblePatchLists());
7364 Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
7365 ExcIncompatiblePatchLists());
7371 const unsigned int old_n_patches = patches.size();
7372 patches.insert (patches.end(),
7373 source_patches.begin(),
7374 source_patches.end());
7377 for (
unsigned int i=old_n_patches; i<patches.size(); ++i)
7378 patches[i].patch_index += old_n_patches;
7381 for (
unsigned int i=old_n_patches; i<patches.size(); ++i)
7382 for (
unsigned int n=0; n<GeometryInfo<dim>::faces_per_cell; ++n)
7384 patches[i].neighbors[n] += old_n_patches;
7389 template <
int dim,
int spacedim>
7390 const std::vector<typename ::DataOutBase::Patch<dim,spacedim> > &
7398 template <
int dim,
int spacedim>
7399 std::vector<std::string>
7402 return dataset_names;
7407 template <
int dim,
int spacedim>
7408 std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
7411 return vector_data_ranges;
7418 template <
int dim,
int spacedim>
7424 out <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]" 7429 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
7433 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
7442 out << patch.
data.n_rows() <<
' ' << patch.
data.n_cols() <<
'\n';
7443 for (
unsigned int i=0; i<patch.
data.n_rows(); ++i)
7444 for (
unsigned int j=0; j<patch.
data.n_cols(); ++j)
7445 out << patch.
data[i][j] <<
' ';
7453 template <
int dim,
int spacedim>
7455 operator >> (std::istream &in,
7468 getline (in, header);
7469 while ((header.size() != 0) &&
7470 (header[header.size()-1] ==
' '))
7471 header.erase(header.size()-1);
7473 while ((header ==
"") && in);
7475 std::ostringstream s;
7476 s <<
"[deal.II intermediate Patch<" << dim <<
',' << spacedim <<
">]";
7478 Assert (header == s.str(), ExcUnexpectedInput(s.str(),header));
7484 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
7487 for (
unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
7494 unsigned int n_rows, n_cols;
7495 in >> n_rows >> n_cols;
7497 for (
unsigned int i=0; i<patch.
data.n_rows(); ++i)
7498 for (
unsigned int j=0; j<patch.
data.n_cols(); ++j)
7499 in >> patch.
data[i][j];
7510 #include "data_out_base.inst" 7512 DEAL_II_NAMESPACE_CLOSE
void write_gmv(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const GmvFlags &flags, std::ostream &out)
virtual std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
static void declare_parameters(ParameterHandler &prm)
long int get_integer(const std::string &entry_string) const
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static const unsigned int invalid_unsigned_int
unsigned int height_vector
void write_vtu_footer(std::ostream &out)
virtual std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
static void declare_parameters(ParameterHandler &prm)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertDimension(dim1, dim2)
void parse_parameters(const ParameterHandler &prm)
void write_ucd(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const UcdFlags &flags, std::ostream &out)
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm) const
void write_tecplot_binary(std::ostream &out) const
void set_flags(const FlagType &flags)
virtual std::vector< std::string > get_dataset_names() const =0
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names) const
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
void write_cell(unsigned int index, unsigned int start, unsigned int d1, unsigned int d2, unsigned int d3)
::ExceptionBase & ExcMessage(std::string arg1)
void parse_parameters(const ParameterHandler &prm)
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
#define AssertThrow(cond, exc)
VtkFlags(const double time=std::numeric_limits< double >::min(), const unsigned int cycle=std::numeric_limits< unsigned int >::min(), const bool print_date_and_time=true, const ZlibCompressionLevel compression_level=best_compression)
void write_vtk(std::ostream &out) const
void write_filtered_data(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, DataOutFilter &filtered_data)
unsigned int default_subdivisions
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
std::string get_xdmf_content(const unsigned int indent_level) const
bool filter_duplicate_vertices
static void declare_parameters(ParameterHandler &prm)
virtual const std::vector< DataOutBase::Patch< dim, spacedim > > & get_patches() const =0
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void parse_parameters(ParameterHandler &prm)
void write_ucd(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
const char * tecplot_binary_file_name
void enter_subsection(const std::string &subsection)
std::string get_data_set_name(const unsigned int &set_num) const
DataOutBase::PovrayFlags povray_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 RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
double get_double(const std::string &entry_name) const
unsigned int n_cells() const
void add_attribute(const std::string &attr_name, const unsigned int dimension)
void write_tecplot(std::ostream &out) const
void reinit(const TableIndices< N > &new_size, const bool omit_default_initialization=false)
void write_povray(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const PovrayFlags &flags, std::ostream &out)
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const EpsFlags &flags, std::ostream &out)
#define Assert(cond, exc)
DXFlags(const bool write_neighbors=false, const bool int_binary=false, const bool coordinates_binary=false, const bool data_binary=false)
void parse_parameters(const ParameterHandler &prm)
DataOutBase::Deal_II_IntermediateFlags deal_II_intermediate_flags
void read(std::istream &in)
void internal_add_cell(const unsigned int &cell_index, const unsigned int &pt_index)
::ExceptionBase & ExcLowerRange(int arg1, int arg2)." )
OutputFormat parse_output_format(const std::string &format_name)
void write_svg(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const SvgFlags &flags, std::ostream &out)
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, MPI_Comm comm) const
void write_dx(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const DXFlags &flags, std::ostream &out)
ColorFunction color_function
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
void write_svg(std::ostream &out) const
unsigned int n_subdivisions
DataOutBase::TecplotFlags tecplot_flags
bool get_bool(const std::string &entry_name) const
void parse_parameters(const ParameterHandler &prm)
DataOutBase::SvgFlags svg_flags
void fill_cell_data(const unsigned int &local_node_offset, std::vector< unsigned int > &cell_data) const
virtual ~DataOutInterface()
void parse_parameters(const ParameterHandler &prm)
const double * get_data_set(const unsigned int &set_num) const
TecplotFlags(const char *tecplot_binary_file_name=NULL, const char *zone_name=NULL, const double solution_time=-1.0)
void fill_node_data(std::vector< double > &node_data) const
unsigned int get_data_set_dim(const unsigned int &set_num) const
static void declare_parameters(ParameterHandler &prm)
void write_vtk(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
static void declare_parameters(ParameterHandler &prm)
void write_eps(std::ostream &out) const
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_deal_II_intermediate(std::ostream &out) const
std_cxx11::enable_if< std_cxx11::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
static void declare_parameters(ParameterHandler &prm)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string > > ×_and_names) const
DataOutBase::GmvFlags gmv_flags
void write_point(const unsigned int &index, const Point< dim > &p)
DataOutBase::VtkFlags vtk_flags
std::size_t memory_consumption() const
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_tecplot_binary(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const TecplotFlags &flags, std::ostream &out)
void write_povray(std::ostream &out) const
DataOutBase::GnuplotFlags gnuplot_flags
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 write_tecplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const TecplotFlags &flags, std::ostream &out)
unsigned int color_vector
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const VtkFlags &flags, std::ostream &out)
DataOutBase::OutputFormat default_fmt
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 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
DataOutBase::EpsFlags eps_flags
unsigned int size(const unsigned int i) const
void write_dx(std::ostream &out) const
void write_deal_II_intermediate(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std_cxx11::tuple< unsigned int, unsigned int, std::string > > &vector_data_ranges, const GnuplotFlags &flags, std::ostream &out)
virtual std::vector< std::string > get_dataset_names() const
bool points_are_available
void write_gnuplot(std::ostream &out) const
void write_data_set(const std::string &name, const unsigned int &dimension, const unsigned int &set_num, const Table< 2, double > &data_vectors)
void write_vtu(std::ostream &out) const
void parse_parameters(const ParameterHandler &prm)
StreamType & operator<<(StreamType &s, UpdateFlags u)
std::string get_output_format_names()
DataOutBase::UcdFlags ucd_flags
unsigned int height_vector
Task< RT > new_task(const std_cxx11::function< RT()> &function)
DataOutBase::DXFlags dx_flags
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, MPI_Comm comm) const