9 const std::vector<int> &boundary_nodes,
10 const std::vector<mesh::LocalBoundary> &local_boundary,
11 const std::vector<mesh::LocalBoundary> &local_neumann_boundary,
12 const int n_boundary_samples,
15 const size_t obstacle_ndof,
16 const bool is_time_dependent,
18 const std::shared_ptr<utils::PeriodicBoundary> &periodic_bc)
20 boundary_nodes_(boundary_nodes),
21 local_boundary_(&local_boundary),
22 local_neumann_boundary_(&local_neumann_boundary),
23 n_boundary_samples_(n_boundary_samples),
24 rhs_assembler_(&rhs_assembler),
25 is_time_dependent_(is_time_dependent)
32 const std::vector<int> &boundary_nodes,
34 const size_t obstacle_ndof,
35 const Eigen::MatrixXd &target_x)
37 boundary_nodes_(boundary_nodes),
38 local_boundary_(nullptr),
39 local_neumann_boundary_(nullptr),
40 n_boundary_samples_(0),
41 rhs_assembler_(nullptr),
42 is_time_dependent_(false),
51 const size_t obstacle_ndof)
53 std::vector<bool> is_boundary_dof(ndof,
true);
55 is_boundary_dof[bn] =
false;
59 double min_diag = std::numeric_limits<double>::max();
65 if (it.col() == it.row())
67 min_diag = std::min(min_diag, it.value());
68 max_diag = std::max(max_diag, it.value());
72 if (max_diag <= 0 || min_diag <= 0 || min_diag / max_diag < 1e-16)
74 logger().warn(
"Lumped mass matrix ill-conditioned. Setting lumped mass matrix to identity.");
82 if (obstacle_ndof != 0)
84 const int n_fe_dof = ndof - obstacle_ndof;
86 for (
int i = n_fe_dof; i < ndof; ++i)
95 return !is_boundary_dof[row];
100 mask_.prune([&](
const int &row,
const int &col,
const double &
value) ->
bool {
102 return !is_boundary_dof[row];
105 std::vector<Eigen::Triplet<double>> tmp_triplets;
111 assert(it.col() == k);
112 tmp_triplets.emplace_back(it.row(), it.col(), sqrt(it.value()));
129 return L_penalty +
k_al_ * A_penalty;
void set_bc(const std::vector< mesh::LocalBoundary > &local_boundary, const std::vector< int > &bounday_nodes, const int resolution, const std::vector< mesh::LocalBoundary > &local_neumann_boundary, Eigen::MatrixXd &rhs, const Eigen::MatrixXd &displacement=Eigen::MatrixXd(), const double t=1) const
Eigen::SparseMatrix< double > lump_matrix(const Eigen::SparseMatrix< double > &M)
Lump each row of a matrix into the diagonal.
Eigen::SparseMatrix< double > sparse_identity(int rows, int cols)
spdlog::logger & logger()
Retrieves the current logger.
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix