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 __NUMERIC_OBJECT_HPP 00019 #define __NUMERIC_OBJECT_HPP 00020 00021 00022 #include "MemoryBank.hpp" 00023 #include "Timer.hpp" 00024 #include <CapeOpen.hpp> 00025 #include <Diana.hpp> 00026 00027 00028 00029 typedef struct 00030 { 00031 CapeDouble Time; 00032 CapeArrayDouble ESOVariables; 00033 CapeArrayDouble ESODerivatives; 00034 CapeArrayDouble ESORealParameters; 00035 } NumericObjectState; //State of numeric object 00036 00037 00040 class CNumericObject 00041 { 00042 private: 00043 CapeLong m_lGlobalIndex; 00044 DianaNumericSolver* m_pSolver; 00045 Numeric::Solvers::Model::ICapeNumericModel* m_pModel; 00046 CapeString m_sModelName; 00047 CapeString m_ESOName; 00048 CapeLong m_lStatus; 00049 std::vector< CMemoryBank* > m_pMemoryBanks; 00050 NumericObjectState OldState; 00051 CapeDouble m_dCurrentTime; 00052 CapeBoolean m_bNeedToDeleteSolver; 00053 CapeBoolean m_bNeedToInitialize; 00054 00055 CapeLong m_lJacCalls, m_lTotalJacCalls; 00056 CapeLong m_lResCalls, m_lTotalResCalls; 00057 CapeLong m_lSolCalls, m_lTotalSolCalls; 00058 00060 CTimer m_SimulationTimer; 00061 private: 00062 //Additional functions to transmit NumericObjectStates 00063 void SendNumericObjectState( NumericObjectState* _pState, CapeLong _nDestinationPE ); 00064 void ReceiveNumericObjectState( NumericObjectState* _pState, CapeLong _nSourcePE ); 00065 00066 void ClearStat(); 00067 void UpdateStat(); 00068 00069 protected: 00070 static void SaveStates( void* _pMemoryBanks, double X, int NEQ, 00071 int KOLD, double* PHI, double* PSI ); 00072 public: 00073 CNumericObject( const CapeString& _sModelName, CapeLong _lGlobalIndex ); 00074 ~CNumericObject(); 00075 00076 /* Group of some simple set and get methods */ 00077 CapeLong GetObjectIndex(); 00078 CapeString GetModelName(); 00079 CapeString GetESOName(); 00080 void SetModel( Numeric::Solvers::Model::ICapeNumericModel* _Model ); 00081 Numeric::Solvers::Model::ICapeNumericModel* GetModel(); 00082 void SetSolver( DianaNumericSolver* _pSolver ); 00083 void SetStatus( CapeLong _Status ); 00084 CapeLong GetStatus(); 00085 00086 CapeLong GetSimulationTime(); 00087 void ResetSimulationTime(); 00088 00089 00091 void SetMemoryAdress( std::vector<CMemoryBank* > _MemoryAdress ); 00092 00093 00095 void SaveState() 00096 throw (Common::Error::ECapeUnknown); 00097 00098 00100 void LoadState() 00101 throw (Common::Error::ECapeUnknown); 00102 00103 00107 CapeBoolean CheckConvergence(); 00108 00109 00112 void ConsistentInitialize( CapeDouble _dStartTime, CapeDouble _dFinishTime, 00113 CapeLong _lIterationNumber, CapeDouble _dInitialStepSize ); 00114 00115 00118 void Simulate( CapeDouble _dStartTime, CapeDouble _dFinishTime, 00119 CapeLong _nIterationNumber); 00120 00121 void DataSend( CRouter* _Router ); 00122 void DataReceive( CRouter* _Router ); 00123 00124 00129 Numeric::Solvers::Solver::ICapeNumericSolver* CreateSolver() 00130 throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument); 00131 00132 void ShowStat(CapeBoolean _bShowTotalStat); 00133 00134 void SaveInitialState(); 00135 00138 static void UpdateReceivedValues( void* _pMemoryBanks ); 00139 void UpdateReceivedData( CapeDouble _dTime ); 00140 00141 void ResendWaveform(); 00142 }; 00143 00144 #endif 00145