faceCoupleInfo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::faceCoupleInfo
26 
27 Description
28  Container for information needed to couple to meshes. When constructed
29  from two meshes and a list of coupled faces returns the mapping between
30  points.
31 
32 SourceFiles
33  faceCoupleInfo.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef faceCoupleInfo_H
38 #define faceCoupleInfo_H
39 
40 #include "pointField.H"
41 #include "indirectPrimitivePatch.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 class polyMesh;
50 
51 /*---------------------------------------------------------------------------*\
52  Class faceCoupleInfo Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class faceCoupleInfo
56 {
57  // Private Data
58 
59  //- Master patch
60  autoPtr<indirectPrimitivePatch> masterPatchPtr_;
61 
62  //- Slave patch
63  autoPtr<indirectPrimitivePatch> slavePatchPtr_;
64 
65  //- The number of coupled points
66  label nCouplePoints_;
67 
68  //- Master-to-couple point addressing
69  labelList masterToCouplePoints_;
70 
71  //- Slave-to-couple point addressing
72  labelList slaveToCouplePoints_;
73 
74 
75  // Private Member Functions
76 
77  // Debugging
78 
79  //- Calculate face centres from (subset of) faces.
80  template<template<class> class FaceList>
81  static pointField calcFaceCentres
82  (
83  const FaceList<face>&,
84  const pointField&,
85  const label start,
86  const label size
87  );
88 
89  //- Calculate face point averages from (subset of) faces.
90  template<template<class> class FaceList>
91  static pointField calcFacePointAverages
92  (
93  const FaceList<face>&,
94  const pointField&,
95  const label start,
96  const label size
97  );
98 
99  //- Write edges
100  static void writeOBJ
101  (
102  const fileName& fName,
103  const edgeList& edges,
104  const pointField& points
105  );
106 
107  //- Write edges
108  static void writeOBJ
109  (
110  const fileName& fName,
111  const pointField& points0,
112  const pointField& points1
113  );
114 
115  //- Write connections between corresponding points and faces
116  // as .obj files.
117  void writePointsFaces() const;
118 
119 
120 public:
121 
122  //- Runtime type information
123  ClassName("faceCoupleInfo");
124 
125 
126  // Constructors
127 
128  //- Construct from meshes and subset of mesh faces (i.e.,
129  // indirectPrimitivePatch addressing). Faces should be supplied in
130  // order and the points within them should be ordered (i.e., coupled
131  // faces should have the same zero-point and opposite orientations).
133  (
134  const polyMesh& masterMesh,
135  const labelList& masterAddressing,
136  const polyMesh& slaveMesh,
137  const labelList& slaveAddressing
138  );
139 
140 
141  //- Destructor
142  ~faceCoupleInfo();
143 
144 
145  // Member Functions
146 
147  // Access
148 
149  //- Addressing engine for coupled faces on mesh0
150  const indirectPrimitivePatch& masterPatch() const
151  {
152  return masterPatchPtr_();
153  }
154 
155  //- Addressing engine for coupled faces on mesh1
156  const indirectPrimitivePatch& slavePatch() const
157  {
158  return slavePatchPtr_();
159  }
160 
161  //- Access master-to-couple point addressing
162  const labelList& masterToCouplePoints() const
163  {
164  return masterToCouplePoints_;
165  }
166 
167  //- Access slave-to-couple point addressing
168  const labelList& slaveToCouplePoints() const
169  {
170  return slaveToCouplePoints_;
171  }
172 
173  //- Generate couple-to-master point addressing
175  {
176  return invertOneToMany(nCouplePoints_, masterToCouplePoints_);
177  }
178 
179  //- Generate couple-to-slave point addressing
181  {
182  return invertOneToMany(nCouplePoints_, slaveToCouplePoints_);
183  }
184 
185  //- Return a coupled face
186  const face coupleFace(const label coupleFacei) const
187  {
188  return
189  renumber
190  (
192  masterPatch().localFaces()[coupleFacei]
193  );
194  }
195  };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #ifdef NoRepository
205  #include "faceCoupleInfoTemplates.C"
206 #endif
207 
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
209 
210 #endif
211 
212 // ************************************************************************* //
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
const face coupleFace(const label coupleFacei) const
Return a coupled face.
const indirectPrimitivePatch & slavePatch() const
Addressing engine for coupled faces on mesh1.
const labelList & slaveToCouplePoints() const
Access slave-to-couple point addressing.
const labelList & masterToCouplePoints() const
Access master-to-couple point addressing.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A class for handling file names.
Definition: fileName.H:79
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
Definition: ListOps.C:67
const indirectPrimitivePatch & masterPatch() const
Addressing engine for coupled faces on mesh0.
faceCoupleInfo(const polyMesh &masterMesh, const labelList &masterAddressing, const polyMesh &slaveMesh, const labelList &slaveAddressing)
Construct from meshes and subset of mesh faces (i.e.,.
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
A list of faces which address into the list of points.
const pointField & points
labelListList coupleToSlavePoints() const
Generate couple-to-slave point addressing.
labelListList coupleToMasterPoints() const
Generate couple-to-master point addressing.
~faceCoupleInfo()
Destructor.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
ClassName("faceCoupleInfo")
Runtime type information.
Namespace for OpenFOAM.