OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

SIMPR.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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