GAMGSolverScale.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-2013 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 "GAMGSolver.H"
27 #include "vector2D.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
32 (
33  scalarField& field,
34  scalarField& Acf,
35  const lduMatrix& A,
36  const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
37  const lduInterfaceFieldPtrsList& interfaceLevel,
38  const scalarField& source,
39  const direction cmpt
40 ) const
41 {
42  A.Amul
43  (
44  Acf,
45  field,
46  interfaceLevelBouCoeffs,
47  interfaceLevel,
48  cmpt
49  );
50 
51  scalar scalingFactorNum = 0.0;
52  scalar scalingFactorDenom = 0.0;
53 
54  forAll(field, i)
55  {
56  scalingFactorNum += source[i]*field[i];
57  scalingFactorDenom += Acf[i]*field[i];
58  }
59 
60  vector2D scalingVector(scalingFactorNum, scalingFactorDenom);
61  A.mesh().reduce(scalingVector, sumOp<vector2D>());
62 
63  scalar sf = scalingVector.x()/stabilise(scalingVector.y(), VSMALL);
64 
65  if (debug >= 2)
66  {
67  Pout<< sf << " ";
68  }
69 
70  const scalarField& D = A.diag();
71 
72  forAll(field, i)
73  {
74  field[i] = sf*field[i] + (source[i] - sf*Acf[i])/D[i];
75  }
76 }
77 
78 
79 // ************************************************************************* //
Foam::FieldField
Generic field type.
Definition: FieldField.H:51
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::lduMatrix
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:77
Foam::Vector2D< scalar >
A
simpleMatrix< scalar > A(Nc)
Foam::Vector2D::y
const Cmpt & y() const
Definition: Vector2DI.H:73
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::stabilise
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
Definition: DimensionedScalarField.C:40
Foam::Vector2D::x
const Cmpt & x() const
Definition: Vector2DI.H:67
Foam::UPtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:53
vector2D.H
sf
volScalarField sf(fieldObject, mesh)
Foam::sumOp
Definition: ops.H:162
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::GAMGSolver::scale
void scale(scalarField &field, scalarField &Acf, const lduMatrix &A, const FieldField< Field, scalar > &interfaceLevelBouCoeffs, const lduInterfaceFieldPtrsList &interfaceLevel, const scalarField &source, const direction cmpt) const
Calculate and apply the scaling factor from Acf, coarseSource.
Definition: GAMGSolverScale.C:32
Foam::direction
unsigned char direction
Definition: direction.H:43
GAMGSolver.H