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>
96 {
97  const Field<Type>& iField = this->primitiveField();
98  const labelUList& nbrFaceCells =
99  this->cyclicPatch().neighbFvPatch().faceCells();
100 
101  auto tpnf = tmp<Field<Type>>::New(this->size());
102  auto& pnf = tpnf.ref();
103 
104  Field<Type> jf(this->jump());
105  if (!this->cyclicPatch().owner())
106  {
107  jf *= -1.0;
108  }
109 
110  if (this->doTransform())
111  {
112  forAll(*this, facei)
113  {
114  pnf[facei] = transform
115  (
116  this->forwardT()[0], iField[nbrFaceCells[facei]]
117  ) - jf[facei];
118  }
119  }
120  else
121  {
122  forAll(*this, facei)
123  {
124  pnf[facei] = iField[nbrFaceCells[facei]] - jf[facei];
125  }
126  }
128  return tpnf;
129 }
130 
131 
132 template<class Type>
134 (
135  solveScalarField& result,
136  const bool add,
137  const lduAddressing& lduAddr,
138  const label patchId,
139  const solveScalarField& psiInternal,
140  const scalarField& coeffs,
141  const direction cmpt,
142  const Pstream::commsTypes
143 ) const
144 {
146 }
147 
148 
149 template<class Type>
151 (
152  Field<Type>& result,
153  const bool add,
154  const lduAddressing& lduAddr,
155  const label patchId,
156  const Field<Type>& psiInternal,
157  const scalarField& coeffs,
158  const Pstream::commsTypes
159 ) const
160 {
161  Field<Type> pnf(this->size());
162 
163  const labelUList& nbrFaceCells =
164  lduAddr.patchAddr
165  (
166  this->cyclicPatch().neighbPatchID()
167  );
168 
169  // only apply jump to original field
170  if (&psiInternal == &this->primitiveField())
171  {
172  Field<Type> jf(this->jump());
173 
174  if (!this->cyclicPatch().owner())
175  {
176  jf *= -1.0;
177  }
178 
179  forAll(*this, facei)
180  {
181  pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
182  }
183  }
184  else
185  {
186  forAll(*this, facei)
187  {
188  pnf[facei] = psiInternal[nbrFaceCells[facei]];
189  }
190  }
191 
192  // Transform according to the transformation tensors
193  this->transformCoupleField(pnf);
194 
195  const labelUList& faceCells = lduAddr.patchAddr(patchId);
196 
197  // Multiply the field by coefficients and add into the result
198  this->addToInternalField(result, !add, faceCells, coeffs, pnf);
199 }
200 
201 
202 // ************************************************************************* //
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:78
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
Generic templated field type.
Definition: Field.H:62
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
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled given internal cell data.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:696