Dear Markus,
> I am trying to solve a time dependent problem with the multigrid
> approach. Each new time step requires to update the boundary
> conditions (Dirichlet and Neumann BC). The nodes at which these BC are
> applied do not change over time, only their corresponding value is
> updated.
>
> As far as my initial test go, each time I change the value I have to
> go through the process of reassembling the matrix, which makes my
> calculation unusably slow (I need to perform on the order of 25000
> time steps or more).
I guess your concern are the Dirichlet boundary conditions, right? There
are at least three ways to deal with this case:
a) You hold a two global matrices. You assemble into the first one
before the time loop. In the time loop, you copy the matrix into another
sparse matrix where you call "apply_boundary_values" (or the respective
ConstraintMatrix::condense call with matrix and vector if you have your
boundary conditions in a ConstraintMatrix).
b) You identify cells where inhomogeneous boundary conditions are,
assemble a matrix there also in the time loop, and pass this matrix to
the distribute_local_to_global call of the constraint matrix (where the
local matrix is the fourth argument). This provides the necessary
columns of the inhomogeneously constrained DoFs that enter the rhs
vector.
c) You reformulate your linear system so that you actually solve for
increments instead of the solution itself. This reflects to first
applying the current values to the solution components at the boundary,
adding terms similar to the matrix entries to the right hand side of
your weak form (the same way as you would compute a residual of your
differential operator e.g. with Newton's method), and solving a linear
system with homogeneous boundary conditions.
Which version to prefer depends on your application. I rarely advise to
use variant a) because it considerably increase matrix memory and
requires care when used in parallel with MPI. Variant b) is the simplest
way because all you need to add is a few checks if the current cell is
at a boundary of interest and then you go through the usual matrix
assembly code that you have already. Variant c) requires new code
(unless you use Newton's method) but is most flexible.
Have also a look at
http://www.dealii.org/developer/doxygen/deal.II/group__constraints.html
(section 'Treatment of inhomogeneous constraints').
Best,
Martin