All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GAMGSolverScale.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 
31 void Foam::GAMGSolver::scale
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  const 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 // ************************************************************************* //
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
uint8_t direction
Definition: direction.H:45
Vector2D< scalar > vector2D
vector2D obtained from generic Vector2D
Definition: vector2D.H:49
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
volScalarField scalarField(fieldObject, mesh)
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53