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 public:
87 
88 
89  //- Runtime type information
90  TypeName(cyclicFvPatch::typeName_());
91 
92 
93  // Constructors
94 
95  //- Construct from patch and internal field
97  (
98  const fvPatch&,
100  );
101 
102  //- Construct from patch, internal field and dictionary
104  (
105  const fvPatch&,
107  const dictionary&,
108  const bool needValue = true
109  );
110 
111  //- Construct by mapping given cyclicFvPatchField onto a new patch
113  (
115  const fvPatch&,
117  const fvPatchFieldMapper&
118  );
119 
120  //- Construct as copy
122  (
124  );
125 
126  //- Construct as copy setting internal field reference
128  (
131  );
132 
133  //- Return a clone
134  virtual tmp<fvPatchField<Type>> clone() const
135  {
136  return fvPatchField<Type>::Clone(*this);
137  }
138 
139  //- Clone with an internal field reference
141  (
143  ) const
144  {
145  return fvPatchField<Type>::Clone(*this, iF);
146  }
147 
148 
149  // Member Functions
150 
151  // Access
152 
153  //- Return local reference cast into the cyclic patch
154  const cyclicFvPatch& cyclicPatch() const
155  {
156  return cyclicPatch_;
157  }
158 
159 
160  // Evaluation functions
161 
162  //- Return neighbour coupled internal cell data
163  virtual tmp<Field<Type>> patchNeighbourField() const;
164 
165  //- Retrieve neighbour coupled internal cell data
166  virtual void patchNeighbourField(UList<Type>& pnf) const;
167 
168  //- Return reference to neighbour patchField
170 
171  //- Update result field based on interface functionality
172  virtual void updateInterfaceMatrix
173  (
174  solveScalarField& result,
175  const bool add,
176  const lduAddressing& lduAddr,
177  const label patchId,
178  const solveScalarField& psiInternal,
179  const scalarField& coeffs,
180  const direction cmpt,
181  const Pstream::commsTypes commsType
182  ) const;
183 
184  //- Update result field based on interface functionality
185  virtual void updateInterfaceMatrix
186  (
187  Field<Type>& result,
188  const bool add,
189  const lduAddressing& lduAddr,
190  const label patchId,
191  const Field<Type>& psiInternal,
192  const scalarField& coeffs,
193  const Pstream::commsTypes commsType
194  ) const;
195 
196 
197  //- Manipulate matrix
198  virtual void manipulateMatrix
199  (
200  fvMatrix<Type>& m,
201  const label iMatrix,
202  const direction cmp
203  );
204 
205 
206 
207  // Cyclic coupled interface functions
208 
209  //- Does the patch field perform the transformation
210  virtual bool doTransform() const
211  {
212  return (pTraits<Type>::rank && !cyclicPatch_.parallel());
213  }
214 
215  //- Return face transformation tensor
216  virtual const tensorField& forwardT() const
217  {
218  return cyclicPatch_.forwardT();
219  }
220 
221  //- Return neighbour-cell transformation tensor
222  virtual const tensorField& reverseT() const
223  {
224  return cyclicPatch_.reverseT();
225  }
226 
227  //- Return rank of component for transform
228  virtual int rank() const
229  {
230  return pTraits<Type>::rank;
231  }
232 
233 
234  // I-O
235 
236  //- Write
237  virtual void write(Ostream& os) const;
238 };
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #ifdef NoRepository
248  #include "cyclicFvPatchField.C"
249 #endif
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
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:61
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:607
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.
virtual 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.