PolyFEM
Loading...
Searching...
No Matches
BCLagrangianForm.hpp
Go to the documentation of this file.
1#pragma once
2
5
8
9namespace polyfem::utils
10{
11 class PeriodicBoundary;
12} // namespace polyfem::utils
13
14namespace polyfem::solver
15{
18 {
19 public:
32 BCLagrangianForm(const int ndof,
33 const std::vector<int> &boundary_nodes,
34 const std::vector<mesh::LocalBoundary> &local_boundary,
35 const std::vector<mesh::LocalBoundary> &local_neumann_boundary,
36 const int n_boundary_samples,
37 const StiffnessMatrix &mass,
38 const assembler::RhsAssembler &rhs_assembler,
39 const size_t obstacle_ndof,
40 const bool is_time_dependent,
41 const double t,
42 const std::shared_ptr<utils::PeriodicBoundary> &periodic_bc = nullptr);
43
44 std::string name() const override
45 {
46 return "bc-alagrangian";
47 }
48
55 BCLagrangianForm(const int ndof,
56 const std::vector<int> &boundary_nodes,
57 const StiffnessMatrix &mass,
58 const size_t obstacle_ndof,
59 const Eigen::MatrixXd &target_x);
60
64 double value_unweighted(const Eigen::VectorXd &x) const override;
65
69 void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override;
70
74 void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override;
75
76 public:
80 void update_quantities(const double t, const Eigen::VectorXd &x) override;
81
82 void update_lagrangian(const Eigen::VectorXd &x, const double k_al) override;
83
85 {
86 return mask_;
87 }
88 const StiffnessMatrix &mask() const { return mask_; }
89 Eigen::VectorXd target(const Eigen::VectorXd &) const override { return target_x_; }
90
91 double compute_error(const Eigen::VectorXd &x) const override;
92
93 private:
94 const std::vector<int> &boundary_nodes_;
95 const std::vector<mesh::LocalBoundary> *local_boundary_;
96 const std::vector<mesh::LocalBoundary> *local_neumann_boundary_;
98
101
105
106 Eigen::MatrixXd target_x_;
107
113 const int ndof,
114 const StiffnessMatrix &mass,
115 const size_t obstacle_ndof);
116
119 void update_target(const double t);
120 };
121} // namespace polyfem::solver
int x
Form of the augmented lagrangian for bc constraints.
void first_derivative_unweighted(const Eigen::VectorXd &x, Eigen::VectorXd &gradv) const override
Compute the first derivative of the value wrt x.
std::string name() const override
void update_quantities(const double t, const Eigen::VectorXd &x) override
Update time dependent quantities.
Eigen::VectorXd target(const Eigen::VectorXd &) const override
void update_target(const double t)
Update target x to the Dirichlet boundary values at time t.
void update_lagrangian(const Eigen::VectorXd &x, const double k_al) override
double compute_error(const Eigen::VectorXd &x) const override
const assembler::RhsAssembler * rhs_assembler_
Reference to the RHS assembler.
void second_derivative_unweighted(const Eigen::VectorXd &x, StiffnessMatrix &hessian) const override
Compute the second derivative of the value wrt x.
const StiffnessMatrix & mask() const
StiffnessMatrix mask_
identity matrix masked by the AL dofs
Eigen::MatrixXd target_x_
actually a vector with the same size as x with target nodal positions
const std::vector< mesh::LocalBoundary > * local_neumann_boundary_
const std::vector< mesh::LocalBoundary > * local_boundary_
StiffnessMatrix masked_lumped_mass_sqrt_
sqrt mass matrix masked by the AL dofs
double value_unweighted(const Eigen::VectorXd &x) const override
Compute the value of the form.
void init_masked_lumped_mass(const int ndof, const StiffnessMatrix &mass, const size_t obstacle_ndof)
Initialize the masked lumped mass matrix.
StiffnessMatrix masked_lumped_mass_
mass matrix masked by the AL dofs
const std::vector< int > & boundary_nodes_
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:22