Hi everyone
I have a time-dependent linear elasticity solver which is different from step-17 in which I assume small-deformation all the time. Due to the time discretization, I have a -K*u^n term at the rhs of the system where u^n is the known displacement (at previous time step) and K is the stiffness matrix. I tried two different approaches to deal with this term:
1. The first approach is simple: I assemble the system_rhs as if there is no such term, and then explicitly compute system_stiffness.vmult(previous_displacement), and
subtract the result from the system_rhs. It worked out nicely and I got my time-dependent results.
2. In the second approach I deal with this term in the assembly, namely I add this term to the local_rhs at cell level
Loop over cells:
local_matrix = 0; // this is stiffness + mass term
local_stiffness = 0;
local_rhs = 0;
Loop over quadrature points:
compute local_matrix
compute local_stiffness
compute local_rhs // here I compute the rhs due to external load
end of quadrature loop
// Now compute the rhs due to time-discretization
cell->get_dof_indices(local_dof_indices);
for (unsigned int i = 0; i < dofs_per_cell; ++i)
{
for (unsigned int j = 0; j < dofs_per_cell; ++j)
{
local_rhs[i] -= local_stiffness[i][j] * dt * previous_displacement[local_dof_indices[j]];
}
}
constraints.distribute_local_to_global(local_matrix, local_rhs, local_dof_indices, system_matrix, system_rhs);
end of cell loop
Because the global stiffness matrix is the sum of local matrices, ideally this approach should work as the first one. But the solution turned out to be garbage. Could anybody see why the second approach is wrong?
Thank you
Jie