Chucui,

Thank you very much for your quick answer! I have thinked about your 
> answers and debuged my code these days, and my question No.1 is still 
> unsolved, and question No.2 has been solved:
>  question No.1 : how to destroy sp efficiently? (unsolved)
> As you say, I can destroy SparsityPattern by using the marked line below, 
> which is " m.reinit(); "
> >{ 
> >   SparseMatrix    m; 
> >   SparsityPattern sp; 
> >   ...fill sp, for example by copying from a DynamicSparsityPattern... 
> >   m.reinit (sp);  // m now points to sp 
> >   ...some more code... 
>
> >   m.reinit();  // *** 
> >}
> But is I use the line directly, which means there isn't anything in the 
> brackets:
> {
>     BlockSparseMatrix system_matrix;
>     BlockSparsityPattern  sparsity_pattern_1;
>     [...]
>     sparsity_pattern_1.copy_from (dsp);
>     system_matrix.reinit (sparsity_pattern_1);
>     [...]
>     system_matrix.reinit ();
> }
>
> And the code cannot run, and the error is shown as :
> error: no matching function for call to 
> ‘dealii::BlockSparseMatrix<double>::reinit()’
>      system_matrix.reinit ();
>
> If I define another BlockSparsityPattern : sparsity_pattern_2; then 
> {
>     BlockSparseMatrix system_matrix;
>     BlockSparsityPattern  sparsity_pattern_1;
>     BlockSparsityPattern  sparsity_pattern_2;
>     [...]
>     sparsity_pattern_1.copy_from (dsp);
>     sparsity_pattern_2.copy_from (dsp);
>     system_matrix.reinit (sparsity_pattern_1);
>     [...]
>     system_matrix.reinit (sparsity_pattern_2);
> }
> So the sparsity_pattern_1 is destroyed, but sparsity_pattern_2 cannot to 
> be destroyed, there is a BlockSparsityPattern object cannot be destroyed 
> in each time step, How to deal with it?
>

You can define your sparsity pattern before your matrix such that it is 
destroyed after the matrix. An alternative is to call SparseMatrix::clear() 
instead of SparseMatrix::reinit() in you code.

Best,
Daniel

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to