cyclicFaPatchField.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2019-2023 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 "cyclicFaPatchField.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const faPatch& p,
38 )
39 :
40  coupledFaPatchField<Type>(p, iF),
41  cyclicPatch_(refCast<const cyclicFaPatch>(p))
42 {}
43 
44 
45 template<class Type>
47 (
48  const cyclicFaPatchField<Type>& ptf,
49  const faPatch& p,
51  const faPatchFieldMapper& mapper
52 )
53 :
54  coupledFaPatchField<Type>(ptf, p, iF, mapper),
55  cyclicPatch_(refCast<const cyclicFaPatch>(p))
56 {
57  if (!isA<cyclicFaPatch>(this->patch()))
58  {
60  << "\n patch type '" << p.type()
61  << "' not constraint type '" << typeName << "'"
62  << "\n for patch " << p.name()
63  << " of field " << this->internalField().name()
64  << " in file " << this->internalField().objectPath()
66  }
67 }
68 
69 
70 template<class Type>
72 (
73  const faPatch& p,
74  const DimensionedField<Type, areaMesh>& iF,
75  const dictionary& dict,
76  IOobjectOption::readOption requireValue
77 )
78 :
79  coupledFaPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
80  cyclicPatch_(refCast<const cyclicFaPatch>(p, dict))
81 {
82  if (!isA<cyclicFaPatch>(p))
83  {
85  << "\n patch type '" << p.type()
86  << "' not constraint type '" << typeName << "'"
87  << "\n for patch " << p.name()
88  << " of field " << this->internalField().name()
89  << " in file " << this->internalField().objectPath()
90  << exit(FatalIOError);
91  }
92 
93  if (IOobjectOption::isReadRequired(requireValue))
94  {
96  }
97 }
98 
99 
100 template<class Type>
102 (
103  const cyclicFaPatchField<Type>& ptf
104 )
105 :
106  cyclicLduInterfaceField(),
108  cyclicPatch_(ptf.cyclicPatch_)
109 {}
110 
111 
112 template<class Type>
114 (
115  const cyclicFaPatchField<Type>& ptf,
117 )
118 :
119  coupledFaPatchField<Type>(ptf, iF),
120  cyclicPatch_(ptf.cyclicPatch_)
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
126 template<class Type>
129 {
130  const Field<Type>& iField = this->primitiveField();
131  const labelUList& faceCells = cyclicPatch_.faceCells();
132 
133  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
134  Field<Type>& pnf = tpnf.ref();
135 
136  const label sizeby2 = this->size()/2;
137 
138  if (doTransform())
139  {
140  for (label facei=0; facei<sizeby2; ++facei)
141  {
142  pnf[facei] = transform
143  (
144  forwardT()[0], iField[faceCells[facei + sizeby2]]
145  );
146 
147  pnf[facei + sizeby2] = transform
148  (
149  reverseT()[0], iField[faceCells[facei]]
150  );
151  }
152  }
153  else
154  {
155  for (label facei=0; facei<sizeby2; ++facei)
156  {
157  pnf[facei] = iField[faceCells[facei + sizeby2]];
158  pnf[facei + sizeby2] = iField[faceCells[facei]];
159  }
160  }
162  return tpnf;
163 }
164 
165 
166 template<class Type>
168 (
169  solveScalarField& result,
170  const bool add,
171  const lduAddressing& lduAddr,
172  const label patchId,
173  const solveScalarField& psiInternal,
174  const scalarField& coeffs,
175  const direction cmpt,
176  const Pstream::commsTypes commsType
177 ) const
178 {
179  solveScalarField pnf(this->size());
180 
181  const label sizeby2 = this->size()/2;
182  const labelUList& faceCells = cyclicPatch_.faceCells();
183 
184  for (label facei = 0; facei < sizeby2; ++facei)
185  {
186  pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
187  pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
188  }
189 
190  // Transform according to the transformation tensors
191  transformCoupleField(pnf, cmpt);
192 
193  // Multiply the field by coefficients and add into the result
194  this->addToInternalField(result, !add, faceCells, coeffs, pnf);
195 }
196 
197 
198 template<class Type>
200 (
201  Field<Type>& result,
202  const bool add,
203  const lduAddressing& lduAddr,
204  const label patchId,
205  const Field<Type>& psiInternal,
206  const scalarField& coeffs,
207  const Pstream::commsTypes commsType
208 ) const
209 {
210  Field<Type> pnf(this->size());
211 
212  const label sizeby2 = this->size()/2;
213  const labelUList& faceCells = cyclicPatch_.faceCells();
214 
215  for (label facei = 0; facei < sizeby2; ++facei)
216  {
217  pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
218  pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
219  }
220 
221  // Transform according to the transformation tensors
222  transformCoupleField(pnf);
223 
224  // Multiply the field by coefficients and add into the result
225  this->addToInternalField(result, !add, faceCells, coeffs, pnf);
226 }
227 
228 
229 // ************************************************************************* //
label patchId(-1)
dictionary dict
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.
"blocking" : (MPI_Bsend, MPI_Recv)
const faPatch & patch() const noexcept
Return the patch.
Definition: faPatchField.H:231
uint8_t direction
Definition: direction.H:46
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
commsTypes
Communications types.
Definition: UPstream.H:72
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Type & refCast(U &obj)
A dynamic_cast (for references). Generates a FatalError on failed casts and uses the virtual type() m...
Definition: typeInfo.H:159
const DimensionedField< Type, areaMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Definition: faPatchField.H:564
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
static const char *const typeName
Typename for Field.
Definition: Field.H:86
Generic templated field type.
Definition: Field.H:62
cyclicFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Foam::cyclicFaPatchField.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
bool isReadRequired() const noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
Cyclic-plane patch.
Definition: cyclicFaPatch.H:53
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:627
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled given internal cell data.
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
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
A FieldMapper for finite-area patch fields.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
readOption
Enumeration defining read preferences.