10 using namespace utils;
16 Eigen::Matrix<bool, 3, 1> dd;
22 assert(data.size() == 3);
23 init((
double)data[0], (
double)data[1], (
double)data[2], dd);
26 else if (data.is_object())
28 Eigen::MatrixXd fun, pts;
31 std::string rbf =
"multiquadric";
38 if (data.contains(
"coordinate"))
39 coord = data[
"coordinate"];
42 pts = pts.block(0, 0, pts.rows(), 2).eval();
44 is_tri = data.contains(
"triangles");
49 if (data.contains(
"rbf"))
51 const std::string tmp = data[
"rbf"];
54 if (data.contains(
"epsilon"))
55 eps = data[
"epsilon"];
58 if (data.contains(
"dimension"))
61 auto &tmp = data[
"dimension"];
62 assert(tmp.is_array());
63 for (
size_t k = 0; k < tmp.size(); ++k)
68 init(pts, tri, fun, coord, dd);
70 init(pts, fun, rbf, eps, coord, dd);
84 return val.transpose();
86 Eigen::RowVector3d res;
88 if (coordiante_0 >= 0)
90 Eigen::RowVector2d pt2;
91 pt2 << pt(coordiante_0), pt(coordiante_1);
94 res = tri_func.interpolate(pt2);
96 res = rbf_func.interpolate(pt2);
101 res = tri_func.interpolate(pt);
103 res = rbf_func.interpolate(pt);
117 val = Eigen::MatrixXd::Constant(pts.rows(), pts.cols(),
rhs_);
122 val = Eigen::MatrixXd::Zero(pts.rows(), mesh.
dimension());
124 for (
long i = 0; i < pts.rows(); ++i)
141 val = Eigen::MatrixXd::Zero(pts.rows(), mesh.
dimension());
143 for (
long i = 0; i < pts.rows(); ++i)
171 bc_.back().init(value, dd);
175 void PointBasedTensorProblem::add_function(
const int bc_tag,
const Eigen::MatrixXd &func,
const Eigen::MatrixXd &pts,
const Eigen::MatrixXi &tri,
const int coord,
const Eigen::Matrix<bool, 3, 1> &dd,
const bool is_neumann)
181 neumann_bc_.back().init(pts.block(0, 0, pts.rows(), 2), tri, func, coord, dd);
189 bc_.back().init(pts.block(0, 0, pts.rows(), 2), tri, func, coord, dd);
193 void PointBasedTensorProblem::add_function(
const int bc_tag,
const Eigen::MatrixXd &func,
const Eigen::MatrixXd &pts,
const std::string &rbf,
const double eps,
const int coord,
const Eigen::Matrix<bool, 3, 1> &dd,
const bool is_neumann)
200 neumann_bc_.back().init(pts.block(0, 0, pts.rows(), 2), func, rbf, eps, coord, dd);
202 neumann_bc_.back().init(pts, func, rbf, eps, coord, dd);
211 bc_.back().init(pts.block(0, 0, pts.rows(), 2), func, rbf, eps, coord, dd);
213 bc_.back().init(pts, func, rbf, eps, coord, dd);
226 return bc_[b].is_dirichet_dim(dim);
239 if (params.contains(
"scaling"))
244 if (params.contains(
"rhs"))
246 rhs_ = params[
"rhs"];
249 if (params.contains(
"translation"))
251 const auto &j_translation = params[
"translation"];
253 assert(j_translation.is_array());
254 assert(j_translation.size() == 3);
256 for (
int k = 0; k < 3; ++k)
260 if (params.contains(
"boundary_ids"))
263 auto j_boundary = params[
"boundary_ids"];
271 const auto ff = j_boundary[i][
"value"];
272 const bool all_d =
bc_[i].init(ff);
277 if (params.contains(
"neumann_boundary_ids"))
280 auto j_boundary = params[
"neumann_boundary_ids"];
288 const auto ff = j_boundary[i][
"value"];
const std::string & name() const
std::vector< int > boundary_ids_
std::vector< int > neumann_boundary_ids_
Abstract mesh class to capture 2d/3d conforming and non-conforming meshes.
virtual int get_boundary_id(const int primitive) const
Get the boundary selection of an element (face in 3d, edge in 2d)
int dimension() const
utily for dimension
Eigen::RowVector3d operator()(const Eigen::RowVector3d &pt) const
bool init(const json &data)
bool all_dimensions_dirichlet_
void set_parameters(const json ¶ms) override
void add_constant(const int bc_tag, const Eigen::Vector3d &value)
bool all_dimensions_dirichlet() const override
Eigen::Vector3d translation_
std::vector< BCValue > neumann_bc_
void dirichlet_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val) const override
void add_function(const int bc_tag, const Eigen::MatrixXd &func, const Eigen::MatrixXd &pts, const Eigen::MatrixXi &tri, const int coord)
bool is_dimension_dirichet(const int tag, const int dim) const override
void neumann_bc(const mesh::Mesh &mesh, const Eigen::MatrixXi &global_ids, const Eigen::MatrixXd &uv, const Eigen::MatrixXd &pts, const Eigen::MatrixXd &normals, const double t, Eigen::MatrixXd &val) const override
PointBasedTensorProblem(const std::string &name)
std::vector< BCValue > bc_
void rhs(const assembler::Assembler &assembler, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val) const override
bool read_matrix(const std::string &path, Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat)
Reads a matrix from a file. Determines the file format based on the path's extension.