.. _Chap:CellTagger: CellTagger =========== The ``CellTagger`` class is responsible for flagging grid cells for refinement or coarsening, and is thus the main class that determines what the grids look like. By default, ``CellTagger`` does not actually flag anything for refinement, so if the user wants to implement a new refinement or coarsening routine, one must do so by writing a new derived class from ``CellTagger``. The ``CellTagger`` parent class is a stand-alone class - it does not have a view of :ref:`Chap:AmrMesh`, :ref:`Chap:Driver`, or :ref:`Chap:TimeStepper` and the user is responsible for providing ``CellTagger`` with these dependencies. .. tip:: Here is the `CellTagger C++ API `_ Refinement flags live in a data holder called ``EBAMRTags``, which is a typedef: .. code-block:: c++ typedef Vector > > EBAMRTags; See :ref:`Chap:Basics` for an explanation of how the individual templates. Briefly, the outer vector in ``EBAMRTags`` indicates the grid level, whereas ``LayoutData`` is a data holder on each grid level and indexes the grid patches. That is, ``LayoutData_lo`` and ``ref_box_hi`` that determine the Cartesian region to be refined. Here, ```` is a placeholder for an integer. If the user specifies ``num_ref_boxes = 2``, then ``ref_box1_lo``, ``ref_box1_hi``, ``ref_box2_lo``, and ``ref_box2_hi`` must all be defined. * ``ref_box_lvl``, which specifies the refinement depth corresponding to box ````. An example of the manual refinement syntax is given in :numref:`CellTaggerOptions`. .. _CellTaggerOptions: .. literalinclude:: ../../../../Source/CellTagger/CD_CellTagger.options :caption: Default class options for ``CellTagger``, including the manual refinement syntax and buffer region definition. :language: text It is possible to prevent ``CellTagger`` from adding refinement flags in specified regions by specifying ``num_tag_boxes``. The default behavior is to add a number of boxes where refinement and coarsening is allowed, and prevent tags from being generated outside of these regions. If no boxes are defined, tagging is allowed everywhere. The syntax is the same as for ``num_ref_boxes``, e.g., one must define ``tag_box_lo`` and ``tag_box_hi``. By adding restrictive boxes, tagging will only be allowed inside the specified box corners ``tag_box1_lo`` and ``tag_box1_hi``. More boxes can be specified by following the same convention, e.g., ``tag_box2_lo`` and ``tag_box2_hi``. Adding a buffer --------------- By default, each MPI rank can only tag grid cells where it owns data, which has has been enforced due to performance and communication reasons. Under the hood, the ``DenseIntVectSet`` is an array of boolean values on a patch which is very fast and simple to communicate with MPI. Adding a grid cell for refinement which lies outside the patch will lead to memory corruptions. Frequently, however, it is necessary to add *buffer regions* to ensure that an area-of-interest around the tagged region is also refined. This is done by growing the final generated tags by specifying the ``buffer``. The syntax for this is given in :numref:`CellTaggerOptions`. Just before passing the flags into ``AmrMesh`` grid generation routines, the tagged cells are put into a different data holder (``IntVectSet``), and this data holder *can* contain cells that are outside the patch boundaries.