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 -------------------------------------------------------------------------------
11 License
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 "jumpCyclicFvPatchField.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
40  cyclicFvPatchField<Type>(p, iF)
41 {}
42 
43 
44 template<class Type>
46 (
48  const fvPatch& p,
50  const fvPatchFieldMapper& mapper
51 )
52 :
53  cyclicFvPatchField<Type>(ptf, p, iF, mapper)
54 {}
55 
56 
57 template<class Type>
59 (
60  const fvPatch& p,
62  const dictionary& dict,
63  const bool needValue
64 )
65 :
66  cyclicFvPatchField<Type>(p, iF, dict, needValue)
67 {}
68 
69 
70 template<class Type>
72 (
74 )
75 :
76  cyclicFvPatchField<Type>(ptf)
77 {}
78 
79 
80 template<class Type>
82 (
85 )
86 :
87  cyclicFvPatchField<Type>(ptf, iF)
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 template<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]);
123  }
124  }
125 }
126 
127 
128 template<class Type>
131 {
132  auto tpnf = tmp<Field<Type>>::New(this->size());
133  this->patchNeighbourField(tpnf.ref());
134  return tpnf;
135 }
136 
137 
138 template<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,
148  const Pstream::commsTypes
149 ) const
150 {
152 }
153 
154 
155 template<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,
164  const Pstream::commsTypes
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 // ************************************************************************* //
label patchId(-1)
dictionary dict
uint8_t direction
Definition: direction.H:46
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
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.
UList< label > labelUList
A UList of labels.
Definition: UList.H:76
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:286
Generic templated field type.
Definition: Field.H:63
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.
A FieldMapper for finite-volume patch fields.
This boundary condition provides a base class for coupled-cyclic conditions with a specified &#39;jump&#39; (...
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
The class contains the addressing required by the lduMatrix: upper, lower and losort.
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled values.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:688