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-2015 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  << "' not constraint type '" << typeName << "'"
64  << "\n for patch " << p.name()
65  << " of field " << this->dimensionedInternalField().name()
66  << " in file " << this->dimensionedInternalField().objectPath()
67  << exit(FatalIOError);
68  }
69 }
70 
71 
72 template<class Type>
74 (
75  const fvPatch& p,
77  const dictionary& dict
78 )
79 :
81  cyclicPatch_(refCast<const cyclicFvPatch>(p))
82 {
83  if (!isA<cyclicFvPatch>(p))
84  {
86  (
87  dict
88  ) << " patch type '" << p.type()
89  << "' not constraint type '" << typeName << "'"
90  << "\n for patch " << p.name()
91  << " of field " << this->dimensionedInternalField().name()
92  << " in file " << this->dimensionedInternalField().objectPath()
93  << exit(FatalIOError);
94  }
95 
96  this->evaluate(Pstream::blocking);
97 }
98 
99 
100 template<class Type>
102 (
103  const cyclicFvPatchField<Type>& ptf
104 )
105 :
108  cyclicPatch_(ptf.cyclicPatch_)
109 {}
110 
111 
112 template<class Type>
114 (
115  const cyclicFvPatchField<Type>& ptf,
117 )
118 :
119  coupledFvPatchField<Type>(ptf, iF),
120  cyclicPatch_(ptf.cyclicPatch_)
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
126 template<class Type>
128 {
129  const Field<Type>& iField = this->internalField();
130  const labelUList& nbrFaceCells =
131  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
132 
133  tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
134  Field<Type>& pnf = tpnf();
135 
136 
137  if (doTransform())
138  {
139  forAll(pnf, facei)
140  {
141  pnf[facei] = transform
142  (
143  forwardT()[0], iField[nbrFaceCells[facei]]
144  );
145  }
146  }
147  else
148  {
149  forAll(pnf, facei)
150  {
151  pnf[facei] = iField[nbrFaceCells[facei]];
152  }
153  }
154 
155  return tpnf;
156 }
157 
158 
159 template<class Type>
161 const
162 {
165  (
166  this->internalField()
167  );
168 
169  return refCast<const cyclicFvPatchField<Type> >
170  (
171  fld.boundaryField()[this->cyclicPatch().neighbPatchID()]
172  );
173 }
174 
175 
176 template<class Type>
178 (
179  scalarField& result,
180  const scalarField& psiInternal,
181  const scalarField& coeffs,
182  const direction cmpt,
183  const Pstream::commsTypes
184 ) const
185 {
186  const labelUList& nbrFaceCells =
187  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
188 
189  scalarField pnf(psiInternal, nbrFaceCells);
190 
191  // Transform according to the transformation tensors
192  transformCoupleField(pnf, cmpt);
193 
194  // Multiply the field by coefficients and add into the result
195  const labelUList& faceCells = cyclicPatch_.faceCells();
196 
197  forAll(faceCells, elemI)
198  {
199  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
200  }
201 }
202 
203 
204 template<class Type>
206 (
207  Field<Type>& result,
208  const Field<Type>& psiInternal,
209  const scalarField& coeffs,
210  const Pstream::commsTypes
211 ) const
212 {
213  const labelUList& nbrFaceCells =
214  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
215 
216  Field<Type> pnf(psiInternal, nbrFaceCells);
217 
218  // Transform according to the transformation tensors
219  transformCoupleField(pnf);
220 
221  // Multiply the field by coefficients and add into the result
222  const labelUList& faceCells = cyclicPatch_.faceCells();
223 
224  forAll(faceCells, elemI)
225  {
226  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
227  }
228 }
229 
230 
231 template<class Type>
233 {
235 }
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // ************************************************************************* //
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
p
p
Definition: pEqn.H:62
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
dimensionedInternalField
rDeltaT dimensionedInternalField()
Foam::FatalIOError
IOerror FatalIOError
Foam::cyclicFvPatchField::cyclicPatch_
const cyclicFvPatch & cyclicPatch_
Local reference cast into the cyclic patch.
Definition: cyclicFvPatchField.H:78
transformField.H
Spatial transformation functions for primitive fields.
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::UPstream::blocking
@ blocking
Definition: UPstream.H:66
Foam::Field< Type >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
fld
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))
Foam::cyclicFvPatchField::updateInterfaceMatrix
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.
Definition: cyclicFvPatchField.C:178
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
internalField
conserve internalField()+
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::cyclicLduInterfaceField
Abstract base class for cyclic coupled interfaces.
Definition: cyclicLduInterfaceField.H:49
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:54
Foam::cyclicFvPatchField::cyclicFvPatchField
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicFvPatchField.C:38
Foam::cyclicFvPatchField::patchNeighbourField
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
Definition: cyclicFvPatchField.C:127
Foam::UList
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
Foam::cyclicFvPatchField::neighbourPatchField
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Definition: cyclicFvPatchField.C:160
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::cyclicFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicFvPatchField.C:232
Foam::cyclicFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries.
Definition: cyclicFvPatchField.H:70
cyclicFvPatchField.H
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51