From: Wolfgang Bangerth Date: Mon, 1 Nov 2021 22:48:42 +0000 (-0600) Subject: Implement gnuplot output for tetrahedra. X-Git-Tag: v9.4.0-rc1~862^2~7 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5e312b94b36d9092bb30d6f0e5f4364f5fe6068;p=dealii.git Implement gnuplot output for tetrahedra. --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 6a44dd6db0..92b530f1a2 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -3873,101 +3873,150 @@ namespace DataOutBase case 3: { - Assert(patch.reference_cell == ReferenceCells::Hexahedron, - ExcNotImplemented()); - Assert(patch.data.n_cols() == - Utilities::fixed_power(n_points_per_direction), - ExcInvalidDatasetSize(patch.data.n_cols(), - n_subdivisions + 1)); + if (patch.reference_cell == ReferenceCells::Hexahedron) + { + Assert(patch.data.n_cols() == Utilities::fixed_power( + n_points_per_direction), + ExcInvalidDatasetSize(patch.data.n_cols(), + n_subdivisions + 1)); - // for all grid points: draw lines into all positive coordinate - // directions if there is another grid point there - for (unsigned int i3 = 0; i3 < n_points_per_direction; ++i3) - for (unsigned int i2 = 0; i2 < n_points_per_direction; ++i2) - for (unsigned int i1 = 0; i1 < n_points_per_direction; ++i1) - { - // compute coordinates for this patch point - const Point this_point = - get_equispaced_location(patch, - {i1, i2, i3}, - n_subdivisions); - // line into positive x-direction if possible - if (i1 < n_subdivisions) + // for all grid points: draw lines into all positive + // coordinate directions if there is another grid point + // there + for (unsigned int i3 = 0; i3 < n_points_per_direction; ++i3) + for (unsigned int i2 = 0; i2 < n_points_per_direction; + ++i2) + for (unsigned int i1 = 0; i1 < n_points_per_direction; + ++i1) { - // write point here and its data - out << this_point << ' '; - output_point_data(i1 + i2 * n_points_per_direction + - i3 * n_points_per_direction * - n_points_per_direction); - out << '\n'; - - // write point there and its data - out << get_equispaced_location(patch, - {i1 + 1, i2, i3}, - n_subdivisions) - << ' '; - - output_point_data((i1 + 1) + - i2 * n_points_per_direction + - i3 * n_points_per_direction * - n_points_per_direction); - out << '\n'; - - // end of line - out << '\n' << '\n'; + // compute coordinates for this patch point + const Point this_point = + get_equispaced_location(patch, + {i1, i2, i3}, + n_subdivisions); + // line into positive x-direction if possible + if (i1 < n_subdivisions) + { + // write point here and its data + out << this_point << ' '; + output_point_data(i1 + + i2 * n_points_per_direction + + i3 * n_points_per_direction * + n_points_per_direction); + out << '\n'; + + // write point there and its data + out << get_equispaced_location(patch, + {i1 + 1, i2, i3}, + n_subdivisions) + << ' '; + + output_point_data((i1 + 1) + + i2 * n_points_per_direction + + i3 * n_points_per_direction * + n_points_per_direction); + out << '\n'; + + // end of line + out << '\n' << '\n'; + } + + // line into positive y-direction if possible + if (i2 < n_subdivisions) + { + // write point here and its data + out << this_point << ' '; + output_point_data(i1 + + i2 * n_points_per_direction + + i3 * n_points_per_direction * + n_points_per_direction); + out << '\n'; + + // write point there and its data + out << get_equispaced_location(patch, + {i1, i2 + 1, i3}, + n_subdivisions) + << ' '; + + output_point_data( + i1 + (i2 + 1) * n_points_per_direction + + i3 * n_points_per_direction * + n_points_per_direction); + out << '\n'; + + // end of line + out << '\n' << '\n'; + } + + // line into positive z-direction if possible + if (i3 < n_subdivisions) + { + // write point here and its data + out << this_point << ' '; + output_point_data(i1 + + i2 * n_points_per_direction + + i3 * n_points_per_direction * + n_points_per_direction); + out << '\n'; + + // write point there and its data + out << get_equispaced_location(patch, + {i1, i2, i3 + 1}, + n_subdivisions) + << ' '; + + output_point_data( + i1 + i2 * n_points_per_direction + + (i3 + 1) * n_points_per_direction * + n_points_per_direction); + out << '\n'; + // end of line + out << '\n' << '\n'; + } } + } + else if (patch.reference_cell == ReferenceCells::Tetrahedron) + { + Assert(n_subdivisions == 1, ExcNotImplemented()); - // line into positive y-direction if possible - if (i2 < n_subdivisions) - { - // write point here and its data - out << this_point << ' '; - output_point_data(i1 + i2 * n_points_per_direction + - i3 * n_points_per_direction * - n_points_per_direction); - out << '\n'; + // Draw the tetrahedron as a two collections of lines. + out << get_node_location(patch, 0) << ' '; + output_point_data(0); + out << '\n'; - // write point there and its data - out << get_equispaced_location(patch, - {i1, i2 + 1, i3}, - n_subdivisions) - << ' '; + out << get_node_location(patch, 1) << ' '; + output_point_data(1); + out << '\n'; - output_point_data( - i1 + (i2 + 1) * n_points_per_direction + - i3 * n_points_per_direction * - n_points_per_direction); - out << '\n'; + out << get_node_location(patch, 2) << ' '; + output_point_data(2); + out << '\n'; - // end of line - out << '\n' << '\n'; - } + out << get_node_location(patch, 0) << ' '; + output_point_data(0); + out << '\n'; - // line into positive z-direction if possible - if (i3 < n_subdivisions) - { - // write point here and its data - out << this_point << ' '; - output_point_data(i1 + i2 * n_points_per_direction + - i3 * n_points_per_direction * - n_points_per_direction); - out << '\n'; + out << get_node_location(patch, 3) << ' '; + output_point_data(3); + out << '\n'; - // write point there and its data - out << get_equispaced_location(patch, - {i1, i2, i3 + 1}, - n_subdivisions) - << ' '; + out << get_node_location(patch, 2) << ' '; + output_point_data(2); + out << '\n'; + out << '\n'; // end of first line - output_point_data(i1 + i2 * n_points_per_direction + - (i3 + 1) * - n_points_per_direction * - n_points_per_direction); - out << '\n'; - // end of line - out << '\n' << '\n'; - } - } + out << get_node_location(patch, 3) << ' '; + output_point_data(3); + out << '\n'; + + out << get_node_location(patch, 1) << ' '; + output_point_data(1); + out << '\n'; + out << '\n'; // end of second line + } + else + // No other reference cells are currently implemented + Assert(false, ExcNotImplemented()); break; }