Peano
|
Manage refine/erase requests within ExaHyPE 2. More...
#include <RefinementControl.h>
Public Types | |
typedef std::list< std::pair< peano4::grid::GridControlEvent, int > > | NewEvents |
Public Member Functions | |
RefinementControl (double tolerance=0.01) | |
virtual | ~RefinementControl () |
void | clear () |
Clears the new 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. | |
std::string | toString () const |
Private Attributes | |
const double | _Tolerance |
We blow up the region around refinement criterion slightly. | |
NewEvents | _newEvents |
Container to accumulate new events. | |
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 getGridControlEvents() 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.
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. |
Definition at line 45 of file RefinementControl.cpp.
|
virtual |
Definition at line 50 of file RefinementControl.cpp.
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. |
Definition at line 59 of file RefinementControl.cpp.
References assertion, assertionNumericalEquals1, peano4::grid::GridControlEvent::Erase, peano4::grid::GridControlEvent::getH(), peano4::grid::GridControlEvent::getWidth(), logDebug, logTraceInWith3Arguments, logTraceOutWith1Argument, peano4::grid::GridControlEvent::Refine, peano4::grid::GridControlEvent::toString(), and toString().
void exahype2::RefinementControl::clear | ( | ) |
Clears the new 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.
Definition at line 54 of file RefinementControl.cpp.
Referenced by peano4.output.Makefile.Makefile::__init__().
std::string exahype2::RefinementControl::toString | ( | ) | const |
Definition at line 115 of file RefinementControl.cpp.
|
friend |
Definition at line 101 of file RefinementControl.h.
|
staticprivate |
Definition at line 153 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 166 of file RefinementControl.h.
Referenced by exahype2::RefinementControlService::merge().
|
staticprivate |
Definition at line 155 of file RefinementControl.h.
|
private |
We blow up the region around refinement criterion slightly.
Definition at line 160 of file RefinementControl.h.