cyclicAMIFvPatchField.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::cyclicAMIFvPatchField
29 
30 Group
31  grpCoupledBoundaryConditions
32 
33 Description
34  This boundary condition enforces a cyclic condition between a pair of
35  boundaries, whereby communication between the patches is performed using
36  an arbitrary mesh interface (AMI) interpolation.
37 
38 Usage
39  Example of the boundary condition specification:
40  \verbatim
41  <patchName>
42  {
43  type cyclicAMI;
44  }
45  \endverbatim
46 
47 Note
48  The outer boundary of the patch pairs must be similar, i.e. if the owner
49  patch is transformed to the neighbour patch, the outer perimiter of each
50  patch should be identical (or very similar).
51 
52 See also
53  Foam::AMIInterpolation
54 
55 SourceFiles
56  cyclicAMIFvPatchField.C
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef Foam_cyclicAMIFvPatchField_H
61 #define Foam_cyclicAMIFvPatchField_H
62 
63 #include "cyclicAMIFvPatch.H"
64 #include "coupledFvPatchField.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class cyclicAMIFvPatchField Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 template<class Type>
78 :
79  virtual public cyclicAMILduInterfaceField,
80  public coupledFvPatchField<Type>
81 {
82  // Private data
83 
84  //- Local reference cast into the cyclic patch
85  const cyclicAMIFvPatch& cyclicAMIPatch_;
86 
87 
88  // Private Member Functions
89 
90  //- Return neighbour side field given internal fields
91  template<class Type2>
92  tmp<Field<Type2>> neighbourSideField
93  (
94  const Field<Type2>&
95  ) const;
96 
97 
98  //- Return new matrix coeffs
99  tmp<Field<scalar>> coeffs
100  (
101  fvMatrix<Type>& matrix,
102  const Field<scalar>&,
103  const label
104  ) const;
105 
106 
107  template<class Type2>
108  void collectStencilData
109  (
110  const refPtr<mapDistribute>& mapPtr,
111  const labelListList& stencil,
112  const Type2& data,
113  List<Type2>& expandedData
114  );
115 
116 
117 public:
118 
119  //- Runtime type information
120  TypeName(cyclicAMIFvPatch::typeName_());
121 
122 
123  // Constructors
124 
125  //- Construct from patch and internal field
127  (
128  const fvPatch&,
130  );
131 
132  //- Construct from patch, internal field and dictionary
134  (
135  const fvPatch&,
137  const dictionary&
138  );
139 
140  //- Construct by mapping given cyclicAMIFvPatchField onto a new patch
142  (
144  const fvPatch&,
146  const fvPatchFieldMapper&
147  );
148 
149  //- Construct as copy
151 
152  //- Construct and return a clone
153  virtual tmp<fvPatchField<Type>> clone() const
154  {
155  return tmp<fvPatchField<Type>>
156  (
157  new cyclicAMIFvPatchField<Type>(*this)
158  );
159  }
160 
161  //- Construct as copy setting internal field reference
163  (
166  );
167 
168  //- Construct and return a clone setting internal field reference
170  (
172  ) const
173  {
174  return tmp<fvPatchField<Type>>
175  (
176  new cyclicAMIFvPatchField<Type>(*this, iF)
177  );
178  }
179 
180 
181  // Member functions
182 
183  // Access
184 
185  //- Return local reference cast into the cyclic AMI patch
186  const cyclicAMIFvPatch& cyclicAMIPatch() const
187  {
188  return cyclicAMIPatch_;
189  }
190 
191 
192  // Evaluation functions
193 
194  //- Return true if coupled. Note that the underlying patch
195  // is not coupled() - the points don't align.
196  virtual bool coupled() const;
197 
198  //- Return neighbour coupled internal cell data
199  virtual tmp<Field<Type>> patchNeighbourField() const;
200 
201  //- Return reference to neighbour patchField
203 
204  //- Update result field based on interface functionality
206  (
207  solveScalarField& result,
208  const bool add,
209  const lduAddressing& lduAddr,
210  const label patchId,
211  const solveScalarField& psiInternal,
212  const scalarField& coeffs,
213  const direction cmpt,
214  const Pstream::commsTypes commsType
215  ) const;
216 
217  //- Update result field based on interface functionality
218  virtual void updateInterfaceMatrix
219  (
220  Field<Type>&,
221  const bool add,
222  const lduAddressing& lduAddr,
223  const label patchId,
224  const Field<Type>&,
225  const scalarField&,
226  const Pstream::commsTypes commsType
227  ) const;
228 
229 
230  //- Manipulate matrix
231  virtual void manipulateMatrix
232  (
233  fvMatrix<Type>& m,
234  const label iMatrix,
235  const direction cmpt
236  );
237 
238 
239  // Cyclic AMI coupled interface functions
240 
241  //- Does the patch field perform the transformation
242  virtual bool doTransform() const
243  {
244  return (pTraits<Type>::rank && !cyclicAMIPatch_.parallel());
245  }
246 
247  //- Return face transformation tensor
248  virtual const tensorField& forwardT() const
249  {
250  return cyclicAMIPatch_.forwardT();
251  }
252 
253  //- Return neighbour-cell transformation tensor
254  virtual const tensorField& reverseT() const
255  {
256  return cyclicAMIPatch_.reverseT();
257  }
258 
259  //- Return rank of component for transform
260  virtual int rank() const
261  {
262  return pTraits<Type>::rank;
263  }
264 
265 
266  // I-O
267 
268  //- Write
269  virtual void write(Ostream& os) const;
270 };
271 
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 } // End namespace Foam
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #ifdef NoRepository
280  #include "cyclicAMIFvPatchField.C"
281 #endif
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 #endif
286 
287 // ************************************************************************* //
label patchId(-1)
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
uint8_t direction
Definition: direction.H:48
TypeName(cyclicAMIFvPatch::typeName_())
Runtime type information.
commsTypes
Communications types.
Definition: UPstream.H:74
virtual bool parallel() const
Are the cyclic planes parallel.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual void manipulateMatrix(fvMatrix< Type > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
Cyclic patch for Arbitrary Mesh Interface (AMI)
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
virtual const tensorField & forwardT() const
Return face transformation tensor.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
A traits class, which is primarily used for primitives.
Definition: pTraits.H:51
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
virtual bool doTransform() const
Does the patch field perform the transformation.
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.
Abstract base class for cyclic AMI coupled interfaces.
const cyclicAMIFvPatch & cyclicAMIPatch() const
Return local reference cast into the cyclic AMI patch.
Generic templated field type.
Definition: Field.H:62
virtual void write(Ostream &os) const
Write.
A FieldMapper for finite-volume patch fields.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
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
Abstract base class for coupled patches.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
virtual int rank() const
Return rank of component for transform.
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)
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const cyclicAMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
The class contains the addressing required by the lduMatrix: upper, lower and losort.
cyclicAMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
Namespace for OpenFOAM.