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-2017 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 fvPatch& p,
46  const dictionary& dict
47 )
48 :
50  coupledFvPatchField<Type>(p, iF, dict, dict.found("value")),
51  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
52 {
53  if (!isA<cyclicAMIFvPatch>(p))
54  {
56  (
57  dict
58  ) << " patch type '" << p.type()
59  << "' not constraint type '" << typeName << "'"
60  << "\n for patch " << p.name()
61  << " of field " << this->internalField().name()
62  << " in file " << this->internalField().objectPath()
63  << exit(FatalIOError);
64  }
65 
66  if (!dict.found("value") && this->coupled())
67  {
68  this->evaluate(Pstream::commsTypes::blocking);
69  }
70 }
71 
72 
73 template<class Type>
75 (
76  const cyclicAMIFvPatchField<Type>& ptf,
77  const fvPatch& p,
79  const fvPatchFieldMapper& mapper
80 )
81 :
83  coupledFvPatchField<Type>(ptf, p, iF, mapper),
84  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
85 {
86  if (!isA<cyclicAMIFvPatch>(this->patch()))
87  {
89  << "' not constraint type '" << typeName << "'"
90  << "\n for patch " << p.name()
91  << " of field " << this->internalField().name()
92  << " in file " << this->internalField().objectPath()
93  << exit(FatalIOError);
94  }
95 }
96 
97 
98 template<class Type>
100 (
101  const cyclicAMIFvPatchField<Type>& ptf
102 )
103 :
106  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
107 {}
108 
109 
110 template<class Type>
112 (
113  const cyclicAMIFvPatchField<Type>& ptf,
115 )
116 :
118  coupledFvPatchField<Type>(ptf, iF),
119  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 
125 template<class Type>
127 {
128  return cyclicAMIPatch_.coupled();
129 }
130 
131 
132 template<class Type>
135 {
136  const Field<Type>& iField = this->primitiveField();
137  const labelUList& nbrFaceCells =
138  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
139 
140  Field<Type> pnf(iField, nbrFaceCells);
141 
142  tmp<Field<Type>> tpnf;
143  if (cyclicAMIPatch_.applyLowWeightCorrection())
144  {
145  tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()());
146  }
147  else
148  {
149  tpnf = cyclicAMIPatch_.interpolate(pnf);
150  }
151 
152  if (doTransform())
153  {
154  tpnf.ref() = transform(forwardT(), tpnf());
155  }
156 
157  return tpnf;
158 }
159 
160 
161 template<class Type>
164 {
167  (
168  this->primitiveField()
169  );
170 
171  return refCast<const cyclicAMIFvPatchField<Type>>
172  (
173  fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
174  );
175 }
176 
177 
178 template<class Type>
180 (
181  scalarField& result,
182  const scalarField& psiInternal,
183  const scalarField& coeffs,
184  const direction cmpt,
185  const Pstream::commsTypes
186 ) const
187 {
188  const labelUList& nbrFaceCells =
189  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
190 
191  scalarField pnf(psiInternal, nbrFaceCells);
192 
193  // Transform according to the transformation tensors
194  transformCoupleField(pnf, cmpt);
195 
196  if (cyclicAMIPatch_.applyLowWeightCorrection())
197  {
198  scalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
199  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
200  }
201  else
202  {
203  pnf = cyclicAMIPatch_.interpolate(pnf);
204  }
205 
206  // Multiply the field by coefficients and add into the result
207  const labelUList& faceCells = cyclicAMIPatch_.faceCells();
208 
209  forAll(faceCells, elemI)
210  {
211  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
212  }
213 }
214 
215 
216 template<class Type>
218 (
219  Field<Type>& result,
220  const Field<Type>& psiInternal,
221  const scalarField& coeffs,
222  const Pstream::commsTypes
223 ) const
224 {
225  const labelUList& nbrFaceCells =
226  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
227 
228  Field<Type> pnf(psiInternal, nbrFaceCells);
229 
230  // Transform according to the transformation tensors
231  transformCoupleField(pnf);
232 
233  if (cyclicAMIPatch_.applyLowWeightCorrection())
234  {
235  Field<Type> pif(psiInternal, cyclicAMIPatch_.faceCells());
236  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
237  }
238  else
239  {
240  pnf = cyclicAMIPatch_.interpolate(pnf);
241  }
242 
243  // Multiply the field by coefficients and add into the result
244  const labelUList& faceCells = cyclicAMIPatch_.faceCells();
245 
246  forAll(faceCells, elemI)
247  {
248  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
249  }
250 }
251 
252 
253 template<class Type>
255 {
257  this->writeEntry("value", os);
258 }
259 
260 
261 // ************************************************************************* //
dictionary dict
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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.
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
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
Generic GeometricField class.
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
Abstract base class for cyclic AMI coupled interfaces.
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:57
virtual void write(Ostream &os) const
Write.
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:61
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
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...
const cyclicAMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
cyclicAMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
IOerror FatalIOError