cyclicFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cyclicFvPatchField.H"
27 #include "transformField.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
39  cyclicPatch_(refCast<const cyclicFvPatch>(p))
40 {}
41 
42 
43 template<class Type>
45 (
46  const fvPatch& p,
48  const dictionary& dict
49 )
50 :
51  coupledFvPatchField<Type>(p, iF, dict, false),
52  cyclicPatch_(refCast<const cyclicFvPatch>(p))
53 {
54  if (!isA<cyclicFvPatch>(p))
55  {
57  (
58  dict
59  ) << " patch type '" << p.type()
60  << "' not constraint type '" << typeName << "'"
61  << "\n for patch " << p.name()
62  << " of field " << this->internalField().name()
63  << " in file " << this->internalField().objectPath()
64  << exit(FatalIOError);
65  }
66 
67  this->evaluate(Pstream::commsTypes::blocking);
68 }
69 
70 
71 template<class Type>
73 (
74  const cyclicFvPatchField<Type>& ptf,
75  const fvPatch& p,
77  const fvPatchFieldMapper& mapper
78 )
79 :
80  coupledFvPatchField<Type>(ptf, p, iF, mapper),
82  cyclicPatch_(refCast<const cyclicFvPatch>(p))
83 {
84  if (!isA<cyclicFvPatch>(this->patch()))
85  {
87  << "' not constraint type '" << typeName << "'"
88  << "\n for patch " << p.name()
89  << " of field " << this->internalField().name()
90  << " in file " << this->internalField().objectPath()
91  << exit(FatalIOError);
92  }
93 }
94 
95 
96 template<class Type>
98 (
99  const cyclicFvPatchField<Type>& ptf
100 )
101 :
104  cyclicPatch_(ptf.cyclicPatch_)
105 {}
106 
107 
108 template<class Type>
110 (
111  const cyclicFvPatchField<Type>& ptf,
113 )
114 :
115  coupledFvPatchField<Type>(ptf, iF),
117  cyclicPatch_(ptf.cyclicPatch_)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
123 template<class Type>
126 {
127  const Field<Type>& iField = this->primitiveField();
128  const labelUList& nbrFaceCells =
129  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
130 
131  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
132  Field<Type>& pnf = tpnf.ref();
133 
134 
135  if (doTransform())
136  {
137  forAll(pnf, facei)
138  {
139  pnf[facei] = transform
140  (
141  forwardT()[0], iField[nbrFaceCells[facei]]
142  );
143  }
144  }
145  else
146  {
147  forAll(pnf, facei)
148  {
149  pnf[facei] = iField[nbrFaceCells[facei]];
150  }
151  }
152 
153  return tpnf;
154 }
155 
156 
157 template<class Type>
160 {
163  (
164  this->primitiveField()
165  );
166 
167  return refCast<const cyclicFvPatchField<Type>>
168  (
169  fld.boundaryField()[this->cyclicPatch().neighbPatchID()]
170  );
171 }
172 
173 
174 template<class Type>
176 (
177  scalarField& result,
178  const scalarField& psiInternal,
179  const scalarField& coeffs,
180  const direction cmpt,
181  const Pstream::commsTypes
182 ) const
183 {
184  const labelUList& nbrFaceCells =
185  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
186 
187  scalarField pnf(psiInternal, nbrFaceCells);
188 
189  // Transform according to the transformation tensors
190  transformCoupleField(pnf, cmpt);
191 
192  // Multiply the field by coefficients and add into the result
193  const labelUList& faceCells = cyclicPatch_.faceCells();
194 
195  forAll(faceCells, elemI)
196  {
197  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
198  }
199 }
200 
201 
202 template<class Type>
204 (
205  Field<Type>& result,
206  const Field<Type>& psiInternal,
207  const scalarField& coeffs,
208  const Pstream::commsTypes
209 ) const
210 {
211  const labelUList& nbrFaceCells =
212  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
213 
214  Field<Type> pnf(psiInternal, nbrFaceCells);
215 
216  // Transform according to the transformation tensors
217  transformCoupleField(pnf);
218 
219  // Multiply the field by coefficients and add into the result
220  const labelUList& faceCells = cyclicPatch_.faceCells();
221 
222  forAll(faceCells, elemI)
223  {
224  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
225  }
226 }
227 
228 
229 template<class Type>
231 {
233 }
234 
235 
236 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const Boundary & boundaryField() const
Return const-reference to the boundary field.
commsTypes
Types of communications.
Definition: UPstream.H:64
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
uint8_t direction
Definition: direction.H:45
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Generic GeometricField class.
Spatial transformation functions for primitive fields.
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
Abstract base class for coupled patches.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual void write(Ostream &os) const
Write.
virtual void updateInterfaceMatrix(scalarField &result, const scalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
Abstract base class for cyclic coupled interfaces.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
IOerror FatalIOError
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.