cyclicAMIFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 :
49  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"))
67  {
68  if (this->coupled())
69  {
70  this->evaluate(Pstream::commsTypes::blocking);
71  }
72  else
73  {
74  fvPatchField<Type>::operator=(this->patchInternalField());
75  }
76  }
77 }
78 
79 
80 template<class Type>
82 (
83  const cyclicAMIFvPatchField<Type>& ptf,
84  const fvPatch& p,
86  const fvPatchFieldMapper& mapper
87 )
88 :
89  coupledFvPatchField<Type>(ptf, p, iF, mapper),
91  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
92 {
93  if (!isA<cyclicAMIFvPatch>(this->patch()))
94  {
96  << "' not constraint type '" << typeName << "'"
97  << "\n for patch " << p.name()
98  << " of field " << this->internalField().name()
99  << " in file " << this->internalField().objectPath()
100  << exit(FatalIOError);
101  }
102 }
103 
104 
105 template<class Type>
107 (
108  const cyclicAMIFvPatchField<Type>& ptf
109 )
110 :
113  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
114 {}
115 
116 
117 template<class Type>
119 (
120  const cyclicAMIFvPatchField<Type>& ptf,
122 )
123 :
124  coupledFvPatchField<Type>(ptf, iF),
126  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
132 template<class Type>
134 {
135  return cyclicAMIPatch_.coupled();
136 }
137 
138 
139 template<class Type>
142 {
143  const Field<Type>& iField = this->primitiveField();
144  const labelUList& nbrFaceCells =
145  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
146 
147  Field<Type> pnf(iField, nbrFaceCells);
148 
149  tmp<Field<Type>> tpnf;
150  if (cyclicAMIPatch_.applyLowWeightCorrection())
151  {
152  tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()());
153  }
154  else
155  {
156  tpnf = cyclicAMIPatch_.interpolate(pnf);
157  }
158 
159  if (doTransform())
160  {
161  tpnf.ref() = transform(forwardT(), tpnf());
162  }
163 
164  return tpnf;
165 }
166 
167 
168 template<class Type>
171 {
174  (
175  this->primitiveField()
176  );
177 
178  return refCast<const cyclicAMIFvPatchField<Type>>
179  (
180  fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
181  );
182 }
183 
184 
185 template<class Type>
187 (
188  scalarField& result,
189  const scalarField& psiInternal,
190  const scalarField& coeffs,
191  const direction cmpt,
192  const Pstream::commsTypes
193 ) const
194 {
195  const labelUList& nbrFaceCells =
196  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
197 
198  scalarField pnf(psiInternal, nbrFaceCells);
199 
200  // Transform according to the transformation tensors
201  transformCoupleField(pnf, cmpt);
202 
203  if (cyclicAMIPatch_.applyLowWeightCorrection())
204  {
205  scalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
206  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
207  }
208  else
209  {
210  pnf = cyclicAMIPatch_.interpolate(pnf);
211  }
212 
213  // Multiply the field by coefficients and add into the result
214  const labelUList& faceCells = cyclicAMIPatch_.faceCells();
215 
216  forAll(faceCells, elemI)
217  {
218  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
219  }
220 }
221 
222 
223 template<class Type>
225 (
226  Field<Type>& result,
227  const Field<Type>& psiInternal,
228  const scalarField& coeffs,
229  const Pstream::commsTypes
230 ) const
231 {
232  const labelUList& nbrFaceCells =
233  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
234 
235  Field<Type> pnf(psiInternal, nbrFaceCells);
236 
237  // Transform according to the transformation tensors
238  transformCoupleField(pnf);
239 
240  if (cyclicAMIPatch_.applyLowWeightCorrection())
241  {
242  Field<Type> pif(psiInternal, cyclicAMIPatch_.faceCells());
243  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
244  }
245  else
246  {
247  pnf = cyclicAMIPatch_.interpolate(pnf);
248  }
249 
250  // Multiply the field by coefficients and add into the result
251  const labelUList& faceCells = cyclicAMIPatch_.faceCells();
252 
253  forAll(faceCells, elemI)
254  {
255  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
256  }
257 }
258 
259 
260 template<class Type>
262 {
264  writeEntry(os, "value", *this);
265 }
266 
267 
268 // ************************************************************************* //
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:434
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:158
#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
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
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:56
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:60
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
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
#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