|
@@ -45,6 +45,13 @@ class AbstractCoupledModel : public AbstractModel < U, V >,
|
|
|
typedef std::map < int, std::pair < type*,
|
|
|
int > > SubModelInternals;
|
|
|
|
|
|
+ struct Var
|
|
|
+ {
|
|
|
+ unsigned int index;
|
|
|
+ type* model;
|
|
|
+ int sub_index;
|
|
|
+ };
|
|
|
+
|
|
|
public:
|
|
|
AbstractCoupledModel()
|
|
|
{ }
|
|
@@ -212,15 +219,46 @@ protected:
|
|
|
void internal(unsigned int index, double T::* var)
|
|
|
{ Internals < T, U >::internal(index, var); }
|
|
|
|
|
|
+ void I(std::initializer_list < std::pair < unsigned int,
|
|
|
+ bool T::* > > internals)
|
|
|
+ { Internals < T, U >::I(internals); }
|
|
|
+
|
|
|
+ void I(std::initializer_list < std::pair < unsigned int,
|
|
|
+ int T::* > > internals)
|
|
|
+ { Internals < T, U >::I(internals); }
|
|
|
+
|
|
|
+ void I(std::initializer_list < std::pair < unsigned int,
|
|
|
+ double T::* > > internals)
|
|
|
+ { Internals < T, U >::I(internals); }
|
|
|
+
|
|
|
void internal(unsigned int index, type* model, int sub_index)
|
|
|
{
|
|
|
submodel_internals[index] =
|
|
|
std::pair < type*, int >(model, sub_index);
|
|
|
}
|
|
|
|
|
|
+ void I(std::initializer_list < Var > internals)
|
|
|
+ {
|
|
|
+ for (typename std::initializer_list < Var >::iterator it =
|
|
|
+ internals.begin(); it != internals.end(); ++it) {
|
|
|
+ submodel_internals[it->index] =
|
|
|
+ std::pair < type*, int >(it->model, it->sub_index);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void submodel(unsigned int index, type* model)
|
|
|
{ submodels[index] = model; }
|
|
|
|
|
|
+ void S(std::initializer_list < std::pair < unsigned int,
|
|
|
+ type* > > models)
|
|
|
+ {
|
|
|
+ for (typename std::initializer_list < std::pair < unsigned int,
|
|
|
+ type* > >::iterator it =
|
|
|
+ models.begin(); it != models.end(); ++it) {
|
|
|
+ submodels[it->first] = it->second;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
void setsubmodel(unsigned int index, type* model)
|
|
|
{
|
|
|
if (setsubmodels.find(index) == setsubmodels.end()) {
|
|
@@ -235,6 +273,67 @@ private:
|
|
|
Setsubmodels setsubmodels;
|
|
|
};
|
|
|
|
|
|
+template < typename T, typename U, typename V, typename W >
|
|
|
+struct IN_t
|
|
|
+{
|
|
|
+ IN_t(AbstractCoupledModel < T, U, V, W >* model,
|
|
|
+ unsigned int index) : model(model), index(index)
|
|
|
+ { }
|
|
|
+
|
|
|
+ AbstractCoupledModel < T, U, V, W >* model;
|
|
|
+ unsigned int index;
|
|
|
+};
|
|
|
+
|
|
|
+template < typename T, typename U, typename V, typename W >
|
|
|
+struct OUT_SC_t
|
|
|
+{
|
|
|
+ OUT_SC_t(double t, AbstractCoupledModel < T, U, V, W >* model,
|
|
|
+ unsigned int index) : t(t), model(model), index(index)
|
|
|
+ { }
|
|
|
+
|
|
|
+ double t;
|
|
|
+ AbstractCoupledModel < T, U, V, W >* model;
|
|
|
+ unsigned int index;
|
|
|
+};
|
|
|
+
|
|
|
+template < typename T >
|
|
|
+struct OUT_A_t
|
|
|
+{
|
|
|
+ OUT_A_t(double t, T value) : t(t), value(value)
|
|
|
+ { }
|
|
|
+
|
|
|
+ double t;
|
|
|
+ T value;
|
|
|
+};
|
|
|
+
|
|
|
+template < typename T, typename U, typename V, typename W >
|
|
|
+IN_t < T, U, V, W > IN(AbstractCoupledModel < T, U, V, W >* model,
|
|
|
+ unsigned int index)
|
|
|
+{ return IN_t < T, U, V, W >(model, index); }
|
|
|
+
|
|
|
+template < typename T, typename U, typename V, typename W >
|
|
|
+OUT_SC_t < T, U, V, W > OUT(double t,
|
|
|
+ AbstractCoupledModel < T, U, V, W >* model,
|
|
|
+ unsigned int index)
|
|
|
+{ return OUT_SC_t < T, U, V, W >(t, model, index); }
|
|
|
+
|
|
|
+template < typename T >
|
|
|
+OUT_A_t < T > OUT(double t, T value)
|
|
|
+{ return OUT_A_t < T >(t, value); }
|
|
|
+
|
|
|
+template < typename T1, typename U1, typename V1, typename W1,
|
|
|
+ typename T2, typename U2, typename V2, typename W2 >
|
|
|
+void operator>>(OUT_SC_t < T2, U2, V2, W2 > out, IN_t < T1, U1, V1, W1 > in)
|
|
|
+{
|
|
|
+ if (out.model->is_computed(out.t, out.index)) {
|
|
|
+ in.model->put(out.t, in.index, out.model->get(out.t, out.index));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+template < typename T, typename U, typename V, typename W, typename Z >
|
|
|
+void operator>>(OUT_A_t < Z > out, IN_t < T, U, V, W > in)
|
|
|
+{ in.model->put(out.t, in.index, out.value); }
|
|
|
+
|
|
|
} }
|
|
|
|
|
|
#endif
|