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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2017-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "GAMGSolver.H"
30#include "FixedList.H"
31
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
35(
36 solveScalarField& field,
37 solveScalarField& Acf,
38 const lduMatrix& A,
39 const FieldField<Field, scalar>& interfaceLevelBouCoeffs,
40 const lduInterfaceFieldPtrsList& interfaceLevel,
41 const solveScalarField& source,
42 const direction cmpt
43) const
44{
45 A.Amul
46 (
47 Acf,
48 field,
49 interfaceLevelBouCoeffs,
50 interfaceLevel,
51 cmpt
52 );
53
54
55 const label nCells = field.size();
56 solveScalar* __restrict__ fieldPtr = field.begin();
57 const solveScalar* const __restrict__ sourcePtr = source.begin();
58 const solveScalar* const __restrict__ AcfPtr = Acf.begin();
59
60
61 FixedList<solveScalar, 2> scalingFactor(Zero);
62
63 for (label i=0; i<nCells; i++)
64 {
65 scalingFactor[0] += fieldPtr[i]*sourcePtr[i];
66 scalingFactor[1] += fieldPtr[i]*AcfPtr[i];
67 }
68
69 A.mesh().reduce(scalingFactor, sumOp<solveScalar>());
70
71 const solveScalar sf =
72 (
73 scalingFactor[0]
74 / stabilise(scalingFactor[1], pTraits<solveScalar>::vsmall)
75 );
76
77 if (debug >= 2)
78 {
79 Pout<< sf << " ";
80 }
81
82 const scalarField& D = A.diag();
83 const scalar* const __restrict__ DPtr = D.begin();
84
85 for (label i=0; i<nCells; i++)
86 {
87 fieldPtr[i] = sf*fieldPtr[i] + (sourcePtr[i] - sf*AcfPtr[i])/DPtr[i];
88 }
89}
90
91
92// ************************************************************************* //
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
scalar scale
Overall scale factor.
Definition: PDRparams.H:140
static const Scalar vsmall
Definition: Scalar.H:107
rDeltaTY field()
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const dimensionedScalar & D