PolyFEM
Loading...
Searching...
No Matches
PressureForceDerivative.cpp
Go to the documentation of this file.
2
3#include <cassert>
4#include <Eigen/Core>
7
8namespace polyfem::solver
9{
11 PressureForm &form,
12 const int n_verts,
13 const double t,
14 const Eigen::MatrixXd &x,
15 const Eigen::MatrixXd &adjoint,
16 Eigen::VectorXd &term)
17 {
18 Eigen::MatrixXd adjoint_zeroed = adjoint;
19 adjoint_zeroed(form.dirichlet_nodes_, Eigen::all).setZero();
20
21 StiffnessMatrix hessian;
23
24 term = -hessian.transpose() * adjoint_zeroed;
25 }
26
28 PressureForm &form,
29 const int n_verts,
30 const double t,
31 const int pressure_boundary_id,
32 const Eigen::MatrixXd &x,
33 const Eigen::MatrixXd &adjoint)
34 {
35 Eigen::MatrixXd adjoint_zeroed = adjoint;
36 adjoint_zeroed(form.dirichlet_nodes_, Eigen::all).setZero();
37
38 Eigen::VectorXd pressure_gradv;
39 form.pressure_assembler_.compute_grad_volume_id(x, pressure_boundary_id, form.local_pressure_boundary_, form.dirichlet_nodes_, form.n_boundary_samples_, pressure_gradv, t, false);
40 pressure_gradv *= -1;
41
42 Eigen::MatrixXd term;
43 term = pressure_gradv.transpose() * adjoint_zeroed;
44 term *= -1;
45
46 assert(term.size() == 1);
47 return term(0);
48 }
49} // namespace polyfem::solver
int x
void compute_grad_volume_id(const Eigen::MatrixXd &displacement, const int boundary_id, const std::vector< mesh::LocalBoundary > &local_boundary, const std::vector< int > &dirichlet_nodes, const QuadratureOrders &resolution, Eigen::VectorXd &grad, const double t=0, const bool multiply_pressure=false) const
void compute_force_jacobian(const Eigen::MatrixXd &displacement, const std::vector< mesh::LocalBoundary > &local_pressure_boundary, const std::vector< int > &dirichlet_nodes, const QuadratureOrders &resolution, const double t, const int n_vertices, StiffnessMatrix &hess) const
static void force_shape_derivative(PressureForm &form, const int n_verts, const double t, const Eigen::MatrixXd &x, const Eigen::MatrixXd &adjoint, Eigen::VectorXd &term)
static double force_pressure_derivative(PressureForm &form, const int n_verts, const double t, const int pressure_boundary_id, const Eigen::MatrixXd &x, const Eigen::MatrixXd &adjoint)
Form representing body forces.
const assembler::PressureAssembler & pressure_assembler_
Reference to the pressure assembler.
const QuadratureOrders n_boundary_samples_
const std::vector< mesh::LocalBoundary > & local_pressure_boundary_
const std::vector< int > & dirichlet_nodes_
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix
Definition Types.hpp:24