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-2012 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const fvPatch& p,
41 )
42 :
44  cyclicPatch_(refCast<const cyclicFvPatch>(p))
45 {}
46 
47 
48 template<class Type>
50 (
51  const cyclicFvPatchField<Type>& ptf,
52  const fvPatch& p,
54  const fvPatchFieldMapper& mapper
55 )
56 :
57  coupledFvPatchField<Type>(ptf, p, iF, mapper),
58  cyclicPatch_(refCast<const cyclicFvPatch>(p))
59 {
60  if (!isA<cyclicFvPatch>(this->patch()))
61  {
63  (
64  "cyclicFvPatchField<Type>::cyclicFvPatchField"
65  "("
66  "const cyclicFvPatchField<Type>& ,"
67  "const fvPatch&, "
68  "const DimensionedField<Type, volMesh>&, "
69  "const fvPatchFieldMapper&"
70  ")"
71  ) << " patch type '" << p.type()
72  << "' not constraint type '" << typeName << "'"
73  << "\n for patch " << p.name()
74  << " of field " << this->dimensionedInternalField().name()
75  << " in file " << this->dimensionedInternalField().objectPath()
76  << exit(FatalIOError);
77  }
78 }
79 
80 
81 template<class Type>
83 (
84  const fvPatch& p,
86  const dictionary& dict
87 )
88 :
90  cyclicPatch_(refCast<const cyclicFvPatch>(p))
91 {
92  if (!isA<cyclicFvPatch>(p))
93  {
95  (
96  "cyclicFvPatchField<Type>::cyclicFvPatchField"
97  "("
98  "const fvPatch&, "
99  "const Field<Type>&, "
100  "const dictionary&"
101  ")",
102  dict
103  ) << " patch type '" << p.type()
104  << "' not constraint type '" << typeName << "'"
105  << "\n for patch " << p.name()
106  << " of field " << this->dimensionedInternalField().name()
107  << " in file " << this->dimensionedInternalField().objectPath()
108  << exit(FatalIOError);
109  }
110 
111  this->evaluate(Pstream::blocking);
112 }
113 
114 
115 template<class Type>
117 (
118  const cyclicFvPatchField<Type>& ptf
119 )
120 :
123  cyclicPatch_(ptf.cyclicPatch_)
124 {}
125 
126 
127 template<class Type>
129 (
130  const cyclicFvPatchField<Type>& ptf,
132 )
133 :
134  coupledFvPatchField<Type>(ptf, iF),
135  cyclicPatch_(ptf.cyclicPatch_)
136 {}
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
141 template<class Type>
143 {
144  const Field<Type>& iField = this->internalField();
145  const labelUList& nbrFaceCells =
146  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
147 
148  tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
149  Field<Type>& pnf = tpnf();
150 
151 
152  if (doTransform())
153  {
154  forAll(pnf, facei)
155  {
156  pnf[facei] = transform
157  (
158  forwardT()[0], iField[nbrFaceCells[facei]]
159  );
160  }
161  }
162  else
163  {
164  forAll(pnf, facei)
165  {
166  pnf[facei] = iField[nbrFaceCells[facei]];
167  }
168  }
169 
170  return tpnf;
171 }
172 
173 
174 template<class Type>
176 const
177 {
180  (
181  this->internalField()
182  );
183 
184  return refCast<const cyclicFvPatchField<Type> >
185  (
186  fld.boundaryField()[this->cyclicPatch().neighbPatchID()]
187  );
188 }
189 
190 
191 template<class Type>
193 (
194  scalarField& result,
195  const scalarField& psiInternal,
196  const scalarField& coeffs,
197  const direction cmpt,
198  const Pstream::commsTypes
199 ) const
200 {
201  const labelUList& nbrFaceCells =
202  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
203 
204  scalarField pnf(psiInternal, nbrFaceCells);
205 
206  // Transform according to the transformation tensors
207  transformCoupleField(pnf, cmpt);
208 
209  // Multiply the field by coefficients and add into the result
210  const labelUList& faceCells = cyclicPatch_.faceCells();
211 
212  forAll(faceCells, elemI)
213  {
214  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
215  }
216 }
217 
218 
219 template<class Type>
221 (
222  Field<Type>& result,
223  const Field<Type>& psiInternal,
224  const scalarField& coeffs,
225  const Pstream::commsTypes
226 ) const
227 {
228  const labelUList& nbrFaceCells =
229  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
230 
231  Field<Type> pnf(psiInternal, nbrFaceCells);
232 
233  // Transform according to the transformation tensors
234  transformCoupleField(pnf);
235 
236  // Multiply the field by coefficients and add into the result
237  const labelUList& faceCells = cyclicPatch_.faceCells();
238 
239  forAll(faceCells, elemI)
240  {
241  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
242  }
243 }
244 
245 
246 template<class Type>
248 {
250 }
251 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 } // End namespace Foam
256 
257 // ************************************************************************* //
unsigned char direction
Definition: direction.H:43
virtual void write(Ostream &os) const
Write.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::fvPatchFieldMapper.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:354
Namespace for OpenFOAM.
Abstract base class for cyclic coupled interfaces.
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
dictionary dict
IOerror FatalIOError
Abstract base class for coupled patches.
volScalarField & p
Definition: createFields.H:51
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
commsTypes
Types of communications.
Definition: UPstream.H:64
#define forAll(list, i)
Definition: UList.H:421
Spatial transformation functions for primitive fields.
Pre-declare SubField and related Field type.
Definition: Field.H:57
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 ))
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
rDeltaT dimensionedInternalField()
Generic GeometricField class.
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.
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
A class for managing temporary objects.
Definition: PtrList.H:118
conserve internalField()+