Peano
Loading...
Searching...
No Matches
Grid-main.cpp
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#include "Grid-main.h"
4
5#include "Constants.h"
6#include "CreateGrid.h"
7#include "EmptyObserver.h"
8#include "peano4/grid/Spacetree.h"
9#include "peano4/grid/TraversalVTKPlotter.h"
10#include "peano4/peano4.h"
11#include "tarch/logging/Log.h"
12#include "tarch/logging/LogFilter.h"
13#include "tarch/timing/Measurement.h"
14#include "tarch/timing/Watch.h"
15
16namespace {
17 tarch::logging::Log _log("");
18
19 tarch::timing::Measurement gridConstructionMeasurement;
20 tarch::timing::Measurement emptyTraversalMeasurement;
21} // namespace
22
23using namespace tests::peano4::grid;
24
25int main(int argc, char** argv) {
26 static tarch::timing::Watch watch("::", "step()", false);
27
28#if DIMENSIONS == 2
29 const auto DomainOffset = {0.0, 0.0};
30 const auto DomainSize = {1.0, 1.0};
31#else
32 const auto DomainOffset = {0.0, 0.0, 0.0};
33 const auto DomainSize = {1.0, 1.0, 1.0};
34#endif
35
36 peano4::init(&argc, &argv, DomainOffset, DomainSize, 0);
37
38 peano4::grid::Spacetree spacetree(DomainOffset, DomainSize, 0);
39
41 int depth = 0;
42 while (spacetree.getGridStatistics().getMinH(0) > MinH) {
43 depth++;
44 watch.start();
45 spacetree.traverse(createGrid, true);
46 watch.stop();
47 logInfo(
48 "main()",
49 "Grid construction for depth="
50 << depth << " with number of cells=" << spacetree.getGridStatistics().getNumberOfLocalRefinedCells() << "/"
51 << spacetree.getGridStatistics().getNumberOfLocalUnrefinedCells() << " [refined/unrefined]"
52 << " took " << watch.getCalendarTime() << " seconds"
53 );
54 gridConstructionMeasurement.setValue(watch.getCalendarTime());
55 }
56
57 EmptyObserver emptyObserver;
58 for (int t = 0; t < 5; t++) {
59 watch.start();
60 spacetree.traverse(emptyObserver, true);
61 watch.stop();
62 logInfo(
63 "main()",
64 "Empty traversal on grid for depth="
65 << depth << " with number of cells=" << spacetree.getGridStatistics().getNumberOfLocalRefinedCells() << "/"
66 << spacetree.getGridStatistics().getNumberOfLocalUnrefinedCells() << " [refined/unrefined]"
67 << " took " << watch.getCalendarTime() << " seconds"
68 );
69 emptyTraversalMeasurement.setValue(watch.getCalendarTime());
70 }
71
72 logInfo(
73 "main()",
74 "Grid construction took " << gridConstructionMeasurement.getAccumulatedValue() << " seconds in total"
75 );
76 logInfo(
77 "main()",
78 "Empty traversals on grid took " << emptyTraversalMeasurement.getAccumulatedValue() << " seconds in total"
79 );
80
81 // peano4::grid::TraversalVTKPlotter plotterObserver("Grid");
82 // spacetree.traverse(plotterObserver);
83
84 peano4::shutdown();
85
86 return EXIT_SUCCESS;
87}
int main(int argc, char **argv)
Definition Grid-main.cpp:25
tarch::timing::Measurement gridConstructionMeasurement
Definition ccz4-main.cpp:57
tarch::logging::Log _log("::")
void createGrid()