Pārlūkot izejas kodu

Added comment in model trace

gbeurier 7 gadi atpakaļ
vecāks
revīzija
23132e8adf

+ 3 - 2
src/artis/kernel/AbstractAtomicModel.hpp

@@ -174,12 +174,13 @@ public:
         state.last_time(type::last_time);
     }
 
-    virtual void trace_element(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    virtual void trace_element(typename U::type t, utils::TraceType type = utils::KERNEL, std::string comment = "") const
     {
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >(
                   AbstractAtomicModel < T, U, V >::path(this),
-                   t, type);
+                   t, type)
+            << comment;;
         utils::Trace < utils::DoubleTime >::trace().flush();
     }
 

+ 3 - 2
src/artis/kernel/AbstractCoupledModel.hpp

@@ -324,12 +324,13 @@ public:
         Externals < T, U, V >::save(this, state);
     }
 
-    virtual void trace_element(typename U::type t, utils::TraceType type = utils::KERNEL) const
+    virtual void trace_element(typename U::type t, utils::TraceType type = utils::KERNEL, std::string comment = "") const
     {
         utils::Trace < utils::DoubleTime >::trace()
             << utils::TraceElement < utils::DoubleTime >(
                   AbstractCoupledModel < T, U, V, W >::path(this),
-                   t, type);
+                   t, type)
+            << comment;
         utils::Trace < utils::DoubleTime >::trace().flush();
     }
 

+ 1 - 1
src/artis/kernel/AbstractModel.hpp

@@ -131,7 +131,7 @@ public:
 
     virtual void save(context::State < Time >& state) const = 0;
 
-    virtual void trace_element(typename Time::type t, utils::TraceType type) const = 0;
+    virtual void trace_element(typename Time::type t, utils::TraceType type, std::string comment = "") const = 0;
     virtual void trace_internals(typename Time::type t, utils::TraceType type) const = 0;
     virtual void trace_externals(typename Time::type t, utils::TraceType type) const = 0;
     virtual void trace_model(typename Time::type t, utils::TraceType type) const = 0;

+ 12 - 13
src/test/models.hpp

@@ -69,16 +69,16 @@ public:
 
     void compute(double t, bool /* update */)
     {
-        ::Trace::trace() << ::TraceElement("A", t, artis::utils::COMPUTE);
-        ::Trace::trace() << "Start";
+        ::Trace::trace() << ::TraceElement("A", t, artis::utils::COMPUTE)
+                         << "Start";
         ::Trace::trace().flush();
 
         ++_ix;
         _bx = not _bx;
         ++_dx;
 
-        ::Trace::trace() << ::TraceElement("A", t, artis::utils::COMPUTE);
-        ::Trace::trace() << "Stop";
+        ::Trace::trace() << ::TraceElement("A", t, artis::utils::COMPUTE)
+                         << "Stop";
         ::Trace::trace().flush();
 
     }
@@ -125,8 +125,8 @@ public:
 
     void compute(double t, bool /* update */)
     {
-        ::Trace::trace() << ::TraceElement("B", t, artis::utils::COMPUTE);
-        ::Trace::trace() << "Start";
+        ::Trace::trace() << ::TraceElement("B", t, artis::utils::COMPUTE)
+                         << "Start";
         ::Trace::trace().flush();
 
         _iy = _ix + 1;
@@ -134,8 +134,8 @@ public:
         _dy = _dx + 1;
         ++_n;
 
-        ::Trace::trace() << ::TraceElement("B", t, artis::utils::COMPUTE);
-        ::Trace::trace() << "Stop";
+        ::Trace::trace() << ::TraceElement("B", t, artis::utils::COMPUTE)
+                         << "Stop";
         ::Trace::trace().flush();
 
     }
@@ -192,8 +192,8 @@ public:
 
     void compute(double t, bool /* update */)
     {
-        ::Trace::trace() << ::TraceElement("ROOT", t, artis::utils::COMPUTE);
-        ::Trace::trace() << "Start";
+        ::Trace::trace() << ::TraceElement(this->path(this), t, artis::utils::COMPUTE)
+                         << "Start";
         ::Trace::trace().flush();
         (*_a)(t);
         _b->put < double >(t, BModel::DX, _a->get < double >(t, AModel::DX));
@@ -203,9 +203,8 @@ public:
 
         ++_n;
 
-        ::Trace::trace() << ::TraceElement("ROOT", t, artis::utils::COMPUTE);
-        ::Trace::trace() << "Stop";
-        ::Trace::trace().flush();
+
+        this->trace_element(t, artis::utils::COMPUTE, "Stop");
 
     }