35 std::vector<basis::ElementBases> &bases,
36 const std::vector<basis::ElementBases> &geom_bases,
40 const double jacobian_threshold,
44 const int n_pressure_bases,
45 const std::vector<int> &boundary_nodes,
46 const std::vector<mesh::LocalBoundary> &local_boundary,
47 const std::vector<mesh::LocalBoundary> &local_neumann_boundary,
48 const int n_boundary_samples,
49 const Eigen::MatrixXd &rhs,
50 const Eigen::MatrixXd &sol,
54 const std::vector<mesh::LocalBoundary> &local_pressure_boundary,
55 const std::unordered_map<
int, std::vector<mesh::LocalBoundary>> &local_pressure_cavity,
56 const std::shared_ptr<assembler::PressureAssembler> pressure_assembler,
59 const bool ignore_inertia,
61 const std::shared_ptr<assembler::ViscousDamping> damping_assembler,
64 const double lagged_regularization_weight,
65 const int lagged_regularization_iterations,
73 const size_t obstacle_ndof,
76 const bool contact_enabled,
77 const ipc::CollisionMesh &collision_mesh,
79 const double avg_mass,
80 const bool use_convergent_contact_formulation,
81 const json &barrier_stiffness,
82 const ipc::BroadPhaseMethod broad_phase,
83 const double ccd_tolerance,
84 const long ccd_max_iterations,
85 const bool enable_shape_derivatives,
91 const bool periodic_contact,
92 const Eigen::VectorXi &tiled_to_single,
93 const std::shared_ptr<utils::PeriodicBoundary> &periodic_bc,
96 const double friction_coefficient,
98 const int friction_iterations,
101 const json &rayleigh_damping)
106 const int ndof = n_bases * dim;
109 const bool is_volume = dim == 3;
111 std::vector<std::shared_ptr<Form>> forms;
115 n_bases, bases, geom_bases, assembler, ass_vals_cache,
116 t, dt, is_volume, jacobian_threshold, check_inversion);
122 ndof, n_pressure_bases, boundary_nodes, local_boundary,
123 local_neumann_boundary, n_boundary_samples, rhs, *
rhs_assembler,
134 local_pressure_boundary,
135 local_pressure_cavity,
145 if (is_time_dependent)
154 if (damping_assembler !=
nullptr)
157 n_bases, bases, geom_bases, *damping_assembler, ass_vals_cache, t, dt, is_volume);
163 if (lagged_regularization_weight > 0)
165 forms.push_back(std::make_shared<LaggedRegForm>(lagged_regularization_iterations));
166 forms.back()->set_weight(lagged_regularization_weight);
178 al_form.push_back(std::make_shared<BCLagrangianForm>(
179 ndof, boundary_nodes, local_boundary, local_neumann_boundary,
180 n_boundary_samples, mass_tmp, *
rhs_assembler, obstacle_ndof, is_time_dependent, t, periodic_bc));
181 forms.push_back(
al_form.back());
187 strain_al_lagr_form = std::make_shared<MacroStrainLagrangianForm>(macro_strain_constraint);
195 const bool use_adaptive_barrier_stiffness = !barrier_stiffness.is_number();
197 if (periodic_contact)
200 collision_mesh, tiled_to_single, dhat, avg_mass, use_convergent_contact_formulation,
201 use_adaptive_barrier_stiffness, is_time_dependent, enable_shape_derivatives, broad_phase, ccd_tolerance,
204 if (use_adaptive_barrier_stiffness)
211 assert(barrier_stiffness.is_number());
212 assert(barrier_stiffness.get<
double>() > 0);
220 collision_mesh, dhat, avg_mass, use_convergent_contact_formulation,
221 use_adaptive_barrier_stiffness, is_time_dependent, enable_shape_derivatives, broad_phase, ccd_tolerance * units.
characteristic_length(),
224 if (use_adaptive_barrier_stiffness)
231 assert(barrier_stiffness.is_number());
232 assert(barrier_stiffness.get<
double>() > 0);
243 if (friction_coefficient != 0)
254 if (is_time_dependent)
257 const std::unordered_map<std::string, std::shared_ptr<Form>> possible_forms_to_damp = {
262 for (
const json ¶ms : rayleigh_damping_jsons)
265 params, possible_forms_to_damp,
269 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, std::vector< basis::ElementBases > &bases, const std::vector< basis::ElementBases > &geom_bases, const assembler::Assembler &assembler, assembler::AssemblyValsCache &ass_vals_cache, const assembler::AssemblyValsCache &mass_ass_vals_cache, const double jacobian_threshold, const solver::ElementInversionCheck check_inversion, 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.