cyclicFvPatchField.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 #include "cyclicFvPatchField.H"
30 #include "transformField.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
42  cyclicPatch_(refCast<const cyclicFvPatch>(p))
43 {}
44 
45 
46 template<class Type>
48 (
49  const fvPatch& p,
51  const dictionary& dict
52 )
53 :
54  coupledFvPatchField<Type>(p, iF, dict, false),
55  cyclicPatch_(refCast<const cyclicFvPatch>(p, dict))
56 {
57  if (!isA<cyclicFvPatch>(p))
58  {
60  << " patch type '" << p.type()
61  << "' not constraint type '" << typeName << "'"
62  << "\n for patch " << p.name()
63  << " of field " << this->internalField().name()
64  << " in file " << this->internalField().objectPath()
65  << exit(FatalIOError);
66  }
67 
68  this->evaluate(Pstream::commsTypes::blocking);
69 }
70 
71 
72 template<class Type>
74 (
75  const cyclicFvPatchField<Type>& ptf,
76  const fvPatch& p,
78  const fvPatchFieldMapper& mapper
79 )
80 :
81  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),
116  cyclicPatch_(ptf.cyclicPatch_)
117 {}
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
122 template<class Type>
125 {
126  const Field<Type>& iField = this->primitiveField();
127  const labelUList& nbrFaceCells =
128  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
129 
130  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
131  Field<Type>& pnf = tpnf.ref();
132 
133 
134  if (doTransform())
135  {
136  forAll(pnf, facei)
137  {
138  pnf[facei] = transform
139  (
140  forwardT()[0], iField[nbrFaceCells[facei]]
141  );
142  }
143  }
144  else
145  {
146  forAll(pnf, facei)
147  {
148  pnf[facei] = iField[nbrFaceCells[facei]];
149  }
150  }
151 
152  return tpnf;
153 }
154 
155 
156 template<class Type>
159 {
162  (
163  this->primitiveField()
164  );
165 
166  return refCast<const cyclicFvPatchField<Type>>
167  (
168  fld.boundaryField()[this->cyclicPatch().neighbPatchID()]
169  );
170 }
171 
172 
173 template<class Type>
175 (
176  solveScalarField& result,
177  const bool add,
178  const solveScalarField& psiInternal,
179  const scalarField& coeffs,
180  const direction cmpt,
181  const Pstream::commsTypes
182 ) const
183 {
184  const labelUList& nbrFaceCells =
185  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
186 
187  solveScalarField pnf(psiInternal, nbrFaceCells);
188 
189  // Transform according to the transformation tensors
190  transformCoupleField(pnf, cmpt);
191 
192  // Multiply the field by coefficients and add into the result
193  this->addToInternalField(result, !add, coeffs, pnf);
194 }
195 
196 
197 template<class Type>
199 (
200  Field<Type>& result,
201  const bool add,
202  const Field<Type>& psiInternal,
203  const scalarField& coeffs,
204  const Pstream::commsTypes
205 ) const
206 {
207  const labelUList& nbrFaceCells =
208  cyclicPatch().cyclicPatch().neighbPatch().faceCells();
209 
210  Field<Type> pnf(psiInternal, nbrFaceCells);
211 
212  // Transform according to the transformation tensors
213  transformCoupleField(pnf);
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 {
224 }
225 
226 
227 // ************************************************************************* //
Foam::cyclicFvPatchField::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: cyclicFvPatchField.C:175
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::cyclicFvPatchField::neighbourPatchField
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Definition: cyclicFvPatchField.C:158
Foam::FatalIOError
IOerror FatalIOError
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
transformField.H
Spatial transformation functions for primitive fields.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
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::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::cyclicLduInterfaceField
Abstract base class for cyclic coupled interfaces.
Definition: cyclicLduInterfaceField.H:52
Foam::cyclicFvPatchField::patchNeighbourField
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
Definition: cyclicFvPatchField.C:124
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::cyclicFvPatchField::cyclicFvPatchField
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicFvPatchField.C:36
Foam::UList< label >
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
Foam::cyclicFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicFvPatchField.C:221
Foam::cyclicFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries.
Definition: cyclicFvPatchField.H:72
cyclicFvPatchField.H
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
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