From: Wolfgang Bangerth Date: Mon, 1 Nov 2021 21:23:41 +0000 (-0600) Subject: Avoid code duplication. X-Git-Tag: v9.4.0-rc1~869^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=052ab5dfbd876fe6d2d076c5c13231816434f957;p=dealii.git Avoid code duplication. --- diff --git a/tests/mpi/data_out_hdf5_02.cc b/tests/mpi/data_out_hdf5_02.cc index 5586a4be17..a0e0635871 100644 --- a/tests/mpi/data_out_hdf5_02.cc +++ b/tests/mpi/data_out_hdf5_02.cc @@ -22,76 +22,13 @@ #include "../tests.h" +#include "../data_out/patches.h" + double cell_coordinates[3][8] = {{0, 1, 0, 1, 0, 1, 0, 1}, {0, 0, 1, 1, 0, 0, 1, 1}, {0, 0, 0, 0, 1, 1, 1, 1}}; -// This function is a copy from tests/data_out/patches.h, included here -// to not introduce dependencies between different test targets -template -void -create_patches(std::vector> &patches) -{ - for (unsigned int p = 0; p < patches.size(); ++p) - { - DataOutBase::Patch &patch = patches[p]; - - const unsigned int nsub = p + 1; - const unsigned int nsubp = nsub + 1; - -#ifdef DEAL_II_HAVE_CXX17 - if constexpr (dim > 0) - patch.n_subdivisions = nsub; -#else - if (dim > 0) - const_cast(patch.n_subdivisions) = nsub; -#endif - -#ifdef DEAL_II_HAVE_CXX17 - if constexpr (dim > 0) - patch.reference_cell = ReferenceCells::get_hypercube(); -#else - if (dim > 0) - const_cast(patch.reference_cell) = - ReferenceCells::get_hypercube(); -#endif - - for (const unsigned int v : GeometryInfo::vertex_indices()) - for (unsigned int d = 0; d < spacedim; ++d) - patch.vertices[v](d) = - p + cell_coordinates[d][v] + ((d >= dim) ? v : 0); - - unsigned int n1 = (dim > 0) ? nsubp : 1; - unsigned int n2 = (dim > 1) ? nsubp : 1; - unsigned int n3 = (dim > 2) ? nsubp : 1; - unsigned int n4 = (dim > 3) ? nsubp : 1; - patch.data.reinit(5, n1 * n2 * n3 * n4); - - for (unsigned int i4 = 0; i4 < n4; ++i4) - for (unsigned int i3 = 0; i3 < n3; ++i3) - for (unsigned int i2 = 0; i2 < n2; ++i2) - for (unsigned int i1 = 0; i1 < n1; ++i1) - { - const unsigned int i = - i1 + nsubp * (i2 + nsubp * (i3 + nsubp * i4)); - const float x1 = 1. * i1 / nsub; - const float x2 = 1. * i2 / nsub; - const float x3 = 1. * i3 / nsub; - const float x4 = 1. * i4 / nsub; - - patch.data(0, i) = p + x1; - patch.data(1, i) = p + x2; - patch.data(2, i) = p + x3; - patch.data(3, i) = p + x4; - patch.data(4, i) = i; - } - patch.patch_index = p; - } -} - - - template void check()