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 geodesic distance between P and N
83  virtual void makeLPN(scalarField&) const = 0;
84 
85  //- Make patch face - neighbour cell distances
86  virtual void makeDeltaCoeffs(scalarField&) const = 0;
87 
88  //- Make non-orthogonality correction vectors
89  virtual void makeCorrectionVectors(vectorField&) const = 0;
90 
91  //- Calculate the uniform transformation tensors
93  (
94  const vector& Cf,
95  const vector& Cr,
96  const vector& nf,
97  const vector& nr
98  ) const;
99 
100  //- Calculate the transformation tensors
102  (
103  const vectorField& Cf,
104  const vectorField& Cr,
105  const vectorField& nf,
106  const vectorField& nr
107  ) const;
108 
109 
110 public:
111 
112  //- Runtime type information
113  TypeNameNoDebug("coupled");
114 
115 
116  // Constructors
117 
118  //- Construct from components
120  (
121  const word& name,
122  const labelUList& edgeLabels,
123  const label index,
124  const faBoundaryMesh& bm,
125  const label nbrPolyPatchIndex,
126  const word& patchType
127  )
128  :
129  faPatch(name, edgeLabels, index, bm, nbrPolyPatchIndex, patchType)
130  {}
131 
132  //- Construct from dictionary
134  (
135  const word& name,
136  const dictionary& dict,
137  const label index,
138  const faBoundaryMesh& bm,
139  const word& patchType
140  )
141  :
142  faPatch(name, dict, index, bm, patchType)
143  {}
144 
145 
146  //- Destructor
147  virtual ~coupledFaPatch() = default;
148 
149 
150  // Member Functions
151 
152  // Access
154  //- Return true because this patch is coupled
155  virtual bool coupled() const
156  {
157  return true;
158  }
159 
160  //- Does this side own the patch ?
161  virtual bool owner() const = 0;
162 
163  //- Does the coupled side own the patch ?
164  virtual bool neighbour() const
165  {
166  return !owner();
167  }
168 
169  //- The referring patchID (eg, for cyclics).
170  // Here for consistency with coupledPolyPatch
171  virtual label referPatchID() const
172  {
173  return -1;
174  }
175 
176  //- Are the coupled planes separated?
177  bool separated() const
178  {
179  return separation_.size();
180  }
181 
182  //- Return the offset (distance) vector from one side of the couple
183  // to the other
184  const vectorField& separation() const
185  {
186  if (!separation_.size())
187  {
189  << "Coupled patches are not separated"
190  << abort(FatalError);
191  }
192 
193  return separation_;
194  }
195 
196  //- Return face transformation tensor
197  const tensorField& forwardT() const
198  {
199  if (!forwardT_.size())
200  {
202  << "Coupled planes do not need transformation"
203  << abort(FatalError);
204  }
205 
206  return forwardT_;
207  }
208 
209  //- Return neighbour-cell transformation tensor
210  const tensorField& reverseT() const
211  {
212  if (!reverseT_.size())
213  {
215  << "Coupled planes do not need transformation"
216  << abort(FatalError);
217  }
218 
219  return reverseT_;
220  }
221 
222  //- Are the cyclic planes parallel
223  bool parallel() const
224  {
225  return forwardT_.size() == 0;
226  }
227 
228 
229  //- Initialise the calculation of the patch geometry
230  virtual void initGeometry(PstreamBuffers&) = 0;
231 
232  //- Calculate the patch geometry
233  virtual void calcGeometry(PstreamBuffers&) = 0;
235  //- Initialise the patches for moving points
236  virtual void initMovePoints(PstreamBuffers&, const pointField&) = 0;
237 
238  //- Correct patches after moving points
239  virtual void movePoints(PstreamBuffers&, const pointField&) = 0;
240 
241 
242  // Access functions for demand driven data
243 
244  //- Return delta (P to N) vectors across coupled patch
245  virtual tmp<vectorField> delta() const = 0;
246 
247 
248  // Interface transfer functions
250  //- Return faceCell addressing: lduInterface virtual function
251  virtual const labelUList& faceCells() const
252  {
253  return edgeFaces();
254  }
255 
256  //- Return the values of the given internal data adjacent to
257  // the interface as a field
259  (
260  const labelUList& internalData
261  ) const = 0;
262 
263  //- Initialise interface data transfer
264  virtual void initTransfer
265  (
266  const Pstream::commsTypes commsType,
267  const labelUList& interfaceData
268  ) const
269  {}
270 
271  //- Transfer and return neighbour field
272  virtual tmp<labelField> transfer
273  (
274  const Pstream::commsTypes commsType,
275  const labelUList& interfaceData
276  ) const = 0;
277 
278  //- Initialise neighbour field transfer
279  virtual void initInternalFieldTransfer
280  (
281  const Pstream::commsTypes commsType,
282  const labelUList& iF
283  ) const
284  {}
285 
286  //- Return neighbour field
287  virtual tmp<labelField> internalFieldTransfer
288  (
289  const Pstream::commsTypes commsType,
290  const labelUList& iF
291  ) const = 0;
292 };
293 
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 } // End namespace Foam
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 #endif
302 
303 // ************************************************************************* //
virtual label referPatchID() const
The referring patchID (eg, for cyclics).
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
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:77
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:600
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:76
virtual void makeLPN(scalarField &) const =0
Make patch geodesic distance between P and N.
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 void makeCorrectionVectors(vectorField &) const =0
Make non-orthogonality correction vectors.
virtual bool neighbour() const
Does the coupled side own the patch ?
const labelUList & edgeFaces() const
Return edge-face addressing.
Definition: faPatch.C:424
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.
coupledFaPatch(const word &name, const labelUList &edgeLabels, const label index, const faBoundaryMesh &bm, const label nbrPolyPatchIndex, const word &patchType)
Construct from components.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
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, which is a faPatch list with registered IO, a reference to the associated ...
virtual bool owner() const =0
Does this side own the patch ?
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.