32 const std::vector<double>& local_x_data,
33 const std::vector<double>& local_x_prev_data,
34 std::vector<double>& local_b_data, std::vector<double>& local_Jac_data)
36 std::vector<double> local_M_data(local_Jac_data.size());
37 std::vector<double> local_K_data(local_Jac_data.size());
43 "The number of specified epsilons ({:d}) and the number of local "
44 "d.o.f.s ({:d}) do not match, i.e., the latter is not divisible by "
50 static_cast<Eigen::MatrixXd::Index
>(local_x_data.size());
54 auto const local_x_prev =
56 Eigen::VectorXd
const local_xdot = (local_x - local_x_prev) / dt;
62 auto const num_dofs_per_component =
73 for (Eigen::MatrixXd::Index i = 0; i < num_r_c; ++i)
76 auto const component = i / num_dofs_per_component;
81 local_x_prev_data, local_M_data, local_K_data,
91 if (!local_M_data.empty())
93 auto const local_M_p =
95 auto const local_M_m =
97 local_Jac.col(i).noalias() +=
99 (local_M_p - local_M_m) * local_xdot / (2.0 * eps);
100 local_M_data.clear();
103 if (!local_K_data.empty())
105 auto const local_K_p =
107 auto const local_K_m =
109 local_Jac.col(i).noalias() +=
111 (local_K_p - local_K_m) * local_x / (2.0 * eps);
112 local_K_data.clear();
115 if (!local_b_data.empty())
117 auto const local_b_p =
119 auto const local_b_m =
121 local_Jac.col(i).noalias() -=
123 (local_b_p - local_b_m) / (2.0 * eps);
124 local_b_data.clear();
130 local_assembler.
assemble(t, dt, local_x_data, local_x_prev_data,
131 local_M_data, local_K_data, local_b_data);
134 if (!local_M_data.empty())
137 local_Jac.noalias() += local_M / dt;
139 if (!local_K_data.empty())
142 local_Jac.noalias() += local_K;
150 if (!local_b_data.empty())
158 if (!local_M_data.empty())
162 local_M_data.clear();
164 if (!local_K_data.empty())
168 local_K_data.clear();
181 "relative_epsilons");
184 "component_magnitudes");
186 if (!!rel_eps != !!comp_mag)
189 "Either both or none of <relative_epsilons> and "
190 "<component_magnitudes> have to be specified.");
193 std::vector<double> abs_eps;
197 if (rel_eps->size() != comp_mag->size())
200 "The numbers of components of <relative_epsilons> and "
201 "<component_magnitudes> do not match.");
204 abs_eps.resize(rel_eps->size());
205 for (std::size_t i = 0; i < rel_eps->size(); ++i)
207 abs_eps[i] = (*rel_eps)[i] * (*comp_mag)[i];
214 abs_eps.emplace_back(1e-8);
217 return std::make_unique<CentralDifferencesJacobianAssembler>(
void assembleWithJacobian(LocalAssemblerInterface &local_assembler, double const t, double const dt, std::vector< double > const &local_x_data, std::vector< double > const &local_x_prev_data, std::vector< double > &local_b_data, std::vector< double > &local_Jac_data) override
virtual void assemble(double const t, double const dt, std::vector< double > const &local_x, std::vector< double > const &local_x_prev, std::vector< double > &local_M_data, std::vector< double > &local_K_data, std::vector< double > &local_b_data)