cyclicFvPatchField.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-2020 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 #include "cyclicFvPatchField.H"
27 #include "transformField.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
39  cyclicPatch_(refCast<const cyclicFvPatch>(p))
40 {}
41 
42 
43 template<class Type>
45 (
46  const fvPatch& p,
48  const dictionary& dict
49 )
50 :
51  coupledFvPatchField<Type>(p, iF, dict, false),
52  cyclicPatch_(refCast<const cyclicFvPatch>(p))
53 {
54  if (!isA<cyclicFvPatch>(p))
55  {
57  (
58  dict
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  this->evaluate(Pstream::commsTypes::blocking);
68 }
69 
70 
71 template<class Type>
73 (
74  const cyclicFvPatchField<Type>& ptf,
75  const fvPatch& p,
77  const fvPatchFieldMapper& mapper
78 )
79 :
80  coupledFvPatchField<Type>(ptf, p, iF, mapper),
82  cyclicPatch_(refCast<const cyclicFvPatch>(p))
83 {
84  if (!isA<cyclicFvPatch>(this->patch()))
85  {
87  << "' not constraint type '" << typeName << "'"
88  << "\n for patch " << p.name()
89  << " of field " << this->internalField().name()
90  << " in file " << this->internalField().objectPath()
91  << exit(FatalIOError);
92  }
93 }
94 
95 
96 template<class Type>
98 (
99  const cyclicFvPatchField<Type>& ptf
100 )
101 :
104  cyclicPatch_(ptf.cyclicPatch_)
105 {}
106 
107 
108 template<class Type>
110 (
111  const cyclicFvPatchField<Type>& ptf,
113 )
114 :
115  coupledFvPatchField<Type>(ptf, iF),
117  cyclicPatch_(ptf.cyclicPatch_)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
123 template<class Type>
126 {
127  const Field<Type>& iField = this->primitiveField();
128  const labelUList& nbrFaceCells =
129  cyclicPatch().cyclicPatch().nbrPatch().faceCells();
130 
131  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
132  Field<Type>& pnf = tpnf.ref();
133 
134 
135  forAll(pnf, facei)
136  {
137  pnf[facei] = transform().transform(iField[nbrFaceCells[facei]]);
138  }
139 
140  return tpnf;
141 }
142 
143 
144 template<class Type>
147 {
150  (
151  this->primitiveField()
152  );
153 
154  return refCast<const cyclicFvPatchField<Type>>
155  (
156  fld.boundaryField()[this->cyclicPatch().nbrPatchID()]
157  );
158 }
159 
160 
161 template<class Type>
163 (
164  scalarField& result,
165  const scalarField& psiInternal,
166  const scalarField& coeffs,
167  const direction cmpt,
168  const Pstream::commsTypes
169 ) const
170 {
171  const labelUList& nbrFaceCells =
172  cyclicPatch().cyclicPatch().nbrPatch().faceCells();
173 
174  scalarField pnf(psiInternal, nbrFaceCells);
175 
176  // Transform according to the transformation tensors
177  transformCoupleField(pnf, cmpt);
178 
179  // Multiply the field by coefficients and add into the result
180  const labelUList& faceCells = cyclicPatch_.faceCells();
181 
182  forAll(faceCells, elemI)
183  {
184  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
185  }
186 }
187 
188 
189 template<class Type>
191 (
192  Field<Type>& result,
193  const Field<Type>& psiInternal,
194  const scalarField& coeffs,
195  const Pstream::commsTypes
196 ) const
197 {
198  const labelUList& nbrFaceCells =
199  cyclicPatch().cyclicPatch().nbrPatch().faceCells();
200 
201  Field<Type> pnf(psiInternal, nbrFaceCells);
202 
203  // Transform according to the transformation tensors
204  transformCoupleField(pnf);
205 
206  // Multiply the field by coefficients and add into the result
207  const labelUList& faceCells = cyclicPatch_.faceCells();
208 
209  forAll(faceCells, elemI)
210  {
211  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
212  }
213 }
214 
215 
216 template<class Type>
218 {
220 }
221 
222 
223 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
Generic GeometricField class.
const cyclicFvPatchField< Type > & nbrPatchField() const
Return reference to neighbour patchField.
Spatial transformation functions for primitive fields.
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
Foam::fvPatchFieldMapper.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
#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...
virtual void write(Ostream &os) const
Write.
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.
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
friend dimensionSet transform(const dimensionSet &)
Return the argument; transformations do not change the dimensions.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
Abstract base class for cyclic coupled interfaces.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
IOerror FatalIOError
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.