10 using namespace utils;
20 auto file = resources.
open(path,
false);
24 while (getline(*file, s))
26 std::stringstream input(s);
38 std::vector<double> ¤tLine =
raw_data_.back();
41 currentLine.push_back(temp);
50 assert(
data_.size() == n_primitive);
55 data_.resize(n_primitive);
58 for (
size_t i = 0; i <
raw_ids_.size(); ++i)
65 for (
size_t j = 0; j <
raw_data_[i].size(); ++j)
75 assert(uv.size() ==
vals.size());
77 return (uv.array() *
vals.transpose().array()).sum();
81 :
Problem(name), rhs_(0), is_all_(false)
92 val = Eigen::MatrixXd::Constant(pts.rows(), pts.cols(),
rhs_);
95 void NodeProblem::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 int)
const
97 val = Eigen::MatrixXd::Zero(pts.rows(), 1);
99 for (
long i = 0; i < uv.rows(); ++i)
101 const int p_id = global_ids(i);
121 void NodeProblem::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 int)
const
123 val = Eigen::MatrixXd::Zero(pts.rows(), 1);
125 for (
long i = 0; i < uv.rows(); ++i)
127 const int p_id = global_ids(i);
165 if (params.contains(
"rhs"))
167 rhs_ = params[
"rhs"];
170 if (params.contains(
"values"))
172 const std::string path = params[
"values"];
176 if (params.contains(
"dirichlet_boundary"))
186 if (j_boundary[i][
"id"] ==
"all")
197 if (j_boundary[i].contains(
"dimension"))
200 auto &tmp = j_boundary[i][
"dimension"];
201 assert(tmp.is_array());
202 for (
size_t k = 0; k < tmp.size(); ++k)
208 if (params.contains(
"neumann_boundary"))
211 auto j_boundary = params[
"neumann_boundary"];
ElementAssemblyValues vals
std::vector< int > boundary_ids_
std::vector< int > neumann_boundary_ids_
Read-only interface to a hierarchical collection of simulation resources.
virtual std::unique_ptr< std::istream > open(const std::string &path, bool binary) const =0
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)
virtual bool is_volume() const =0
checks if mesh is volume
virtual int n_faces() const =0
number of faces
virtual int n_edges() const =0
number of edges
void init(const mesh::Mesh &mesh) override
NodeProblem(const std::string &name)
void set_parameters(const json ¶ms, const io::ResourceIO &resources) override
void rhs(const assembler::Assembler &assembler, const Eigen::MatrixXd &pts, const double t, Eigen::MatrixXd &val, const int fe_space_id=-1) const override
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 int fe_space_id=-1) const override
bool all_dimensions_dirichlet(const int fe_space_id) const override
std::vector< Eigen::Matrix< bool, 1, 3, Eigen::RowMajor > > dirichlet_dimensions_
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 int fe_space_id=-1) const override
bool all_dimensions_dirichlet_
bool is_dimension_dirichet(const int tag, const int dim, const int fe_space_id=-1) const override
std::vector< bool > dirichlet_
double neumann_interpolate(const int p_id, const Eigen::MatrixXd &uv) const
std::vector< int > raw_ids_
std::vector< bool > raw_dirichlet_
void load(const io::ResourceIO &resources, const std::string &path)
double interpolate(const int p_id, const Eigen::MatrixXd &uv, bool is_dirichlet) const
void init(const mesh::Mesh &mesh)
std::vector< std::vector< double > > raw_data_
double dirichlet_interpolate(const int p_id, const Eigen::MatrixXd &uv) const
std::vector< Eigen::VectorXd > data_
std::vector< T > json_as_array(const json &j)
Return the value of a json object as an array.