Loading...
Searching...
No Matches
jumpCyclicFvPatchField.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-2017 OpenFOAM Foundation
9 Copyright (C) 2019-2024 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
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const fvPatch& p,
39:
40 cyclicFvPatchField<Type>(p, iF)
41{}
42
43
44template<class Type>
46(
48 const fvPatch& p,
50 const fvPatchFieldMapper& mapper
52:
53 cyclicFvPatchField<Type>(ptf, p, iF, mapper)
54{}
55
56
57template<class Type>
59(
60 const fvPatch& p,
62 const dictionary& dict,
63 const bool needValue
65:
66 cyclicFvPatchField<Type>(p, iF, dict, needValue)
67{}
68
69
70template<class Type>
72(
75:
76 cyclicFvPatchField<Type>(ptf)
77{}
78
79
80template<class Type>
82(
85)
86:
87 cyclicFvPatchField<Type>(ptf, iF)
88{}
89
90
91// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92
93template<class Type>
95(
96 UList<Type>& pnf
97) const
98{
99 const Field<Type>& iField = this->primitiveField();
100 const labelUList& nbrFaceCells =
101 this->cyclicPatch().neighbFvPatch().faceCells();
102
103 Field<Type> jf(this->jump());
104 if (!this->cyclicPatch().owner())
105 {
106 jf *= -1.0;
107 }
108
109 if (this->doTransform())
110 {
111 const auto& rot = this->forwardT()[0];
112
113 forAll(pnf, i)
114 {
115 pnf[i] = (transform(rot, iField[nbrFaceCells[i]]) - jf[i]);
116 }
117 }
118 else
119 {
120 forAll(pnf, i)
121 {
122 pnf[i] = (iField[nbrFaceCells[i]] - jf[i]);
124 }
125}
126
127
128template<class Type>
129Foam::tmp<Foam::Field<Type>>
131{
132 auto tpnf = tmp<Field<Type>>::New(this->size());
133 this->patchNeighbourField(tpnf.ref());
134 return tpnf;
135}
136
137
138template<class Type>
140(
141 solveScalarField& result,
142 const bool add,
143 const lduAddressing& lduAddr,
144 const label patchId,
145 const solveScalarField& psiInternal,
146 const scalarField& coeffs,
147 const direction cmpt,
149) const
150{
152}
153
154
155template<class Type>
157(
158 Field<Type>& result,
159 const bool add,
160 const lduAddressing& lduAddr,
161 const label patchId,
162 const Field<Type>& psiInternal,
163 const scalarField& coeffs,
165) const
166{
167 Field<Type> pnf(this->size());
168
169 const labelUList& nbrFaceCells =
170 lduAddr.patchAddr
171 (
172 this->cyclicPatch().neighbPatchID()
173 );
174
175 // only apply jump to original field
176 if (&psiInternal == &this->primitiveField())
177 {
178 Field<Type> jf(this->jump());
179
180 if (!this->cyclicPatch().owner())
181 {
182 jf *= -1.0;
183 }
184
185 forAll(pnf, facei)
186 {
187 pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
188 }
189 }
190 else
191 {
192 forAll(pnf, facei)
193 {
194 pnf[facei] = psiInternal[nbrFaceCells[facei]];
195 }
196 }
197
198 // Transform according to the transformation tensors
199 this->transformCoupleField(pnf);
200
201 const labelUList& faceCells = lduAddr.patchAddr(patchId);
202
203 // Multiply the field by coefficients and add into the result
204 this->addToInternalField(result, !add, faceCells, coeffs, pnf);
205}
206
207
208// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
void size(const label n)
Definition UList.H:118
commsTypes
Communications types.
Definition UPstream.H:81
virtual bool doTransform() const
Does the patch field perform the transformation.
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
const cyclicFvPatch & cyclicPatch() const
Return local reference cast into the cyclic patch.
virtual const tensorField & forwardT() const
Return face transformation tensor.
void transformCoupleField(Field< Type > &f) const
Transform given patch field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Smooth ATC in cells next to a set of patches supplied by type.
Definition faceCells.H:55
A FieldMapper for finite-volume patch fields.
const Field< Type > & primitiveField() const noexcept
Return const-reference to the internal field values.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
This boundary condition provides a base class for coupled-cyclic conditions with a specified 'jump' (...
jumpCyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
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.
virtual tmp< Field< Type > > jump() const =0
Return the "jump" across the patch as a "half" field.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled values.
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.
void addToInternalField(Field< Type > &result, const bool add, const labelUList &faceCells, const scalarField &coeffs, const Field< Type > &vals) const
Add/subtract weighted contributions to internal field.
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
label patchId(-1)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
Field< solveScalar > solveScalarField
uint8_t direction
Definition direction.H:49
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299