12#ifndef BEMBEL_SRC_HOMOGENISEDLAPLACE_COEFFICIENTS_HPP_
13#define BEMBEL_SRC_HOMOGENISEDLAPLACE_COEFFICIENTS_HPP_
16#define POINT_DEGREE 20
20#include <Bembel/HomogenisedLaplace>
21#include <Bembel/Quadrature>
29inline unsigned int getDegree(
double precision);
32 Eigen::MatrixXd
ps_b);
34inline double k_mod(Eigen::Vector3d
in);
36inline Eigen::Vector3d
Dk_mod(Eigen::Vector3d
in);
39 Eigen::MatrixXd
ps_l, Eigen::MatrixXd
ps_f, Eigen::MatrixXd
ps_b);
62 Eigen::RowVectorXd
difft;
68 unsigned int Msquare = (POINT_DEGREE + 1) * (POINT_DEGREE + 1);
74 Eigen::MatrixXd
xs =
GS[POINT_DEGREE].xi_;
75 xs -= 0.5 * Eigen::MatrixXd::Ones(
xs.rows(),
xs.cols());
77 Eigen::Vector3d
ex(1.0, 0.0, 0.0);
78 Eigen::Vector3d
ey(0.0, 1.0, 0.0);
79 Eigen::Vector3d
ez(0.0, 0.0, 1.0);
82 ps_left.row(0) = -0.5 * Eigen::VectorXd::Ones(
xs.cols());
83 ps_left.block(1, 0, 2,
xs.cols()) =
xs.block(0, 0, 2,
xs.cols());
87 ps_front.row(1) = -0.5 * Eigen::VectorXd::Ones(
xs.cols());
92 ps_bottom.row(2) = -0.5 * Eigen::VectorXd::Ones(
xs.cols());
110 for (
n = 1;
n <= deg;
n++) {
119 diff.segment(1,
n) *= 2.0;
120 difft.segment(1,
n) *= 2.0;
137 for (
n = 1;
n <= deg;
n++) {
146 diff.segment(1,
n) *= 2.0;
147 difft.segment(1,
n) *= 2.0;
166 for (
n = 1;
n <= deg;
n++) {
175 diff.segment(1,
n) *= 2.0;
176 difft.segment(1,
n) *= 2.0;
186 Eigen::VectorXd
coeffs(((deg + 1) * (deg + 2)) / 2);
188 coeffs.segment(1, ((deg + 1) * (deg + 2)) / 2 - 1) =
192 Eigen::VectorXd
coeffs_full((deg + 1) * (deg + 1));
194 for (
n = 1;
n <= deg;
n++) {
196 for (
m = 1;
m <=
n;
m++) {
222 if (precision > 1
e-4) {
224 }
else if (precision > 1
e-6) {
239 Eigen::MatrixXd
ps_b) {
241 std::function<
double(Eigen::Vector3d)>
u = [](Eigen::Vector3d
in) {
244 std::function<Eigen::Vector3d(Eigen::Vector3d)>
Du = [](Eigen::Vector3d
in) {
248 unsigned int Msquare = (POINT_DEGREE + 1) * (POINT_DEGREE + 1);
251 Eigen::Vector3d
ex(1.0, 0.0, 0.0);
252 Eigen::Vector3d
ey(0.0, 1.0, 0.0);
253 Eigen::Vector3d
ez(0.0, 0.0, 1.0);
291 for (
i = -1;
i <= 1;
i++) {
292 for (
j = -1;
j <= 1;
j++) {
293 for (
k = -1;
k <= 1;
k++) {
294 m = Eigen::Vector3d(
i,
j,
k);
303 r += (
in.dot(
in)) / 6.0;
313 Eigen::Vector3d
r,
s;
318 for (
i = -1;
i <= 1;
i++) {
319 for (
j = -1;
j <= 1;
j++) {
320 for (
k = -1;
k <= 1;
k++) {
321 s =
in - Eigen::Vector3d(
i,
j,
k);
347 Eigen::MatrixXd
ps_l, Eigen::MatrixXd
ps_f, Eigen::MatrixXd
ps_b) {
351 Eigen::VectorXd
ws =
GS[POINT_DEGREE].w_;
353 Eigen::VectorXd
cs_tmp(cs.rows());
359 for (
k = 0;
k <
ps_l.cols();
k++) {
361 for (
n = 1;
n <= deg;
n++) {
363 * cs.segment(
n *
n, 2 *
n + 1);
Routines for the evalutation of pointwise errors.
Eigen::VectorXd getCoefficients(double precision)
Calculates the coefficients for the solid harmonics expansion of the periodic kernel .
double evaluate_sphericals(Eigen::Vector3d x, Eigen::VectorXd cs, unsigned int deg)
Evaluates the series for real coefficients, with the convenction that .
unsigned int getDegree(double precision)
Returns the degree of the sphericals expansion given a precision. Can be extended,...
Eigen::VectorXd getDisplacement(Eigen::MatrixXd ps_l, Eigen::MatrixXd ps_f, Eigen::MatrixXd ps_b)
Returns the right-hand side for the homogenised coefficient calculation.
Eigen::Vector3d Dk_mod(Eigen::Vector3d in)
Returns the gradient of the modified kernel .
double k_mod(Eigen::Vector3d in)
Returns the modified kernel .
constexpr int getFunctionSpaceOutputDimension()
Eigen::Matrix< double, 3, Eigen::Dynamic > Dsolid_harmonics_full(Eigen::Vector3d x, unsigned int N, Eigen::MatrixXd spherical_val)
Calculates all gradients of the solid harmonics, given the Legendre Coefficients L.
Eigen::Matrix< double, Eigen::Dynamic, 2 > spherical_harmonics_full(Eigen::Vector3d x, unsigned int N)
Calculates the the spherical harmonics , ordered by .
double calculateFirstCoefficient(Eigen::VectorXd cs, unsigned int deg, Eigen::MatrixXd ps_l, Eigen::MatrixXd ps_f, Eigen::MatrixXd ps_b)
Calculates the first coefficient such that the mean of the kernel vanishes.