My apologies for a delayed reply as I was pondering on a good way to replicate the problem without bogging you down with the unnecessary dependencies in my program. So what I come up with is to adapt the step-22 by adding a particle handler object and mimic what is done in step-19. I was able to reproduce the error for refinement. I am working on a way to reproduce the error for coarsening. The overall idea is:
--------------------------------------------------------
An error occurred in line <495> of file </home/wuqihang/.local/src/dealii-9.2.0/include/deal.II/grid/tria_iterator.templates.h> in function
dealii::TriaActiveIterator<Accessor>& dealii::TriaActiveIterator<Accessor>::operator=(const dealii::TriaIterator<Accessor>&) [with Accessor = dealii::CellAccessor<2, 2>]
The violated condition was:
this->accessor.has_children() == false
Additional information:
(none)
Stacktrace:
-----------
#0 /home/wuqihang/.local/lib/libdeal_II.g.so.9.2.0: dealii::TriaActiveIterator<dealii::CellAccessor<2, 2> >::operator=(dealii::TriaIterator<dealii::CellAccessor<2, 2> > const&)
#1 /home/wuqihang/.local/lib/libdeal_II.g.so.9.2.0: dealii::Particles::ParticleHandler<2, 2>::update_cached_numbers()
#2 /home/wuqihang/.local/lib/libdeal_II.g.so.9.2.0: dealii::Particles::ParticleHandler<2, 2>::sort_particles_into_subdomains_and_cells()
#3 /home/wuqihang/Dropbox/Coding/DEAL.II/Step22ParticlesAMR/build/step-22_PtclAMR: Step22::StokesParticles<2, double>::move_particles()
#4 /home/wuqihang/Dropbox/Coding/DEAL.II/Step22ParticlesAMR/build/step-22_PtclAMR: Step22::StokesProblem<2>::second_step()
#5 /home/wuqihang/Dropbox/Coding/DEAL.II/Step22ParticlesAMR/build/step-22_PtclAMR: Step22::StokesProblem<2>::run()
#6 /home/wuqihang/Dropbox/Coding/DEAL.II/Step22ParticlesAMR/build/step-22_PtclAMR: main
--------------------------------------------------------
My limited understanding is that after the grid refinement the particle is not correctly associated with the finer child cell. I have not setup the callback function in dealii::Triangulation for this test because the dynamic_cast in the callback functions will throw an error anyways. What I will try now is to follow Bruno's advice to remove dynamic_cast in the callback functions and see what happens. I will report back if I shall make any progress.
I very much appreciate your time bearing with me and I look forward to helping out to fix the problem.
Qihang.