Peano
Loading...
Searching...
No Matches
grid.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include <list>
6#include <map>
7#include <set>
8#include <vector>
9
10#include "GridVertex.h"
11
12namespace peano4 {
36
39
40 static std::string toString(Mode mode);
41 std::string toString() const;
42 };
43
44 typedef std::map<int, SplitInstruction> SplitSpecification;
45
71 namespace grid {
75 struct GridStatistics;
76 struct GridControlEvent;
77
78 struct AutomatonState;
79 struct GridControlEvent;
80
81 struct GridVertex;
82
87 void clear(GridStatistics& statistics, bool isGlobalMasterTree);
88
178 std::vector<GridControlEvent> merge(std::vector<GridControlEvent> events, const double Tolerance = 0.1);
179
203 GridVertex createVertex(
206 int level,
207 const tarch::la::Vector<TwoPowerD, int>& adjacentRanks,
208 bool isNewFineGridVertex
209 );
210
224 bool isSpacetreeNodeRefined(GridVertex vertices[TwoPowerD]);
225
230 bool willVertexBeRefined(const GridVertex& vertex);
231
236 bool hasVertexBeenRefined(const GridVertex& vertex);
237
245 std::bitset<TwoPowerD> willVerticesBeRefined(GridVertex vertices[TwoPowerD]);
246 std::bitset<TwoPowerD> haveVerticesBeenRefined(GridVertex vertices[TwoPowerD]);
247
263 GridVertex vertices[TwoPowerD], bool splittingIsConsideredLocal, bool joiningIsConsideredLocal, int id
264 );
265
267
269
270 enum class CellType { New, Persistent, Delete };
271
272 std::string toString(VertexType type);
273 std::string toString(FaceType type);
274 std::string toString(CellType type);
275
276 constexpr int InvalidRank(-1);
277
278 enum class SpacetreeState {
285 EmptyRun,
286 NewRoot,
293 Running,
300 Joining,
301 Joined
302 };
303
304 std::string toString(SpacetreeState state);
305
306 bool overlaps(const tarch::la::Vector<Dimensions, double>& x, const GridControlEvent& event);
307 bool overlaps(const AutomatonState& x, const GridControlEvent& event);
308
315 bool isContained(const AutomatonState& x, const GridControlEvent& event, double upscaleAutomatonState = 1.0);
316
326 void reduceGridControlEvents(std::vector<GridControlEvent>& events);
327
328 std::string toString(const std::vector<GridControlEvent>& events);
329 std::string toString(const std::list<GridControlEvent>& events);
330
331 namespace internal {
340 const std::list<peano4::grid::GridControlEvent>& refineEvents,
341 std::list<peano4::grid::GridControlEvent>& eraseEvents
342 );
343
361 void mergeAdjacentRefinementEvents(std::list<peano4::grid::GridControlEvent>& inputEvents, int Tolerance);
362
367
369
377 const peano4::grid::GridControlEvent& refineEvent, const peano4::grid::GridControlEvent& eraseEvent
378 );
379
390 const peano4::grid::GridControlEvent& lhs, const peano4::grid::GridControlEvent& rhs, double Tolerance
391 );
392
422 void sort(std::list<peano4::grid::GridControlEvent>& events);
423
426 );
427 } // namespace internal
428 } // namespace grid
429} // namespace peano4
430
432
433std::ostream& operator<<(std::ostream& out, const peano4::SplitInstruction& instruction);
434std::ostream& operator<<(std::ostream& out, const peano4::SplitInstruction::Mode& mode);
#define TwoPowerD
Definition Globals.h:19
AutomatonState state
bool twoEventsAreAdjacent(const peano4::grid::GridControlEvent &lhs, const peano4::grid::GridControlEvent &rhs, double Tolerance)
Are two events adjacent.
Definition grid.cpp:368
void mergeAdjacentRefinementEvents(std::list< peano4::grid::GridControlEvent > &inputEvents, int Tolerance)
Merge adjacent events.
Definition grid.cpp:183
void removeEraseEventsThatAreCancelledByRefineEvents(const std::list< peano4::grid::GridControlEvent > &refineEvents, std::list< peano4::grid::GridControlEvent > &eraseEvents)
This is the first thing I do.
Definition grid.cpp:166
bool refinementEventOverrulesCoarsening(const peano4::grid::GridControlEvent &refineEvent, const peano4::grid::GridControlEvent &eraseEvent)
A refinement event overrules the coarsening if.
Definition grid.cpp:359
peano4::grid::GridControlEvent createBoundingBoxEvent(const peano4::grid::GridControlEvent &lhs, const peano4::grid::GridControlEvent &rhs)
Definition grid.cpp:384
void sort(std::list< peano4::grid::GridControlEvent > &events)
Sort grid control events geometrically.
Definition grid.cpp:150
bool twoEventsOverlap(const peano4::grid::GridControlEvent &lhs, const peano4::grid::GridControlEvent &rhs)
Helper function which helps us throughout the merge.
Definition grid.cpp:336
bool equals(const peano4::grid::GridControlEvent &lhs, const peano4::grid::GridControlEvent &rhs)
Definition grid.cpp:347
bool isSpacetreeNodeRefined(GridVertex vertices[TwoPowerD])
A spacetree node is refined if any of its adjacent vertices holds one of the following flags:
Definition grid.cpp:241
std::string toString(VertexType type)
Definition grid.cpp:276
bool isSpacetreeNodeLocal(GridVertex vertices[TwoPowerD], bool splittingIsConsideredLocal, bool joiningIsConsideredLocal, int id)
A spacetree node as 2^d adjacent vertices.
void clear(GridStatistics &statistics, bool isGlobalMasterTree)
The term clear() is not 100% correct, as the number of stationary traversals is not reset to a dummy ...
Definition grid.cpp:230
void reduceGridControlEvents(std::vector< GridControlEvent > &events)
Peano 4 does not reduce any grid control events globally.
Definition grid.cpp:394
GridVertex createVertex(GridVertex::State state, const tarch::la::Vector< Dimensions, double > &x, int level, const tarch::la::Vector< TwoPowerD, int > &adjacentRanks, bool isNewFineGridVertex)
Factory mechanism.
Definition grid.cpp:61
@ NewFromSplit
Set if this tree results from a split and if this is the first grid sweep when the former owner actua...
@ JoinTriggered
Join has been triggered for this tree.
@ EmptyRun
Not yet a new root.
std::bitset< TwoPowerD > haveVerticesBeenRefined(GridVertex vertices[TwoPowerD])
Definition grid.cpp:267
bool overlaps(const tarch::la::Vector< Dimensions, double > &x, const GridControlEvent &event)
Definition grid.cpp:56
std::bitset< TwoPowerD > willVerticesBeRefined(GridVertex vertices[TwoPowerD])
A vertex is unrefined if it is hanging.
Definition grid.cpp:258
constexpr int InvalidRank(-1)
bool hasVertexBeenRefined(const GridVertex &vertex)
A vertex has been refined if it is (already) refined or is erasing or the erase has been triggered.
Definition grid.cpp:253
std::vector< GridControlEvent > merge(std::vector< GridControlEvent > events, const double Tolerance=0.1)
Merge set of refinement/coarsening commands.
Definition grid.cpp:112
bool willVertexBeRefined(const GridVertex &vertex)
A vertex will be refined if it is already refined or currently refining.
Definition grid.cpp:248
bool isContained(const AutomatonState &x, const GridControlEvent &event, double upscaleAutomatonState=1.0)
isContained() is defined over the closed interval, i.e.
Definition grid.cpp:40
std::map< int, SplitInstruction > SplitSpecification
Definition grid.h:44
peano4::grid::GridStatistics operator+(peano4::grid::GridStatistics lhs, peano4::grid::GridStatistics rhs)
Definition grid.cpp:217
std::ostream & operator<<(std::ostream &out, const peano4::SplitInstruction &instruction)
Definition grid.cpp:30
Instruction to split.
Definition grid.h:34
std::string toString() const
Definition grid.cpp:24
Simple vector class.
Definition Vector.h:134