Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / matrices / lduMatrix / solvers / GAMG / interfaceFields / processorGAMGInterfaceField / processorGAMGInterfaceField.C
blobf400f458e6d331ddbe8ab53ad67b7df0454a3af7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "processorGAMGInterfaceField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "lduMatrix.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34     defineTypeNameAndDebug(processorGAMGInterfaceField, 0);
35     addToRunTimeSelectionTable
36     (
37         GAMGInterfaceField,
38         processorGAMGInterfaceField,
39         lduInterface
40     );
44 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
46 Foam::processorGAMGInterfaceField::processorGAMGInterfaceField
48     const GAMGInterface& GAMGCp,
49     const lduInterfaceField& fineInterfaceField
52     GAMGInterfaceField(GAMGCp, fineInterfaceField),
53     procInterface_(refCast<const processorGAMGInterface>(GAMGCp)),
54     doTransform_(false),
55     rank_(0)
57     const processorLduInterfaceField& p =
58         refCast<const processorLduInterfaceField>(fineInterfaceField);
60     doTransform_ = p.doTransform();
61     rank_ = p.rank();
65 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
67 Foam::processorGAMGInterfaceField::~processorGAMGInterfaceField()
71 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
73 void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate
75     const scalarField& psiInternal,
76     scalarField&,
77     const lduMatrix&,
78     const scalarField&,
79     const direction,
80     const Pstream::commsTypes commsType,
81     const bool switchToLhs
82 ) const
84     procInterface_.compressedSend
85     (
86         commsType,
87         procInterface_.interfaceInternalField(psiInternal)()
88     );
92 void Foam::processorGAMGInterfaceField::updateInterfaceMatrix
94     const scalarField&,
95     scalarField& result,
96     const lduMatrix&,
97     const scalarField& coeffs,
98     const direction cmpt,
99     const Pstream::commsTypes commsType,
100     const bool switchToLhs
101 ) const
103     scalarField pnf
104     (
105         procInterface_.compressedReceive<scalar>(commsType, coeffs.size())
106     );
107     transformCoupleField(pnf, cmpt);
109     const unallocLabelList& faceCells = procInterface_.faceCells();
111     if (switchToLhs)
112     {
113         forAll(faceCells, elemI)
114         {
115             result[faceCells[elemI]] += coeffs[elemI]*pnf[elemI];
116         }
117     }
118     else
119     {
120         forAll(faceCells, elemI)
121         {
122             result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
123         }
124     }
128 // ************************************************************************* //