25 const int n_boundary = polygon.rows();
27 Eigen::MatrixXd segments(n_boundary, 2);
28 Eigen::VectorXd radii(n_boundary);
29 Eigen::VectorXd areas(n_boundary);
30 Eigen::VectorXd products(n_boundary);
31 Eigen::VectorXd tangents(n_boundary);
34 b.resize(n_boundary, 1);
37 for (
int i = 0; i < n_boundary; ++i)
39 segments.row(i) = polygon.row(i) - point;
41 radii(i) = segments.row(i).norm();
52 for (
int i = 0; i < n_boundary; ++i)
54 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
56 mat.row(0) = segments.row(i);
57 mat.row(1) = segments.row(ip1);
59 areas(i) = mat.determinant();
60 products(i) = segments.row(i).dot(segments.row(ip1));
63 if (fabs(areas[i]) < tol && products(i) < 0)
65 const double denominator = 1.0 / (radii(i) + radii(ip1));
67 b(i) = radii(ip1) * denominator;
68 b(ip1) = radii(i) * denominator;
74 for (
int i = 0; i < n_boundary; ++i)
76 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
78 tangents(i) = areas(i) / (radii(i) * radii(ip1) + products(i));
82 for (
int i = 0; i < n_boundary; ++i)
84 const int im1 = i == 0 ? (n_boundary - 1) : (i - 1);
86 b(i) = (tangents(im1) + tangents(i)) / radii(i);
95 const int n_boundary = polygon.rows();
100 derivatives.resize(n_boundary, 2);
101 derivatives.setZero();
103 Eigen::MatrixXd segments(n_boundary, 2);
104 Eigen::VectorXd radii(n_boundary);
105 Eigen::VectorXd areas(n_boundary);
106 Eigen::VectorXd products(n_boundary);
107 Eigen::VectorXd tangents(n_boundary);
110 Eigen::MatrixXd areas_prime(n_boundary, 2);
111 Eigen::MatrixXd products_prime(n_boundary, 2);
112 Eigen::MatrixXd radii_prime(n_boundary, 2);
113 Eigen::MatrixXd tangents_prime(n_boundary, 2);
114 Eigen::MatrixXd w_prime(n_boundary, 2);
118 for (
int i = 0; i < n_boundary; ++i)
120 segments.row(i) = polygon.row(i) - point;
122 radii(i) = segments.row(i).norm();
134 double w0 = 0, w1 = 0;
136 for (
int i = 0; i < n_boundary; ++i)
138 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
140 mat.row(0) = segments.row(i);
141 mat.row(1) = segments.row(ip1);
143 areas(i) = mat.determinant();
144 products(i) = segments.row(i).dot(segments.row(ip1));
147 if (fabs(areas[i]) < tol && products(i) < 0)
180 const Eigen::RowVector2d vi = polygon.row(i);
181 const Eigen::RowVector2d vip1 = polygon.row(ip1);
183 areas_prime(i, 0) = vi(1) - vip1(1);
184 areas_prime(i, 1) = vip1(0) - vi(0);
186 products_prime.row(i) = 2 * point - vi - vip1;
187 radii_prime.row(i) = (point - vi) / radii(i);
190 for (
int i = 0; i < n_boundary; ++i)
195 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
197 const double denominator = radii(i) * radii(ip1) + products(i);
198 const Eigen::RowVector2d denominator_prime = radii_prime.row(i) * radii(ip1) + radii(i) * radii_prime.row(ip1) + products_prime.row(i);
200 tangents_prime.row(i) = (areas_prime.row(i) * denominator - areas(i) * denominator_prime) / (denominator * denominator);
201 tangents(i) = areas(i) / denominator;
205 Eigen::RowVector2d W_prime;
208 for (
int i = 0; i < n_boundary; ++i)
210 const int im1 = (i > 0) ? (i - 1) : (n_boundary - 1);
212 if (i != on_edge && im1 != on_edge)
213 w_prime.row(i) = ((tangents_prime.row(im1) + tangents_prime.row(i)) * radii(i) - (tangents(im1) + tangents(i)) * radii_prime.row(i)) / (radii(i) * radii(i));
216 W_prime += w_prime.row(i);
219 else if (im1 == on_edge)
221 else if (on_edge < 0)
222 W += (tangents(im1) + tangents(i)) / radii(i);
225 for (
int i = 0; i < n_boundary; ++i)
227 const int im1 = (i > 0) ? (i - 1) : (n_boundary - 1);
232 else if (im1 == on_edge)
234 else if (on_edge < 0)
235 wi = (tangents(im1) + tangents(i)) / radii(i);
237 derivatives.row(i) = (w_prime.row(i) * W - wi * W_prime) / (W * W);
242 const std::string &assembler_name,
246 const int quadrature_order,
247 const int mass_quadrature_order,
248 std::vector<ElementBases> &bases,
249 std::vector<mesh::LocalBoundary> &local_boundary,
250 std::map<int, Eigen::MatrixXd> &mapped_boundary)
252 return BarycentricBasis2d::build_bases(assembler_name, dim, mesh, n_bases, quadrature_order, mass_quadrature_order,
meanvalue,
meanvalue_derivative, bases, local_boundary, mapped_boundary);
static int build_bases(const std::string &assembler_name, const int dim, const mesh::Mesh2D &mesh, const int n_bases, const int quadrature_order, const int mass_quadrature_order, const std::function< void(const Eigen::MatrixXd &, const Eigen::RowVector2d &, Eigen::MatrixXd &, const double)> bc, const std::function< void(const Eigen::MatrixXd &, const Eigen::RowVector2d &, Eigen::MatrixXd &, const double)> bc_prime, std::vector< ElementBases > &bases, std::vector< mesh::LocalBoundary > &local_boundary, std::map< int, Eigen::MatrixXd > &mapped_boundary)
static int build_bases(const std::string &assembler_name, const int dim, const mesh::Mesh2D &mesh, const int n_bases, const int quadrature_order, const int mass_quadrature_order, std::vector< ElementBases > &bases, std::vector< mesh::LocalBoundary > &local_boundary, std::map< int, Eigen::MatrixXd > &mapped_boundary)