Loading...
Searching...
No Matches
meshToMeshDataI.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2017-2025 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26\*---------------------------------------------------------------------------*/
27
28#include "polyMesh.H"
29
30// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33:
34 tgtCelli_(-2)
35{}
36
37
38inline Foam::meshToMeshData::meshToMeshData(const label tgtCelli)
39:
40 tgtCelli_(tgtCelli)
41{}
42
43
44// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
45
46template<class TrackingData>
47inline bool Foam::meshToMeshData::valid(TrackingData& td) const
49 return tgtCelli_ != -2;
50}
51
52
53// No geometric data so never any problem on cyclics
54template<class TrackingData>
56(
57 const polyMesh&,
58 const meshToMeshData&,
59 const scalar,
60 TrackingData& td
61) const
62{
63 return true;
64}
65
66
67template<class TrackingData>
69(
70 const polyMesh&,
71 const polyPatch& patch,
72 const label patchFacei,
73 const point& faceCentre,
74 TrackingData& td
75)
76{}
77
78
79template<class TrackingData>
81(
82 const polyMesh&,
83 const tensor& rotTensor,
84 TrackingData& td
85)
86{}
87
88
89// Update absolute geometric quantities.
90template<class TrackingData>
92(
93 const polyMesh&,
94 const polyPatch& patch,
95 const label patchFacei,
96 const point& faceCentre,
97 TrackingData& td
98)
99{}
100
101
102// Update cell with neighbouring face information
103template<class TrackingData>
105(
106 const polyMesh& mesh,
107 const label thisCelli,
108 const label neighbourFacei,
109 const meshToMeshData& neighbourInfo,
110 const scalar tol,
111 TrackingData& td
112)
113{
114 if (!valid(td))
115 {
116 const point& cc = mesh.cellCentres()[thisCelli];
117
118 // See if we are in the neighbour
119 const label tgti = neighbourInfo.tgtCelli_;
120
121 // Try match of neighbour
122 if (td.tgtMesh_.pointInCell(cc, tgti, polyMesh::CELL_TETS))
123 {
124 tgtCelli_ = tgti;
125 return true;
126 }
127
128 // Try match of neighbour's neighbours
129 const labelList& tgtNbrs = td.tgtMesh_.cellCells(tgti);
130 for (const label tgti : tgtNbrs)
131 {
132 // Try match of neighbour
133 if (td.tgtMesh_.pointInCell(cc, tgti, polyMesh::CELL_TETS))
134 {
135 tgtCelli_ = tgti;
136 return true;
137 }
138 }
139
140 // Leave unmatched cell for visit from different face
141 }
143 return false;
144}
145
146
147// Update face with neighbouring cell information
148template<class TrackingData>
150(
151 const polyMesh& mesh,
152 const label thisFacei,
153 const label neighbourCelli,
154 const meshToMeshData& neighbourInfo,
155 const scalar tol,
156 TrackingData& td
157)
158{
159 if (!valid(td))
160 {
161 tgtCelli_ = neighbourInfo.tgtCelli_;
162 return true;
163 }
165 return false;
166}
167
168
169// Update face with coupled face information
170template<class TrackingData>
172(
173 const polyMesh& mesh,
174 const label thisFacei,
175 const meshToMeshData& neighbourInfo,
176 const scalar tol,
177 TrackingData& td
178)
179{
180 if (!valid(td))
181 {
182 tgtCelli_ = neighbourInfo.tgtCelli_;
183 return true;
185
186 return false;
187}
188
189
190template<class TrackingData>
192(
193 const meshToMeshData& rhs,
194 TrackingData& td
195) const
196{
197 if (!valid(td))
198 {
199 return (!rhs.valid(td));
200 }
201 else
203 return operator==(rhs);
204 }
205}
206
207
208template<class TrackingData>
210(
211 const polyMesh& mesh,
212 const point& pt,
213 const label i0,
214 const meshToMeshData& f0,
215 const label i1,
216 const meshToMeshData& f1,
217 const scalar weight,
218 const scalar tol,
219 TrackingData& td
220)
221{
222 if (f0.valid(td))
223 {
224 return updateFace(mesh, -1, f0, tol, td);
225 }
226 if (f1.valid(td))
227 {
228 return updateFace(mesh, -1, f1, tol, td);;
229 }
230 else
231 {
232 return false;
233 }
234}
235
236
237// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
238
239inline bool Foam::meshToMeshData::operator==
240(
242) const
243{
244 return tgtCelli_ == rhs.tgtCelli_;
245}
246
247
248inline bool Foam::meshToMeshData::operator!=
249(
250 const meshToMeshData& rhs
251) const
252{
253 return !(*this == rhs);
254}
255
256
257// ************************************************************************* //
Transfers refinement levels such that slow transition between levels is maintained....
bool updateCell(const polyMesh &, const label thisCelli, const label neighbourFacei, const meshToMeshData &neighbourInfo, const scalar tol, TrackingData &)
Influence of neighbouring face.
bool updateFace(const polyMesh &, const label thisFacei, const label neighbourCelli, const meshToMeshData &neighbourInfo, const scalar tol, TrackingData &)
Influence of neighbouring cell.
void leaveDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &)
Convert absolute coordinates into relative to (patch)face centre.
bool equal(const meshToMeshData &, TrackingData &) const
Test for equality, with TrackingData.
bool interpolate(const polyMesh &, const point &pt, const label i0, const meshToMeshData &f0, const label i1, const meshToMeshData &f1, const scalar weight, const scalar tol, TrackingData &td)
Interpolate between two values (lerp). Returns true if causes changes. Not sure if needs to be specia...
meshToMeshData()
Default construct.
bool valid(TrackingData &) const
Changed or contains original (invalid) value.
void enterDomain(const polyMesh &, const polyPatch &, const label patchFacei, const point &faceCentre, TrackingData &)
Reverse of leaveDomain.
void transform(const polyMesh &, const tensor &, TrackingData &)
Apply rotation matrix to any coordinates.
bool sameGeometry(const polyMesh &, const meshToMeshData &, const scalar, TrackingData &) const
Check for identical geometrical data (eg, cyclics checking).
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
dynamicFvMesh & mesh
wallPoints::trackData td(isBlockedFace, regionToBlockSize)
List< label > labelList
A List of labels.
Definition List.H:62
Tensor< scalar > tensor
Definition symmTensor.H:57
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
vector point
Point is a vector.
Definition point.H:37
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)