SIMPR.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "SIBS.H"
00028
00029
00030
00031 void Foam::SIBS::SIMPR
00032 (
00033 const ODE& ode,
00034 const scalar xStart,
00035 const scalarField& y,
00036 const scalarField& dydx,
00037 const scalarField& dfdx,
00038 const scalarSquareMatrix& dfdy,
00039 const scalar deltaX,
00040 const label nSteps,
00041 scalarField& yEnd
00042 ) const
00043 {
00044 scalar h = deltaX/nSteps;
00045
00046 scalarSquareMatrix a(n_);
00047 for (register label i=0; i<n_; i++)
00048 {
00049 for (register label j=0; j<n_; j++)
00050 {
00051 a[i][j] = -h*dfdy[i][j];
00052 }
00053 ++a[i][i];
00054 }
00055
00056 labelList pivotIndices(n_);
00057 LUDecompose(a, pivotIndices);
00058
00059 for (register label i=0; i<n_; i++)
00060 {
00061 yEnd[i] = h*(dydx[i] + h*dfdx[i]);
00062 }
00063
00064 LUBacksubstitute(a, pivotIndices, yEnd);
00065
00066 scalarField del(yEnd);
00067 scalarField ytemp(n_);
00068
00069 for (register label i=0; i<n_; i++)
00070 {
00071 ytemp[i] = y[i] + del[i];
00072 }
00073
00074 scalar x = xStart + h;
00075
00076 ode.derivatives(x, ytemp, yEnd);
00077
00078 for (register label nn=2; nn<=nSteps; nn++)
00079 {
00080 for (register label i=0; i<n_; i++)
00081 {
00082 yEnd[i] = h*yEnd[i] - del[i];
00083 }
00084
00085 LUBacksubstitute(a, pivotIndices, yEnd);
00086
00087 for (register label i=0; i<n_; i++)
00088 {
00089 ytemp[i] += (del[i] += 2.0*yEnd[i]);
00090 }
00091
00092 x += h;
00093
00094 ode.derivatives(x, ytemp, yEnd);
00095 }
00096 for (register label i=0; i<n_; i++)
00097 {
00098 yEnd[i] = h*yEnd[i] - del[i];
00099 }
00100
00101 LUBacksubstitute(a, pivotIndices, yEnd);
00102
00103 for (register label i=0; i<n_; i++)
00104 {
00105 yEnd[i] += ytemp[i];
00106 }
00107 }
00108
00109
00110
Copyright © 2000-2009 OpenCFD Ltd