Commit bda19ffc authored by COULAUD Olivier's avatar COULAUD Olivier
Browse files

Fix bug in the sign of the gradient.

parent 9a6c8dbb
......@@ -191,7 +191,7 @@ namespace scalfmm::matrix_kernels::laplace
/// grad_one_over_r\f$ k(x,y) : R -> R^{d}\f$ with \f$d \f$ the space
/// dimension.
///
/// \f$k(x,y) = \grad | x - y |^{-1}\f$
/// \f$k(x,y) = \grad | x - y |^{-1} = -(x-y) | x - y |^{-3}\f$
///
/// scale factor \f$k(ax,ay)= 1/a^2 k(x,y)\f$
template<std::size_t Dim = 3>
......@@ -242,7 +242,7 @@ namespace scalfmm::matrix_kernels::laplace
using std::sqrt;
ValueType tmp = ValueType(1.0) / sqrt((((xs.at(Is) - ys.at(Is)) * (xs.at(Is) - ys.at(Is))) + ...));
ValueType r3{pow(tmp, int(3))};
return std::make_tuple((r3 * (xs.at(Is) - ys.at(Is)))...);
return std::make_tuple((r3 * (ys.at(Is) - xs.at(Is)))...);
//-r3 * (xs - ys);
}
......@@ -257,6 +257,8 @@ namespace scalfmm::matrix_kernels::laplace
/// val_grad_one_over_r \f$k(x,y) : R^{km} -> R^{kn}\f$ with \f$ km = 1\f$ and \f$kn = d+1\f$ with \f$ d\f$ the
/// space dimension.
///
/// \f$k(x,y) = ( | x - y |^{-1}, \grad | x - y |^{-1} ) =(| x - y |^{-1}, -(x-y) | x - y |^{-3}\f)$
///
/// Is a specific kernel used to compute the value of the kernel and its gradient
///
/// scale factor \f$ k(ax,ay)= (1/a, 1/a^2 ... 1/a^2) k(x,y)\f$
......@@ -302,7 +304,7 @@ namespace scalfmm::matrix_kernels::laplace
using std::sqrt;
ValueType tmp = ValueType(1.0) / sqrt((((xs.at(Is) - ys.at(Is)) * (xs.at(Is) - ys.at(Is))) + ...));
ValueType r3{pow(tmp, int(3))};
return std::make_tuple(tmp, (r3 * (xs.at(Is) - ys.at(Is)))...); //-r3 * (xs - ys);
return std::make_tuple(tmp, (r3 * (ys.at(Is) - xs.at(Is)))...); //-r3 * (xs - ys);
}
const std::size_t separation_criterion{1};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment