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: SingAnalyser.hpp 8160 2009-03-16 18:36:30Z miha $ 00013 * ----------------------------------------------------------------------------- 00014 * Description: 00015 */ 00016 00017 #ifndef SINGULARITY_ANALYSER__HPP 00018 #define SINGULARITY_ANALYSER__HPP 00019 00020 #ifdef HAVE_CONFIG_H 00021 #include <config.h> 00022 #endif 00023 00024 #include <Diana.hpp> 00025 #include <DianaContinuation.hpp> 00026 #include <DianaSparseSolver.hpp> 00027 #include <DianaLSQRSolver.hpp> 00028 00029 #ifdef HAVE_UFSPARSE_CHOLMOD 00030 #include <DianaNormalEquationsSolver.hpp> 00031 #endif 00032 00033 namespace Diana { 00034 00039 class SingAnalyser : public DianaContinuation { 00040 public: 00047 SingAnalyser(Numeric::Solvers::Model::ICapeNumericModel* _pModel); 00048 virtual ~SingAnalyser(); 00049 00057 Numeric::Solvers::Solver::SolveReturn Solve() 00058 throw (Common::Error::ECapeUnknown, Common::Error::ECapeBadInvOrder, 00059 Common::Error::ECapeSolvingError, Common::Error::ECapeOutOfResources); 00060 00065 ContiReturn Continuate() 00066 throw (Common::Error::ECapeUnknown, Common::Error::ECapeSolvingError); 00067 00068 Common::Types::CapeString GetVariableName(Common::Types::CapeLong index) 00069 throw (Common::Error::ECapeUnknown); 00070 00071 protected: 00073 int getModelEquations(); 00074 00076 int getModelVariables(); 00077 00080 void packModelBoundaries(Common::Types::CapeArrayDouble& arrMinY, 00081 Common::Types::CapeArrayDouble& arrMaxY); 00082 00084 void packModelVector(Common::Types::CapeArrayDouble& modelVector); 00085 00087 void unpackModelVector(const Common::Types::CapeArrayDouble& modelVector); 00088 00090 void packModelResidual(Common::Types::CapeArrayDouble& modelResidual); 00091 00093 void packModelJacobian(Diana::DianaSparseArray& Jaco); 00094 00098 void addDerivativeByParameter(Diana::DianaSparseArray& Jaco, int nJacCol, int nParamIndex); 00099 00100 CapeBoolean calcTestCondition(CapeBoolean bFirstCall=false); 00101 00102 protected: 00103 // methods defined in the SingAnalyserEigensolver.cpp 00104 bool areEigenVectorsConsistent(IDianaLinearAlgebraSolver& dssaA); 00105 CapeBoolean calcInitialEigenpairs(); 00106 void calcArpackEigenpairs(CapeBoolean bTranspose, IDianaLinearAlgebraSolver& dssA, 00107 Common::Types::CapeDouble& dblEigenvalue, 00108 Common::Types::CapeArrayDouble& arrEigenvector); 00109 void calcLapackEigenpairs(const Diana::DianaSparseArray& dsaA); 00110 protected: 00111 // methods defined in the SingAnalyserConditions.cpp 00112 Common::Types::CapeLong getLambdaParameterIndex(); 00113 void getConditionCheckParameters(); 00114 00115 double calcGx(); 00116 void addGxJacobianRow(int nPosRow, Diana::DianaSparseArray& dsa); 00117 00118 double calcGxx(); 00119 void addGxxJacobianRow(int nPosRow, Diana::DianaSparseArray& dsa); 00120 void addGxxJacobianRowS(int nPosRow, Diana::DianaSparseArray& dsa); 00121 void addGxxJacobianRowFD(int nPosRow, Diana::DianaSparseArray& dsa); 00122 00123 double calcGp(int nParamIndex); 00124 double calcGp(); 00125 void addGpJacobianRow(int nPosRow, Diana::DianaSparseArray& dsa); 00126 00127 double calcGxp(); 00128 void addGxpJacobianRow(int nPosRow, Diana::DianaSparseArray& dsa); 00129 void calcLm1EPhi(int nParamIndex, Common::Types::CapeArrayDouble& vecLm1EResult); 00130 00131 protected: 00132 Common::Types::CapeLong nConditionCheck; 00133 Common::Types::CapeLong nConditionShow; 00134 Common::Types::CapeLong nConditionCurrent; 00135 Common::Types::CapeDouble dblTestGx; 00136 Common::Types::CapeDouble dblTestGxx; 00137 DianaParameter* parTestGp; 00138 Common::Types::CapeArrayDouble vecTestGp; 00139 DianaArray arrTestGp; 00140 Common::Types::CapeDouble dblTestGxp; 00141 00142 Common::Types::CapeLong nSingularityEquations; 00143 00144 DianaParameter* parLambdaParameter; 00145 DianaParameter* parConditionCheckParameters; 00146 DianaParameter* parConditionParameter; 00147 Common::Types::CapeLong nLambdaParameter; 00148 Common::Types::CapeArrayString arrConditionCheckParametersNames; 00149 Common::Types::CapeArrayLong arrConditionCheckParameters; 00150 00151 private: 00152 Common::Types::CapeDouble dblNAN; 00153 Common::Types::CapeLong nESOSize; 00154 00155 Common::Types::CapeArrayDouble arrEigenvector; 00156 Common::Types::CapeArrayDouble arrAdjEigenvector; 00157 Common::Types::CapeDouble dblBeta; 00158 Common::Types::CapeDouble dblGamma; 00159 00160 DianaSparseSolver dssEigJacobian; 00161 DianaLSQRSolver dssLm1E; 00162 //DianaSparseSolver dssLm1E; // no MNS 00163 //DianaSparseArray dsaLm1E; // no MNS 00164 }; 00165 }; 00166 00167 #endif // SINGULARITY_ANALYSER__HPP 00168