On 03/17/2017 08:03 AM, Jaekwang Kim wrote:
After the first cycle, I am doing

template<intdim>

voidnonlinear<dim>::refine_grid ()

{


Vector<float> estimated_error_per_cell (triangulation.n_active_cells());

    KellyErrorEstimator<dim>::estimate (dof_handler,

                                        QGauss<dim-1>(3),

                                        typenameFunctionMap<dim>::type(),

                                        solution,

                                        estimated_error_per_cell);

    GridRefinement::refine_and_coarsen_fixed_number (triangulation,

                                                     estimated_error_per_cell,

                                                     0.3, 0.0);





    triangulation.prepare_coarsening_and_refinement ();

    SolutionTransfer<dim> solution_transfer(dof_handler);

    solution_transfer.prepare_for_coarsening_and_refinement(solution);

    triangulation.execute_coarsening_and_refinement(); // I think n_dof() has
increased here. You need to check this if necessary

    dof_handler.distribute_dofs(fe);





    previous_solution.reinit (dof_handler.n_dofs());



    solution_transfer.interpolate(solution, previous_solution);



       DynamicSparsityPattern dsp(dof_handler.n_dofs());

        DoFTools::make_sparsity_pattern (dof_handler, dsp);

        sparsity_pattern.copy_from(dsp);



        solution.reinit (dof_handler.n_dofs());

        system_matrix.reinit (sparsity_pattern);

        system_rhs.reinit (dof_handler.n_dofs());


}


I am sure that I am reinitialize matrixes...
but I am not sure about whether the redline is doing enough for
reinitialization of sparsity pattern....

It looks like it, but it seems like it's not working, and just seeing the little code snippet is not enough for me to tell for sure. You'll have to debug what is going on. My first stab would be: At the beginning of your assembly function, put something like
  Assert (system_matrix.n() == dof_handler.n_dofs(), ExcInternalError());
to verify that indeed your matrix has the right size.

Best
 W.



--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 [email protected]
                           www: http://www.math.colostate.edu/~bangerth/

--
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