Dear Prof. Wolfgang,
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?
question No.2 : what differences between triangulation and
triangulation_active? (solved)
The definition of these two are:
GridGenerator::hyper_cube (triangulation_active, 0, 4.5);
triangulation_active.refine_global (8);
GridGenerator::flatten_triangulation (triangulation_active,
triangulation);
By using GridGenerator::flatten_triangulation, the level of triangulation
is 0, i.e. the coarsest mesh, which is used when define a periodic boundary
conditions. So triangulation.n_levels() is always 0. and cannot use
triangulation when determine which cell to be coarsen or refined:
if (triangulation.n_levels() > max_grid_level)
> for (typename Triangulation<dim>::active_cell_iterator
> cell = triangulation.begin_active(max_grid_level);
> cell != triangulation.end(); ++cell)
> cell->clear_refine_flag ();
So if we not only want to use triangulation.n_levels() like above,but also
want to use the coarsest mesh to define periodic boundary conditions, we
should learn from step-45, like this:
GridGenerator::hyper_cube (triangulation, 0, 4.5);
for (typename Triangulation<dim>::active_cell_iterator
cell = triangulation.begin_active();
cell != triangulation.end();
++cell)
{
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell;
++f)
{
if (cell->face(f)->at_boundary())
{
if (std::fabs(cell->face(f)->center()(0) - (4.5))
< 1e-12)
cell->face(f)->set_boundary_id (1);
else if(std::fabs(cell->face(f)->center()(1) -
(0)) < 1e-12)
cell->face(f)->set_boundary_id (2);
else if(std::fabs(cell->face(f)->center()(1)
- (4.5)) < 1e-12)
cell->face(f)->set_boundary_id (3);
else
if(std::fabs(cell->face(f)->center()(0) - (0)) < 1e-12)
{
cell->face(f)->set_boundary_id
(0);
}
}
}
}
triangulation.refine_global (3);
Hope the answer of question No.1. Thanks in advance.
Best,
Chucui
>
--
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.