00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef motionSmoother_H
00058 #define motionSmoother_H
00059
00060 #include "pointFields.H"
00061 #include "labelHashSet.H"
00062 #include "PackedList.H"
00063 #include "indirectPrimitivePatch.H"
00064 #include "className.H"
00065
00066
00067
00068 namespace Foam
00069 {
00070
00071
00072 class twoDPointCorrector;
00073
00074
00075
00076
00077
00078 class motionSmoother
00079 {
00080
00081
00083 template <class T>
00084 class minEqOp
00085 {
00086
00087 public:
00088
00089 void operator()(T& x, const T& y) const
00090 {
00091 x = min(x, y);
00092 }
00093 };
00094
00095
00096
00097
00098
00099 polyMesh& mesh_;
00100
00101
00102 pointMesh& pMesh_;
00103
00104
00105 indirectPrimitivePatch& pp_;
00106
00107
00108
00109 const labelList adaptPatchIDs_;
00110
00111
00112
00113
00114
00115 const scalar reduction_;
00116
00117
00118 const label nSmoothScale_;
00119
00120
00121
00122
00123
00124 const scalar maxNonOrtho_;
00125
00126
00127 const scalar minVol_;
00128
00129
00130
00131 const scalar maxConcave_;
00132
00133
00134 const scalar minArea_;
00135
00136
00137
00138
00139
00140 pointVectorField displacement_;
00141
00142
00143 pointScalarField scale_;
00144
00145
00146 pointField oldPoints_;
00147
00148
00149 PackedList<1> isInternalPoint_;
00150
00151
00152 Switch twoDMotion_;
00153
00154
00155 twoDPointCorrector* correct2DPtr_;
00156
00157
00158
00159
00160
00161
00162 template <class Type>
00163 static Type avg
00164 (
00165 const GeometricField<Type, pointPatchField, pointMesh>& fld,
00166 const edgeList& edges,
00167 const pointField& points,
00168 const labelList& edgeLabels,
00169 const label pointI
00170 );
00171
00172
00173
00174 template <class Type>
00175 static Type avg
00176 (
00177 const GeometricField<Type, pointPatchField, pointMesh>& fld,
00178 const scalarField& edgeGamma,
00179 const edgeList& edges,
00180 const pointField& points,
00181 const labelList& edgeLabels,
00182 const label pointI
00183 );
00184
00185 static void checkFld(const pointScalarField& fld);
00186
00187
00188 labelHashSet getPoints(const labelHashSet&) const;
00189
00190
00191 void minSmooth(const pointScalarField&, pointScalarField&) const;
00192
00193
00194 void minSmooth
00195 (
00196 const labelList& meshPoints,
00197 const pointScalarField& fld,
00198 pointScalarField& newFld
00199 ) const;
00200
00201
00202 void scaleField
00203 (
00204 const labelHashSet& pointLabels,
00205 const scalar scale,
00206 pointScalarField& fld
00207 ) const;
00208
00209
00210
00211 void scaleField
00212 (
00213 const labelList& meshPoints,
00214 const labelHashSet& pointLabels,
00215 const scalar scale,
00216 pointScalarField& fld
00217 ) const;
00218
00219
00220 bool isInternalPoint(const label pointI) const;
00221
00222
00223 motionSmoother(const motionSmoother&);
00224
00225
00226 void operator=(const motionSmoother&);
00227
00228
00229 public:
00230
00231 ClassName("motionSmoother");
00232
00233
00234
00235
00236
00237
00238
00239 motionSmoother
00240 (
00241 polyMesh&,
00242 pointMesh&,
00243 indirectPrimitivePatch& pp,
00244 const labelList& adaptPatchIDs,
00245 const scalar reduction = 0.5,
00246 const label nSmoothScale = 1,
00247 const scalar maxNonOrtho = 90,
00248 const scalar minVol = SMALL,
00249 const scalar maxConcave = 180,
00250 const scalar minArea = VSMALL
00251 );
00252
00253
00254
00255
00256 ~motionSmoother();
00257
00258
00259
00260
00261
00262
00263
00264 const polyMesh& mesh() const;
00265
00266
00267 const pointMesh& pMesh() const;
00268
00269
00270 const indirectPrimitivePatch& patch() const;
00271
00272 scalar maxNonOrtho() const;
00273
00274 scalar minVol() const;
00275
00276 scalar maxConcave() const;
00277
00278 scalar minArea() const;
00279
00280
00281
00282 pointVectorField& displacement();
00283
00284
00285 const pointVectorField& displacement() const;
00286
00287
00288 const pointScalarField& scale() const;
00289
00290
00291 const pointField& oldPoints() const;
00292
00293 bool twoDMotion() const
00294 {
00295 return twoDMotion_;
00296 }
00297
00298 twoDPointCorrector& twoDCorrector()
00299 {
00300 if (!correct2DPtr_)
00301 {
00302 FatalErrorIn("motionSmoother::correct2D()")
00303 << "No 2D motion. Check constant/dynamicMeshDict"
00304 << " and empty 3D boundaries" << abort(FatalError);
00305 }
00306 return *correct2DPtr_;
00307 }
00308
00309
00310
00311
00312
00313
00314 void correct();
00315
00316
00317
00318
00319 tmp<scalarField> movePoints(pointField&);
00320
00321
00322
00323
00324
00325
00326
00327 bool scaleMesh
00328 (
00329 const bool smoothMesh = true,
00330 const label nAllow = 0
00331 );
00332
00333
00334 void updateMesh();
00335
00336
00337
00338
00339 bool checkMesh(labelHashSet&) const;
00340
00341
00342
00343
00344
00345 template <class Type>
00346 void smooth
00347 (
00348 GeometricField<Type, pointPatchField, pointMesh>&
00349 ) const;
00350
00351
00352
00353 template <class Type>
00354 void smooth
00355 (
00356 const GeometricField<Type, pointPatchField, pointMesh>& fld,
00357 const scalarField& edgeGamma,
00358 GeometricField<Type, pointPatchField, pointMesh>& newFld
00359 ) const;
00360
00361
00362 template<class Type, class CombineOp>
00363 static void syncField
00364 (
00365 GeometricField<Type, pointPatchField, pointMesh>&,
00366 const Type& zero,
00367 const CombineOp& cop
00368 );
00369
00370 };
00371
00372
00373
00374
00375 }
00376
00377
00378
00379 #ifdef NoRepository
00380 # include "motionSmootherTemplates.C"
00381 #endif
00382
00383
00384
00385 #endif
00386
00387