Skip to content

Commit 145fbae

Browse files
author
Marcus Walther
committed
- revert revision 24937, because windows build fails
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24940 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent eff9e59 commit 145fbae

File tree

6 files changed

+84
-6
lines changed

6 files changed

+84
-6
lines changed

SimulationRuntime/cpp/Include/Core/Math/Functions.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <math.h> ///< mathematical expressions
44
#include <stdlib.h>
5+
#include "ILapack.h" ///< For the use of DGESV, etc.
56
#include <limits>
67
#include <string>
78
#include <exception>
@@ -148,6 +149,86 @@ inline double Phorner(double &x, int degree_P, double* P)
148149
return h*x + P[degree_P];
149150
}
150151

152+
/// Solution of a (determined) linear homogeneous or inhomogeneous system of equation with quadratic coefficient matrix A
153+
inline int solveLGS(long int* dim, double* A, double* b)
154+
{
155+
if(dim > 0)
156+
{
157+
long int
158+
dimRHS = 1, // number of right hand sides (dimension of b)
159+
irtrn = 0; // return value
160+
161+
long int* p = new long int[(int)*dim]; // Pivot elements
162+
163+
// Solution is written to b
164+
/*dgesv_*/dgesv_(dim,&dimRHS,A,dim,p,b,dim,&irtrn);
165+
166+
delete [] p;
167+
168+
return ((int)irtrn);
169+
}
170+
else
171+
return 0;
172+
}
173+
174+
/// Solution of a (determined) linear homogeneous or inhomogeneous system of equation with quadratic almost singular coefficient matrix A
175+
inline int solveLGSPrecond(long int* dim, double* A, double* b)
176+
{
177+
if(dim > 0)
178+
{
179+
double
180+
dRcond = 0.0, // Conditionnumber
181+
dForwErr = 0.0, // Upper limit for error of largest element in solution vector (=\frac{(\hat{x}_j - x_j)}{x_j})
182+
dBackErr = 0.0; // Lower limit for error of largest element in solution vector (=\frac{(\hat{x}_j - x_j)}{x_j})
183+
184+
char
185+
jobFactorize = 'E', // Jac is equilibrated if necessary, then copied to JacScal and factored
186+
jobTranspose = 'N', // A * X = B (No transpose)
187+
jobEquilibriate = 'B'; // Both row and column equilibration, Jac isreplaced by diag(R)*Jac*diag(C).
188+
189+
double
190+
*p, // Pivot elements
191+
*AScaled, // Factored form of the equilibrated matrix A
192+
*R, // Row scale factors for A
193+
*C, // Column scale factors for A
194+
*X,
195+
*work; // work array
196+
197+
long int
198+
dimRHS = 1, // number of right hand sides (dimension of b)
199+
irtrn = 0, // return value
200+
*iwork; // work array
201+
202+
p = new double[(int)*dim];
203+
R = new double[(int)*dim];
204+
C = new double[(int)*dim];
205+
X = new double[(int)*dim];
206+
work = new double[4*(int)*dim];
207+
iwork = new long int[(int)*dim];
208+
AScaled = new double[(int)*dim*(int)*dim];
209+
210+
// Scale row and columns of A, so that condition number is reduced
211+
// solve linear system by LU-decomposion and Forw.-Backw.-Subst.
212+
// _f is overwirtten with diag(R)*_f
213+
DGESVX(&jobFactorize,&jobTranspose,dim,&dimRHS,A,dim,AScaled,dim,p,
214+
&jobEquilibriate,R,C,b,dim,X,dim,&dRcond,&dForwErr,&dBackErr,
215+
work,iwork,&irtrn);
216+
217+
delete [] p;
218+
delete [] R;
219+
delete [] C;
220+
delete [] X;
221+
delete [] work;
222+
delete [] iwork;
223+
delete [] AScaled;
224+
225+
return irtrn;
226+
227+
}
228+
else
229+
return 0;
230+
}
231+
151232
template<class T >
152233
inline bool in_range(T i,T start,T stop)
153234
{

SimulationRuntime/cpp/Include/Solver/CVode/CVode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <cvode/cvode.h>
99
#include <nvector/nvector_serial.h>
1010
#include <sundials/sundials_direct.h>
11-
//#include <cvode/cvode_dense.h>
12-
#include <cvode/cvode_lapack.h>
11+
#include <cvode/cvode_dense.h>
12+
#include <cvode/cvode_spgmr.h>
1313

1414
#ifdef RUNTIME_PROFILING
1515
#include <Core/Utils/extension/measure_time.hpp>

SimulationRuntime/cpp/Solver/CVode/CVode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void Cvode::initialize()
254254
throw ModelicaSimulationError(SOLVER,/*_idid,_tCurrent,*/"Cvode::initialize()");
255255

256256
// Initialize linear solver
257-
_idid = CVLapackDense(_cvodeMem, _dimSys);
257+
_idid = CVDense(_cvodeMem, _dimSys);
258258
if (_idid < 0)
259259
throw ModelicaSimulationError(SOLVER,"Cvode::initialize()");
260260

SimulationRuntime/cpp/Solver/Euler/Euler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <SimCoreFactory/OMCFactory/OMCFactory.h>
44
#include <Solver/Euler/Euler.h>
55
#include <Solver/Euler/EulerSettings.h>
6-
#include <Core/Math/ILapack.h>
76

87

98

SimulationRuntime/cpp/Solver/Kinsol/Kinsol.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <Core/Modelica.h>
22
#include <Solver/Kinsol/Kinsol.h>
33
#include <Solver/Kinsol/KinsolSettings.h>
4-
#include <Core/Math/ILapack.h>
54

65
#if defined(__TRICORE__)
76
#include <include/kinsol/kinsol.h>

SimulationRuntime/cpp/Solver/UmfPack/UmfPack.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <Solver/UmfPack/UmfPack.h>
2-
#include <Core/Math/ILapack.h>
32

43
UmfPack::UmfPack(IAlgLoop* algLoop, ILinSolverSettings* settings) : _iterationStatus(CONTINUE), _umfpackSettings(settings), _algLoop(algLoop), _jacs(NULL), _rhs(NULL), _firstuse(true), _jacd(NULL)
54
{

0 commit comments

Comments
 (0)