pointPatch.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-2012 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::pointPatch
29 
30 Description
31  Basic pointPatch represents a set of points from the mesh.
32 
33 SourceFiles
34  pointPatch.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_pointPatch_H
39 #define Foam_pointPatch_H
40 
41 #include "patchIdentifier.H"
42 #include "labelList.H"
43 #include "vectorField.H"
44 #include "pointField.H"
45 #include "PtrList.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class pointBoundaryMesh;
54 class pointConstraint;
55 class pointPatch;
56 class PstreamBuffers;
57 
59 
60 //- Store lists of pointPatch as a PtrList
62 
63 /*---------------------------------------------------------------------------*\
64  Class pointPatch Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class pointPatch
68 :
69  public patchIdentifier
70 {
71  // Private Data
72 
73  //- Reference to boundary mesh
74  const pointBoundaryMesh& boundaryMesh_;
75 
76 
77 protected:
78 
79  // Protected Member Functions
80 
81  // The geometry initialisation is called by pointBoundaryMesh
82  friend class pointBoundaryMesh;
83 
84  //- Initialise the calculation of the patch geometry
85  virtual void initGeometry(PstreamBuffers&)
86  {}
87 
88  //- Calculate the patch geometry
89  virtual void calcGeometry(PstreamBuffers&)
90  {}
91 
92  //- Initialise the patches for moving points
93  virtual void initMovePoints(PstreamBuffers&, const pointField&)
94  {}
95 
96  //- Correct patches after moving points
97  virtual void movePoints(PstreamBuffers&, const pointField&)
98  {}
99 
100  //- Initialise the update of the patch topology
101  virtual void initUpdateMesh(PstreamBuffers&)
102  {}
103 
104  //- Update of the patch topology
105  virtual void updateMesh(PstreamBuffers&)
106  {}
107 
108 
109  //- No copy construct
110  pointPatch(const pointPatch&) = delete;
111 
112  //- No copy assignment
113  void operator=(const pointPatch&) = delete;
114 
115 
116 public:
117 
118  //- Runtime type information
119  TypeName("basePatch");
120 
121 
122  // Declare run-time constructor selection tables
123 
125  (
126  autoPtr,
127  pointPatch,
128  dictionary,
129  (
130  const word& name,
131  const dictionary& dict,
132  const label index,
133  const pointBoundaryMesh& bm,
134  const word& patchType
135  ),
136  (name, dict, index, bm, patchType)
137  );
138 
139 
140  // Constructor
141 
142  //- Construct from components
143  explicit pointPatch
144  (
145  const word& name,
146  const label index,
147  const pointBoundaryMesh& bm,
148  const word& physicalType,
149  const wordList& inGroups
150  )
151  :
153  boundaryMesh_(bm)
154  {}
155 
156  //- Construct from dictionary
157  explicit pointPatch
158  (
159  const word& name,
160  const dictionary& dict,
161  const label index,
162  const pointBoundaryMesh& bm
163  )
164  :
166  boundaryMesh_(bm)
167  {}
168 
169  //- Construct given the original patch and a map
170  explicit pointPatch
171  (
172  const pointPatch& pp,
173  const pointBoundaryMesh& bm,
174  const label index,
175  const labelUList& mapAddressing,
176  const labelUList& reversePointMap
177  )
178  :
180  boundaryMesh_(bm)
181  {}
182 
183  //- Construct and return a subset clone,
184  //- resetting the point list and boundary mesh
185  virtual autoPtr<pointPatch> clone
186  (
187  const pointBoundaryMesh& bm,
188  const label index,
189  const labelUList& mapAddressing,
190  const labelUList& reversePointMap
191  ) const = 0;
192 
193 
194  // Selectors
195 
196  //- Return a pointer to a new patch created on freestore. Returns
197  //- null if not found
198  static autoPtr<pointPatch> New
199  (
200  const word& name,
201  const dictionary& dict,
202  const label index,
203  const pointBoundaryMesh&
204  );
205 
206 
207  //- Destructor
208  virtual ~pointPatch() = default;
209 
210 
211  // Member Functions
212 
213  //- Return size
214  virtual label size() const = 0;
215 
216  //- Return boundaryMesh reference
217  const pointBoundaryMesh& boundaryMesh() const
218  {
219  return boundaryMesh_;
220  }
221 
222  //- Return true if this patch field is coupled
223  virtual bool coupled() const
224  {
225  return false;
226  }
227 
228  //- Return mesh points
229  virtual const labelList& meshPoints() const = 0;
230 
231  //- Return pointField of points in patch
232  virtual const vectorField& localPoints() const = 0;
233 
234  //- Return point unit normals
235  virtual const vectorField& pointNormals() const = 0;
236 
237  //- Return the constraint type this pointPatch implements.
238  virtual const word& constraintType() const
239  {
240  return word::null;
241  }
242 
243  //- Accumulate the effect of constraint direction of this patch
244  virtual void applyConstraint
245  (
246  const label pointi,
247  pointConstraint&
248  ) const
249  {}
251  //- Write the pointPatch data as a dictionary
252  virtual void write(Ostream&) const;
253 
254 
255  // Ostream Operator
256 
257  friend Ostream& operator<<(Ostream&, const pointPatch&);
258 };
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace Foam
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #endif
268 
269 // ************************************************************************* //
dictionary dict
PtrList< pointPatch > pointPatchList
Store lists of pointPatch as a PtrList.
Definition: pointPatch.H:58
pointPatch(const pointPatch &)=delete
No copy construct.
A pointBoundaryMesh is a pointPatch list with registered IO, a reference to the associated pointMesh...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: pointPatch.H:116
static autoPtr< pointPatch > New(const word &name, const dictionary &dict, const label index, const pointBoundaryMesh &)
Return a pointer to a new patch created on freestore. Returns null if not found.
Definition: pointPatchNew.C:24
Identifies a patch by name and index, with optional physical type and group information.
const wordList & inGroups() const noexcept
The (optional) groups that the patch belongs to.
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: pointPatch.H:258
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: pointPatch.H:92
friend Ostream & operator<<(Ostream &, const pointPatch &)
virtual autoPtr< pointPatch > clone(const pointBoundaryMesh &bm, const label index, const labelUList &mapAddressing, const labelUList &reversePointMap) const =0
Construct and return a subset clone, resetting the point list and boundary mesh.
virtual void applyConstraint(const label pointi, pointConstraint &) const
Accumulate the effect of constraint direction of this patch.
Definition: pointPatch.H:290
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: pointPatch.H:110
A class for handling words, derived from Foam::string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:84
virtual void write(Ostream &) const
Write the pointPatch data as a dictionary.
Definition: pointPatch.C:41
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: pointPatch.H:98
virtual const word & constraintType() const
Return the constraint type this pointPatch implements.
Definition: pointPatch.H:281
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const word & physicalType() const noexcept
The (optional) physical type of the patch.
TypeName("basePatch")
Runtime type information.
void operator=(const pointPatch &)=delete
No copy assignment.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual const vectorField & pointNormals() const =0
Return point unit normals.
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: pointPatch.H:250
virtual const vectorField & localPoints() const =0
Return pointField of points in patch.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
virtual void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: pointPatch.H:86
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: PtrList.H:56
virtual ~pointPatch()=default
Destructor.
declareRunTimeSelectionTable(autoPtr, pointPatch, dictionary,(const word &name, const dictionary &dict, const label index, const pointBoundaryMesh &bm, const word &patchType),(name, dict, index, bm, patchType))
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
label index() const noexcept
The index of this patch in the boundaryMesh.
List< label > labelList
A List of labels.
Definition: List.H:61
virtual void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: pointPatch.H:104
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Namespace for OpenFOAM.
virtual const labelList & meshPoints() const =0
Return mesh points.
virtual label size() const =0
Return size.