|
Peano
|
Manage refine/erase requests within ExaHyPE 2. More...
#include <RefinementControl.h>

Data Structures | |
| struct | SiblingEraseEvent |
| Erase request of one cell which knows its parent. More... | |
Public Types | |
| typedef std::list< std::pair< peano4::grid::GridControlEvent, int > > | NewEvents |
| typedef std::list< SiblingEraseEvent > | NewSiblingEraseEvents |
Public Member Functions | |
| RefinementControl (double tolerance=0.01) | |
| virtual | ~RefinementControl () |
| void | clear () |
| Clears the new events, including the sibling erase events. | |
| void | addCommand (const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h, exahype2::RefinementCommand command, int lifetime) |
| Add a new command. | |
| void | addCommand (const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h, exahype2::RefinementCommand command, int lifetime, const tarch::la::Vector< Dimensions, int > &relativePositionWithinFatherCell) |
| Add a new command of a cell which knows its position within its parent. | |
| std::string | toString () const |
Private Member Functions | |
| peano4::grid::GridControlEvent | createEraseEvent (const tarch::la::Vector< Dimensions, double > &x, const tarch::la::Vector< Dimensions, double > &h) const |
| Construct the grid control event which erases the cell with centre x and size h. | |
Private Attributes | |
| const double | _Tolerance |
| We blow up the region around refinement criterion slightly. | |
| NewEvents | _newEvents |
| Container to accumulate new events. | |
| NewSiblingEraseEvents | _newSiblingEraseEvents |
| Erase requests of cells which know their parent,. | |
Static Private Attributes | |
| static tarch::logging::Log | _log |
| static tarch::multicore::BooleanSemaphore | _semaphore |
Friends | |
| class | RefinementControlService |
Manage refine/erase requests within ExaHyPE 2.
This class is a very simple container which collects a point set of refinement and coarsening commands. It then constructs bounding boxes for each command and returns the bounding boxes to Peano 4.
Note: Peano will internally decide to merge many many bounding boxes into fewer, larger ones.
We have a two stage refinement process in ExaHyPE. These are ExaHyPE-specific stages and they have nothing to do with the fact that we always trigger the refinement and then refine in the subsequent grid sweep, i.e. it has nothing do do with the fact that ExaHyPE needs two grid sweeps to realise (commit) adaptive mesh refinement:
ExaHyPE first collects all refinement requests within this class. These events are called new events. After the sweep, we roll over the refinement requests. We commit them. These committed events then are delivered to the grid traversal automaton. finishStep() does the roll-over, the delivery happens once you call createGridControlEventsForNextTraversal() through the AMR observer.
Hence, the overall refinement spawns three grid traversals:
Due to the overall three-step mechanism, we make the bookkeeping of the events persistent. Each event can potentially survive a couple of sets within the new events. It is rolled over multiple times until it "expires" within the new events.
As we use the class within a multithreaded environment, Peano 4 creates an observer object per spacetree through a clone from observer no -1 (per rank, so this observer is not really an observer. It is rather an observer prototype) and then asks this observer how to refine. So we design the following pattern:
Definition at line 97 of file RefinementControl.h.
| typedef std::list< std::pair<peano4::grid::GridControlEvent,int> > exahype2::RefinementControl::NewEvents |
Definition at line 99 of file RefinementControl.h.
| typedef std::list< SiblingEraseEvent > exahype2::RefinementControl::NewSiblingEraseEvents |
Definition at line 121 of file RefinementControl.h.
| exahype2::RefinementControl::RefinementControl | ( | double | tolerance = 0.01 | ) |
| tolerance | How much should the code add around each grid control. By default we use one percent additional tolerance. |
|
virtual |
| void exahype2::RefinementControl::addCommand | ( | const tarch::la::Vector< Dimensions, double > & | x, |
| const tarch::la::Vector< Dimensions, double > & | h, | ||
| exahype2::RefinementCommand | command, | ||
| int | lifetime | ||
| ) |
Add a new command.
Depending on the context, we add a new refinement instruction interpreting x and h. If you refine, I divide h by three.
If a refinement event is triggered, we keep it alive for a while. This avoids oscillations (refinement events always overwrite coarsening) and it helps ranks to catch up - a code might not be able to refine immediately as it implements a Runge-Kutta scheme, e.g. In this case, we keep the event alive and then realise it once the code is ready to do so.
| x | Centre of the cell for which this command is triggered. This is typically marker.x(). |
| h | Size of this cell. Typically marker.h(). |
| lifetime | Has to be greater equal 1. |
| void exahype2::RefinementControl::addCommand | ( | const tarch::la::Vector< Dimensions, double > & | x, |
| const tarch::la::Vector< Dimensions, double > & | h, | ||
| exahype2::RefinementCommand | command, | ||
| int | lifetime, | ||
| const tarch::la::Vector< Dimensions, int > & | relativePositionWithinFatherCell | ||
| ) |
Add a new command of a cell which knows its position within its parent.
Refine and keep commands are handled the same way as by the other addCommand(). An erase command is collected as SiblingEraseEvent instead: The refinement service keeps it only if all 3^d children of the cell's parent have asked to be erased within the same mesh sweep, and drops it otherwise. Peano could not realise an incomplete set of erase requests anyway, and such requests would only trigger mesh sweeps which do not change the mesh.
| relativePositionWithinFatherCell | Position of the cell within its parent, typically marker.getRelativePositionWithinFatherCell(). Each entry is 0, 1 or 2. |
| void exahype2::RefinementControl::clear | ( | ) |
Clears the new events, including the sibling erase events.
Has no affect for the committed events. This routine should only ever be called by the action sets on their local refinement control assembly. The global one is persistent and should not be cleared by the user, as you would loose all those events that should remain alive. Thererfore, there's no clear for the service.
Referenced by peano4.api.output.Makefile.Makefile::__init__().

|
private |
Construct the grid control event which erases the cell with centre x and size h.
| std::string exahype2::RefinementControl::toString | ( | ) | const |
|
friend |
Definition at line 123 of file RefinementControl.h.
|
staticprivate |
Definition at line 198 of file RefinementControl.h.
|
private |
Container to accumulate new events.
This is a list as we may assume that a lot of inserts are done per iteration.
Definition at line 211 of file RefinementControl.h.
|
private |
Erase requests of cells which know their parent,.
Definition at line 216 of file RefinementControl.h.
|
staticprivate |
Definition at line 200 of file RefinementControl.h.
|
private |
We blow up the region around refinement criterion slightly.
Definition at line 205 of file RefinementControl.h.