From efa2e10e09d51092252e7b9302b204be6922a2f7 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Fri, 6 Jan 2012 13:52:49 +0100
Subject: [PATCH] Stop assembly time

---
 src/one-body-sample.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc
index 12429526..96ff6b43 100644
--- a/src/one-body-sample.cc
+++ b/src/one-body-sample.cc
@@ -19,6 +19,7 @@
 #include <dune/common/parametertreeparser.hh>
 #include <dune/common/shared_ptr.hh>
 #include <dune/common/stdstreams.hh>
+#include <dune/common/timer.hh>
 #include <dune/grid/common/mcmgmapper.hh>
 #include <dune/grid/yaspgrid.hh>
 #include <dune/istl/bcrsmatrix.hh>
@@ -177,6 +178,8 @@ int main(int argc, char *argv[]) {
                                            parset); // FIXME
     Dune::ParameterTreeParser::readOptions(argc, argv, parset);
 
+    Dune::Timer timer;
+
     typedef Dune::FieldVector<double, dim> SmallVector;
     typedef Dune::FieldMatrix<double, dim, dim> SmallMatrix;
     typedef Dune::BCRSMatrix<SmallMatrix> OperatorType;
@@ -219,8 +222,11 @@ int main(int argc, char *argv[]) {
                                P1Basis::LocalFiniteElement> const
     localStiffness(E, nu);
     OperatorType stiffnessMatrix;
+    timer.reset();
     OperatorAssembler<P1Basis, P1Basis>(p1Basis, p1Basis)
         .assemble(localStiffness, stiffnessMatrix);
+    std::cout << "Assembled stiffness matrix in " << timer.elapsed() << "s"
+              << std::endl;
     EnergyNorm<OperatorType, VectorType> energyNorm(stiffnessMatrix);
 
     // Set up the boundary
@@ -304,7 +310,9 @@ int main(int argc, char *argv[]) {
     multigridStep.ignoreNodes_ = &ignoreNodes;
     // }}}
 
-    for (size_t run = 1; run <= parset.get<size_t>("timesteps"); ++run) {
+    timer.reset();
+    auto const timesteps = parset.get<size_t>("timesteps");
+    for (size_t run = 1; run <= timesteps; ++run) {
       if (parset.get<bool>("printProgress")) {
         std::cout << ".";
         std::cout.flush();
@@ -407,6 +415,8 @@ int main(int argc, char *argv[]) {
       u3 += u3_diff;
     }
     std::cout << std::endl;
+    std::cout << "Making " << timesteps << " time steps took "
+              << timer.elapsed() << "s" << std::endl;
 
     // Clean up after the TNNMG solver
     for (auto &x : transferOperators)
-- 
GitLab