Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
autoMesh
autoHexMesh
autoHexMeshDriver
autoSnapDriver.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) 1991-2010 OpenCFD Ltd.
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::autoSnapDriver
26
27
Description
28
All to do with snapping to surface
29
30
SourceFiles
31
autoSnapDriver.C
32
33
\*---------------------------------------------------------------------------*/
34
35
#ifndef autoSnapDriver_H
36
#define autoSnapDriver_H
37
38
#include <
autoMesh/meshRefinement.H
>
39
40
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42
namespace
Foam
43
{
44
45
// Forward declaration of classes
46
class
motionSmoother;
47
class
snapParameters;
48
49
/*---------------------------------------------------------------------------*\
50
Class autoSnapDriver Declaration
51
\*---------------------------------------------------------------------------*/
52
53
class
autoSnapDriver
54
{
55
// Private classes
56
57
//- Combine operator class for equalizing displacements.
58
class
minMagEqOp
59
{
60
public
:
61
62
void
operator()(
vector
& x,
const
vector
&
y
)
const
63
{
64
if
(
magSqr
(y) <
magSqr
(x))
65
{
66
x =
y
;
67
}
68
}
69
};
70
71
72
// Private data
73
74
//- Mesh+surface
75
meshRefinement
& meshRefiner_;
76
77
//- From surface region to patch
78
const
labelList
globalToPatch_;
79
80
81
// Private Member Functions
82
83
84
// Snapping
85
86
//- Get faces to repatch. Returns map from face to patch.
87
Map<label>
getZoneBafflePatches(
const
bool
allowBoundary)
const
;
88
89
//- Calculates (geometric) shared points
90
static
label getCollocatedPoints
91
(
92
const
scalar tol,
93
const
pointField
&,
94
PackedBoolList
&
95
);
96
97
//- Calculate displacement per patch point to smooth out patch.
98
// Quite complicated in determining which points to move where.
99
pointField
smoothPatchDisplacement
100
(
101
const
motionSmoother
&,
102
const
List<labelPair>
&
103
)
const
;
104
105
//- Check that face zones are synced
106
void
checkCoupledFaceZones()
const
;
107
108
//- Per edge distance to patch
109
static
tmp<scalarField>
edgePatchDist
110
(
111
const
pointMesh
&,
112
const
indirectPrimitivePatch
&
113
);
114
115
//- Write displacement as .obj file.
116
static
void
dumpMove
117
(
118
const
fileName
&,
119
const
pointField
&,
120
const
pointField
&
121
);
122
123
//- Check displacement is outwards pointing
124
static
bool
outwardsDisplacement
125
(
126
const
indirectPrimitivePatch
&,
127
const
vectorField
&
128
);
129
130
131
//- Disallow default bitwise copy construct
132
autoSnapDriver
(
const
autoSnapDriver
&);
133
134
//- Disallow default bitwise assignment
135
void
operator=(
const
autoSnapDriver
&);
136
137
138
public
:
139
140
//- Runtime type information
141
ClassName
(
"autoSnapDriver"
);
142
143
144
// Constructors
145
146
//- Construct from components
147
autoSnapDriver
148
(
149
meshRefinement
& meshRefiner,
150
const
labelList
& globalToPatch
151
);
152
153
154
// Member Functions
155
156
// Snapping
157
158
//- Create baffles for faces straddling zoned surfaces. Return
159
// baffles.
160
autoPtr<mapPolyMesh>
createZoneBaffles
(
List<labelPair>
&);
161
162
//- Merge baffles.
163
autoPtr<mapPolyMesh>
mergeZoneBaffles
(
const
List<labelPair>
&);
164
165
//- Calculate edge length per patch point.
166
scalarField
calcSnapDistance
167
(
168
const
snapParameters
& snapParams,
169
const
indirectPrimitivePatch
&
170
)
const
;
171
172
//- Smooth the mesh (patch and internal) to increase visibility
173
// of surface points (on castellated mesh) w.r.t. surface.
174
void
preSmoothPatch
175
(
176
const
snapParameters
& snapParams,
177
const
label nInitErrors,
178
const
List<labelPair>
& baffles,
179
motionSmoother
&
180
)
const
;
181
182
//- Get points both on patch and facezone.
183
labelList
getZoneSurfacePoints
184
(
185
const
indirectPrimitivePatch
&,
186
const
word
& zoneName
187
)
const
;
188
189
//- Per patch point calculate point on nearest surface. Set as
190
// boundary conditions of motionSmoother displacement field. Return
191
// displacement of patch points.
192
vectorField
calcNearestSurface
193
(
194
const
scalarField
& snapDist,
195
motionSmoother
& meshMover
196
)
const
;
197
198
//- Smooth the displacement field to the internal.
199
void
smoothDisplacement
200
(
201
const
snapParameters
& snapParams,
202
motionSmoother
&
203
)
const
;
204
205
//- Do the hard work: move the mesh according to displacement,
206
// locally relax the displacement.
207
void
scaleMesh
208
(
209
const
snapParameters
& snapParams,
210
const
label nInitErrors,
211
const
List<labelPair>
& baffles,
212
motionSmoother
&
213
);
214
215
//- Repatch faces according to surface nearest the face centre
216
autoPtr<mapPolyMesh>
repatchToSurface
217
(
218
const
snapParameters
& snapParams,
219
const
labelList
& adaptPatchIDs
220
);
221
222
223
void
doSnap
224
(
225
const
dictionary
& snapDict,
226
const
dictionary
& motionDict,
227
const
snapParameters
& snapParams
228
);
229
230
};
231
232
233
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234
235
}
// End namespace Foam
236
237
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238
239
#endif
240
241
// ************************ vim: set sw=4 sts=4 et: ************************ //