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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
40  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
41 {}
42 
43 
44 template<class Type>
46 (
47  const fvPatch& p,
49  const dictionary& dict
50 )
51 :
53  coupledFvPatchField<Type>(p, iF, dict, dict.found("value")),
54  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p, dict))
55 {
56  if (!isA<cyclicAMIFvPatch>(p))
57  {
59  << " patch type '" << p.type()
60  << "' not constraint type '" << typeName << "'"
61  << "\n for patch " << p.name()
62  << " of field " << this->internalField().name()
63  << " in file " << this->internalField().objectPath()
64  << exit(FatalIOError);
65  }
66 
67  if (!dict.found("value") && this->coupled())
68  {
69  this->evaluate(Pstream::commsTypes::blocking);
70  }
71 }
72 
73 
74 template<class Type>
76 (
77  const cyclicAMIFvPatchField<Type>& ptf,
78  const fvPatch& p,
80  const fvPatchFieldMapper& mapper
81 )
82 :
84  coupledFvPatchField<Type>(ptf, p, iF, mapper),
85  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
86 {
87  if (!isA<cyclicAMIFvPatch>(this->patch()))
88  {
90  << "' not constraint type '" << typeName << "'"
91  << "\n for patch " << p.name()
92  << " of field " << this->internalField().name()
93  << " in file " << this->internalField().objectPath()
94  << exit(FatalIOError);
95  }
96 }
97 
98 
99 template<class Type>
101 (
102  const cyclicAMIFvPatchField<Type>& ptf
103 )
104 :
107  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
108 {}
109 
110 
111 template<class Type>
113 (
114  const cyclicAMIFvPatchField<Type>& ptf,
116 )
117 :
119  coupledFvPatchField<Type>(ptf, iF),
120  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
126 template<class Type>
128 {
129  return cyclicAMIPatch_.coupled();
130 }
131 
132 
133 template<class Type>
136 {
137  const Field<Type>& iField = this->primitiveField();
138  const labelUList& nbrFaceCells =
139  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
140 
141  Field<Type> pnf(iField, nbrFaceCells);
142 
143  tmp<Field<Type>> tpnf;
144  if (cyclicAMIPatch_.applyLowWeightCorrection())
145  {
146  tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()());
147  }
148  else
149  {
150  tpnf = cyclicAMIPatch_.interpolate(pnf);
151  }
152 
153  if (doTransform())
154  {
155  tpnf.ref() = transform(forwardT(), tpnf());
156  }
157 
158  return tpnf;
159 }
160 
161 
162 template<class Type>
165 {
168  (
169  this->primitiveField()
170  );
171 
172  return refCast<const cyclicAMIFvPatchField<Type>>
173  (
174  fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
175  );
176 }
177 
178 
179 template<class Type>
181 (
182  solveScalarField& result,
183  const bool add,
184  const solveScalarField& psiInternal,
185  const scalarField& coeffs,
186  const direction cmpt,
187  const Pstream::commsTypes
188 ) const
189 {
190  const labelUList& nbrFaceCells =
191  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
192 
193  solveScalarField pnf(psiInternal, nbrFaceCells);
194 
195  // Transform according to the transformation tensors
196  transformCoupleField(pnf, cmpt);
197 
198  if (cyclicAMIPatch_.applyLowWeightCorrection())
199  {
200  solveScalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
201  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
202  }
203  else
204  {
205  pnf = cyclicAMIPatch_.interpolate(pnf);
206  }
207 
208  // Multiply the field by coefficients and add into the result
209  this->addToInternalField(result, !add, coeffs, pnf);
210 }
211 
212 
213 template<class Type>
215 (
216  Field<Type>& result,
217  const bool add,
218  const Field<Type>& psiInternal,
219  const scalarField& coeffs,
220  const Pstream::commsTypes
221 ) const
222 {
223  const labelUList& nbrFaceCells =
224  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
225 
226  Field<Type> pnf(psiInternal, nbrFaceCells);
227 
228  // Transform according to the transformation tensors
229  transformCoupleField(pnf);
230 
231  if (cyclicAMIPatch_.applyLowWeightCorrection())
232  {
233  Field<Type> pif(psiInternal, cyclicAMIPatch_.faceCells());
234  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
235  }
236  else
237  {
238  pnf = cyclicAMIPatch_.interpolate(pnf);
239  }
240 
241  // Multiply the field by coefficients and add into the result
242  this->addToInternalField(result, !add, coeffs, pnf);
243 }
244 
245 
246 template<class Type>
248 {
250  this->writeEntry("value", os);
251 }
252 
253 
254 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::cyclicAMILduInterfaceField
Abstract base class for cyclic AMI coupled interfaces.
Definition: cyclicAMILduInterfaceField.H:51
Foam::cyclicAMIFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicAMIFvPatchField.C:247
Foam::FatalIOError
IOerror FatalIOError
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
Foam::cyclicAMIFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
Definition: cyclicAMIFvPatchField.H:76
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::cyclicAMIFvPatchField::cyclicAMIFvPatchField
cyclicAMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicAMIFvPatchField.C:33
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:66
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::cyclicAMIFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: cyclicAMIFvPatchField.C:181
Foam::UList< label >
Foam::cyclicAMIFvPatchField::coupled
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
Definition: cyclicAMIFvPatchField.C:127
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::cyclicAMIFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
Definition: cyclicAMIFvPatchField.C:135
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::stringOps::evaluate
string evaluate(const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:37
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::cyclicAMIFvPatchField::neighbourPatchField
const cyclicAMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Definition: cyclicAMIFvPatchField.C:164