After the first cycle, I am doing
template <int dim>
void nonlinear<dim>::refine_grid ()
{
Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
KellyErrorEstimator<dim>::estimate (dof_handler,
QGauss<dim-1>(3),
typename FunctionMap<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....
Jaekwang Kim
2017년 3월 17일 금요일 오전 8시 30분 21초 UTC-5, Wolfgang Bangerth 님의 말:
>
> On 03/16/2017 08:38 PM, Jaekwang Kim wrote:
> >
> > I think this two function do everything I needed... but when I run my
> code, I
> > run into error message when I assemble system in second time.
> > what might be the problem.....?
>
> As the error message says, you are trying to write into a matrix entry
> that
> does not exist. Did you re-initialize the sparsity pattern and matrix
> after
> you refined the mesh?
>
> Best
> W.
>
> --
> ------------------------------------------------------------------------
> Wolfgang Bangerth email: [email protected]
> <javascript:>
> 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.