GAMGSolverInterpolate.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) 2013-2015 OpenFOAM Foundation
9  Copyright (C) 2017-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 void Foam::GAMGSolver::interpolate
34 (
36  solveScalarField& Apsi,
37  const lduMatrix& m,
38  const FieldField<Field, scalar>& interfaceBouCoeffs,
39  const lduInterfaceFieldPtrsList& interfaces,
40  const direction cmpt
41 ) const
42 {
43  solveScalar* __restrict__ psiPtr = psi.begin();
44 
45  const label* const __restrict__ uPtr = m.lduAddr().upperAddr().begin();
46  const label* const __restrict__ lPtr = m.lduAddr().lowerAddr().begin();
47 
48  const scalar* const __restrict__ diagPtr = m.diag().begin();
49  const scalar* const __restrict__ upperPtr = m.upper().begin();
50  const scalar* const __restrict__ lowerPtr = m.lower().begin();
51 
52  Apsi = 0;
53  solveScalar* __restrict__ ApsiPtr = Apsi.begin();
54 
55  m.initMatrixInterfaces
56  (
57  true,
59  interfaces,
60  psi,
61  Apsi,
62  cmpt
63  );
64 
65  const label nFaces = m.upper().size();
66  for (label face=0; face<nFaces; face++)
67  {
68  ApsiPtr[uPtr[face]] += lowerPtr[face]*psiPtr[lPtr[face]];
69  ApsiPtr[lPtr[face]] += upperPtr[face]*psiPtr[uPtr[face]];
70  }
71 
72  m.updateMatrixInterfaces
73  (
74  true,
76  interfaces,
77  psi,
78  Apsi,
79  cmpt
80  );
81 
82  const label nCells = m.diag().size();
83  for (label celli=0; celli<nCells; celli++)
84  {
85  psiPtr[celli] = -ApsiPtr[celli]/(diagPtr[celli]);
86  }
87 }
88 
89 
90 void Foam::GAMGSolver::interpolate
91 (
93  solveScalarField& Apsi,
94  const lduMatrix& m,
95  const FieldField<Field, scalar>& interfaceBouCoeffs,
96  const lduInterfaceFieldPtrsList& interfaces,
97  const labelList& restrictAddressing,
98  const solveScalarField& psiC,
99  const direction cmpt
100 ) const
101 {
103  (
104  psi,
105  Apsi,
106  m,
107  interfaceBouCoeffs,
108  interfaces,
109  cmpt
110  );
111 
112  const label nCells = m.diag().size();
113  solveScalar* __restrict__ psiPtr = psi.begin();
114  const scalar* const __restrict__ diagPtr = m.diag().begin();
115  const solveScalar* const __restrict__ psiCPtr = psiC.begin();
116 
117 
118  const label nCCells = psiC.size();
119  solveScalarField corrC(nCCells, 0);
120  solveScalar* __restrict__ corrCPtr = corrC.begin();
121 
122  solveScalarField diagC(nCCells, 0);
123  solveScalar* __restrict__ diagCPtr = diagC.begin();
124 
125  for (label celli=0; celli<nCells; celli++)
126  {
127  corrCPtr[restrictAddressing[celli]] += diagPtr[celli]*psiPtr[celli];
128  diagCPtr[restrictAddressing[celli]] += diagPtr[celli];
129  }
130 
131  for (label ccelli=0; ccelli<nCCells; ccelli++)
132  {
133  corrCPtr[ccelli] = psiCPtr[ccelli] - corrCPtr[ccelli]/diagCPtr[ccelli];
134  }
135 
136  for (label celli=0; celli<nCells; celli++)
137  {
138  psiPtr[celli] += corrCPtr[restrictAddressing[celli]];
139  }
140 }
141 
142 
143 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
Foam::lduMatrix::solver::interfaces
const lduInterfaceFieldPtrsList & interfaces() const
Definition: lduMatrix.H:246
Foam::lduInterfaceFieldPtrsList
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
Definition: lduInterfaceFieldPtrsList.H:44
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
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:62
Foam::solveScalarField
Field< solveScalar > solveScalarField
Definition: primitiveFieldsFwd.H:53
Foam::lduMatrix::solver::interfaceBouCoeffs
const FieldField< Field, scalar > & interfaceBouCoeffs() const
Definition: lduMatrix.H:236
Foam::direction
uint8_t direction
Definition: direction.H:47
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
GAMGSolver.H