jumpCyclicFvPatchFields.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2018-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
31#include "volFields.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
38}
39
40// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41
42template<>
44(
45 solveScalarField& result,
46 const bool add,
47 const lduAddressing& lduAddr,
48 const label patchId,
49 const solveScalarField& psiInternal,
50 const scalarField& coeffs,
51 const direction cmpt,
53) const
54{
55 solveScalarField pnf(this->size());
56
57 const labelUList& nbrFaceCells =
58 lduAddr.patchAddr
59 (
60 this->cyclicPatch().neighbPatchID()
61 );
62
63 // only apply jump to original field
64 if
65 (
66 reinterpret_cast<const void*>(&psiInternal)
67 == reinterpret_cast<const void*>(&this->primitiveField())
68 )
69 {
70 Field<scalar> jf(this->jump());
71
72 if (!this->cyclicPatch().owner())
73 {
74 jf *= -1.0;
75 }
76
77 forAll(*this, facei)
78 {
79 pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
80 }
81 }
82 else
83 {
84 forAll(*this, facei)
85 {
86 pnf[facei] = psiInternal[nbrFaceCells[facei]];
87 }
88 }
89
90 // Transform according to the transformation tensors
91 this->transformCoupleField(pnf, cmpt);
92
93 const labelUList& faceCells = lduAddr.patchAddr(patchId);
94
95 // Multiply the field by coefficients and add into the result
96 this->addToInternalField(result, !add, faceCells, coeffs, pnf);
97}
98
99
100template<>
102(
103 solveScalarField& result,
104 const bool add,
105 const lduAddressing& lduAddr,
106 const label patchId,
107 const solveScalarField& psiInternal,
108 const scalarField& coeffs,
109 const direction cmpt,
111) const
112{
113 solveScalarField pnf(this->size());
114
115 const labelUList& nbrFaceCells =
116 lduAddr.patchAddr
117 (
118 this->cyclicPatch().neighbPatchID()
119 );
120
121 const Field<vector>& iField = this->primitiveField();
122
123 // only apply jump to original field
124 if
125 (
126 reinterpret_cast<const void*>(&psiInternal)
127 == reinterpret_cast<const void*>(&(iField.component(cmpt).ref()))
128 )
129 {
130 Field<vector> jf(this->jump());
131
132 if (!this->cyclicPatch().owner())
133 {
134 jf *= -1.0;
135 }
136
137 forAll(*this, facei)
138 {
139 pnf[facei] =
140 psiInternal[nbrFaceCells[facei]]
141 - jf[facei].component(cmpt);
142 }
143 }
144 else
145 {
146 forAll(*this, facei)
147 {
148 pnf[facei] = psiInternal[nbrFaceCells[facei]];
149 }
150 }
151
152 // Transform according to the transformation tensors
153 this->transformCoupleField(pnf, cmpt);
154
155 const labelUList& faceCells = lduAddr.patchAddr(patchId);
156
157 // Multiply the field by coefficients and add into the result
158 this->addToInternalField(result, !add, faceCells, coeffs, pnf);
159}
160
161// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:545
commsTypes
Types of communications.
Definition: UPstream.H:67
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
#define makePatchFieldTypeNames(type)
Definition: fvPatchField.H:708
label patchId(-1)
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:56
dict add("bounds", meshBb)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333