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 | Copyright (C) 2013-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 "GAMGSolver.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 void Foam::GAMGSolver::interpolate
31 (
32  scalarField& psi,
33  scalarField& Apsi,
34  const lduMatrix& m,
35  const FieldField<Field, scalar>& interfaceBouCoeffs,
36  const lduInterfaceFieldPtrsList& interfaces,
37  const direction cmpt
38 ) const
39 {
40  scalar* __restrict__ psiPtr = psi.begin();
41 
42  const label* const __restrict__ uPtr = m.lduAddr().upperAddr().begin();
43  const label* const __restrict__ lPtr = m.lduAddr().lowerAddr().begin();
44 
45  const scalar* const __restrict__ diagPtr = m.diag().begin();
46  const scalar* const __restrict__ upperPtr = m.upper().begin();
47  const scalar* const __restrict__ lowerPtr = m.lower().begin();
48 
49  Apsi = 0;
50  scalar* __restrict__ ApsiPtr = Apsi.begin();
51 
52  m.initMatrixInterfaces
53  (
54  interfaceBouCoeffs,
55  interfaces,
56  psi,
57  Apsi,
58  cmpt
59  );
60 
61  const label nFaces = m.upper().size();
62  for (label face=0; face<nFaces; face++)
63  {
64  ApsiPtr[uPtr[face]] += lowerPtr[face]*psiPtr[lPtr[face]];
65  ApsiPtr[lPtr[face]] += upperPtr[face]*psiPtr[uPtr[face]];
66  }
67 
68  m.updateMatrixInterfaces
69  (
70  interfaceBouCoeffs,
71  interfaces,
72  psi,
73  Apsi,
74  cmpt
75  );
76 
77  const label nCells = m.diag().size();
78  for (label celli=0; celli<nCells; celli++)
79  {
80  psiPtr[celli] = -ApsiPtr[celli]/(diagPtr[celli]);
81  }
82 }
83 
84 
85 void Foam::GAMGSolver::interpolate
86 (
87  scalarField& psi,
88  scalarField& Apsi,
89  const lduMatrix& m,
90  const FieldField<Field, scalar>& interfaceBouCoeffs,
91  const lduInterfaceFieldPtrsList& interfaces,
92  const labelList& restrictAddressing,
93  const scalarField& psiC,
94  const direction cmpt
95 ) const
96 {
98  (
99  psi,
100  Apsi,
101  m,
102  interfaceBouCoeffs,
103  interfaces,
104  cmpt
105  );
106 
107  const label nCells = m.diag().size();
108  scalar* __restrict__ psiPtr = psi.begin();
109  const scalar* const __restrict__ diagPtr = m.diag().begin();
110 
111  const label nCCells = psiC.size();
112  scalarField corrC(nCCells, 0);
113  scalarField diagC(nCCells, 0);
114 
115  for (label celli=0; celli<nCells; celli++)
116  {
117  corrC[restrictAddressing[celli]] += diagPtr[celli]*psiPtr[celli];
118  diagC[restrictAddressing[celli]] += diagPtr[celli];
119  }
120 
121  for (label ccelli=0; ccelli<nCCells; ccelli++)
122  {
123  corrC[ccelli] = psiC[ccelli] - corrC[ccelli]/diagC[ccelli];
124  }
125 
126  for (label celli=0; celli<nCells; celli++)
127  {
128  psiPtr[celli] += corrC[restrictAddressing[celli]];
129  }
130 }
131 
132 
133 // ************************************************************************* //
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
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
uint8_t direction
Definition: direction.H:46
tmp< surfaceScalarField > interpolate(const RhoType &rho)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
Definition: labelList.H:56
volScalarField scalarField(fieldObject, mesh)