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 | Copyright (C) 2013-2014 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 #include "pointList.H"
40 #include "Tuple2.H"
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  //- Return the intersection volume and centroid between two cells
90  (
91  const label srcCellI,
92  const label tgtCellI
93  );
94 
95  //- Append target cell neihgbour cells to cellIDs list
96  virtual void appendNbrCells
97  (
98  const label tgtCellI,
99  const polyMesh& mesh,
100  const DynamicList<label>& visitedTgtCells,
101  DynamicList<label>& nbrTgtCellIDs
102  ) const;
103 
104  virtual bool initialise
105  (
106  labelListList& srcToTgtAddr,
107  scalarListList& srcToTgtWght,
108  labelListList& tgtToTgtAddr,
109  scalarListList& tgtToTgtWght
110  ) const;
111 
112  //- Disallow default bitwise copy construct
114 
115  //- Disallow default bitwise assignment
116  void operator=(const meshToMeshMethod&);
117 
118 
119 public:
120 
121  //- Run-time type information
122  TypeName("meshToMeshMethod");
123 
124  //- Declare runtime constructor selection table
126  (
127  autoPtr,
129  components,
130  (
131  const polyMesh& src,
132  const polyMesh& tgt
133  ),
134  (src, tgt)
135  );
136 
137  //- Construct from source and target meshes
138  meshToMeshMethod(const polyMesh& src, const polyMesh& tgt);
139 
140  //- Selector
142  (
143  const word& methodName,
144  const polyMesh& src,
145  const polyMesh& tgt
146  );
147 
148 
149  //- Destructor
150  virtual ~meshToMeshMethod();
151 
152 
153  // Member Functions
154 
155  // Evaluate
156 
157  //- Calculate addressing and weights and optionally offset vectors
158  virtual void calculate
159  (
160  labelListList& srcToTgtAddr,
161  scalarListList& srcToTgtWght,
162  pointListList& srcToTgtVec,
163  labelListList& tgtToSrcAddr,
164  scalarListList& tgtToSrcWght,
165  pointListList& tgtToSrcVec
166  ) = 0;
167 
168 
169  // Access
170 
171  //- Return const access to the source mesh
172  inline const polyMesh& src() const;
173 
174  //- Return const access to the target mesh
175  inline const polyMesh& tgt() const;
176 
177  //- Return const access to the overlap volume
178  inline scalar V() const;
179 
180 
181  // Check
182 
183  //- Write the connectivity (debugging)
184  void writeConnectivity
185  (
186  const polyMesh& mesh1,
187  const polyMesh& mesh2,
188  const labelListList& mesh1ToMesh2Addr
189  ) const;
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #include "meshToMeshMethodI.H"
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #endif
204 
205 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Tuple2.H
Foam::meshToMeshMethod::~meshToMeshMethod
virtual ~meshToMeshMethod()
Destructor.
Definition: meshToMeshMethod.C:245
Foam::DynamicList< label >
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:126
Foam::meshToMeshMethod::interVol
virtual scalar interVol(const label srcCellI, const label tgtCellI) const
Return the intersection volume between two cells.
Definition: meshToMeshMethod.C:102
Foam::meshToMeshMethod::tolerance_
static scalar tolerance_
Tolerance used in volume overlap calculations.
Definition: meshToMeshMethod.H:65
polyMesh.H
Foam::meshToMeshMethod::V
scalar V() const
Return const access to the overlap volume.
Definition: meshToMeshMethodI.H:38
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::meshToMeshMethod::operator=
void operator=(const meshToMeshMethod &)
Disallow default bitwise assignment.
Foam::meshToMeshMethod
Base class for mesh-to-mesh calculation methods.
Definition: meshToMeshMethod.H:48
Foam::meshToMeshMethod::New
static autoPtr< meshToMeshMethod > New(const word &methodName, const polyMesh &src, const polyMesh &tgt)
Selector.
Definition: meshToMeshMethodNew.C:31
Foam::meshToMeshMethod::writeConnectivity
void writeConnectivity(const polyMesh &mesh1, const polyMesh &mesh2, const labelListList &mesh1ToMesh2Addr) const
Write the connectivity (debugging)
Definition: meshToMeshMethod.C:252
Foam::meshToMeshMethod::src
const polyMesh & src() const
Return const access to the source mesh.
Definition: meshToMeshMethodI.H:26
Foam::meshToMeshMethod::V_
scalar V_
Cell total volume in overlap region [m3].
Definition: meshToMeshMethod.H:62
Foam::label
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
Foam::meshToMeshMethod::tgt_
const polyMesh & tgt_
Reference to the target mesh.
Definition: meshToMeshMethod.H:59
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:32
Foam::meshToMeshMethod::src_
const polyMesh & src_
Reference to the source mesh.
Definition: meshToMeshMethod.H:56
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::meshToMeshMethod::appendNbrCells
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.
Definition: meshToMeshMethod.C:161
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::meshToMeshMethod::maskCells
labelList maskCells() const
Return src cell IDs for the overlap region.
Definition: meshToMeshMethod.C:44
Foam::meshToMeshMethod::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, meshToMeshMethod, components,(const polyMesh &src, const polyMesh &tgt),(src, tgt))
Declare runtime constructor selection table.
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::meshToMeshMethod::initialise
virtual bool initialise(labelListList &srcToTgtAddr, scalarListList &srcToTgtWght, labelListList &tgtToTgtAddr, scalarListList &tgtToTgtWght) const
Definition: meshToMeshMethod.C:188
Foam::meshToMeshMethod::meshToMeshMethod
meshToMeshMethod(const meshToMeshMethod &)
Disallow default bitwise copy construct.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::Tuple2
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
Foam::meshToMeshMethod::intersect
virtual bool intersect(const label srcCellI, const label tgtCellI) const
Return the true if cells intersect.
Definition: meshToMeshMethod.C:78
Foam::meshToMeshMethod::TypeName
TypeName("meshToMeshMethod")
Run-time type information.
meshToMeshMethodI.H