13 const Eigen::VectorXi &tiled_to_single,
15 const double avg_mass,
16 const bool use_convergent_formulation,
17 const bool use_adaptive_barrier_stiffness,
18 const bool is_time_dependent,
19 const bool enable_shape_derivatives,
20 const ipc::BroadPhaseMethod broad_phase_method,
21 const double ccd_tolerance,
22 const int ccd_max_iterations) :
ContactForm(periodic_collision_mesh, dhat, avg_mass, use_convergent_formulation, use_adaptive_barrier_stiffness, is_time_dependent, enable_shape_derivatives, broad_phase_method, ccd_tolerance, ccd_max_iterations), tiled_to_single_(tiled_to_single), n_single_dof_(tiled_to_single_.maxCoeff() + 1)
41 std::vector<Eigen::Triplet<double>>
entries;
45 for (
int d = 0; d < dim; d++)
48 for (
int p = 0; p < dim; p++)
49 for (
int q = 0; q < dim; q++)
50 entries.emplace_back(
n_single_dof_ * dim + p * dim + q, i_full * dim + p, boundary_vertices(i, q));
64 Eigen::VectorXd tiled_x;
69 for (
int d = 0; d < dim; d++)
72 for (
int p = 0; p < dim; p++)
73 for (
int q = 0; q < dim; q++)
74 tiled_x(i_full * dim + p) +=
x(
n_single_dof_ * dim + p * dim + q) * boundary_vertices(i, q);
85 Eigen::VectorXd reduced_grad;
90 for (
int d = 0; d < dim; d++)
93 for (
int p = 0; p < dim; p++)
94 for (
int q = 0; q < dim; q++)
95 reduced_grad(
n_single_dof_ * dim + p * dim + q) += boundary_vertices(i, q) * grad(i_full * dim + p);
123 hessian =
proj * hessian_full *
proj.transpose();
155 polysolve::nonlinear::PostStepData(
174 Eigen::VectorXd tiled_term;
182 Eigen::VectorXd force;
185 Eigen::MatrixXd adjoint_affine =
utils::unflatten(adjoint_sol.tail(dim * dim), dim);
189 tiled_term.segment(k_full * dim, dim) += adjoint_affine.transpose() * force.segment(k_full * dim, dim);
196 Eigen::VectorXd tmp =
single_to_tiled(adjoint_sol).transpose() * hessian_full;
197 Eigen::MatrixXd sol_affine =
utils::unflatten(solution.tail(dim * dim), dim);
201 tiled_term.segment(k_full * dim, dim) += sol_affine.transpose() * tmp.segment(k_full * dim, dim);
206 Eigen::VectorXd unit_term;
207 Eigen::MatrixXd affine_term;
208 affine_term.setZero(dim, dim);
209 unit_term.setZero(tiled_term.size());
210 Eigen::MatrixXd affine =
utils::unflatten(periodic_mesh_representation.tail(dim * dim), dim).transpose();
214 affine_term += tiled_term.segment(k_full * dim, dim) *
collision_mesh_.rest_positions().row(k);
215 unit_term.segment(k_full * dim, dim) += affine.transpose() * tiled_term.segment(k_full * dim, dim);
221 term.setZero(periodic_mesh_representation.size());
223 term.segment(periodic_mesh_map.
full_to_periodic(i) * dim, dim).array() += single_term.segment(i * dim, dim).array();
224 term.tail(dim * dim) = Eigen::Map<Eigen::VectorXd>(affine_term.data(), dim * dim, 1);
std::vector< Eigen::Triplet< double > > entries
main class that contains the polyfem solver and all its state
std::vector< int > primitive_to_node() const
int n_geom_bases
number of geometric bases
StiffnessMatrix basis_nodes_to_gbasis_nodes
int full_to_periodic(int i) const
Eigen::MatrixXd unflatten(const Eigen::VectorXd &x, int dim)
Unflatten rowwises, so every dim elements in x become a row.
Eigen::VectorXd flatten(const Eigen::MatrixXd &X)
Flatten rowwises.
Eigen::SparseMatrix< double, Eigen::ColMajor > StiffnessMatrix