35 const std::vector<basis::ElementBases> &bases,
36 const std::vector<basis::ElementBases> &geom_bases,
42 const int n_pressure_bases,
43 const std::vector<int> &boundary_nodes,
44 const std::vector<mesh::LocalBoundary> &local_boundary,
45 const std::vector<mesh::LocalBoundary> &local_neumann_boundary,
46 const int n_boundary_samples,
47 const Eigen::MatrixXd &rhs,
48 const Eigen::MatrixXd &sol,
52 const std::vector<mesh::LocalBoundary> &local_pressure_boundary,
53 const std::unordered_map<
int, std::vector<mesh::LocalBoundary>> &local_pressure_cavity,
54 const std::shared_ptr<assembler::PressureAssembler> pressure_assembler,
57 const bool ignore_inertia,
59 const std::shared_ptr<assembler::ViscousDamping> damping_assembler,
62 const double lagged_regularization_weight,
63 const int lagged_regularization_iterations,
71 const size_t obstacle_ndof,
74 const bool contact_enabled,
75 const ipc::CollisionMesh &collision_mesh,
77 const double avg_mass,
78 const bool use_convergent_contact_formulation,
79 const json &barrier_stiffness,
80 const ipc::BroadPhaseMethod broad_phase,
81 const double ccd_tolerance,
82 const long ccd_max_iterations,
83 const bool enable_shape_derivatives,
89 const bool periodic_contact,
90 const Eigen::VectorXi &tiled_to_single,
91 const std::shared_ptr<utils::PeriodicBoundary> &periodic_bc,
94 const double friction_coefficient,
96 const int friction_iterations,
99 const json &rayleigh_damping)
104 const int ndof = n_bases * dim;
107 const bool is_volume = dim == 3;
109 std::vector<std::shared_ptr<Form>> forms;
113 n_bases, bases, geom_bases, assembler, ass_vals_cache,
120 ndof, n_pressure_bases, boundary_nodes, local_boundary,
121 local_neumann_boundary, n_boundary_samples, rhs, *
rhs_assembler,
132 local_pressure_boundary,
133 local_pressure_cavity,
143 if (is_time_dependent)
152 if (damping_assembler !=
nullptr)
155 n_bases, bases, geom_bases, *damping_assembler, ass_vals_cache, t, dt, is_volume);
161 if (lagged_regularization_weight > 0)
163 forms.push_back(std::make_shared<LaggedRegForm>(lagged_regularization_iterations));
164 forms.back()->set_weight(lagged_regularization_weight);
176 al_form.push_back(std::make_shared<BCLagrangianForm>(
177 ndof, boundary_nodes, local_boundary, local_neumann_boundary,
178 n_boundary_samples, mass_tmp, *
rhs_assembler, obstacle_ndof, is_time_dependent, t, periodic_bc));
179 forms.push_back(
al_form.back());
185 strain_al_lagr_form = std::make_shared<MacroStrainLagrangianForm>(macro_strain_constraint);
193 const bool use_adaptive_barrier_stiffness = !barrier_stiffness.is_number();
195 if (periodic_contact)
198 collision_mesh, tiled_to_single, dhat, avg_mass, use_convergent_contact_formulation,
199 use_adaptive_barrier_stiffness, is_time_dependent, enable_shape_derivatives, broad_phase, ccd_tolerance,
202 if (use_adaptive_barrier_stiffness)
209 assert(barrier_stiffness.is_number());
210 assert(barrier_stiffness.get<
double>() > 0);
218 collision_mesh, dhat, avg_mass, use_convergent_contact_formulation,
219 use_adaptive_barrier_stiffness, is_time_dependent, enable_shape_derivatives, broad_phase, ccd_tolerance * units.
characteristic_length(),
222 if (use_adaptive_barrier_stiffness)
229 assert(barrier_stiffness.is_number());
230 assert(barrier_stiffness.get<
double>() > 0);
241 if (friction_coefficient != 0)
252 if (is_time_dependent)
255 const std::unordered_map<std::string, std::shared_ptr<Form>> possible_forms_to_damp = {
260 for (
const json ¶ms : rayleigh_damping_jsons)
263 params, possible_forms_to_damp,
267 else if (rayleigh_damping_jsons.size() > 0)
std::vector< std::shared_ptr< Form > > init_forms(const Units &units, const int dim, const double t, const int n_bases, const std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const assembler::Assembler &assembler, const assembler::AssemblyValsCache &ass_vals_cache, const assembler::AssemblyValsCache &mass_ass_vals_cache, const int n_pressure_bases, const std::vector< int > &boundary_nodes, const std::vector< mesh::LocalBoundary > &local_boundary, const std::vector< mesh::LocalBoundary > &local_neumann_boundary, const int n_boundary_samples, const Eigen::MatrixXd &rhs, const Eigen::MatrixXd &sol, const assembler::Density &density, const std::vector< mesh::LocalBoundary > &local_pressure_boundary, const std::unordered_map< int, std::vector< mesh::LocalBoundary > > &local_pressure_cavity, const std::shared_ptr< assembler::PressureAssembler > pressure_assembler, const bool ignore_inertia, const StiffnessMatrix &mass, const std::shared_ptr< assembler::ViscousDamping > damping_assembler, const double lagged_regularization_weight, const int lagged_regularization_iterations, const size_t obstacle_ndof, const bool contact_enabled, const ipc::CollisionMesh &collision_mesh, const double dhat, const double avg_mass, const bool use_convergent_contact_formulation, const json &barrier_stiffness, const ipc::BroadPhaseMethod broad_phase, const double ccd_tolerance, const long ccd_max_iterations, const bool enable_shape_derivatives, const assembler::MacroStrainValue ¯o_strain_constraint, const bool periodic_contact, const Eigen::VectorXi &tiled_to_single, const std::shared_ptr< utils::PeriodicBoundary > &periodic_bc, const double friction_coefficient, const double epsv, const int friction_iterations, const json &rayleigh_damping)
Initialize the forms and return a vector of pointers to them.