Hi, I am implementing the backward Euler method to solve a time-dependent
problem like u(n+1)= h*f(n+1)+u(n). n is the nth time step. h is the time
step length. f is a function of time. I tried two ways to assemble the
system right-hand side(rhs).
One is to form a mass matrix first, then time the old value of u at the
node. This way is similar to Step-26. The code is like
mass_matrix.vmult(system_rhs, old_solution);
The other way is to get the value of u at quadrature points by
interpolation, then do the integral in cells to get the local rhs, finally
assemble the system rhs by the local rhs. This method is from Step-31 and
shown in the following code.
for (; cell != endc; ++cell) {
local_rhs = 0;
fe_values.reinit(cell);
fe_values.get_function_values(old_solution, old_sol_values);
for (unsigned int q = 0; q < n_q_points; ++q ){
for (unsigned int i = 0; i < dofs_per_cell; ++i) {
const double phi_i = fe_values.shape_value(i, q);
local_rhs(i) += old_sol_values[q] * phi_i * fe_values.JxW(q);
}
}
cell->get_dof_indices(local_dof_indices);
for (unsigned int i = 0; i < dofs_per_cell; ++i) {
system_rhs(local_dof_indices[i]) += local_rhs(i)*0;
}
}
I thought these two methods should give the same answer, but they can't. I
don't know where I made a mistake. Thank you very much.
--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dealii/6887c68e-64c3-4e74-a53f-64775f467a3b%40googlegroups.com.