Another option you have is not to eliminate the columns of the matrix, and feed 
the apply boundary conditions (version with the map) a vectors of ones. In this 
case, the vector is filled with the scaling factors of the boundary conditions, 
and you can scale your successive boundary conditions using this, to obtain 
exactly what you asked for at the beginning. 

This procedure assumes that you don't care about symmetry of the matrix, 
therefore, you don't truly eliminate the boundary dofs from the matrix, but 
only the rows, i.e., you let the iterative solver do the gauss elimination step.

In other words: 

coefficients = 0;
ones = 1;

MatrixTools::apply_boundary_values(boundary_values, matrix, coefficients, ones, 
false);

then each time you need to apply different boundary values, you loop on each 
item of the map, and do

for(iterator in boundary_values) {
        id = iterator->first;
        value = iterator->second;
        solution[id] = coefficients[id]*value;
}

Luca.

--
Luca Heltai <[email protected]>
http://people.sissa.it/~heltai/
Scuola Internazionale Superiore di Studi Avanzati
Phone:  +39 040 3787 449, Office: 732
--
There are no answers, only cross references

On Jan 12, 2011, at 12:21 PM, Martin Stoll wrote:

> Hi Martin,
> 
> thanks for the comments.
> 
> The last option you gave in your message of storing two matrices is what I 
> would have come up but dismissed it for inefficiency. 
> 
> Essentially, if I could extract the matrix entries that correspond to the 
> columns for the non-zero boundary constraints, I could compute the right hand 
> side contributions in a more straightforward way.
> Something like lower_part(S_before-S_after) [yb_1,..,yb_NT] would then give 
> me the sought-after right hand sides. I am just wondering how to do this 
> efficiently?
> 
> Martin, if you can suggest something better I am all ears! Thanks anyways.
> 
> Cheers,
> Martin
> 
> 
> I would like to take you 
> 
> On Wed, Jan 12, 2011 at 12:07 PM, Martin Kronbichler 
> <[email protected]> wrote:
> 
> > > For non-time-dependent problems I would simply use 
> > > apply_boundary_conditions
> > > to get the right-hand-side contributions. Is there any way to do this
> > > efficiently for N_T (number of time-steps) boundary conditions?
> >
> > I would advice to use the ConstraintMatrix class for that, see step-22.
> 
> Well, if the boundary conditions change in every time step, I don't
> think ConstraintMatrix is very efficient: One would need to hold a
> ConstraintMatrix with other constraints (e.g. hanging nodes), copy that
> over to the actual constraint matrix _in every time step_, insert the
> boundary conditions, and then close that constraint matrix. In the
> assembly loop, one can use the call
> 
>  ConstraintMatrix::distribute_local_to_global
>        (local_vector, local_dof_indices, rhs_vector, local_matrix)
> 
> Reference:
> http://www.dealii.org/developer/doxygen/deal.II/classConstraintMatrix.html#a70f344e871f346e5c9e7b234bc9dd0ee
> 
> There one only needs to compute the columns in local matrix associated
> with inhomogeneously constrained entries (check with
> CM::is_inhomogeneously_constrained(local_dof_indices[i])), but of course
> they need to be exactly the same as have been filled into the global
> matrix.
> 
> However, this approach of recomputing the constraint matrix in every
> time step might introduce a significant cost, depending on what other
> work is done in each time step (e.g. solution of linear systems). This
> is necessary because the inhomogeneities change from time step to time
> step, and ConstraintMatrix does not have a fast method for updating
> inhomogeneities other than reconstructing the whole thing - at least not
> yet. I have some ideas and would help you with the implementation in
> case you want more efficiency than the approach below.
> 
> In such a case I would say that using apply_boundary_conditions with
> std::map (computed from interpolate_boundary_values in each time step)
> is the best you can do. If the matrix does not change from time step to
> time step, you will need to have two matrices: one without boundary
> values applied, and another one where you copy the content to and apply
> the boundary values from time step to time step.
> 
> Best,
> Martin
> 
> 
> 
> 
> -- 
> Martin Stoll
> Postdoctoral Research Fellow
> Computational Methods in Systems and Control Theory 
> Max Planck Institute for Dynamics of Complex Technical Systems
> 
> Sandtorstr. 1
> D-39106 Magdeburg
> 
> Germany
> 
> Email: [email protected]
> URL : http://www.mpi-magdeburg.mpg.de/people/stollm
> Tel :+49 391 6110 384
> 
> _______________________________________________
> dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to