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