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-------------------------------------------------------------------------------
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
31// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32
34(
35 solveScalarField& psi,
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 const label startRequest = Pstream::nRequests();
56
57 m.initMatrixInterfaces
58 (
59 true,
62 psi,
63 Apsi,
64 cmpt
65 );
66
67 const label nFaces = m.upper().size();
68 for (label face=0; face<nFaces; face++)
69 {
70 ApsiPtr[uPtr[face]] += lowerPtr[face]*psiPtr[lPtr[face]];
71 ApsiPtr[lPtr[face]] += upperPtr[face]*psiPtr[uPtr[face]];
72 }
73
74 m.updateMatrixInterfaces
75 (
76 true,
79 psi,
80 Apsi,
81 cmpt,
82 startRequest
83 );
84
85 const label nCells = m.diag().size();
86 for (label celli=0; celli<nCells; celli++)
87 {
88 psiPtr[celli] = -ApsiPtr[celli]/(diagPtr[celli]);
89 }
90}
91
92
94(
96 solveScalarField& Apsi,
97 const lduMatrix& m,
98 const FieldField<Field, scalar>& interfaceBouCoeffs,
99 const lduInterfaceFieldPtrsList& interfaces,
100 const labelList& restrictAddressing,
101 const solveScalarField& psiC,
102 const direction cmpt
103) const
104{
106 (
107 psi,
108 Apsi,
109 m,
110 interfaceBouCoeffs,
111 interfaces,
112 cmpt
113 );
114
115 const label nCells = m.diag().size();
116 solveScalar* __restrict__ psiPtr = psi.begin();
117 const scalar* const __restrict__ diagPtr = m.diag().begin();
118 const solveScalar* const __restrict__ psiCPtr = psiC.begin();
119
120
121 const label nCCells = psiC.size();
122 solveScalarField corrC(nCCells, 0);
123 solveScalar* __restrict__ corrCPtr = corrC.begin();
124
125 solveScalarField diagC(nCCells, 0);
126 solveScalar* __restrict__ diagCPtr = diagC.begin();
127
128 for (label celli=0; celli<nCells; celli++)
129 {
130 corrCPtr[restrictAddressing[celli]] += diagPtr[celli]*psiPtr[celli];
131 diagCPtr[restrictAddressing[celli]] += diagPtr[celli];
132 }
133
134 for (label ccelli=0; ccelli<nCCells; ccelli++)
135 {
136 corrCPtr[ccelli] = psiCPtr[ccelli] - corrCPtr[ccelli]/diagCPtr[ccelli];
137 }
138
139 for (label celli=0; celli<nCells; celli++)
140 {
141 psiPtr[celli] += corrCPtr[restrictAddressing[celli]];
142 }
143}
144
145
146// ************************************************************************* //
iterator begin() noexcept
Return an iterator to begin traversing the UList.
Definition: UListI.H:329
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
static label nRequests()
Get number of outstanding requests.
Definition: UPstream.C:90
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition: lduMatrix.H:248
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition: lduMatrix.H:238
bool interpolate() const noexcept
Same as isPointData()
const volScalarField & psi
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
List< label > labelList
A List of labels.
Definition: List.H:66
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
Field< solveScalar > solveScalarField
uint8_t direction
Definition: direction.H:56
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75