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  //- Runtime type information
97  TypeName(cyclicFvPatch::typeName_());
98 
99 
100  // Constructors
101 
102  //- Construct from patch and internal field
104  (
105  const fvPatch&,
107  );
108 
109  //- Construct from patch, internal field and dictionary
111  (
112  const fvPatch&,
114  const dictionary&
115  );
116 
117  //- Construct by mapping given cyclicFvPatchField onto a new patch
119  (
121  const fvPatch&,
123  const fvPatchFieldMapper&
124  );
125 
126  //- Construct as copy
128  (
130  );
131 
132  //- Construct and return a clone
133  virtual tmp<fvPatchField<Type>> clone() const
134  {
135  return tmp<fvPatchField<Type>>
136  (
137  new cyclicFvPatchField<Type>(*this)
138  );
139  }
140 
141  //- Construct as copy setting internal field reference
143  (
146  );
147 
148  //- Construct and return a clone setting internal field reference
150  (
152  ) const
153  {
154  return tmp<fvPatchField<Type>>
155  (
156  new cyclicFvPatchField<Type>(*this, iF)
157  );
158  }
159 
160 
161  // Member functions
162 
163  // Access
164 
165  //- Return local reference cast into the cyclic patch
166  const cyclicFvPatch& cyclicPatch() const
167  {
168  return cyclicPatch_;
169  }
170 
171 
172  // Evaluation functions
173 
174  //- Return neighbour coupled internal cell data
176 
177  //- Return reference to neighbour patchField
179 
180  //- Update result field based on interface functionality
181  virtual void updateInterfaceMatrix
182  (
183  solveScalarField& result,
184  const bool add,
185  const solveScalarField& psiInternal,
186  const scalarField& coeffs,
187  const direction cmpt,
188  const Pstream::commsTypes commsType
189  ) const;
190 
191  //- Update result field based on interface functionality
192  virtual void updateInterfaceMatrix
193  (
194  Field<Type>& result,
195  const bool add,
196  const Field<Type>& psiInternal,
197  const scalarField& coeffs,
198  const Pstream::commsTypes commsType
199  ) const;
200 
201 
202  // Cyclic coupled interface functions
203 
204  //- Does the patch field perform the transformation
205  virtual bool doTransform() const
206  {
207  return !(cyclicPatch_.parallel() || pTraits<Type>::rank == 0);
208  }
209 
210  //- Return face transformation tensor
211  virtual const tensorField& forwardT() const
212  {
213  return cyclicPatch_.forwardT();
214  }
215 
216  //- Return neighbour-cell transformation tensor
217  virtual const tensorField& reverseT() const
218  {
219  return cyclicPatch_.reverseT();
220  }
221 
222  //- Return rank of component for transform
223  virtual int rank() const
224  {
225  return pTraits<Type>::rank;
226  }
227 
228 
229  // I-O
230 
231  //- Write
232  virtual void write(Ostream& os) const;
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace Foam
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #ifdef NoRepository
243  #include "cyclicFvPatchField.C"
244 #endif
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #endif
249 
250 // ************************************************************************* //
Foam::cyclicFvPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: cyclicFvPatch.H:118
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
Foam::cyclicFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: cyclicFvPatchField.H:222
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:158
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:130
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:165
Foam::cyclicFvPatchField::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicFvPatchField.H:216
cyclicFvPatchField.C
Foam::cyclicFvPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: cyclicFvPatchField.H:204
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::cyclicFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: cyclicFvPatchField.H:132
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cyclicFvPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicFvPatch.H:124
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::cyclicFvPatch
Cyclic-plane patch.
Definition: cyclicFvPatch.H:53
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::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:54
Foam::cyclicFvPatchField::cyclicFvPatchField
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicFvPatchField.C:36
Foam::cyclicFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicFvPatchField.H:210
cyclicLduInterfaceField.H
Foam::direction
uint8_t direction
Definition: direction.H:52
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
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
coupledFvPatchField.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54