From: Wolfgang Bangerth Date: Fri, 30 Dec 2022 19:59:09 +0000 (-0700) Subject: Inline the write_high_order_cells() function into write_vtu_main(). X-Git-Tag: v9.5.0-rc1~690^2~10 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4384f2bde54635e0c79199403716e2446d84fb1;p=dealii.git Inline the write_high_order_cells() function into write_vtu_main(). --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 416856087b..236fbd85c7 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -5941,9 +5941,121 @@ namespace DataOutBase { VtuStream vtu_out(oo, flags); - write_high_order_cells(patches, - vtu_out, - /* legacy_format = */ false); + Assert(dim <= 3 && dim > 1, ExcNotImplemented()); + unsigned int first_vertex_of_patch = 0; + // Array to hold all the node numbers of a cell + std::vector connectivity; + + for (const auto &patch : patches) + { + if (patch.reference_cell != + ReferenceCells::get_hypercube()) + { + connectivity.resize(patch.data.n_cols()); + + for (unsigned int i = 0; i < patch.data.n_cols(); ++i) + connectivity[i] = i; + + vtu_out.template write_high_order_cell( + first_vertex_of_patch, connectivity); + + first_vertex_of_patch += patch.data.n_cols(); + } + else + { + const unsigned int n_subdivisions = patch.n_subdivisions; + const unsigned int n = n_subdivisions + 1; + + connectivity.resize(Utilities::fixed_power(n)); + + switch (dim) + { + case 0: + { + Assert(false, + ExcMessage( + "Point-like cells should not be possible " + "when writing higher-order cells.")); + break; + } + case 1: + { + for (unsigned int i1 = 0; i1 < n_subdivisions + 1; + ++i1) + { + const unsigned int local_index = i1; + const unsigned int connectivity_index = + patch.reference_cell + .template vtk_lexicographic_to_node_index< + 1>({{i1}}, + {{n_subdivisions}}, + /* use VTU, not VTK: */ false); + connectivity[connectivity_index] = local_index; + } + + break; + } + case 2: + { + for (unsigned int i2 = 0; i2 < n_subdivisions + 1; + ++i2) + for (unsigned int i1 = 0; i1 < n_subdivisions + 1; + ++i1) + { + const unsigned int local_index = i2 * n + i1; + const unsigned int connectivity_index = + patch.reference_cell + .template vtk_lexicographic_to_node_index< + 2>({{i1, i2}}, + {{n_subdivisions, n_subdivisions}}, + /* use VTU, not VTK: */ false); + connectivity[connectivity_index] = + local_index; + } + + break; + } + case 3: + { + for (unsigned int i3 = 0; i3 < n_subdivisions + 1; + ++i3) + for (unsigned int i2 = 0; i2 < n_subdivisions + 1; + ++i2) + for (unsigned int i1 = 0; + i1 < n_subdivisions + 1; + ++i1) + { + const unsigned int local_index = + i3 * n * n + i2 * n + i1; + const unsigned int connectivity_index = + patch.reference_cell + .template vtk_lexicographic_to_node_index< + 3>({{i1, i2, i3}}, + {{n_subdivisions, + n_subdivisions, + n_subdivisions}}, + /* use VTU, not VTK: */ false); + connectivity[connectivity_index] = + local_index; + } + + break; + } + default: + Assert(false, ExcNotImplemented()); + } + + // Having so set up the 'connectivity' data structure, + // output it: + vtu_out.template write_high_order_cell( + first_vertex_of_patch, connectivity); + + // Finally update the number of the first vertex of this + // patch + first_vertex_of_patch += Utilities::fixed_power(n); + } + } + vtu_out.flush_cells(); } o << oo.str() << '\n';