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-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::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  //- Return the corresponding AMI method for patch interpolation
149  virtual const word& AMImethod() const = 0;
150 
151  // Evaluate
152 
153  //- Calculate addressing and weights
154  virtual void calculate
155  (
156  labelListList& srcToTgtAddr,
157  scalarListList& srcToTgtWght,
158  labelListList& tgtToTgtAddr,
159  scalarListList& tgtToTgtWght
160  ) = 0;
161 
162 
163  // Access
164 
165  //- Return const access to the source mesh
166  inline const polyMesh& src() const;
167 
168  //- Return const access to the target mesh
169  inline const polyMesh& tgt() const;
170 
171  //- Return const access to the overlap volume
172  inline scalar V() const;
173 
174 
175  // Check
176 
177  //- Write the connectivity (debugging)
178  void writeConnectivity
179  (
180  const polyMesh& mesh1,
181  const polyMesh& mesh2,
182  const labelListList& mesh1ToMesh2Addr
183  ) const;
184 
185 
186  // Member Operators
187 
188  //- Disallow default bitwise assignment
189  void operator=(const meshToMeshMethod&) = delete;
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #include "meshToMeshMethodI.H"
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
meshToMeshMethod(const polyMesh &src, const polyMesh &tgt)
Construct from source and target meshes.
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.
fvMesh & mesh
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.
const polyMesh & tgt() const
Return const access to the target mesh.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
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.
virtual const word & AMImethod() const =0
Return the corresponding AMI method for patch interpolation.
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:76
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.