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 cyclicAMIFvPatchField_H
61 #define cyclicAMIFvPatchField_H
62 
63 
64 #include "coupledFvPatchField.H"
66 #include "cyclicAMIFvPatch.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class cyclicAMIFvPatchField Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class Type>
79 :
80  virtual public cyclicAMILduInterfaceField,
81  public coupledFvPatchField<Type>
82 {
83  // Private data
84 
85  //- Local reference cast into the cyclic patch
86  const cyclicAMIFvPatch& cyclicAMIPatch_;
87 
88 
89  // Private Member Functions
90 
91  //- Return neighbour side field given internal fields
92  template<class Type2>
93  tmp<Field<Type2>> neighbourSideField
94  (
95  const Field<Type2>&
96  ) const;
97 
98 
99  //- Return new matrix coeffs
100  tmp<Field<scalar>> coeffs
101  (
102  fvMatrix<Type>& matrix,
103  const Field<scalar>&,
104  const label
105  ) const;
106 
107 
108  template<class Type2>
109  void collectStencilData
110  (
111  const refPtr<mapDistribute>& mapPtr,
112  const labelListList& stencil,
113  const Type2& data,
114  List<Type2>& expandedData
115  );
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName(cyclicAMIFvPatch::typeName_());
122 
123 
124  // Constructors
125 
126  //- Construct from patch and internal field
128  (
129  const fvPatch&,
131  );
132 
133  //- Construct from patch, internal field and dictionary
135  (
136  const fvPatch&,
138  const dictionary&
139  );
140 
141  //- Construct by mapping given cyclicAMIFvPatchField onto a new patch
143  (
145  const fvPatch&,
147  const fvPatchFieldMapper&
148  );
149 
150  //- Construct as copy
152 
153  //- Construct and return a clone
154  virtual tmp<fvPatchField<Type>> clone() const
155  {
156  return tmp<fvPatchField<Type>>
157  (
158  new cyclicAMIFvPatchField<Type>(*this)
159  );
160  }
161 
162  //- Construct as copy setting internal field reference
164  (
167  );
168 
169  //- Construct and return a clone setting internal field reference
171  (
173  ) const
174  {
175  return tmp<fvPatchField<Type>>
176  (
177  new cyclicAMIFvPatchField<Type>(*this, iF)
178  );
179  }
180 
181 
182  // Member functions
183 
184  // Access
185 
186  //- Return local reference cast into the cyclic AMI patch
187  const cyclicAMIFvPatch& cyclicAMIPatch() const
188  {
189  return cyclicAMIPatch_;
190  }
191 
192 
193  // Evaluation functions
194 
195  //- Return true if coupled. Note that the underlying patch
196  // is not coupled() - the points don't align.
197  virtual bool coupled() const;
198 
199  //- Return neighbour coupled internal cell data
200  virtual tmp<Field<Type>> patchNeighbourField() const;
201 
202  //- Return reference to neighbour patchField
204 
205  //- Update result field based on interface functionality
206  virtual void updateInterfaceMatrix
207  (
208  solveScalarField& result,
209  const bool add,
210  const lduAddressing& lduAddr,
211  const label patchId,
212  const solveScalarField& psiInternal,
213  const scalarField& coeffs,
214  const direction cmpt,
215  const Pstream::commsTypes commsType
216  ) const;
217 
218  //- Update result field based on interface functionality
219  virtual void updateInterfaceMatrix
220  (
221  Field<Type>&,
222  const bool add,
223  const lduAddressing& lduAddr,
224  const label patchId,
225  const Field<Type>&,
226  const scalarField&,
227  const Pstream::commsTypes commsType
228  ) const;
229 
230 
231  //- Manipulate matrix
232  virtual void manipulateMatrix
233  (
234  fvMatrix<Type>& m,
235  const label iMatrix,
236  const direction cmpt
237  );
238 
239 
240  // Cyclic AMI coupled interface functions
241 
242  //- Does the patch field perform the transformation
243  virtual bool doTransform() const
244  {
245  return
246  !(cyclicAMIPatch_.parallel() || pTraits<Type>::rank == 0);
247  }
248 
249  //- Return face transformation tensor
250  virtual const tensorField& forwardT() const
251  {
252  return cyclicAMIPatch_.forwardT();
253  }
254 
255  //- Return neighbour-cell transformation tensor
256  virtual const tensorField& reverseT() const
257  {
258  return cyclicAMIPatch_.reverseT();
259  }
260 
261  //- Return rank of component for transform
262  virtual int rank() const
263  {
264  return pTraits<Type>::rank;
265  }
266 
267 
268  // I-O
269 
270  //- Write
271  virtual void write(Ostream& os) const;
272 };
273 
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 } // End namespace Foam
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #ifdef NoRepository
282  #include "cyclicAMIFvPatchField.C"
283 #endif
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #endif
288 
289 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
Foam::cyclicAMIFvPatchField::doTransform
virtual bool doTransform() const
Does the patch field perform the transformation.
Definition: cyclicAMIFvPatchField.H:242
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::cyclicAMILduInterfaceField
Abstract base class for cyclic AMI coupled interfaces.
Definition: cyclicAMILduInterfaceField.H:51
cyclicAMIFvPatchField.C
Foam::cyclicAMIFvPatchField::write
virtual void write(Ostream &os) const
Write.
Definition: cyclicAMIFvPatchField.C:439
Foam::cyclicAMIFvPatchField::rank
virtual int rank() const
Return rank of component for transform.
Definition: cyclicAMIFvPatchField.H:261
Foam::cyclicAMIFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries, whereby communicati...
Definition: cyclicAMIFvPatchField.H:77
Foam::cyclicAMIFvPatchField::manipulateMatrix
virtual void manipulateMatrix(fvMatrix< Type > &m, const label iMatrix, const direction cmpt)
Manipulate matrix.
Definition: cyclicAMIFvPatchField.C:272
cyclicAMILduInterfaceField.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::cyclicAMIFvPatchField::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicAMIFvPatchField.H:249
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::cyclicAMIFvPatch::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicAMIFvPatch.H:192
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::cyclicAMIFvPatchField::cyclicAMIPatch
const cyclicAMIFvPatch & cyclicAMIPatch() const
Return local reference cast into the cyclic AMI patch.
Definition: cyclicAMIFvPatchField.H:186
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cyclicAMIFvPatchField::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: cyclicAMIFvPatchField.C:197
Foam::cyclicAMIFvPatchField::reverseT
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Definition: cyclicAMIFvPatchField.H:255
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::cyclicAMIFvPatchField::cyclicAMIFvPatchField
cyclicAMIFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: cyclicAMIFvPatchField.C:37
Foam::coupledFvPatchField
Abstract base class for coupled patches.
Definition: coupledFvPatchField.H:57
Foam::List< labelList >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::cyclicAMIFvPatchField::coupled
virtual bool coupled() const
Return true if coupled. Note that the underlying patch.
Definition: cyclicAMIFvPatchField.C:138
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::cyclicAMIFvPatchField::TypeName
TypeName(cyclicAMIFvPatch::typeName_())
Runtime type information.
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::cyclicAMIFvPatch
Cyclic patch for Arbitrary Mesh Interface (AMI)
Definition: cyclicAMIFvPatch.H:54
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
patchId
label patchId(-1)
Foam::cyclicAMIFvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled internal cell data.
Definition: cyclicAMIFvPatchField.C:146
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
coupledFvPatchField.H
Foam::cyclicAMIFvPatch::forwardT
virtual const tensorField & forwardT() const
Return face transformation tensor.
Definition: cyclicAMIFvPatch.H:186
Foam::cyclicAMIFvPatch::parallel
virtual bool parallel() const
Are the cyclic planes parallel.
Definition: cyclicAMIFvPatch.H:180
Foam::cyclicAMIFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: cyclicAMIFvPatchField.H:153
Foam::data
Database for solution data, solver performance and other reduced data.
Definition: data.H:55
cyclicAMIFvPatch.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
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition: PtrList.H:60
Foam::cyclicAMIFvPatchField::neighbourPatchField
const cyclicAMIFvPatchField< Type > & neighbourPatchField() const
Return reference to neighbour patchField.
Definition: cyclicAMIFvPatchField.C:180