reduction of std::pow calls; stronger usage of
Cartesian- and CylinderCoordinate objects
This commit is contained in:
@@ -108,9 +108,9 @@ void PoissonSolver::solvePotential(
|
||||
void PoissonSolver::solverIteration(
|
||||
const blitz::Array<double, 3>& interpolated_density) {
|
||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||
const double dr_sq = std::pow(stepsize(0), 2); // shorthand
|
||||
const double dth_sq = std::pow(stepsize(1), 2); // shorthand
|
||||
const double dz_sq = std::pow(stepsize(2), 2); // shorthand
|
||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
||||
const double dth_sq = stepsize(1)*stepsize(1); // shorthand
|
||||
const double dz_sq = stepsize(2)*stepsize(2); // shorthand
|
||||
|
||||
for (int i = potential_.lbound(0); i <= potential_.ubound(0); ++i) {
|
||||
for (int j = potential_.lbound(1); j <= potential_.ubound(1); ++j) {
|
||||
@@ -149,13 +149,13 @@ void PoissonSolver::solverIteration(
|
||||
: j - 1; // j-1 with periodic guard
|
||||
|
||||
const double scaling_factor = 2 / dr_sq + 2 / dz_sq +
|
||||
2 / (std::pow(i, 2) * dr_sq * dth_sq);
|
||||
2 / (i*i * dr_sq * dth_sq);
|
||||
|
||||
potential_(i, j, k).value =
|
||||
(1 / scaling_factor) *
|
||||
((1 / dr_sq * (1 + 1. / (2. * i))) * potential_(i + 1, j, k).value +
|
||||
(1 / dr_sq * (1 - 1. / (2. * i))) * potential_(i - 1, j, k).value +
|
||||
(1 / (std::pow(i, 2) * dr_sq * dth_sq)) *
|
||||
(1 / (i*i * dr_sq * dth_sq)) *
|
||||
(potential_(i, jp1, k).value + potential_(i, jm1, k).value) +
|
||||
(1 / dz_sq) * (potential_(i, j, k + 1).value +
|
||||
potential_(i, j, k - 1).value) +
|
||||
@@ -171,9 +171,9 @@ void PoissonSolver::solverIteration(
|
||||
bool PoissonSolver::converged(
|
||||
const blitz::Array<double, 3>& interpolated_density) {
|
||||
blitz::TinyVector<double, 3> stepsize = density_binning_.stepsize();
|
||||
const double dr_sq = std::pow(stepsize(0), 2); // shorthand
|
||||
const double dth_sq = std::pow(stepsize(1), 2); // shorthand
|
||||
const double dz_sq = std::pow(stepsize(2), 2); // shorthand
|
||||
const double dr_sq = stepsize(0)*stepsize(0); // shorthand
|
||||
const double dth_sq = stepsize(1)*stepsize(1); // shorthand
|
||||
const double dz_sq = stepsize(2)*stepsize(2); // shorthand
|
||||
|
||||
double cumulated_quadradic_difference = 0.;
|
||||
double normalized_difference = 0.;
|
||||
@@ -200,7 +200,7 @@ bool PoissonSolver::converged(
|
||||
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
||||
potential_(i,j,k-1).value)/dz_sq;
|
||||
|
||||
cumulated_quadradic_difference += std::pow(difference, 2);
|
||||
cumulated_quadradic_difference += difference*difference;
|
||||
|
||||
if(fabs(difference) > maximum_difference) {
|
||||
maximum_difference = fabs(difference);
|
||||
@@ -220,11 +220,11 @@ bool PoissonSolver::converged(
|
||||
(potential_(i+1,j,k).value - potential_(i-1,j,k).value)/
|
||||
(2*i*dr_sq) +
|
||||
(potential_(i,jp1,k).value - 2*potential_(i,j,k).value +
|
||||
potential_(i,jm1,k).value)/(std::pow(i,2)*dr_sq*dth_sq) +
|
||||
potential_(i,jm1,k).value)/(i*i*dr_sq*dth_sq) +
|
||||
(potential_(i,j,k+1).value - 2*potential_(i,j,k).value +
|
||||
potential_(i,j,k-1).value)/dz_sq;
|
||||
|
||||
cumulated_quadradic_difference += std::pow(difference, 2);
|
||||
cumulated_quadradic_difference += difference*difference;
|
||||
|
||||
if(fabs(difference) > maximum_difference) {
|
||||
maximum_difference = fabs(difference);
|
||||
|
||||
Reference in New Issue
Block a user