Diana  0.8.3
ParallelSolver.hpp
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 __PARALLSOLVER_HPP
00019 #define __PARALLSOLVER_HPP
00020 
00021 #include "Router.hpp"
00022 #include "NumericObject.hpp"
00023 #include "MemoryManager.hpp"
00024 #include "Convertor.hpp"
00025 #include <Diana.hpp>
00026 
00030 class CParallelSolver : virtual public IParallelSolver
00031 {
00032 private:
00033    int m_nMyRank; 
00034    int m_nProcQuantity; 
00035    CRouter m_Router; 
00036    CMemoryManager m_MemoryManager; 
00037 
00038    CapeString m_szConnectionsFileName;
00039    std::vector<CNumericObject*> m_Objects; 
00040    CapeArrayBoolean m_ObjectsConvergences; 
00041 
00043    CapeArrayLong m_ModelDisplacement;
00044 
00045    CapeLong m_lVerboseLevel;
00046    CapeBoolean m_bNeedToConsistentInitialize;
00047    
00048    CapeLong m_lErrorStatus; 
00049 private:
00053    void InitialLoadBalancing()
00054         throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument);
00055  
00058    void TransmitData();
00059 
00060 
00064    void SaveState()
00065       throw (Common::Error::ECapeUnknown);
00066    void LoadState()
00067       throw (Common::Error::ECapeUnknown);
00068 
00069    CapeBoolean CheckConvergence();
00070    
00072    void ReduceError();
00073 
00079    CapeLong MoveNumericObject( CapeLong _nObjectIndex, 
00080       CapeLong _nSourcePE, CapeLong _nDestinationPE );
00081 
00082    CapeDouble CalculateNewWindowSize( CapeLong _lIterationNumber, CapeDouble _dOldWindowSize,
00083       CapeBoolean _bWasConverged );
00084 
00085    void ShowStat( CapeBoolean _bShowTotal );
00086    
00087 
00088 public:
00089    CParallelSolver( const Common::Types::CapeString& _szConnectionsFileName );
00090    ~CParallelSolver();
00091 
00092    CapeLong FindInitialConditions( CapeDouble _dStartTime, CapeDouble _dEndTime,
00093       CapeDouble _dInitialStepSize = 0 )
00094       throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument);
00095 
00096    void Run( CapeDouble _dInitialWindowSize, CapeDouble _dEndTime, 
00097       CapeDouble _dInitialStepSize = 0 )
00098       throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument);
00099 
00104    Numeric::Solvers::Solver::ICapeNumericSolver* 
00105       AddModel( Numeric::Solvers::Model::ICapeNumericModel* _Model, 
00106       const Common::Types::CapeString& ModelName )
00107       throw (Common::Error::ECapeUnknown, Common::Error::ECapeInvalidArgument);
00108 
00109 
00110    void ShowInfo();
00111 
00112    Common::Types::CapeArrayString GetAllModelNames();
00113    Common::Types::CapeArrayString GetAllESONames();
00114 
00115 };
00116 
00117 #endif