cyclicAMIFvPatchField.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-2014 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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 (
31  const fvPatch& p,
33 )
34 :
37  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
38 {}
39 
40 
41 template<class Type>
43 (
44  const cyclicAMIFvPatchField<Type>& ptf,
45  const fvPatch& p,
47  const fvPatchFieldMapper& mapper
48 )
49 :
51  coupledFvPatchField<Type>(ptf, p, iF, mapper),
52  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
53 {
54  if (!isA<cyclicAMIFvPatch>(this->patch()))
55  {
57  (
58  "cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField"
59  "("
60  "const cyclicAMIFvPatchField<Type>& ,"
61  "const fvPatch&, "
62  "const DimensionedField<Type, volMesh>&, "
63  "const fvPatchFieldMapper&"
64  ")"
65  ) << " patch type '" << p.type()
66  << "' not constraint type '" << typeName << "'"
67  << "\n for patch " << p.name()
68  << " of field " << this->dimensionedInternalField().name()
69  << " in file " << this->dimensionedInternalField().objectPath()
70  << exit(FatalIOError);
71  }
72 }
73 
74 
75 template<class Type>
77 (
78  const fvPatch& p,
80  const dictionary& dict
81 )
82 :
85  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
86 {
87  if (!isA<cyclicAMIFvPatch>(p))
88  {
90  (
91  "cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField"
92  "("
93  "const fvPatch&, "
94  "const DimensionedField<Type, volMesh>&, "
95  "const dictionary&"
96  ")",
97  dict
98  ) << " patch type '" << p.type()
99  << "' not constraint type '" << typeName << "'"
100  << "\n for patch " << p.name()
101  << " of field " << this->dimensionedInternalField().name()
102  << " in file " << this->dimensionedInternalField().objectPath()
103  << exit(FatalIOError);
104  }
105 
106  if (!dict.found("value") && this->coupled())
107  {
108  this->evaluate(Pstream::blocking);
109  }
110 }
111 
112 
113 template<class Type>
115 (
116  const cyclicAMIFvPatchField<Type>& ptf
117 )
118 :
121  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
122 {}
123 
124 
125 template<class Type>
127 (
128  const cyclicAMIFvPatchField<Type>& ptf,
130 )
131 :
133  coupledFvPatchField<Type>(ptf, iF),
134  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
135 {}
136 
137 
138 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
139 
140 template<class Type>
142 {
143  return cyclicAMIPatch_.coupled();
144 }
145 
146 
147 template<class Type>
150 {
151  const Field<Type>& iField = this->internalField();
152  const labelUList& nbrFaceCells =
153  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
154 
155  Field<Type> pnf(iField, nbrFaceCells);
156 
157  tmp<Field<Type> > tpnf;
158  if (cyclicAMIPatch_.applyLowWeightCorrection())
159  {
160  tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()());
161  }
162  else
163  {
164  tpnf = cyclicAMIPatch_.interpolate(pnf);
165  }
166 
167  if (doTransform())
168  {
169  tpnf() = transform(forwardT(), tpnf());
170  }
171 
172  return tpnf;
173 }
174 
175 
176 template<class Type>
179 {
182  (
183  this->internalField()
184  );
185 
186  return refCast<const cyclicAMIFvPatchField<Type> >
187  (
188  fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
189  );
190 }
191 
192 
193 template<class Type>
195 (
196  scalarField& result,
197  const scalarField& psiInternal,
198  const scalarField& coeffs,
199  const direction cmpt,
200  const Pstream::commsTypes
201 ) const
202 {
203  const labelUList& nbrFaceCells =
204  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
205 
206  scalarField pnf(psiInternal, nbrFaceCells);
207 
208  // Transform according to the transformation tensors
209  transformCoupleField(pnf, cmpt);
210 
211  if (cyclicAMIPatch_.applyLowWeightCorrection())
212  {
213  scalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
214  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
215  }
216  else
217  {
218  pnf = cyclicAMIPatch_.interpolate(pnf);
219  }
220 
221  // Multiply the field by coefficients and add into the result
222  const labelUList& faceCells = cyclicAMIPatch_.faceCells();
223 
224  forAll(faceCells, elemI)
225  {
226  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
227  }
228 }
229 
230 
231 template<class Type>
233 (
234  Field<Type>& result,
235  const Field<Type>& psiInternal,
236  const scalarField& coeffs,
237  const Pstream::commsTypes
238 ) const
239 {
240  const labelUList& nbrFaceCells =
241  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
242 
243  Field<Type> pnf(psiInternal, nbrFaceCells);
244 
245  // Transform according to the transformation tensors
246  transformCoupleField(pnf);
247 
248  if (cyclicAMIPatch_.applyLowWeightCorrection())
249  {
250  Field<Type> pif(psiInternal, cyclicAMIPatch_.faceCells());
251  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
252  }
253  else
254  {
255  pnf = cyclicAMIPatch_.interpolate(pnf);
256  }
257 
258  // Multiply the field by coefficients and add into the result
259  const labelUList& faceCells = cyclicAMIPatch_.faceCells();
260 
261  forAll(faceCells, elemI)
262  {
263  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
264  }
265 }
266 
267 
268 template<class Type>
270 {
272  this->writeEntry("value", os);
273 }
274 
275 
276 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
unsigned char direction
Definition: direction.H:43
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const cyclicAMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
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
runTime write()
dictionary dict
virtual void write(Ostream &os) const
Write.
IOerror FatalIOError
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.
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
cyclicAMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
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.
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, whereby communicati...
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
Abstract base class for cyclic AMI coupled interfaces.
#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()+
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.