SIMPR.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "SIBS.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
31 (
32  const scalar xStart,
33  const scalarField& y,
34  const scalarField& dydx,
35  const scalarField& dfdx,
36  const scalarSquareMatrix& dfdy,
37  const scalar deltaX,
38  const label nSteps,
39  scalarField& yEnd
40 ) const
41 {
42  scalar h = deltaX/nSteps;
43 
44  scalarSquareMatrix a(n_);
45  for (label i=0; i<n_; i++)
46  {
47  for (label j=0; j<n_; j++)
48  {
49  a[i][j] = -h*dfdy[i][j];
50  }
51  ++a[i][i];
52  }
53 
54  labelList pivotIndices(n_);
55  LUDecompose(a, pivotIndices);
56 
57  for (label i=0; i<n_; i++)
58  {
59  yEnd[i] = h*(dydx[i] + h*dfdx[i]);
60  }
61 
62  LUBacksubstitute(a, pivotIndices, yEnd);
63 
64  scalarField del(yEnd);
65  scalarField ytemp(n_);
66 
67  for (label i=0; i<n_; i++)
68  {
69  ytemp[i] = y[i] + del[i];
70  }
71 
72  scalar x = xStart + h;
73 
74  odes_.derivatives(x, ytemp, yEnd);
75 
76  for (label nn=2; nn<=nSteps; nn++)
77  {
78  for (label i=0; i<n_; i++)
79  {
80  yEnd[i] = h*yEnd[i] - del[i];
81  }
82 
83  LUBacksubstitute(a, pivotIndices, yEnd);
84 
85  for (label i=0; i<n_; i++)
86  {
87  ytemp[i] += (del[i] += 2.0*yEnd[i]);
88  }
89 
90  x += h;
91 
92  odes_.derivatives(x, ytemp, yEnd);
93  }
94  for (label i=0; i<n_; i++)
95  {
96  yEnd[i] = h*yEnd[i] - del[i];
97  }
98 
99  LUBacksubstitute(a, pivotIndices, yEnd);
100 
101  for (label i=0; i<n_; i++)
102  {
103  yEnd[i] += ytemp[i];
104  }
105 }
106 
107 
108 // ************************************************************************* //
Foam::SIBS::SIMPR
void SIMPR(const scalar xStart, const scalarField &y, const scalarField &dydx, const scalarField &dfdx, const scalarSquareMatrix &dfdy, const scalar deltaX, const label nSteps, scalarField &yEnd) const
Definition: SIMPR.C:31
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: createFields.H:6
Foam::LUBacksubstitute
void LUBacksubstitute(const scalarSquareMatrix &luMmatrix, const labelList &pivotIndices, List< Type > &source)
LU back-substitution with given source, returning the solution.
Definition: scalarMatricesTemplates.C:120
Foam::LUDecompose
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
Definition: scalarMatrices.C:32
Foam::SquareMatrix< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
x
x
Definition: LISASMDCalcMethod2.H:52
SIBS.H
y
scalar y
Definition: LISASMDCalcMethod1.H:14