Skip to content
Snippets Groups Projects
Commit 213fff3c authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MatL] CreepBGRa; Faster residual/jac computation.

Also simplify the logic by removing the side effects.
parent 272e8bcb
No related branches found
No related tags found
No related merge requests found
...@@ -74,31 +74,26 @@ CreepBGRa<DisplacementDim>::integrateStress( ...@@ -74,31 +74,26 @@ CreepBGRa<DisplacementDim>::integrateStress(
dt * constant_coefficient * dt * constant_coefficient *
std::exp(-Q / (MaterialLib::PhysicalConstant::IdealGasConstant * T)); std::exp(-Q / (MaterialLib::PhysicalConstant::IdealGasConstant * T));
// In newton_solver.solve(), the Jacobian is calculated first, and then double const G2b = 2.0 * b * this->_mp.mu(t, x);
// then comes the assembly of the residue vector. In order to save
// computation time, the following two variables are set visible in this auto const update_jacobian = [&solution, &G2b, &n](JacobianMatrix& jacobian) {
// function. The two variables keep the computation results of the auto const& D = Invariants::deviatoric_projection;
// norm of the deviatoric stress and 2bG||s_{n+1}||^{n-1} in KelvinVector const s_n1 = D * solution;
// update_jacobian, and then they are directly used in update_residual
// without repeating the computation. Of course, update_jacobian is not a
// pure function anymore, but has side effects.
double pow_norm_s_n1_n_minus_one_2b_G = 0.;
KelvinVector s_n1;
auto const update_jacobian = [&](JacobianMatrix& jacobian) {
// side effect
s_n1 = deviatoric_matrix * solution;
double const norm_s_n1 = Invariants::FrobeniusNorm(s_n1); double const norm_s_n1 = Invariants::FrobeniusNorm(s_n1);
double const G2b = 2.0 * b * this->_mp.mu(t, x); double const pow_norm_s_n1_n_minus_one_2b_G =
// side effect G2b * std::pow(norm_s_n1, n - 1);
pow_norm_s_n1_n_minus_one_2b_G = G2b * std::pow(norm_s_n1, n - 1);
jacobian = KelvinMatrix::Identity() + jacobian = KelvinMatrix::Identity() +
(pow_norm_s_n1_n_minus_one_2b_G * deviatoric_matrix + (pow_norm_s_n1_n_minus_one_2b_G * D +
(n - 1) * G2b * std::pow(norm_s_n1, n - 3) * s_n1 * (n - 1) * G2b * std::pow(norm_s_n1, n - 3) * s_n1 *
s_n1.transpose()); s_n1.transpose());
}; };
auto const update_residual = [&](ResidualVectorType& r) { auto const update_residual = [&solution, &G2b, &n,
&sigma_try](ResidualVectorType& r) {
KelvinVector const s_n1 = Invariants::deviatoric_projection * solution;
double const norm_s_n1 = Invariants::FrobeniusNorm(s_n1);
double const pow_norm_s_n1_n_minus_one_2b_G =
G2b * std::pow(norm_s_n1, n - 1);
r = solution - sigma_try + pow_norm_s_n1_n_minus_one_2b_G * s_n1; r = solution - sigma_try + pow_norm_s_n1_n_minus_one_2b_G * s_n1;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment