coupledFaPatch.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2022 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::coupledFaPatch
29 
30 Author
31  Zeljko Tukovic and Hrvoje Jasak
32 
33 Description
34  coupledFaPatch is an abstract base class for patches that couple regions
35  of the computational domain e.g. cyclic, arbitrary interfaces, sliding
36  interfaces and processor-processor links.
37 
38 SourceFiles
39  coupledFaPatch.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Foam_coupledFaPatch_H
44 #define Foam_coupledFaPatch_H
45 
46 #include "lduInterface.H"
47 #include "faPatch.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class coupledFaPatch Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class coupledFaPatch
59 :
60  public lduInterface,
61  public faPatch
62 {
63  // Private Data
64 
65  //- offset (distance) vector from one side of the couple to the other
66  mutable vectorField separation_;
67 
68  //- Face transformation tensor
69  mutable tensorField forwardT_;
70 
71  //- Neighbour-cell transformation tensor
72  mutable tensorField reverseT_;
73 
74 
75 protected:
76 
77  // Protected Member Functions
78 
79  //- Make patch weighting factors
80  virtual void makeWeights(scalarField&) const = 0;
81 
82  //- Make patch face - neighbour cell distances
83  virtual void makeDeltaCoeffs(scalarField&) const = 0;
84 
85  //- Calculate the uniform transformation tensors
87  (
88  const vector& Cf,
89  const vector& Cr,
90  const vector& nf,
91  const vector& nr
92  ) const;
93 
94  //- Calculate the transformation tensors
96  (
97  const vectorField& Cf,
98  const vectorField& Cr,
99  const vectorField& nf,
100  const vectorField& nr
101  ) const;
102 
103 
104 public:
105 
106  //- Runtime type information
107  TypeNameNoDebug("coupled");
108 
109 
110  // Constructors
111 
112  //- Construct from components
114  (
115  const word& name,
116  const labelList& edgeLabels,
117  const label index,
118  const faBoundaryMesh& bm,
119  const label nbrPolyPatchIndex,
120  const word& patchType
121  )
122  :
123  faPatch(name, edgeLabels, index, bm, nbrPolyPatchIndex, patchType)
124  {}
125 
126  //- Construct from dictionary
128  (
129  const word& name,
130  const dictionary& dict,
131  const label index,
132  const faBoundaryMesh& bm,
133  const word& patchType
134  )
135  :
136  faPatch(name, dict, index, bm, patchType)
137  {}
138 
139 
140  //- Destructor
141  virtual ~coupledFaPatch() = default;
142 
144  // Member Functions
145 
146  // Access
147 
148  //- Return true because this patch is coupled
149  virtual bool coupled() const
150  {
151  return true;
152  }
153 
154  //- Does this side own the patch ?
155  virtual bool owner() const = 0;
156 
157  //- Does the coupled side own the patch ?
158  virtual bool neighbour() const
159  {
160  return !owner();
161  }
162 
163  //- The referring patchID (eg, for cyclics).
164  // Here for consistency with coupledPolyPatch
165  virtual label referPatchID() const
166  {
167  return -1;
168  }
169 
170  //- Are the coupled planes separated?
171  bool separated() const
172  {
173  return separation_.size();
174  }
175 
176  //- Return the offset (distance) vector from one side of the couple
177  // to the other
178  const vectorField& separation() const
179  {
180  if (!separation_.size())
181  {
183  << "Coupled patches are not separated"
184  << abort(FatalError);
185  }
186 
187  return separation_;
188  }
189 
190  //- Return face transformation tensor
191  const tensorField& forwardT() const
192  {
193  if (!forwardT_.size())
194  {
196  << "Coupled planes do not need transformation"
197  << abort(FatalError);
198  }
200  return forwardT_;
201  }
202 
203  //- Return neighbour-cell transformation tensor
204  const tensorField& reverseT() const
205  {
206  if (!reverseT_.size())
207  {
209  << "Coupled planes do not need transformation"
210  << abort(FatalError);
211  }
212 
213  return reverseT_;
214  }
215 
216  //- Are the cyclic planes parallel
217  bool parallel() const
218  {
219  return forwardT_.size() == 0;
220  }
221 
222 
223  //- Initialise the calculation of the patch geometry
224  virtual void initGeometry(PstreamBuffers&) = 0;
225 
226  //- Calculate the patch geometry
227  virtual void calcGeometry(PstreamBuffers&) = 0;
228 
229  //- Initialise the patches for moving points
230  virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
231 
232  //- Correct patches after moving points
233  virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
234 
235 
236  // Access functions for demand driven data
237 
238  //- Return delta (P to N) vectors across coupled patch
239  virtual tmp<vectorField> delta() const = 0;
240 
241 
242  // Interface transfer functions
243 
244  //- Return faceCell addressing: lduInterface virtual function
245  virtual const labelUList& faceCells() const
246  {
247  return edgeFaces();
248  }
249 
250  //- Return the values of the given internal data adjacent to
251  // the interface as a field
253  (
254  const labelUList& internalData
255  ) const = 0;
256 
257  //- Initialise interface data transfer
258  virtual void initTransfer
259  (
260  const Pstream::commsTypes commsType,
261  const labelUList& interfaceData
262  ) const
263  {}
264 
265  //- Transfer and return neighbour field
266  virtual tmp<labelField> transfer
267  (
268  const Pstream::commsTypes commsType,
269  const labelUList& interfaceData
270  ) const = 0;
271 
272  //- Initialise neighbour field transfer
273  virtual void initInternalFieldTransfer
274  (
275  const Pstream::commsTypes commsType,
276  const labelUList& iF
277  ) const
278  {}
279 
280  //- Return neighbour field
281  virtual tmp<labelField> internalFieldTransfer
282  (
283  const Pstream::commsTypes commsType,
284  const labelUList& iF
285  ) const = 0;
286 };
287 
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 } // End namespace Foam
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 #endif
296 
297 // ************************************************************************* //
coupledFaPatch(const word &name, const labelList &edgeLabels, const label index, const faBoundaryMesh &bm, const label nbrPolyPatchIndex, const word &patchType)
Construct from components.
virtual label referPatchID() const
The referring patchID (eg, for cyclics).
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual void initTransfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const
Initialise interface data transfer.
commsTypes
Communications types.
Definition: UPstream.H:72
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
virtual bool coupled() const
Return true because this patch is coupled.
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
const vectorField & separation() const
Return the offset (distance) vector from one side of the couple.
const labelList & edgeLabels() const noexcept
Return the list of edges.
Definition: faPatch.H:335
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
UList< label > labelUList
A UList of labels.
Definition: UList.H:78
virtual const labelUList & faceCells() const
Return faceCell addressing: lduInterface virtual function.
bool separated() const
Are the coupled planes separated?
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void initGeometry(PstreamBuffers &)=0
Initialise the calculation of the patch geometry.
virtual void makeDeltaCoeffs(scalarField &) const =0
Make patch face - neighbour cell distances.
virtual void makeWeights(scalarField &) const =0
Make patch weighting factors.
virtual bool neighbour() const
Does the coupled side own the patch ?
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:433
errorManip< error > abort(error &err)
Definition: errorManip.H:139
virtual void initInternalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Initialise neighbour field transfer.
const word & name() const noexcept
The patch name.
virtual void initMovePoints(PstreamBuffers &, const pointField &)=0
Initialise the patches for moving points.
virtual ~coupledFaPatch()=default
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
virtual void movePoints(PstreamBuffers &, const pointField &)=0
Correct patches after moving points.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual tmp< labelField > transfer(const Pstream::commsTypes commsType, const labelUList &interfaceData) const =0
Transfer and return neighbour field.
bool parallel() const
Are the cyclic planes parallel.
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const =0
Return the values of the given internal data adjacent to.
TypeNameNoDebug("coupled")
Runtime type information.
coupledFaPatch is an abstract base class for patches that couple regions of the computational domain ...
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
Finite area boundary mesh.
virtual bool owner() const =0
Does this side own the patch ?
Field< vector > vectorField
Specialisation of Field<T> for vector.
const tensorField & forwardT() const
Return face transformation tensor.
label index() const noexcept
The index of this patch in the boundaryMesh.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const =0
Return neighbour field.
Namespace for OpenFOAM.
void calcTransformTensors(const vector &Cf, const vector &Cr, const vector &nf, const vector &nr) const
Calculate the uniform transformation tensors.