|
@@ -36,6 +36,9 @@
|
|
|
|
|
|
namespace artis { namespace kernel {
|
|
namespace artis { namespace kernel {
|
|
|
|
|
|
|
|
+template < typename T, typename U, typename V, typename W >
|
|
|
|
+class Simulator;
|
|
|
|
+
|
|
template < typename T, typename U, typename V, typename W >
|
|
template < typename T, typename U, typename V, typename W >
|
|
class AbstractCoupledModel : public AbstractModel < U, V >,
|
|
class AbstractCoupledModel : public AbstractModel < U, V >,
|
|
public States < T, U, V >,
|
|
public States < T, U, V >,
|
|
@@ -49,45 +52,60 @@ class AbstractCoupledModel : public AbstractModel < U, V >,
|
|
typedef std::map < int, std::pair < type*,
|
|
typedef std::map < int, std::pair < type*,
|
|
int > > SubModelInternals;
|
|
int > > SubModelInternals;
|
|
|
|
|
|
|
|
+ using Externals < T, U, V >::restore;
|
|
|
|
+ using Internals < T, U, V >::restore;
|
|
|
|
+ using States < T, U, V >::restore;
|
|
|
|
+ using Externals < T, U, V >::save;
|
|
|
|
+ using Internals < T, U, V >::save;
|
|
|
|
+ using States < T, U, V >::save;
|
|
|
|
+
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ friend class Simulator < T, U, V, W >;
|
|
|
|
+#endif
|
|
|
|
+
|
|
public:
|
|
public:
|
|
struct Var
|
|
struct Var
|
|
{
|
|
{
|
|
unsigned int index;
|
|
unsigned int index;
|
|
type* model;
|
|
type* model;
|
|
int sub_index;
|
|
int sub_index;
|
|
|
|
+ std::string var_name;
|
|
|
|
+ std::string sub_var_name;
|
|
|
|
|
|
- Var (unsigned int index, type* model, int sub_index) :
|
|
|
|
- index(index), model(model), sub_index(sub_index)
|
|
|
|
|
|
+ Var (unsigned int index, std::string var_name,
|
|
|
|
+ type* model, int sub_index, std::string sub_var_name) :
|
|
|
|
+ index(index), model(model), sub_index(sub_index),
|
|
|
|
+ var_name(var_name), sub_var_name(sub_var_name)
|
|
{ }
|
|
{ }
|
|
};
|
|
};
|
|
|
|
|
|
AbstractCoupledModel(const type* parent = 0) : type(parent)
|
|
AbstractCoupledModel(const type* parent = 0) : type(parent)
|
|
- { }
|
|
|
|
|
|
+ {
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ true,
|
|
|
|
+ boost::core::demangle(typeid(T).name()),
|
|
|
|
+ utils::DoubleTime::null,
|
|
|
|
+ utils::CONSTRUCT);
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
|
|
virtual ~AbstractCoupledModel()
|
|
virtual ~AbstractCoupledModel()
|
|
- { }
|
|
|
|
|
|
+ {
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ trace_element(true, utils::DoubleTime::null,
|
|
|
|
+ utils::DESTRUCT);
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
|
|
virtual void after(typename U::type t)
|
|
virtual void after(typename U::type t)
|
|
{
|
|
{
|
|
|
|
|
|
#ifdef WITH_TRACE
|
|
#ifdef WITH_TRACE
|
|
- utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
- << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
|
|
|
|
- utils::KERNEL)
|
|
|
|
- << "AFTER - "
|
|
|
|
- << AbstractCoupledModel < T, U, V, W >::path(this);
|
|
|
|
- utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
- for (size_t i = 0; i < Internals < T, U, V >::size(); ++i) {
|
|
|
|
- if (not Internals < T, U, V >::get(i).is_null()) {
|
|
|
|
- utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
- << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
|
|
|
|
- utils::KERNEL)
|
|
|
|
- << Internals < T, U, V >::name(i) << " = "
|
|
|
|
- << Internals < T, U, V >::get(i).to_string(
|
|
|
|
- dynamic_cast < const T* >(this));
|
|
|
|
- utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ trace_element(true, t, utils::AFTER_COMPUTE);
|
|
|
|
+ trace_internals(true, t, utils::AFTER_COMPUTE);
|
|
#else
|
|
#else
|
|
(void) t;
|
|
(void) t;
|
|
#endif
|
|
#endif
|
|
@@ -110,23 +128,9 @@ public:
|
|
{
|
|
{
|
|
|
|
|
|
#ifdef WITH_TRACE
|
|
#ifdef WITH_TRACE
|
|
- utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
- << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
|
|
|
|
- utils::KERNEL)
|
|
|
|
- << "BEFORE - "
|
|
|
|
- << AbstractCoupledModel < T, U, V, W >::path(this);
|
|
|
|
- utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
- for (size_t i = 0; i < Internals < T, U, V >::size(); ++i) {
|
|
|
|
- if (not Internals < T, U, V >::get(i).is_null()) {
|
|
|
|
- utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
- << utils::TraceElement < utils::DoubleTime >("KERNEL", t,
|
|
|
|
- utils::KERNEL)
|
|
|
|
- << Internals < T, U, V >::name(i) << " = "
|
|
|
|
- << Internals < T, U, V >::get(i).to_string(
|
|
|
|
- dynamic_cast < const T* >(this));
|
|
|
|
- utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ trace_element(true, t, utils::BEFORE_COMPUTE);
|
|
|
|
+ trace_internals(true, t, utils::BEFORE_COMPUTE);
|
|
|
|
+ trace_externals(true, t, utils::BEFORE_COMPUTE);
|
|
#else
|
|
#else
|
|
(void) t;
|
|
(void) t;
|
|
#endif
|
|
#endif
|
|
@@ -348,37 +352,136 @@ public:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ virtual void trace_element(typename U::type t,
|
|
|
|
+ utils::TraceType type = utils::NONE,
|
|
|
|
+ std::string comment = "") const
|
|
|
|
+ { trace_element(false, t, type, comment); }
|
|
|
|
+
|
|
|
|
+ virtual void trace_internals(typename U::type t,
|
|
|
|
+ utils::TraceType type) const
|
|
|
|
+ { trace_internals(false, t, type); }
|
|
|
|
+
|
|
|
|
+ virtual void trace_externals(typename U::type t,
|
|
|
|
+ utils::TraceType type = utils::NONE) const
|
|
|
|
+ { trace_externals(false, t, type); }
|
|
|
|
+
|
|
|
|
+ virtual void trace_model(typename U::type t,
|
|
|
|
+ utils::TraceType type = utils::NONE) const
|
|
|
|
+ { trace_model(false, t, type); }
|
|
|
|
+
|
|
|
|
+private:
|
|
|
|
+ void trace_element(bool from_kernel, typename U::type t,
|
|
|
|
+ utils::TraceType type = utils::NONE,
|
|
|
|
+ std::string comment = "") const
|
|
|
|
+ {
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ from_kernel,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ t, type)
|
|
|
|
+ << comment;
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void trace_internals(bool from_kernel, typename U::type t,
|
|
|
|
+ utils::TraceType type) const
|
|
|
|
+ {
|
|
|
|
+ for (size_t i = 0; i < Internals < T, U, V >::size(); ++i) {
|
|
|
|
+ if (not Internals < T, U, V >::get(i).is_null()) {
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ from_kernel,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ t, type)
|
|
|
|
+ << utils::KernelInfo(
|
|
|
|
+ Internals < T, U, V >::name(i), true,
|
|
|
|
+ Internals < T, U, V >::get(i).to_string(
|
|
|
|
+ dynamic_cast < const T* >(this))
|
|
|
|
+ );
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void trace_externals(bool from_kernel, typename U::type t,
|
|
|
|
+ utils::TraceType type = utils::NONE) const
|
|
|
|
+ {
|
|
|
|
+ for (size_t i = 0; i < Externals < T, U, V >::size(); ++i) {
|
|
|
|
+ if (not Externals < T, U, V >::get(i).is_null()) {
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ from_kernel,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ t, type)
|
|
|
|
+ << utils::KernelInfo(
|
|
|
|
+ Externals < T, U, V >::name(i), false,
|
|
|
|
+ Externals < T, U, V >::get(i).to_string(
|
|
|
|
+ dynamic_cast < const T* >(this))
|
|
|
|
+ );
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void trace_model(bool from_kernel, typename U::type t,
|
|
|
|
+ utils::TraceType type = utils::NONE) const
|
|
|
|
+ {
|
|
|
|
+ trace_element(from_kernel, t, type);
|
|
|
|
+ trace_internals(from_kernel, t, type);
|
|
|
|
+ trace_externals(from_kernel, t, type);
|
|
|
|
+
|
|
|
|
+ // typename AbstractCoupledModel::Submodels::const_iterator it =
|
|
|
|
+ // submodels.begin();
|
|
|
|
+
|
|
|
|
+ // while (it != submodels.end()) {
|
|
|
|
+ // it->second->trace_model(from_kernel, t, type);
|
|
|
|
+ // ++it;
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+
|
|
protected:
|
|
protected:
|
|
- void change_internal(unsigned int index, double T::* var)
|
|
|
|
- {
|
|
|
|
- submodel_internals.erase(index);
|
|
|
|
- Internals < T, U, V >::internal(index, var);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void change_internal(unsigned int index, int T::* var)
|
|
|
|
- {
|
|
|
|
- submodel_internals.erase(index);
|
|
|
|
- Internals < T, U, V >::internalI(index, var);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void change_internal(unsigned int index, bool T::* var)
|
|
|
|
- {
|
|
|
|
- submodel_internals.erase(index);
|
|
|
|
- Internals < T, U, V >::internalB(index, var);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void link_internal_(unsigned int index, type* model, int sub_index)
|
|
|
|
|
|
+ void link_internal_(unsigned int index, std::string var_name,
|
|
|
|
+ type* model, int sub_index, std::string sub_var_name)
|
|
{
|
|
{
|
|
submodel_internals[index] =
|
|
submodel_internals[index] =
|
|
std::pair < type*, int >(model, sub_index);
|
|
std::pair < type*, int >(model, sub_index);
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ true,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ utils::DoubleTime::null,
|
|
|
|
+ utils::INTERNAL_LINK)
|
|
|
|
+ << utils::KernelInfo(
|
|
|
|
+ var_name,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(model),
|
|
|
|
+ sub_var_name);
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
void I_(std::initializer_list < Var > internals)
|
|
void I_(std::initializer_list < Var > internals)
|
|
{
|
|
{
|
|
for (typename std::initializer_list < Var >::iterator it =
|
|
for (typename std::initializer_list < Var >::iterator it =
|
|
internals.begin(); it != internals.end(); ++it) {
|
|
internals.begin(); it != internals.end(); ++it) {
|
|
|
|
+
|
|
submodel_internals[it->index] =
|
|
submodel_internals[it->index] =
|
|
std::pair < type*, int >(it->model, it->sub_index);
|
|
std::pair < type*, int >(it->model, it->sub_index);
|
|
|
|
+
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ true,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ utils::DoubleTime::null,
|
|
|
|
+ utils::INTERNAL_LINK)
|
|
|
|
+ << utils::KernelInfo(
|
|
|
|
+ it->var_name,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(it->model),
|
|
|
|
+ it->sub_var_name);
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -390,6 +493,19 @@ protected:
|
|
models.begin(); it != models.end(); ++it) {
|
|
models.begin(); it != models.end(); ++it) {
|
|
submodels[it->first] = it->second;
|
|
submodels[it->first] = it->second;
|
|
it->second->set_parent(this);
|
|
it->second->set_parent(this);
|
|
|
|
+
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ true,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ utils::DoubleTime::null,
|
|
|
|
+ utils::SUBMODEL_ADD)
|
|
|
|
+ << utils::KernelInfo(
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(it->second));
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+#endif
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -400,6 +516,18 @@ protected:
|
|
}
|
|
}
|
|
setsubmodels[index].push_back(model);
|
|
setsubmodels[index].push_back(model);
|
|
model->set_parent(this);
|
|
model->set_parent(this);
|
|
|
|
+
|
|
|
|
+#ifdef WITH_TRACE
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace()
|
|
|
|
+ << utils::TraceElement < utils::DoubleTime >(
|
|
|
|
+ true,
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(this),
|
|
|
|
+ utils::DoubleTime::null,
|
|
|
|
+ utils::SUBMODEL_ADD)
|
|
|
|
+ << utils::KernelInfo(
|
|
|
|
+ AbstractCoupledModel < T, U, V, W >::path(model));
|
|
|
|
+ utils::Trace < utils::DoubleTime >::trace().flush();
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
private:
|
|
private:
|
|
@@ -408,9 +536,9 @@ private:
|
|
Setsubmodels setsubmodels;
|
|
Setsubmodels setsubmodels;
|
|
};
|
|
};
|
|
|
|
|
|
-#define InternalS(index, var, sub_index) link_internal_(index, var, sub_index)
|
|
|
|
|
|
|
|
-#define ITEM_S(index, var, sub_index) Var(index, var, sub_index)
|
|
|
|
|
|
+#define InternalS(index, var, sub_index) link_internal_(index, std::string(ESCAPEQUOTE(index)), var, sub_index, std::string(ESCAPEQUOTE(index)))
|
|
|
|
+#define ITEM_S(index, var, sub_index) Var(index, std::string(ESCAPEQUOTE(index)), var, sub_index, std::string(ESCAPEQUOTE(index)))
|
|
#define UNWRAP_ITEM_S(...) ITEM_S __VA_ARGS__
|
|
#define UNWRAP_ITEM_S(...) ITEM_S __VA_ARGS__
|
|
#define LIST_S_16(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14), UNWRAP_ITEM_S(L15), UNWRAP_ITEM_S(L16) }
|
|
#define LIST_S_16(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14), UNWRAP_ITEM_S(L15), UNWRAP_ITEM_S(L16) }
|
|
#define LIST_S_15(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14), UNWRAP_ITEM_S(L15) }
|
|
#define LIST_S_15(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15) { UNWRAP_ITEM_S(L1), UNWRAP_ITEM_S(L2), UNWRAP_ITEM_S(L3), UNWRAP_ITEM_S(L4), UNWRAP_ITEM_S(L5), UNWRAP_ITEM_S(L6), UNWRAP_ITEM_S(L7), UNWRAP_ITEM_S(L8), UNWRAP_ITEM_S(L9), UNWRAP_ITEM_S(L10), UNWRAP_ITEM_S(L11), UNWRAP_ITEM_S(L12), UNWRAP_ITEM_S(L13), UNWRAP_ITEM_S(L14), UNWRAP_ITEM_S(L15) }
|