cyclicFvPatchField.H
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-2016 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 Class
28  Foam::cyclicFvPatchField
29 
30 Group
31  grpCoupledBoundaryConditions
32 
33 Description
34  This boundary condition enforces a cyclic condition between a pair of
35  boundaries.
36 
37 Usage
38  Example of the boundary condition specification:
39  \verbatim
40  <patchName>
41  {
42  type cyclic;
43  }
44  \endverbatim
45 
46 Note
47  The patches must be topologically similar, i.e. if the owner patch is
48  transformed to the neighbour patch, the patches should be identical (or
49  very similar).
50 
51 SourceFiles
52  cyclicFvPatchField.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef cyclicFvPatchField_H
57 #define cyclicFvPatchField_H
58 
59 #include "coupledFvPatchField.H"
61 #include "cyclicFvPatch.H"
62 
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
64 
65 namespace Foam
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class cyclicFvPatch Declaration
70 \*---------------------------------------------------------------------------*/
71 
72 template<class Type>
74 :
75  virtual public cyclicLduInterfaceField,
76  public coupledFvPatchField<Type>
77 {
78  // Private data
79 
80  //- Local reference cast into the cyclic patch
81  const cyclicFvPatch& cyclicPatch_;
82 
83 
84  // Private Member Functions
85 
86  //- Return neighbour side field given internal fields
87  template<class Type2>
88  tmp<Field<Type2>> neighbourSideField
89  (
90  const Field<Type2>&
91  ) const;
92 
93 
94 public:
95 
96 
97  //- Runtime type information
98  TypeName(cyclicFvPatch::typeName_());
99 
100 
101  // Constructors
102 
103  //- Construct from patch and internal field
105  (
106  const fvPatch&,
108  );
109 
110  //- Construct from patch, internal field and dictionary
112  (
113  const fvPatch&,
115  const dictionary&,
116  const bool valueRequired = true
117  );
118 
119  //- Construct by mapping given cyclicFvPatchField onto a new patch
121  (
123  const fvPatch&,
125  const fvPatchFieldMapper&
126  );
127 
128  //- Construct as copy
130  (
132  );
133 
134  //- Construct and return a clone
135  virtual tmp<fvPatchField<Type>> clone() const
136  {
137  return tmp<fvPatchField<Type>>
138  (
139  new cyclicFvPatchField<Type>(*this)
140  );
141  }
142 
143  //- Construct as copy setting internal field reference
145  (
148  );
149 
150  //- Construct and return a clone setting internal field reference
152  (
154  ) const
155  {
156  return tmp<fvPatchField<Type>>
157  (
158  new cyclicFvPatchField<Type>(*this, iF)
159  );
160  }
161 
162 
163  // Member functions
164 
165  // Access
166 
167  //- Return local reference cast into the cyclic patch
168  const cyclicFvPatch& cyclicPatch() const
169  {
170  return cyclicPatch_;
171  }
172 
173 
174  // Evaluation functions
175 
176  //- Return neighbour coupled internal cell data
178 
179  //- Return reference to neighbour patchField
181 
182  //- Update result field based on interface functionality
183  virtual void updateInterfaceMatrix
184  (
185  solveScalarField& result,
186  const bool add,
187  const lduAddressing& lduAddr,
188  const label patchId,
189  const solveScalarField& psiInternal,
190  const scalarField& coeffs,
191  const direction cmpt,
192  const Pstream::commsTypes commsType
193  ) const;
194 
195  //- Update result field based on interface functionality
196  virtual void updateInterfaceMatrix
197  (
198  Field<Type>& result,
199  const bool add,
200  const lduAddressing& lduAddr,
201  const label patchId,
202  const Field<Type>& psiInternal,
203  const scalarField& coeffs,
204  const Pstream::commsTypes commsType
205  ) const;
206 
207 
208  //- Manipulate matrix
209  virtual void manipulateMatrix
210  (
211  fvMatrix<Type>& m,
212  const label iMatrix,
213  const direction cmp
214  );
215 
216 
217 
218  // Cyclic coupled interface functions
219 
220  //- Does the patch field perform the transformation
221  virtual bool doTransform() const
222  {
223  return !(cyclicPatch_.parallel() || pTraits<Type>::rank == 0);
224  }
225 
226  //- Return face transformation tensor
227  virtual const tensorField& forwardT() const
228  {
229  return cyclicPatch_.forwardT();
230  }
231 
232  //- Return neighbour-cell transformation tensor
233  virtual const tensorField& reverseT() const
234  {
235  return cyclicPatch_.reverseT();
236  }
237 
238  //- Return rank of component for transform
239  virtual int rank() const
240  {
241  return pTraits<Type>::rank;
242  }
243 
244 
245  // I-O
246 
247  //- Write
248  virtual void write(Ostream& os) const;
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #ifdef NoRepository
259  #include "cyclicFvPatchField.C"
260 #endif
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
Foam::cyclicFvPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: cyclicFvPatch.H:120
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::cyclicFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: cyclicFvPatchField.H:238
cyclicFvPatch.H
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:164
Foam::cyclicFvPatchField::TypeName
TypeName(cyclicFvPatch::typeName_())
Runtime type information.
Foam::cyclicFvPatch::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicFvPatch.H:132
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
Foam::cyclicFvPatchField::cyclicPatch
const cyclicFvPatch & cyclicPatch() const
Return local reference cast into the cyclic patch.
Definition: cyclicFvPatchField.H:167
Foam::cyclicFvPatchField::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicFvPatchField.H:232
cyclicFvPatchField.C
Foam::cyclicFvPatchField::manipulateMatrix
virtual void manipulateMatrix(fvMatrix< Type > &m, const label iMatrix, const direction cmp)
Manipulate matrix.
Definition: cyclicFvPatchField.C:251
Foam::cyclicFvPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: cyclicFvPatchField.H:220
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
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
os
OBJstream os(runTime.globalPath()/outputName)
Foam::cyclicFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: cyclicFvPatchField.H:134
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::cyclicFvPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicFvPatch.H:126
Foam::cyclicFvPatch
Cyclic-plane patch.
Definition: cyclicFvPatch.H:54
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:130
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::cyclicFvPatchField::cyclicFvPatchField
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicFvPatchField.C:38
Foam::cyclicFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicFvPatchField.H:226
cyclicLduInterfaceField.H
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::cyclicFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicFvPatchField.C:243
Foam::cyclicFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries.
Definition: cyclicFvPatchField.H:72
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
patchId
label patchId(-1)
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
coupledFvPatchField.H
Foam::cyclicFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: cyclicFvPatchField.C:182
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54