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"))
68  {
69  if (this->coupled())
70  {
71  this->evaluate(Pstream::commsTypes::blocking);
72  }
73  else
74  {
75  fvPatchField<Type>::operator=(this->patchInternalField());
76  }
77  }
78 }
79 
80 
81 template<class Type>
83 (
84  const cyclicAMIFvPatchField<Type>& ptf,
85  const fvPatch& p,
87  const fvPatchFieldMapper& mapper
88 )
89 :
91  coupledFvPatchField<Type>(ptf, p, iF, mapper),
92  cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p))
93 {
94  if (!isA<cyclicAMIFvPatch>(this->patch()))
95  {
97  << "' not constraint type '" << typeName << "'"
98  << "\n for patch " << p.name()
99  << " of field " << this->internalField().name()
100  << " in file " << this->internalField().objectPath()
101  << exit(FatalIOError);
102  }
103 }
104 
105 
106 template<class Type>
108 (
109  const cyclicAMIFvPatchField<Type>& ptf
110 )
111 :
114  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
115 {}
116 
117 
118 template<class Type>
120 (
121  const cyclicAMIFvPatchField<Type>& ptf,
123 )
124 :
126  coupledFvPatchField<Type>(ptf, iF),
127  cyclicAMIPatch_(ptf.cyclicAMIPatch_)
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
132 
133 template<class Type>
135 {
136  return cyclicAMIPatch_.coupled();
137 }
138 
139 
140 template<class Type>
143 {
144  const Field<Type>& iField = this->primitiveField();
145  const labelUList& nbrFaceCells =
146  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
147 
148  Field<Type> pnf(iField, nbrFaceCells);
149 
150  tmp<Field<Type>> tpnf;
151  if (cyclicAMIPatch_.applyLowWeightCorrection())
152  {
153  tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()());
154  }
155  else
156  {
157  tpnf = cyclicAMIPatch_.interpolate(pnf);
158  }
159 
160  if (doTransform())
161  {
162  tpnf.ref() = transform(forwardT(), tpnf());
163  }
164 
165  return tpnf;
166 }
167 
168 
169 template<class Type>
172 {
175  (
176  this->primitiveField()
177  );
178 
179  return refCast<const cyclicAMIFvPatchField<Type>>
180  (
181  fld.boundaryField()[cyclicAMIPatch_.neighbPatchID()]
182  );
183 }
184 
185 
186 template<class Type>
188 (
189  solveScalarField& result,
190  const bool add,
191  const solveScalarField& psiInternal,
192  const scalarField& coeffs,
193  const direction cmpt,
194  const Pstream::commsTypes
195 ) const
196 {
197  const labelUList& nbrFaceCells =
198  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
199 
200  solveScalarField pnf(psiInternal, nbrFaceCells);
201 
202  // Transform according to the transformation tensors
203  transformCoupleField(pnf, cmpt);
204 
205  if (cyclicAMIPatch_.applyLowWeightCorrection())
206  {
207  solveScalarField pif(psiInternal, cyclicAMIPatch_.faceCells());
208  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
209  }
210  else
211  {
212  pnf = cyclicAMIPatch_.interpolate(pnf);
213  }
214 
215  // Multiply the field by coefficients and add into the result
216  this->addToInternalField(result, !add, coeffs, pnf);
217 }
218 
219 
220 template<class Type>
222 (
223  Field<Type>& result,
224  const bool add,
225  const Field<Type>& psiInternal,
226  const scalarField& coeffs,
227  const Pstream::commsTypes
228 ) const
229 {
230  const labelUList& nbrFaceCells =
231  cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells();
232 
233  Field<Type> pnf(psiInternal, nbrFaceCells);
234 
235  // Transform according to the transformation tensors
236  transformCoupleField(pnf);
237 
238  if (cyclicAMIPatch_.applyLowWeightCorrection())
239  {
240  Field<Type> pif(psiInternal, cyclicAMIPatch_.faceCells());
241  pnf = cyclicAMIPatch_.interpolate(pnf, pif);
242  }
243  else
244  {
245  pnf = cyclicAMIPatch_.interpolate(pnf);
246  }
247 
248  // Multiply the field by coefficients and add into the result
249  this->addToInternalField(result, !add, coeffs, pnf);
250 }
251 
252 
253 template<class Type>
255 {
257  this->writeEntry("value", os);
258 }
259 
260 
261 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
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:254
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:228
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
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:69
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
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:188
Foam::UList< label >
Foam::cyclicAMIFvPatchField::coupled
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
Definition: cyclicAMIFvPatchField.C:134
Foam::direction
uint8_t direction
Definition: direction.H:52
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:401
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:142
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:171