HOTFIX: Adjust Windows build instructions repo
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / fvPatchVectorNFields / processorFvPatchVectorNFields.C
blob48fe8aad806df05659f8504f2d33e0658fe757ab
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 "processorFvPatchVectorNFields.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
36 #define VectorNMatrixInterfaceFunc(Type)                                      \
37 template <>                                                                   \
38 void processorFvPatchField<Type>::initInterfaceMatrixUpdate                   \
39 (                                                                             \
40     const Field<Type>& psiInternal,                                           \
41     Field<Type>&,                                                             \
42     const BlockLduMatrix<Type>&,                                              \
43     const CoeffField<Type>&,                                                  \
44     const Pstream::commsTypes commsType,                                      \
45     const bool switchToLhs                                                    \
46 ) const                                                                       \
47 {                                                                             \
48     procPatch_.compressedSend                                                 \
49     (                                                                         \
50         commsType,                                                            \
51         this->patch().patchInternalField(psiInternal)()                       \
52     );                                                                        \
53 }                                                                             \
54                                                                               \
55 template <>                                                                   \
56 void processorFvPatchField<Type>::updateInterfaceMatrix                       \
57 (                                                                             \
58     const Field<Type>& psiInternal,                                           \
59     Field<Type>& result,                                                      \
60     const BlockLduMatrix<Type>&,                                              \
61     const CoeffField<Type>& coeffs,                                           \
62     const Pstream::commsTypes commsType,                                      \
63     const bool switchToLhs                                                    \
64 ) const                                                                       \
65 {                                                                             \
66     Field<Type> pnf(this->size());                                            \
67                                                                               \
68     if (coeffs.activeType() == blockCoeffBase::SCALAR)                        \
69     {                                                                         \
70         pnf = coeffs.asScalar() *                                             \
71             procPatch_.compressedReceive<Type>(commsType, this->size())();    \
72     }                                                                         \
73     else if (coeffs.activeType() == blockCoeffBase::LINEAR)                   \
74     {                                                                         \
75         pnf = cmptMultiply(coeffs.asLinear(),                                 \
76             procPatch_.compressedReceive<Type>(commsType, this->size())()     \
77         );                                                                    \
78     }                                                                         \
79     else if (coeffs.activeType() == blockCoeffBase::SQUARE)                   \
80     {                                                                         \
81         pnf = coeffs.asSquare() &                                             \
82             procPatch_.compressedReceive<Type>(commsType, this->size())();    \
83     }                                                                         \
84                                                                               \
85     const unallocLabelList& faceCells = this->patch().faceCells();            \
86                                                                               \
87     if (switchToLhs)                                                          \
88     {                                                                         \
89         forAll(faceCells, elemI)                                              \
90         {                                                                     \
91             result[faceCells[elemI]] += pnf[elemI];                           \
92         }                                                                     \
93     }                                                                         \
94     else                                                                      \
95     {                                                                         \
96         forAll(faceCells, elemI)                                              \
97         {                                                                     \
98             result[faceCells[elemI]] -= pnf[elemI];                           \
99         }                                                                     \
100     }                                                                         \
104 #define doMakePatchTypeField(type, Type, args...)                             \
105                                                                               \
106 VectorNMatrixInterfaceFunc(type)                                              \
107                                                                               \
108 makeTemplatePatchTypeField                                                    \
109 (                                                                             \
110     fvPatch##Type##Field,                                                     \
111     processorFvPatch##Type##Field                                             \
114 forAllVectorNTypes(doMakePatchTypeField)
116 #undef doMakePatchTypeField
118 #undef VectorNMatrixInterfaceFunc
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 } // End namespace Foam
124 // ************************************************************************* //