nearestCellsToCells.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-2023 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::cellsToCellss::nearest
26 
27 Description
28  Nearest cells-to-cells interpolation class.
29 
30 SourceFiles
31  nearestCellsToCells.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef nearestCellsToCells_H
36 #define nearestCellsToCells_H
37 
38 #include "cellsToCells.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 namespace cellsToCellss
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class nearest Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class nearest
52 :
53  public cellsToCells
54 {
55 private:
56 
57  // Private Member Functions
58 
59  //- Find indices of overlapping cells in src and tgt meshes - returns
60  // true if found a matching pair
61  bool findInitialSeeds
62  (
63  const polyMesh& srcMesh,
64  const polyMesh& tgtMesh,
65  const labelList& srcCellIDs,
66  const boolList& mapFlag,
67  const label startSeedI,
68  label& srcSeedI,
69  label& tgtSeedI
70  ) const;
71 
72  //- Calculate the mesh-to-mesh addressing and weights
73  scalar calculateAddressing
74  (
75  const polyMesh& srcMesh,
76  const polyMesh& tgtMesh,
77  labelListList& srcToTgtCellAddr,
78  scalarListList& srcToTgtCellWght,
79  labelListList& tgtToSrcCellAddr,
80  scalarListList& tgtToSrcCellWght,
81  const label srcSeedI,
82  const label tgtSeedI,
83  const labelList& srcCellIDs,
84  boolList& mapFlag,
85  label& startSeedI
86  );
87 
88  //- Find the nearest cell on mesh2 for cell1 on mesh1
89  void findNearestCell
90  (
91  const polyMesh& mesh1,
92  const polyMesh& mesh2,
93  const label cell1,
94  label& cell2
95  ) const;
96 
97  //- Set the next cells for the marching front algorithm
98  void setNextNearestCells
99  (
100  const polyMesh& srcMesh,
101  const polyMesh& tgtMesh,
102  label& startSeedI,
103  label& srcCelli,
104  label& tgtCelli,
105  boolList& mapFlag,
106  const labelList& srcCellIDs
107  ) const;
108 
109  //- Find a source cell mapped to target cell tgtCelli
110  label findMappedSrcCell
111  (
112  const polyMesh& srcMesh,
113  const polyMesh& tgtMesh,
114  const label tgtCelli,
116  ) const;
117 
118 
119 protected:
120 
121  // Protected Member Functions
122 
123  // Intersection
124 
125  //- Calculate the addressing and weights
126  virtual scalar calculate
127  (
128  const polyMesh& srcMesh,
129  const polyMesh& tgtMesh
130  );
131 
132  //- Normalise the weights for a given mesh
133  virtual void normalise
134  (
135  const polyMesh& mesh,
136  labelListList& localOtherCells,
137  scalarListList& weights
138  ) const;
139 
140 
141 public:
142 
143  //- Run-time type information
144  TypeName("nearest");
145 
146 
147  // Constructors
148 
149  //- Construct null
150  nearest();
151 
152 
153  //- Destructor
154  virtual ~nearest();
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace cellsToCellss
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #endif
166 
167 // ************************************************************************* //
Class to calculate interpolative addressing and weights between the cells of two overlapping meshes.
Definition: cellsToCells.H:56
tmp< Field< Type > > tgtToSrc(const Field< Type > &tgtFld) const
Interpolate a target cell field to the source with no left.
Nearest cells-to-cells interpolation class.
virtual scalar calculate(const polyMesh &srcMesh, const polyMesh &tgtMesh)
Calculate the addressing and weights.
virtual void normalise(const polyMesh &mesh, labelListList &localOtherCells, scalarListList &weights) const
Normalise the weights for a given mesh.
TypeName("nearest")
Run-time type information.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Namespace for OpenFOAM.
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