[ libohymos | Source | Keywords | Summary | Ancestors | All Members | Descendants ]
Back to the top of Element
An element model
In hydrolgic simulations, we need various element models because various processes are involved.
Class Element expresses the common part of those hydrologic element models.
Back to the top of Element
enum OperationFlag ;
OperationFlag
enum OperationFlag {E_UNDONE, E_DONE, E_ALREADY};
Back to the top of Element
Boolean initialworkdone_p;
whether the initial work has been completed or not.
Boolean initialworkdone_p;
Back to the top of Element
Boolean shareinfodone_p;
whether the 'Share_info' has been completed or not.
Boolean shareinfodone_p;
Back to the top of Element
List* object_list;
pointer to a list for storing Object*
List* object_list;
Back to the top of Element
void** receive_port_array;
array of Receive_port*
void** receive_port_array;
Back to the top of Element
int number_of_receive_ports;
number of receive ports
int number_of_receive_ports;
Back to the top of Element
void** send_port_array;
array of Send_port*
void** send_port_array;
Back to the top of Element
int number_of_send_ports;
number of send-ports
int number_of_send_ports;
Back to the top of Element
void** object_array;
array of Object*
void** object_array;
Back to the top of Element
int number_of_objects;
the number of objects stored in object_array
int number_of_objects;
Back to the top of Element
char* data_string;
data string
char* data_string;
Back to the top of Element
time_t current_time;
current time in unix time (sec)
time_t current_time;
Back to the top of Element
time_t time_step;
time step (sec)
time_t time_step;
Back to the top of Element
time_t fixed_time;
time_t fixed_time;
Back to the top of Element
(* 注意 *)
反復計算する要素では、計算開始時に fixed_time,
target_time を current_time と一致させる必要があります。
Set_initial_state で current_time が初期設定された後、
下で定義する void Cur2fix2tar(void) をよぶか、直接
target_time = fixed_time = current_time; としてください。
time_t target_time;
time_t target_time;
Back to the top of Element
Boolean mCreqp;
Flag of request of calculation. Initial value is NO.
Boolean mCreqp;
Back to the top of Element
void* Get_from_list(char* c_name, char* o_name, int o_num);
Finds an object with class name 'c_name', object name 'o_name', and
object number 'o_num' from object_list and returns the pointer to
the object. When such an object could not be found from
object_list, NULL will be returned.
void* Get_from_list(char* c_name, char* o_name, int o_num);
Back to the top of Element
void* Get_from_list(char* o_name, int o_num);
Finds an object with object name 'o_name', and
object number 'o_num' from object_list and returns the pointer to
the object. When such an object could not be found from
object_list, NULL will be returned.
void* Get_from_list(char* o_name, int o_num);
Back to the top of Element
Boolean Register(void* obj);
Registers an object 'obj' to the data member 'object_list'
Boolean Register(void* obj);
Back to the top of Element
void Register_receive_ports(void) ;
Declares member function Register_receive_ports(void) as pure
virtual. In classes derived from class Element, its definition
should be given.
Register_receive_port は, 派生クラスの全受信
端子メンバ, 全送信端子メンバのアドレスを Element::Register により
登録します.
登録されていない端子は, 接続できないので, 送受信に利用できません.
例えば, 派生クラスで受信端子メンバ abc を定義した場合,
とすれば, abc を受信端子として登録できます.
virtual void Register_receive_ports(void) = NULL;
Back to the top of Element
void Register_send_ports(void) ;
Declares member function Register_send_ports(void) as pure
virtual. In classes derived from class Element, its definition
should be given.
Register_send_port は, 派生クラスの全受信
端子メンバ, 全送信端子メンバのアドレスを Element::Register により
登録します.
登録されていない端子は, 接続できないので, 送受信に利用できません.
例えば, 派生クラスで受信端子メンバ abc を定義した場合,
とすれば, abc を受信端子として登録できます.
virtual void Register_send_ports(void) = NULL;
Back to the top of Element
Boolean Make_object_array(void**& obj_array, int& num_of_objs);
Creates an array of Objects* which are included in 'objext_list'
and stores its address in 'obj_array' and the number of elements in
'num_of_objs'
object_list が NULL を指している場合, エラーメッセージを表示して
NO を返します.
また num_of_objs が 0 以上の場合は, 既に配列を作成済みと判断し,
エラーメッセージを表示して NO を返します.
配列化後, num_of_objs は 0 以上に設定されます.
従って配列設定前, num_of_objs は 0 未満に初期化しておいて下さい.
number_of_receive_port, number_of_send_port は, コンストラクタで
-1 に初期化されます.
Boolean Make_object_array(void**& obj_array, int& num_of_objs);
Back to the top of Element
Boolean Set_object_array(int num_of_objs);
Acquire the memory to store 'num_of_objs' objects and makes
'object_array' point to the memory
Boolean Set_object_array(int num_of_objs);
Back to the top of Element
Boolean Register(void* obj, int num);
Registers the object 'obj' with which the current object
communicates directly to object_array[num]
Boolean Register(void* obj, int num);
Back to the top of Element
Boolean Construct(void);
Creates 'receive_port_array' and 'send_port_array'.
Construct does the following work
virtual Boolean Construct(void);
Back to the top of Element
void* Get_from_array(char* c_name, char* o_name, int o_num, void** obj_array, int num_of_objs);
void* Get_from_array(char* c_name, char* o_name, int o_num, void** obj_array, int num_of_objs);
Back to the top of Element
void* Get_from_array(char* o_name, int o_num, void** obj_array, int num_of_objs);
void* Get_from_array(char* o_name, int o_num, void** obj_array, int num_of_objs);
Back to the top of Element
void* Get_receive_port(char* c_name, char* o_name, int o_num );
void* Get_receive_port(char* c_name, char* o_name, int o_num = 0);
Back to the top of Element
void* Get_send_port(char* c_name, char* o_name, int o_num );
void* Get_send_port(char* c_name, char* o_name, int o_num = 0);
Back to the top of Element
void* Get_receive_port(char* o_name, int o_num );
void* Get_receive_port(char* o_name, int o_num = 0);
Back to the top of Element
void* Get_send_port(char* o_name, int o_num );
void* Get_send_port(char* o_name, int o_num = 0);
Back to the top of Element
void* Get_object(char* c_name, char* o_name, int o_num );
void* Get_object(char* c_name, char* o_name, int o_num = 0);
Back to the top of Element
void* Get_component(char* c_name, char* o_name, int o_num ) ;
virtual void* Get_component(char* c_name, char* o_name, int o_num = 0) ;
Function is currently defined inline.
Back to the top of Element
void* Get_component(char* o_name, int o_num ) ;
virtual void* Get_component(char* o_name, int o_num = 0) ;
Function is currently defined inline.
Back to the top of Element
全ての所有送信端子で Send_port::Switch を実行します.
この時, Send_port::buffer_list を送信先受信端子登録用から, 送信デー
タパック収録用に転換し, 送信先受信端子配列, 送信データパック配列が
作成されます.
この関数の実行後は, 所有送信端子を接続, リンクできません.
Boolean Switch(void);
RETURN:
・YES 正常に実行できた場合.
・NO Send_port::Switch で NO を返す送信端子が存在する場合.
(既に Send_port::Switch されている場合. )
EXIT:
・Level 5 Send_port::Switch で強制終了される場合.
virtual Boolean Switch(void);
Back to the top of Element
受信端子, 送信端子が, データパックを送受信可能な状態であることを
確認します.
全受信端子の Receive_port::Are_you_ready の戻り値, 及び全送信端子
の Send_port::Are_you_ready の戻り値が YES であることを確認します.
戻り値が NO の端子が存在する場合は NO を返し, 存在しない場合 YES
を返します.
この関数の戻り値が YES の場合, Element は計算を実行できます.
NO の場合は, データパックを受信できない受信端子, またはデータパッ
クを送信できない送信端子が存在し, この Element, 送信先の Element
で計算を実行できません.
この場合, 接続作業に誤りがあるか, Swith_send_port を実行していな
い可能性があります.
Boolean Are_you_ready(void);
RETURN:
・YES 全端子の Are_you_ready の戻り値が YES の場合.
・NO 戻り値が NO の端子が存在する場合.
virtual Boolean Are_you_ready(void);
Back to the top of Element
Boolean Set_data_string(char* d_str, int d_strlen );
Boolean Set_data_string(char* d_str, int d_strlen = -1);
Back to the top of Element
virtual void Clear_data_string(void);
Back to the top of Element
Boolean Get_data_string(char* d_str);
Boolean Get_data_string(char* d_str);
Back to the top of Element
Boolean Look_data_string(char*& buffer);
Boolean Look_data_string(char*& buffer);
Back to the top of Element
char* Get_line(FILE* fp, char* buffer, int buflen, Boolean& stock_p, int& iflag);
char* Get_line(FILE* fp, char* buffer, int buflen, Boolean& stock_p, int& iflag);
Back to the top of Element
void Get_line(FILE*fp, char* buffer, int buflen, char* fname, int line_number);
void Get_line(FILE*fp, char* buffer, int buflen, char* fname, int line_number);
Back to the top of Element
ファイルポインタ fp で指定されるファイルからデータを読みとって,
パラメタを設定します。
例えば, パラメータ用データメンバ p0, p1 を設定する場合,
純粋仮想関数なので, 派生クラスで必ず定義して下さい.
void Set_parameter(FILE* fp) ;
void Set_parameter(FILE* fp) {
fscanf(fp, "%lf %lf", &p0, &p1);
}
パラメタを直接指定する関数を同じ名前で,例えば,
void Set_parameter(double p0a, double p1a) {
p0 = p0a; p1 = p1a;
}
のように用意しておくのも親切であると思います。
virtual void Set_parameter(FILE* fp) = NULL;
Back to the top of Element
void Parameter(FILE* fp, char*& buffer, int buflen, Boolean& stock_p);
virtual void Parameter(FILE* fp, char*& buffer, int buflen, Boolean& stock_p);
Back to the top of Element
初期状態量を設定する関数を, 各派生クラスに応じて定義します.
ファイルポインタ fp で指定されるファイルからデータを読みとって,
初期状態量を設定します。
最終状態をファイルに保存するプログラムとつじつまがあうようにして
ください。
例
Set_initial_state は純粋仮想関数なので, 派生クラスで必ず定義して
下さい.
void Set_initial_state(FILE* fp) ;
void Set_initial_state(FILE* fp) {
fscanf(fp, "%ld %lf", ¤t_time, &x);
}
この例では,要素の current_time と x が読みとられています。
virtual void Set_initial_state(FILE* fp) = NULL;
Back to the top of Element
void Initial_state(FILE* fp, char*& buffer, int buflen, Boolean& stock_p);
virtual void Initial_state(FILE* fp, char*& buffer, int buflen, Boolean& stock_p);
Back to the top of Element
Boolean Share_info(void) ;
virtual Boolean Share_info(void) ;
Function is currently defined inline.
Back to the top of Element
void Save_send_port_stock(FILE* fp);
virtual void Save_send_port_stock(FILE* fp);
Back to the top of Element
void Restore_send_port_stock(void);
void Restore_send_port_stock(void);
Back to the top of Element
time_t Current_time(void) ;
Function is currently defined inline.
Back to the top of Element
time_t Time_step(void) ;
Function is currently defined inline.
Back to the top of Element
time_t Next_time(void) ;
Function is currently defined inline.
Back to the top of Element
virtual time_t Terminal_time(void) ;
Function is currently defined inline.
Back to the top of Element
time_t MediumTermTargetTime(void) ;
Returns the medium term target time
virtual time_t MediumTermTargetTime(void) ;
Function is currently defined inline.
Back to the top of Element
time_t Fixed_time(void) ;
Function is currently defined inline.
Back to the top of Element
time_t Target_time(void) ;
Function is currently defined inline.
Back to the top of Element
void Cur2fix2tar(void) ;
Function is currently defined inline.
Back to the top of Element
Boolean Renew_current_time(void) ;
virtual Boolean Renew_current_time(void) ;
Function is currently defined inline.
Back to the top of Element
void Rewind_current_time(void);
virtual void Rewind_current_time(void);
Back to the top of Element
virtual void Renew_fixed_time(void);
Back to the top of Element
void Initialize_target_time(void) ;
virtual void Initialize_target_time(void) ;
Function is currently defined inline.
Back to the top of Element
void Renew_target_time(time_t itrs);
virtual void Renew_target_time(time_t itrs);
Back to the top of Element
time_t Calculate_iteration_step(void);
virtual time_t Calculate_iteration_step(void);
Back to the top of Element
time_t Necessary_time_from(Receive_port* rp);
virtual time_t Necessary_time_from(Receive_port* rp);
Back to the top of Element
time_t Necessary_time_to(Receive_port* rp);
virtual time_t Necessary_time_to(Receive_port* rp);
Back to the top of Element
Boolean Initial_time(time_t i_time);
virtual Boolean Initial_time(time_t i_time);
Back to the top of Element
Boolean Initial_output(void) ;
virtual Boolean Initial_output(void) = NULL;
Back to the top of Element
virtual Boolean Initial_work(void);
Back to the top of Element
time_t Calculate_time_step(void) ;
virtual time_t Calculate_time_step(void) = NULL;
Back to the top of Element
Boolean Can_you_calculate0(void);
Boolean Can_you_calculate0(void);
Back to the top of Element
Boolean Can_you_calculate1(void);
Boolean Can_you_calculate1(void);
Back to the top of Element
まず, current_time が Element::Terminal_time 以上の場合, 計算済み
と判断し NO を返します.
次に, 全ての所有受信端子が Necessary_time_from, Necessary_time_to
間のデータパックを取得可能であることを確認します.
取得可能な場合, 計算実行可能と判断して YES を返します.
取得不可能な場合, 計算実行不可と判断して NO を返します.
Boolean Can_you_calculate(void) ;
RETURN:
・YES 計算実行可能の場合.
・NO 計算実行不可能の場合.
計算済みの場合.
virtual Boolean Can_you_calculate(void) = NULL;
Back to the top of Element
1ステップ分の計算手続きを定義して下さい.
一般的な Element では,
この関数の中で current_time, time_step を変更しないで下さい.
必要ならば time_step を更に細かい時間区分に分割して計算できますが,
この時は作業用変数を用い, current_time, time_step を変更しないよ
うに注意して下さい.
計算に必要な全ての数値は, データメンバ, 及び所有受信端子からの入
力として取得できます. 従って引数は不要です.
予定通り計算できた場合は, YES を返します。Calculate の内部で計算
時間ステップを計算し, その計算時間ステップ分のデータを取得できな
いなどして, 計算を進めることができなかった場合は, NO を返します。
純粋仮装関数なので, 派生クラスで必ず定義して下さい.
Boolean Calculate(void) ;
・最初, 各状態量には, current_time における値が格納されている.
・ここでは current_time + time_step における状態量, 出力値を
計算する.
・この関数終了後, 状態量は current_time + time_step における
値に更新されている.
の3点を満足するように, 下記の (1) から (4) を順に記述して下さい.
(1) 受信端子からの入力.
(2) 数理計算.
(3) 送信端子への出力.
(4) 状態量の更新.
(2) では, パラメータ, current_time における状態量, 受信端子からの
入力を用い, current_time + time_step における状態量, 送信すべき出
力値を計算する, 数理モデルの1ステップ分を具体的に定義して下さい.
ACCIDENT:
・この関数の中で current_time, time_step が変更された場合, 異
常発生の恐れがある.
virtual Boolean Calculate(void) = NULL;
Back to the top of Element
void Set_data_pack_array(void);
void Set_data_pack_array(void);
Back to the top of Element
void Reduce_data_pack_stock(void);
void Reduce_data_pack_stock(void);
Back to the top of Element
virtual Boolean Print_status(void) ;
Function is currently defined inline.
Back to the top of Element
Boolean Record_status(void);
Back to the top of Element
Boolean Work0(void);
Boolean Work0(void);
Back to the top of Element
Boolean Work1(void);
Boolean Work1(void);
Back to the top of Element
Boolean Work2(void); //; 反復計算要素用 Work の例
Back to the top of Element
Boolean Work3(void);
Boolean Work3(void);
Back to the top of Element
virtual Boolean Work(void) = NULL;
Back to the top of Element
Boolean Do_you_reach_target_time(void);
virtual Boolean Do_you_reach_target_time(void);
Back to the top of Element
virtual void Flush_data(void);
Back to the top of Element
virtual void Send_stocked_data(void);
Back to the top of Element
void Creq(void) ;
Register request of calculation to this element
この関数は、この要素の送信端子から呼ばれます。部分系では、この関数
が呼ばれることはありません。中継端子は、計算要求を送信端子に転送す
るだけで、中継端子の所有者である部分系には計算要求を送らないからで
す。
void Creq(void) ;
Function is currently defined inline.
Back to the top of Element
void Print_objects(FILE* fp, char* head, char* title, void** obj_array, int number_of_objs);
void Print_objects(FILE* fp, char* head, char* title, void** obj_array, int number_of_objs);
Back to the top of Element
void Print_receive_ports(FILE* fp , char* head ) ;
void Print_receive_ports(FILE* fp = stderr, char* head = " ") ;
Function is currently defined inline.
Back to the top of Element
void Print_send_ports(FILE* fp , char* head ) ;
void Print_send_ports(FILE* fp = stderr, char* head = " ") ;
Function is currently defined inline.
Back to the top of Element
void Print_connection(FILE* fp , char* head );
void Print_connection(FILE* fp = stderr, char* head = " ");
Back to the top of Element
最終状態を書き込む仕様は次のようにしてください。
(data_string)
void Save_terminal_state(FILE* fp) ;
virtual void Save_terminal_state(FILE* fp) = NULL;
Back to the top of Element
void Terminal_state(FILE* fp);
virtual void Terminal_state(FILE* fp);
Back to the top of Element
Element* NewElement() ;
Returns a pointer to a new Element
virtual Element* NewElement() ;
Function is currently defined inline.
Back to the top of Element
Boolean Init(char*, int, FILE*) ;
Initilization with the information which is given through a file.
のようにして、構成要素を割り当てます。
構成要素のクラス名をファイルから読みとってつくりあげる部分系モデル
で利用されるようにするためには、この関数を定義しておく必要がありま
す。
Init(objname, objnum, fp) が未定義の構成要素が呼ばれたときにエラー
メッセージを表示して停止するようにしておきます。
Element* p = new_element(classname);
p->Init(objname, objnum, fp);
virtual Boolean Init(char*, int, FILE*) ;
Function is currently defined inline.
Back to the top of Element
Boolean Init(char* o_name, int o_num, int num_of_objs , char* p_str ) ;
Boolean Init(char* o_name, int o_num, int num_of_objs = 0, char* p_str = NULL) ;
Function is currently defined inline.
Back to the top of Element
Boolean Init(char* o_name, int o_num, char* p_str) ;
Boolean Init(char* o_name, int o_num, char* p_str) ;
Function is currently defined inline.
Back to the top of Element
Element(char* o_name, int o_num, int num_of_objs , char* p_str );
Element(char* o_name, int o_num, int num_of_objs = 0, char* p_str = NULL);
Back to the top of Element
Element(char* o_name, int o_num, char* p_str);
Element(char* o_name, int o_num, char* p_str);
Back to the top of Element
Element(void);
Back to the top of Element
~Element(void);
Back to the top of Element
Back to the top of Element
Back to the top of Element
Back to the top of Element
Report problems to jkotula@stratasys.com