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 Cs(n_boundary);
33 b.resize(n_boundary, 1);
36 for (
int i = 0; i < n_boundary; ++i)
38 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
39 const int im1 = i == 0 ? (n_boundary - 1) : (i - 1);
41 mat.row(0) = polygon.row(im1) - polygon.row(i);
42 mat.row(1) = polygon.row(ip1) - polygon.row(i);
44 Cs(i) = mat.determinant();
47 for (
int i = 0; i < n_boundary; ++i)
49 segments.row(i) = polygon.row(i) - point;
50 radii(i) = segments.row(i).norm();
60 for (
int i = 0; i < n_boundary; ++i)
62 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
64 mat.row(0) = segments.row(i);
65 mat.row(1) = segments.row(ip1);
67 areas(i) = mat.determinant();
68 const double prod = segments.row(i).dot(segments.row(ip1));
71 if (fabs(areas[i]) < tol && prod < 0)
73 const double denominator = 1.0 / (radii(i) + radii(ip1));
75 b(i) = radii(ip1) * denominator;
76 b(ip1) = radii(i) * denominator;
83 for (
int i = 0; i < n_boundary; ++i)
85 const int im1 = i == 0 ? (n_boundary - 1) : (i - 1);
87 b(i) = Cs(i) / (areas(im1) * areas(i));
96 const int n_boundary = polygon.rows();
98 derivatives.resize(n_boundary, 2);
99 derivatives.setZero();
101 Eigen::MatrixXd segments(n_boundary, 2);
102 Eigen::VectorXd radii(n_boundary);
103 Eigen::VectorXd areas(n_boundary);
104 Eigen::VectorXd Cs(n_boundary);
107 Eigen::MatrixXd areas_prime(n_boundary, 2);
108 Eigen::MatrixXd w_prime(n_boundary, 2);
110 for (
int i = 0; i < n_boundary; ++i)
112 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
113 const int im1 = i == 0 ? (n_boundary - 1) : (i - 1);
115 mat.row(0) = polygon.row(im1) - polygon.row(i);
116 mat.row(1) = polygon.row(ip1) - polygon.row(i);
118 Cs(i) = mat.determinant();
121 for (
int i = 0; i < n_boundary; ++i)
123 segments.row(i) = polygon.row(i) - point;
124 radii(i) = segments.row(i).norm();
136 double w0 = 0, w1 = 0;
138 for (
int i = 0; i < n_boundary; ++i)
140 const int ip1 = (i + 1) == n_boundary ? 0 : (i + 1);
142 mat.row(0) = segments.row(i);
143 mat.row(1) = segments.row(ip1);
145 areas(i) = mat.determinant();
146 const double prod = segments.row(i).dot(segments.row(ip1));
149 if (fabs(areas[i]) < tol && prod < 0)
155 const Eigen::RowVector2d vi = polygon.row(i);
156 const Eigen::RowVector2d vip1 = polygon.row(ip1);
158 areas_prime(i, 0) = vi(1) - vip1(1);
159 areas_prime(i, 1) = vip1(0) - vi(0);
163 Eigen::RowVector2d W_prime;
166 for (
int i = 0; i < n_boundary; ++i)
168 const int im1 = (i > 0) ? (i - 1) : (n_boundary - 1);
170 w_prime.row(i) = Cs(i) / (areas(im1) * areas(i)) / (areas(im1) * areas(i)) * (areas_prime.row(im1) * areas(i) + areas(im1) * areas_prime.row(i));
172 W_prime += w_prime.row(i);
174 W += Cs(i) / (areas(im1) * areas(i));
177 for (
int i = 0; i < n_boundary; ++i)
179 const int im1 = (i > 0) ? (i - 1) : (n_boundary - 1);
181 const double wi = Cs(i) / (areas(im1) * areas(i));
182 derivatives.row(i) = -(w_prime.row(i) * W - wi * W_prime) / (W * W);
187 const std::string &assembler_name,
191 const int quadrature_order,
192 const int mass_quadrature_order,
193 std::vector<ElementBases> &bases,
194 std::vector<mesh::LocalBoundary> &local_boundary,
195 std::map<int, Eigen::MatrixXd> &mapped_boundary)
197 return BarycentricBasis2d::build_bases(assembler_name, dim, mesh, n_bases, quadrature_order, mass_quadrature_order,
wachspress,
wachspress_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)