Hi Stephen, I know that Wolfgang has already answered you and has mentioned that having the refinement levels differ across periodic interfaces is permitted. At some point I wanted to ensure that they were identical, and I wrote a little function to do that and have pasted it below just in case its of any use to you. From this part of you question
> elements on opposite sides of linked boundaries to be of the same size > locally otherwise the constraints won't match I’m curious to know if you mean that the elements must be conformal across the interface? There seems to be a wide body of literature that discusses the weak imposition of periodic constraints, so I guess if you take that approach then there’s (probably) no specific requirements for the mesh to match across the interface. Best, Jean-Paul template <int dim> void add_periodic_refinement_signals(Triangulation<dim> &triangulation) { // Before refining we ensure that periodic face pairs have the same // refinement flag. { auto signal_periodic_faces_symmetric_marking = [&triangulation]() -> void { for (typename Triangulation<dim>::active_cell_iterator cell = triangulation.begin_active(); cell != triangulation.end(); ++cell) { for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face) { if (cell->has_periodic_neighbor(face)) { if (cell->refine_flag_set()) { cell->periodic_neighbor(face)->clear_coarsen_flag(); cell->periodic_neighbor(face)->set_refine_flag(); } else if (cell->periodic_neighbor(face)->refine_flag_set()) { cell->clear_coarsen_flag(); cell->set_refine_flag(); } else if (cell->coarsen_flag_set()) { cell->periodic_neighbor(face)->clear_refine_flag(); cell->periodic_neighbor(face)->set_coarsen_flag(); } else if (cell->periodic_neighbor(face)->coarsen_flag_set()) { cell->clear_refine_flag(); cell->set_coarsen_flag(); } } } } // Its quite possible that, after all of this, we violate some // of the 2:1 cell level ratio expectations... Thats this error: // An error occurred in line <12816> of file <.../dealii/source/grid/tria.cc> in function // virtual bool dealii::Triangulation<2, 2>::prepare_coarsening_and_refinement() [dim = 2, spacedim = 2] // The violated condition was: // cell_is_patch_level_1(cell) // To fix this, we make the following call: triangulation.prepare_coarsening_and_refinement(); }; // Add signals triangulation.signals.pre_refinement.connect(signal_periodic_faces_symmetric_marking); } } > On 7. Apr 2021, at 20:24, Stephen <smetcalfe...@gmail.com> wrote: > > Hi all, > > Has anyone here successfully implemented mesh refinement for problems with > (spatial) periodic boundary conditions before? If so, I'd welcome ideas on > the best way to approach the problem. As far as I can tell, it is a > requirement in deal.II for the elements on opposite sides of linked > boundaries to be of the same size locally otherwise the constraints won't > match and, I'd imagine, bad things would happen. What is the best way to > maintain these constraints assuming an arbitrary refinement vector? I'm > thinking the best approach is to just refine the mesh as normal then "patch > it up" through a second sweep to ensure the mesh sizes on opposite sides of > the linked boundaries are the same by forcing additional refinement if > necessary. > > Thanks, > > Stephen > > -- > The deal.II project is located at http://www.dealii.org/ > <http://www.dealii.org/> > For mailing list/forum options, see > https://groups.google.com/d/forum/dealii?hl=en > <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 dealii+unsubscr...@googlegroups.com > <mailto:dealii+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/21c92dac-55de-4ef8-89c7-f3aee063c1a4n%40googlegroups.com > > <https://groups.google.com/d/msgid/dealii/21c92dac-55de-4ef8-89c7-f3aee063c1a4n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 dealii+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/A011D86F-D7F0-4D55-B020-133052B29260%40gmail.com.