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  The "value" entry is NO_READ.
38 
39 Usage
40  Example of the boundary condition specification:
41  \verbatim
42  <patchName>
43  {
44  type cyclic;
45  }
46  \endverbatim
47 
48 Note
49  The patches must be topologically similar, i.e. if the owner patch is
50  transformed to the neighbour patch, the patches should be identical (or
51  very similar).
52 
53 SourceFiles
54  cyclicFvPatchField.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef Foam_cyclicFvPatchField_H
59 #define Foam_cyclicFvPatchField_H
60 
61 #include "coupledFvPatchField.H"
63 #include "cyclicFvPatch.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 /*---------------------------------------------------------------------------*\
71  Class cyclicFvPatch Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 template<class Type>
76 :
77  virtual public cyclicLduInterfaceField,
78  public coupledFvPatchField<Type>
79 {
80  // Private Data
81 
82  //- Local reference cast into the cyclic patch
83  const cyclicFvPatch& cyclicPatch_;
84 
85 
86  // Private Member Functions
87 
88  //- Return neighbour side field given internal fields
89  template<class Type2>
90  tmp<Field<Type2>> neighbourSideField
91  (
92  const Field<Type2>&
93  ) const;
94 
95 
96 public:
97 
98 
99  //- Runtime type information
100  TypeName(cyclicFvPatch::typeName_());
101 
102 
103  // Constructors
104 
105  //- Construct from patch and internal field
107  (
108  const fvPatch&,
110  );
111 
112  //- Construct from patch, internal field and dictionary
114  (
115  const fvPatch&,
117  const dictionary&,
118  const bool needValue = true
119  );
120 
121  //- Construct by mapping given cyclicFvPatchField onto a new patch
123  (
125  const fvPatch&,
127  const fvPatchFieldMapper&
128  );
129 
130  //- Construct as copy
132  (
134  );
135 
136  //- Construct as copy setting internal field reference
138  (
141  );
142 
143  //- Return a clone
144  virtual tmp<fvPatchField<Type>> clone() const
145  {
146  return fvPatchField<Type>::Clone(*this);
147  }
148 
149  //- Clone with an internal field reference
151  (
153  ) const
154  {
155  return fvPatchField<Type>::Clone(*this, iF);
156  }
158 
159  // Member Functions
160 
161  // Access
162 
163  //- Return local reference cast into the cyclic patch
164  const cyclicFvPatch& cyclicPatch() const
165  {
166  return cyclicPatch_;
167  }
168 
169 
170  // Evaluation functions
171 
172  //- Return neighbour coupled internal cell data
174 
175  //- Return reference to neighbour patchField
177 
178  //- Update result field based on interface functionality
179  virtual void updateInterfaceMatrix
180  (
182  const bool add,
183  const lduAddressing& lduAddr,
184  const label patchId,
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 lduAddressing& lduAddr,
197  const label patchId,
198  const Field<Type>& psiInternal,
199  const scalarField& coeffs,
200  const Pstream::commsTypes commsType
201  ) const;
202 
203 
204  //- Manipulate matrix
205  virtual void manipulateMatrix
206  (
207  fvMatrix<Type>& m,
208  const label iMatrix,
209  const direction cmp
210  );
211 
212 
213 
214  // Cyclic coupled interface functions
215 
216  //- Does the patch field perform the transformation
217  virtual bool doTransform() const
218  {
219  return (pTraits<Type>::rank && !cyclicPatch_.parallel());
220  }
221 
222  //- Return face transformation tensor
223  virtual const tensorField& forwardT() const
224  {
225  return cyclicPatch_.forwardT();
226  }
227 
228  //- Return neighbour-cell transformation tensor
229  virtual const tensorField& reverseT() const
230  {
231  return cyclicPatch_.reverseT();
232  }
233 
234  //- Return rank of component for transform
235  virtual int rank() const
236  {
237  return pTraits<Type>::rank;
238  }
239 
240 
241  // I-O
242 
243  //- Write
244  virtual void write(Ostream& os) const;
245 };
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 } // End namespace Foam
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #ifdef NoRepository
255  #include "cyclicFvPatchField.C"
256 #endif
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #endif
261 
262 // ************************************************************************* //
label patchId(-1)
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.
uint8_t direction
Definition: direction.H:46
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
A traits class, which is primarily used for primitives and vector-space.
Definition: pTraits.H:75
virtual int rank() const
Return rank of component for transform.
TypeName(cyclicFvPatch::typeName_())
Runtime type information.
const cyclicFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
Generic templated field type.
Definition: Field.H:62
const cyclicFvPatch & cyclicPatch() const
Return local reference cast into the cyclic patch.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
A FieldMapper for finite-volume patch fields.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Cyclic-plane patch.
Definition: cyclicFvPatch.H:50
Abstract base class for coupled patches.
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
OBJstream os(runTime.globalPath()/outputName)
virtual void manipulateMatrix(fvMatrix< Type > &m, const label iMatrix, const direction cmp)
Manipulate matrix.
virtual bool doTransform() const
Does the patch field perform the transformation.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
virtual const tensorField & forwardT() const
Return face transformation tensor.
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.
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
Definition: exprTraits.C:70
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Abstract base class for cyclic coupled interfaces.
virtual bool parallel() const
Are the cyclic planes parallel.
Namespace for OpenFOAM.
cyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.