Diana
0.8.3
|
00001 /* ----------------------------------------------------------------------------- 00002 * Diana process modelling, simulation and analysis software 00003 * Copyright (c) 2005, Michael Krasnyk 00004 * All rights reserved. 00005 * 00006 * This file is a part of Diana process modelling, simulation and analysis software 00007 * 00008 * Diana is free software; you can redistribute it and/or modify it 00009 * under the terms of the GNU General Public License as published 00010 * by the Free Software Foundation (see accompanying file LICENSE) 00011 * ----------------------------------------------------------------------------- 00012 * $Id$ 00013 * ----------------------------------------------------------------------------- 00014 * Description: 00015 */ 00016 00017 00018 #ifndef __MEMORY_BANK_HPP 00019 #define __MEMORY_BANK_HPP 00020 00021 #include "Parallel_defines.hpp" 00022 #include "Router.hpp" 00023 #include "CapeMPI.hpp" 00024 #include <stdio.h> 00025 00026 00030 typedef struct 00031 { 00032 long Size; 00033 double Times[ MAX_TRANSMIT_QUANTITY ]; 00034 long Orders[ MAX_TRANSMIT_QUANTITY ]; 00035 double Steps[ MAX_TRANSMIT_QUANTITY ]; 00036 double Variables[ MAX_TRANSMIT_QUANTITY ]; 00037 } TransmitDataStructure; //TDS 00038 00039 typedef struct 00040 { 00041 CapeBoolean bNeedToWait; 00042 MPI_Request SizeReq; 00043 MPI_Request TimesReq; 00044 MPI_Request VariablesReq; 00045 MPI_Request OrdersReq; 00046 MPI_Request StepsReq; 00047 } TransmitRequestsDataStructureRequests; //TRDS 00048 00054 class CMemoryBank 00055 { 00056 private: 00057 DianaDAESO* m_pOwner; 00058 CapeLong m_lOwnerIndex; 00059 CapeLong m_lReceiverIndex; 00060 CapeArrayLong m_SendVariablesIndexes, m_ReceiveParametersIndexes; 00061 00062 CapeLong lSendNewIdx, lSendOldIdx, lReceiveOldIdx, lReceiveNewIdx; 00063 std::vector<TransmitDataStructure> TDSVector; 00064 00065 CapeLong lSendReqIdx, lReceiveReqIdx; 00066 std::vector<TransmitRequestsDataStructureRequests> TRDSVector; 00067 00068 /* Relative and absolute tolerance for convergence test */ 00069 CapeDouble m_dRelTol, m_dAbsTol; 00070 CapeLong m_lMaxOrder; 00071 00072 /* This values is used for identifying connections between two objects. 00073 Each memorybank could have just one connection. 00074 Identificators should be unique for each connection.*/ 00075 CapeLong m_lConnectionsSendIdentificator, m_lConnectionsReceiveIdentificator; 00076 00077 CapeDouble m_dLastUpdateTime; 00078 00079 private: 00080 00083 CapeArrayDouble GetValueAtTime( CapeDouble _Time, TransmitDataStructure* _Struct ); 00084 00085 void Initialize(); 00086 00089 void WaitFor( TransmitRequestsDataStructureRequests* _Requests ); 00090 00091 public: 00092 CapeLong m_lIterationNumber; //the value of iteration on this window 00093 00094 CapeBoolean m_bTempConvergence; 00095 00096 public: 00097 CMemoryBank(); 00098 CMemoryBank( DianaDAESO* _pOwner, CapeLong _nOwnerIndex, CapeLong _nReceiverIndex, 00099 CapeLong _lConnectionsSendIdentificator, CapeLong _lConnectionsReceivedIdentificator ); 00100 ~CMemoryBank(); 00101 00104 void AddSendIndex( CapeLong _Index ); 00105 00106 00109 void AddReceiveIndexes( CapeLong _ParIndex ); 00110 00111 00114 void SetESO ( DianaDAESO* _pOwner ); 00115 00116 void SaveStateNew( double X, int NEQ, int KOLD, double* PHI, double* PSI ); 00117 00121 void SendData( CRouter* _Router ); 00122 00123 00127 void ReceiveSize( CRouter* _Router ); 00128 00129 00132 void ReceiveData( CRouter* _Router ); 00133 00134 00139 CapeBoolean CheckConvergence(); 00140 00141 00142 void SaveInitialState(); 00143 00144 00147 void UpdateReceivedValues() 00148 throw (Common::Error::ECapeUnknown); 00149 00151 void ResendWaveform(); 00152 }; 00153 00154 00155 #endif