From: Wolfgang Bangerth Date: Wed, 23 Mar 2016 22:13:08 +0000 (-0500) Subject: Simplify some manifold code. X-Git-Tag: v8.5.0-rc1~1178^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94c00fc3926360064ecaaf0d5a750a50e0b0539c;p=dealii.git Simplify some manifold code. The previous code precomputed a global flag whether the manifold is periodic or not, but ultimately had to check each coordinate direction manually anyway. So do away with the global flag, and simplify the code structure somewhat. --- diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index 80f4aa9970..9f18fe8d81 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -246,37 +246,36 @@ get_new_point (const Quadrature &quad) const const std::vector > &surrounding_points = quad.get_points(); const std::vector &weights = quad.get_weights(); - Point p; - Point dp; Point minP = periodicity; - const bool check_period = (periodicity.norm() > tolerance); - if (check_period) - for (unsigned int i=0; i 0) + for (unsigned int i=0; i 0) - Assert( (surrounding_points[i][d] < periodicity[d]+tolerance*periodicity.norm()) || - (surrounding_points[i][d] >= -tolerance*periodicity.norm()), - ExcPeriodicBox(d, surrounding_points[i], periodicity, tolerance*periodicity.norm())); + Assert( (surrounding_points[i][d] < periodicity[d]+tolerance*periodicity.norm()) || + (surrounding_points[i][d] >= -tolerance*periodicity.norm()), + ExcPeriodicBox(d, surrounding_points[i], periodicity, tolerance*periodicity.norm())); } + // compute the weighted average point, possibly taking into account periodicity + Point p; for (unsigned int i=0; i(); - if (check_period) - { - for (unsigned int d=0; d 0) - dp[d] = ( (surrounding_points[i][d]-minP[d]) > periodicity[d]/2.0 ? - -periodicity[d] : 0.0 ); - } + Point dp; + for (unsigned int d=0; d 0) + dp[d] = ( (surrounding_points[i][d]-minP[d]) > periodicity[d]/2.0 ? + -periodicity[d] : 0.0 ); + p += (surrounding_points[i]+dp)*weights[i]; } - if (check_period) - for (unsigned int d=0; d 0) - p[d] = (p[d] < 0 ? p[d] + periodicity[d] : p[d]); + + // if necessary, also adjust the weighted point by the periodicity + for (unsigned int d=0; d 0) + if (p[d] < 0) + p[d] += periodicity[d]; return project_to_manifold(surrounding_points, p); }