From: Daniel Arndt Date: Tue, 6 Feb 2018 21:45:32 +0000 (+0100) Subject: Fix another ice for ICC-15 X-Git-Tag: v9.0.0-rc1~463^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F5872%2Fhead;p=dealii.git Fix another ice for ICC-15 --- diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index b22ed339d1..af800ccfd0 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -2809,6 +2809,33 @@ namespace GridTools + namespace internal + { + // We hit an internal compiler error in ICC 15 if we define this as a lambda + // inside the project_to_object function below. + template + inline + bool weights_are_ok (const Tensor<1, GeometryInfo::vertices_per_cell> &v) + { + // clang has trouble figuring out structdim here, so define it + // again: + static const std::size_t n_vertices_per_cell + = Tensor<1, GeometryInfo::vertices_per_cell>::n_independent_components; + std::array copied_weights; + for (unsigned int i = 0; i < n_vertices_per_cell; ++i) + { + copied_weights[i] = v[i]; + if (v[i] < 0.0 || v[i] > 1.0) + return false; + } + + // check the sum: try to avoid some roundoff errors by summing in order + std::sort(copied_weights.begin(), copied_weights.end()); + const double sum = std::accumulate(copied_weights.begin(), copied_weights.end(), 0.0); + return std::abs(sum - 1.0) < 1e-10; // same tolerance used in manifold.cc + } + } + template Point project_to_object(const Iterator &object, @@ -2878,29 +2905,8 @@ namespace GridTools // could rewrite the projection as a 1D optimization problem), but // to reduce the potential for bugs we use the same code in both // cases. - auto weights_are_ok = [](const Tensor<1, GeometryInfo::vertices_per_cell> &v) - -> bool - { - // clang has trouble figuring out structdim here, so define it - // again: - static const std::size_t n_vertices_per_cell - = Tensor<1, GeometryInfo::vertices_per_cell>::n_independent_components; - std::array copied_weights; - for (unsigned int i = 0; i < n_vertices_per_cell; ++i) - { - copied_weights[i] = v[i]; - if (v[i] < 0.0 || v[i] > 1.0) - return false; - } - - // check the sum: try to avoid some roundoff errors by summing in order - std::sort(copied_weights.begin(), copied_weights.end()); - const double sum = std::accumulate(copied_weights.begin(), copied_weights.end(), 0.0); - return std::abs(sum - 1.0) < 1e-10; // same tolerance used in manifold.cc - }; const double step_size = object->diameter()/64.0; - std::array, GeometryInfo::vertices_per_cell> vertices; for (unsigned int vertex_n = 0; vertex_n < GeometryInfo::vertices_per_cell; ++vertex_n) @@ -2938,7 +2944,7 @@ namespace GridTools } } guess_weights /= guess_weights_sum; - Assert(weights_are_ok(guess_weights), ExcInternalError()); + Assert(internal::weights_are_ok(guess_weights), ExcInternalError()); // The optimization algorithm consists of two parts: // @@ -3023,7 +3029,7 @@ namespace GridTools double new_gradient_weight = gradient_weight; for (unsigned int iteration_count = 0; iteration_count < 40; ++iteration_count) { - if (weights_are_ok(tentative_weights)) + if (internal::weights_are_ok(tentative_weights)) break; for (unsigned int i = 0; i < GeometryInfo::vertices_per_cell; ++i) @@ -3043,7 +3049,7 @@ namespace GridTools // the update might still send us outside the valid region, so // check again and quit if the update is still not valid - if (!weights_are_ok(tentative_weights)) + if (!internal::weights_are_ok(tentative_weights)) break; // if we cannot get closer by traveling in the gradient direction then quit @@ -3052,9 +3058,9 @@ namespace GridTools guess_weights = tentative_weights; else break; - Assert(weights_are_ok(guess_weights), ExcInternalError()); + Assert(internal::weights_are_ok(guess_weights), ExcInternalError()); } - Assert(weights_are_ok(guess_weights), ExcInternalError()); + Assert(internal::weights_are_ok(guess_weights), ExcInternalError()); projected_point = get_point_from_weights(guess_weights); }