cyclicFvPatchField.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 | Copyright (C) 2011-2016 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 :
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::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),
81  cyclicPatch_(refCast<const cyclicFvPatch>(p))
82 {
83  if (!isA<cyclicFvPatch>(this->patch()))
84  {
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 
94 
95 template<class Type>
97 (
98  const cyclicFvPatchField<Type>& ptf
99 )
100 :
103  cyclicPatch_(ptf.cyclicPatch_)
104 {}
105 
106 
107 template<class Type>
109 (
110  const cyclicFvPatchField<Type>& ptf,
112 )
113 :
114  coupledFvPatchField<Type>(ptf, iF),
115  cyclicPatch_(ptf.cyclicPatch_)
116 {}
117 
118 
119 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 
121 template<class Type>
124 {
125  const Field<Type>& iField = this->primitiveField();
126  const labelUList& nbrFaceCells =
127  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
128 
129  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
130  Field<Type>& pnf = tpnf.ref();
131 
132 
133  if (doTransform())
134  {
135  forAll(pnf, facei)
136  {
137  pnf[facei] = transform
138  (
139  forwardT()[0], iField[nbrFaceCells[facei]]
140  );
141  }
142  }
143  else
144  {
145  forAll(pnf, facei)
146  {
147  pnf[facei] = iField[nbrFaceCells[facei]];
148  }
149  }
150 
151  return tpnf;
152 }
153 
154 
155 template<class Type>
158 {
161  (
162  this->primitiveField()
163  );
164 
165  return refCast<const cyclicFvPatchField<Type>>
166  (
167  fld.boundaryField()[this->cyclicPatch().neighbPatchID()]
168  );
169 }
170 
171 
172 template<class Type>
174 (
175  scalarField& result,
176  const scalarField& psiInternal,
177  const scalarField& coeffs,
178  const direction cmpt,
179  const Pstream::commsTypes
180 ) const
181 {
182  const labelUList& nbrFaceCells =
183  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
184 
185  scalarField pnf(psiInternal, nbrFaceCells);
186 
187  // Transform according to the transformation tensors
188  transformCoupleField(pnf, cmpt);
189 
190  // Multiply the field by coefficients and add into the result
191  const labelUList& faceCells = cyclicPatch_.faceCells();
192 
193  forAll(faceCells, elemI)
194  {
195  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
196  }
197 }
198 
199 
200 template<class Type>
202 (
203  Field<Type>& result,
204  const Field<Type>& psiInternal,
205  const scalarField& coeffs,
206  const Pstream::commsTypes
207 ) const
208 {
209  const labelUList& nbrFaceCells =
210  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
211 
212  Field<Type> pnf(psiInternal, nbrFaceCells);
213 
214  // Transform according to the transformation tensors
215  transformCoupleField(pnf);
216 
217  // Multiply the field by coefficients and add into the result
218  const labelUList& faceCells = cyclicPatch_.faceCells();
219 
220  forAll(faceCells, elemI)
221  {
222  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
223  }
224 }
225 
226 
227 template<class Type>
229 {
231 }
232 
233 
234 // ************************************************************************* //
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
dictionary dict
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
uint8_t direction
Definition: direction.H:46
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:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
commsTypes
Types of communications.
Definition: UPstream.H:64
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Generic GeometricField class.
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.
Spatial transformation functions for primitive fields.
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))
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Pre-declare SubField and related Field type.
Definition: Field.H:57
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...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:54
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
Abstract base class for cyclic coupled interfaces.
runTime write()
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
IOerror FatalIOError
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.