24 double kernel(
const bool is_volume,
const double r)
41 double kernel_prime(
const bool is_volume,
const double r)
63 const Eigen::MatrixXd ¢ers,
64 const Eigen::MatrixXd &samples,
65 const Eigen::MatrixXd &local_basis_integral,
68 bool with_constraints)
71 compute_weights(samples, local_basis_integral, quadr, rhs, with_constraints);
80 val = tmp.col(local_index);
89 val.resize(samples.rows(), dim);
90 for (
int d = 0; d < dim; ++d)
93 val.col(d) = tmp.col(local_index);
113 const int num_kernels =
centers_.rows();
117 Eigen::MatrixXd A_prime(samples.rows(), num_kernels + 1 + dim);
120 for (
int j = 0; j < num_kernels; ++j)
122 A_prime.col(j) = (samples.rowwise() -
centers_.row(j)).rowwise().norm().unaryExpr([
this](
double x) {
return kernel_prime(
is_volume(),
x) /
x; });
123 A_prime.col(j) = (samples.col(axis).array() -
centers_(j, axis)) * A_prime.col(j).array();
126 A_prime.middleCols(num_kernels + 1 + axis, 1).setOnes();
137 const int num_kernels =
centers_.rows();
140 A.resize(samples.rows(), num_kernels + 1 + dim);
141 for (
int j = 0; j < num_kernels; ++j)
143 A.col(j) = (samples.rowwise() -
centers_.row(j)).rowwise().norm().unaryExpr([
this](
double x) {
return kernel(
is_volume(),
x); });
145 A.col(num_kernels).setOnes();
146 A.rightCols(dim) = samples;
154 const Eigen::MatrixXd &local_basis_integral,
156 Eigen::MatrixXd &t)
const
158 const int num_kernels =
centers_.rows();
162 Eigen::MatrixXd KI(num_kernels, dim);
163 for (
int j = 0; j < num_kernels; ++j)
170 const Eigen::MatrixXd drdp = quadr.
points.rowwise() -
centers_.row(j);
171 const Eigen::VectorXd r = drdp.rowwise().norm();
172 KI.row(j) = (drdp.array().colwise() * (quadr.
weights.array() * r.unaryExpr([
this](
double x) {
return kernel_prime(
is_volume(),
x); }).array() / r.array())).colwise().sum();
177 L.resize(num_kernels + dim + 1, num_kernels + 1);
179 L.diagonal().setOnes();
180 L.block(num_kernels + 1, 0, dim, num_kernels) = -KI.transpose();
184 t.resize(num_kernels + 1 + dim, num_bases);
186 t.bottomRows(dim) = local_basis_integral.transpose().topRows(dim) / quadr.
weights.sum();
192 const Eigen::MatrixXd &local_basis_integral,
const Quadrature &quadr,
193 Eigen::MatrixXd &rhs,
bool with_constraints)
196 logger().trace(
"#collocation points: {}", samples.rows());
197 logger().trace(
"#quadrature points: {}", quadr.
weights.size());
198 logger().trace(
"#non-vanishing bases: {}", rhs.cols());
200 if (!with_constraints)
207 const int num_kernels =
centers_.rows();
208 logger().trace(
"-- Solving system of size {}x{}", num_kernels, num_kernels);
209 weights_ = (A.transpose() * A).ldlt().solve(A.transpose() * rhs);
210 logger().trace(
"-- Solved!");
265 const int num_bases = rhs.cols();
280 logger().trace(
"-- Solving system of size {}x{}", L.cols(), L.cols());
281 weights_ += L * (L.transpose() * A.transpose() * A * L).ldlt().solve(L.transpose() * A.transpose() * rhs);
282 logger().trace(
"-- Solved!");
void compute_weights(const Eigen::MatrixXd &collocation_points, const Eigen::MatrixXd &local_basis_integral, const quadrature::Quadrature &quadr, Eigen::MatrixXd &rhs, bool with_constraints)
void bases_values(const Eigen::MatrixXd &samples, Eigen::MatrixXd &val) const
Batch evaluates the RBF + polynomials on a set of sample points.
void compute_constraints_matrix(const int num_bases, const quadrature::Quadrature &quadr, const Eigen::MatrixXd &local_basis_integral, Eigen::MatrixXd &L, Eigen::MatrixXd &t) const
RBFWithLinear(const Eigen::MatrixXd ¢ers, const Eigen::MatrixXd &collocation_points, const Eigen::MatrixXd &local_basis_integral, const quadrature::Quadrature &quadr, Eigen::MatrixXd &rhs, bool with_constraints=true)
Initialize RBF functions over a polytope element.
void compute_kernels_matrix(const Eigen::MatrixXd &samples, Eigen::MatrixXd &A) const
void grad(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val) const
Evaluates the gradient of one RBF function over a list of coordinates.
void basis(const int local_index, const Eigen::MatrixXd &uv, Eigen::MatrixXd &val) const
Evaluates one RBF function over a list of coordinates.
void bases_grads(const int axis, const Eigen::MatrixXd &samples, Eigen::MatrixXd &val) const
Batch evaluates the gradient of the RBF + polynomials on a set of sample points.
spdlog::logger & logger()
Retrieves the current logger.