meshToMeshMethod.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2015 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::meshToMeshMethod
29 
30 Description
31  Base class for mesh-to-mesh calculation methods
32 
33 SourceFiles
34  meshToMeshMethod.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef meshToMeshMethod_H
39 #define meshToMeshMethod_H
40 
41 #include "polyMesh.H"
42 #include "pointList.H"
43 #include "Tuple2.H"
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class meshToMeshMethod Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class meshToMeshMethod
53 {
54 
55 protected:
56 
57  // Protected data
58 
59  //- Reference to the source mesh
60  const polyMesh& src_;
61 
62  //- Reference to the target mesh
63  const polyMesh& tgt_;
64 
65  //- Cell total volume in overlap region [m3]
66  scalar V_;
67 
68  //- Tolerance used in volume overlap calculations
69  static scalar tolerance_;
70 
71 
72  // Protected Member Functions
73 
74  //- Return src cell IDs for the overlap region
75  labelList maskCells() const;
76 
77  //- Return the true if cells intersect
78  virtual bool intersect
79  (
80  const label srcCelli,
81  const label tgtCelli
82  ) const;
83 
84  //- Return the intersection volume between two cells
85  virtual scalar interVol
86  (
87  const label srcCelli,
88  const label tgtCelli
89  ) const;
90 
91  //- Return the intersection volume and centroid between two cells
93  (
94  const label srcCellI,
95  const label tgtCellI
96  );
97 
98  //- Append target cell neighbour cells to cellIDs list
99  virtual void appendNbrCells
100  (
101  const label tgtCelli,
102  const polyMesh& mesh,
103  const DynamicList<label>& visitedTgtCells,
104  DynamicList<label>& nbrTgtCellIDs
105  ) const;
106 
107  virtual bool initialise
108  (
109  labelListList& srcToTgtAddr,
110  scalarListList& srcToTgtWght,
111  labelListList& tgtToTgtAddr,
112  scalarListList& tgtToTgtWght
113  ) const;
114 
115 
116 private:
117 
118  // Private member functions
119 
120  //- No copy construct
121  meshToMeshMethod(const meshToMeshMethod&) = delete;
122 
123  //- No copy assignment
124  void operator=(const meshToMeshMethod&) = delete;
125 
126 
127 public:
128 
129  //- Run-time type information
130  TypeName("meshToMeshMethod");
131 
132  //- Declare runtime constructor selection table
134  (
135  autoPtr,
137  components,
138  (
139  const polyMesh& src,
140  const polyMesh& tgt
141  ),
142  (src, tgt)
143  );
144 
145  //- Construct from source and target meshes
146  meshToMeshMethod(const polyMesh& src, const polyMesh& tgt);
147 
148  //- Selector
150  (
151  const word& methodName,
152  const polyMesh& src,
153  const polyMesh& tgt
154  );
155 
156 
157  //- Destructor
158  virtual ~meshToMeshMethod();
159 
160 
161  // Member Functions
162 
163  // Evaluate
164 
165  //- Calculate addressing and weights and optionally offset vectors
166  virtual void calculate
167  (
168  labelListList& srcToTgtAddr,
169  scalarListList& srcToTgtWght,
170  pointListList& srcToTgtVec,
171  labelListList& tgtToSrcAddr,
172  scalarListList& tgtToSrcWght,
173  pointListList& tgtToSrcVec
174  ) = 0;
175 
176 
177  // Access
178 
179  //- Return const access to the source mesh
180  inline const polyMesh& src() const;
181 
182  //- Return const access to the target mesh
183  inline const polyMesh& tgt() const;
184 
185  //- Return const access to the overlap volume
186  inline scalar V() const;
187 
188 
189  // Check
190 
191  //- Write the connectivity (debugging)
192  void writeConnectivity
193  (
194  const polyMesh& mesh1,
195  const polyMesh& mesh2,
196  const labelListList& mesh1ToMesh2Addr
197  ) const;
198 };
199 
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 } // End namespace Foam
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #include "meshToMeshMethodI.H"
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #endif
212 
213 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Tuple2.H
Foam::meshToMeshMethod::~meshToMeshMethod
virtual ~meshToMeshMethod()
Destructor.
Definition: meshToMeshMethod.C:263
Foam::DynamicList< label >
Foam::meshToMeshMethod::appendNbrCells
virtual void appendNbrCells(const label tgtCelli, const polyMesh &mesh, const DynamicList< label > &visitedTgtCells, DynamicList< label > &nbrTgtCellIDs) const
Append target cell neighbour cells to cellIDs list.
Definition: meshToMeshMethod.C:185
Foam::meshToMeshMethod::interVolAndCentroid
virtual Tuple2< scalar, point > interVolAndCentroid(const label srcCellI, const label tgtCellI)
Return the intersection volume and centroid between two cells.
Definition: meshToMeshMethod.C:143
Foam::meshToMeshMethod::interVol
virtual scalar interVol(const label srcCelli, const label tgtCelli) const
Return the intersection volume between two cells.
Definition: meshToMeshMethod.C:112
Foam::meshToMeshMethod::tolerance_
static scalar tolerance_
Tolerance used in volume overlap calculations.
Definition: meshToMeshMethod.H:68
polyMesh.H
Foam::meshToMeshMethod::V
scalar V() const
Return const access to the overlap volume.
Definition: meshToMeshMethodI.H:40
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::meshToMeshMethod
Base class for mesh-to-mesh calculation methods.
Definition: meshToMeshMethod.H:51
Foam::meshToMeshMethod::New
static autoPtr< meshToMeshMethod > New(const word &methodName, const polyMesh &src, const polyMesh &tgt)
Selector.
Definition: meshToMeshMethodNew.C:34
Foam::meshToMeshMethod::writeConnectivity
void writeConnectivity(const polyMesh &mesh1, const polyMesh &mesh2, const labelListList &mesh1ToMesh2Addr) const
Write the connectivity (debugging)
Definition: meshToMeshMethod.C:270
Foam::meshToMeshMethod::src
const polyMesh & src() const
Return const access to the source mesh.
Definition: meshToMeshMethodI.H:28
Foam::meshToMeshMethod::intersect
virtual bool intersect(const label srcCelli, const label tgtCelli) const
Return the true if cells intersect.
Definition: meshToMeshMethod.C:81
Foam::meshToMeshMethod::V_
scalar V_
Cell total volume in overlap region [m3].
Definition: meshToMeshMethod.H:65
Foam::meshToMeshMethod::tgt_
const polyMesh & tgt_
Reference to the target mesh.
Definition: meshToMeshMethod.H:62
pointList.H
Foam::meshToMeshMethod::calculate
virtual void calculate(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, pointListList &srcToTgtVec, labelListList &tgtToSrcAddr, scalarListList &tgtToSrcWght, pointListList &tgtToSrcVec)=0
Calculate addressing and weights and optionally offset vectors.
Foam::meshToMeshMethod::tgt
const polyMesh & tgt() const
Return const access to the target mesh.
Definition: meshToMeshMethodI.H:34
Foam::meshToMeshMethod::src_
const polyMesh & src_
Reference to the source mesh.
Definition: meshToMeshMethod.H:59
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::meshToMeshMethod::maskCells
labelList maskCells() const
Return src cell IDs for the overlap region.
Definition: meshToMeshMethod.C:47
Foam::meshToMeshMethod::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, meshToMeshMethod, components,(const polyMesh &src, const polyMesh &tgt),(src, tgt))
Declare runtime constructor selection table.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::meshToMeshMethod::initialise
virtual bool initialise(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, labelListList &tgtToTgtAddr, scalarListList &tgtToTgtWght) const
Definition: meshToMeshMethod.C:206
Foam::List< label >
Foam::Tuple2< scalar, point >
Foam::meshToMeshMethod::TypeName
TypeName("meshToMeshMethod")
Run-time type information.
meshToMeshMethodI.H