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-2018 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 [m3]
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 neihgbour 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 private:
107 
108  // Private member functions
109 
110  //- Disallow default bitwise copy construct
112 
113  //- Disallow default bitwise assignment
114  void operator=(const meshToMeshMethod&);
115 
116 
117 public:
118 
119  //- Run-time type information
120  TypeName("meshToMeshMethod");
121 
122  //- Declare runtime constructor selection table
124  (
125  autoPtr,
127  components,
128  (
129  const polyMesh& src,
130  const polyMesh& tgt
131  ),
132  (src, tgt)
133  );
134 
135  //- Construct from source and target meshes
136  meshToMeshMethod(const polyMesh& src, const polyMesh& tgt);
137 
138  //- Selector
140  (
141  const word& methodName,
142  const polyMesh& src,
143  const polyMesh& tgt
144  );
145 
146 
147  //- Destructor
148  virtual ~meshToMeshMethod();
149 
150 
151  // Member Functions
152 
153  // Evaluate
154 
155  //- Calculate addressing and weights
156  virtual void calculate
157  (
158  labelListList& srcToTgtAddr,
159  scalarListList& srcToTgtWght,
160  labelListList& tgtToTgtAddr,
161  scalarListList& tgtToTgtWght
162  ) = 0;
163 
164 
165  // Access
166 
167  //- Return const access to the source mesh
168  inline const polyMesh& src() const;
169 
170  //- Return const access to the target mesh
171  inline const polyMesh& tgt() const;
172 
173  //- Return const access to the overlap volume
174  inline scalar V() const;
175 
176 
177  // Check
178 
179  //- Write the connectivity (debugging)
180  void writeConnectivity
181  (
182  const polyMesh& mesh1,
183  const polyMesh& mesh2,
184  const labelListList& mesh1ToMesh2Addr
185  ) const;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #include "meshToMeshMethodI.H"
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
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
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 neihgbour 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 [m3].
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.