|
|
|
PointEdgeWave.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 PointEdgeWave 00027 00028 Description 00029 Wave propagation of information through grid. Every iteration 00030 information goes through one layer of edges. Templated on information 00031 that is transferred. 00032 00033 Handles parallel and cyclics. Only parallel reasonably tested. Cyclics 00034 hardly tested. 00035 00036 Note: whether to propagate depends on the return value of Type::update 00037 which returns true (i.e. propagate) if the value changes by more than a 00038 certain tolerance. 00039 00040 Note: parallel is done in two steps: 00041 1. transfer patch points in offset notation, i.e. every patch point is 00042 denoted by a patchface label and an index in this face. Receiving end uses 00043 that fact that f[0] is shared and order is reversed. 00044 2. do all non-local shared points by means of reduce of data on them. 00045 00046 Note: cyclics is with offset in patchface as well. Patch is divided into 00047 two sub patches and the point-point addressing is never explicitly 00048 calculated but instead use is made of the face-face correspondence. 00049 (it probably is more efficient to calculate a point-point 00050 correspondence at the start and then reuse this; task to be done) 00051 00052 SourceFiles 00053 PointEdgeWave.C 00054 00055 \*---------------------------------------------------------------------------*/ 00056 00057 #ifndef PointEdgeWave_H 00058 #define PointEdgeWave_H 00059 00060 #include "label.H" 00061 #include "boolList.H" 00062 #include "labelList.H" 00063 #include "scalarField.H" 00064 #include "pointFields.H" 00065 #include "tensor.H" 00066 #include "primitivePatch.H" 00067 #include "PtrList.H" 00068 00069 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00070 00071 namespace Foam 00072 { 00073 00074 // Class forward declarations 00075 class pointMesh; 00076 00077 00078 /*---------------------------------------------------------------------------*\ 00079 Class PointEdgeWaveName Declaration 00080 \*---------------------------------------------------------------------------*/ 00081 00082 TemplateName(PointEdgeWave); 00083 00084 00085 /*---------------------------------------------------------------------------*\ 00086 Class PointEdgeWave Declaration 00087 \*---------------------------------------------------------------------------*/ 00088 00089 template <class Type> 00090 class PointEdgeWave 00091 : 00092 public PointEdgeWaveName 00093 { 00094 // Private static data 00095 00096 //- Relative tolerance. Stop propagation if relative changes 00097 // less than this tolerance (responsability for checking this is 00098 // up to Type implementation) 00099 static scalar propagationTol_; 00100 00101 00102 // Private data 00103 00104 //- Reference to mesh 00105 const pointMesh& pMesh_; 00106 00107 //- Wall information for all points 00108 List<Type>& allPointInfo_; 00109 00110 //- Information on all mesh edges 00111 List<Type>& allEdgeInfo_; 00112 00113 //- Has point changed 00114 boolList changedPoint_; 00115 00116 //- List of changed points 00117 labelList changedPoints_; 00118 00119 //- Number of changed points 00120 label nChangedPoints_; 00121 00122 //- Edges that have changed 00123 boolList changedEdge_; 00124 labelList changedEdges_; 00125 label nChangedEdges_; 00126 00127 //- Number of cyclic patches 00128 bool nCyclicPatches_; 00129 00130 //- For every cyclic patch two primitivePatches 00131 PtrList<primitivePatch> cycHalves_; 00132 00133 //- Contains processor patches 00134 bool hasProcPatches_; 00135 00136 //- Number of evaluations 00137 label nEvals_; 00138 00139 //- Number of unvisited edges/points 00140 label nUnvisitedPoints_; 00141 label nUnvisitedEdges_; 00142 00143 00144 // Private Member Functions 00145 00146 //- Add value to all elements of labelList 00147 static void offset(const label val, labelList& elems); 00148 00149 00150 //- Adapt pointInfo for leaving domain 00151 void leaveDomain 00152 ( 00153 const polyPatch& meshPatch, 00154 const primitivePatch& patch, 00155 const List<label>& patchPointLabels, 00156 List<Type>& pointInfo 00157 ) const; 00158 00159 //- Adapt pointInfo for entering domain 00160 void enterDomain 00161 ( 00162 const polyPatch& meshPatch, 00163 const primitivePatch& patch, 00164 const List<label>& patchPointLabels, 00165 List<Type>& pointInfo 00166 ) const; 00167 00168 //- Transform. Implementation referred to Type 00169 void transform 00170 ( 00171 const tensorField& rotTensor, 00172 List<Type>& pointInfo 00173 ) const; 00174 00175 //- Updates pointInfo with information from neighbour. Updates all 00176 // statistics. 00177 bool updatePoint 00178 ( 00179 const label pointI, 00180 const label neighbourEdgeI, 00181 const Type& neighbourInfo, 00182 const scalar tol, 00183 Type& pointInfo 00184 ); 00185 00186 //- Updates pointInfo with information from same point. Updates all 00187 // statistics. 00188 bool updatePoint 00189 ( 00190 const label pointI, 00191 const Type& neighbourInfo, 00192 const scalar tol, 00193 Type& pointInfo 00194 ); 00195 00196 //- Updates edgeInfo with information from neighbour. Updates all 00197 // statistics. 00198 bool updateEdge 00199 ( 00200 const label edgeI, 00201 const label neighbourPointI, 00202 const Type& neighbourInfo, 00203 const scalar tol, 00204 Type& edgeInfo 00205 ); 00206 00207 // Parallel, cyclic 00208 00209 //- Has patches of certain type? 00210 template <class PatchType> 00211 label countPatchType() const; 00212 00213 //- Get info on patch points 00214 void getChangedPatchPoints 00215 ( 00216 const primitivePatch& patch, 00217 DynamicList<Type>& patchInfo, 00218 DynamicList<label>& patchPoints, 00219 DynamicList<label>& owner, 00220 DynamicList<label>& ownerIndex 00221 ) const; 00222 00223 //- Merge data from patch into overall data 00224 void updateFromPatchInfo 00225 ( 00226 const polyPatch& meshPatch, 00227 const primitivePatch& patch, 00228 const labelList& owner, 00229 const labelList& ownerIndex, 00230 List<Type>& patchInfo 00231 ); 00232 00233 //- Merge data from across processor boundaries 00234 void handleProcPatches(); 00235 00236 //- Calculate cyclic halves addressing. 00237 void calcCyclicAddressing(); 00238 00239 //- Merge data from across cyclic boundaries 00240 void handleCyclicPatches(); 00241 00242 00243 //- Disallow default bitwise copy construct 00244 PointEdgeWave(const PointEdgeWave&); 00245 00246 //- Disallow default bitwise assignment 00247 void operator=(const PointEdgeWave&); 00248 00249 public: 00250 00251 // Static Functions 00252 00253 //- Access to tolerance 00254 static scalar propagationTol() 00255 { 00256 return propagationTol_; 00257 } 00258 00259 //- Change tolerance 00260 static void setPropagationTol(const scalar tol) 00261 { 00262 propagationTol_ = tol; 00263 } 00264 00265 00266 00267 // Constructors 00268 00269 //- Construct from mesh, list of changed points with the Type 00270 // for these points. Gets work arrays to operate on, one of size 00271 // number of mesh points, the other number of mesh edges. 00272 // Iterates until nothing changes or maxIter reached. 00273 // (maxIter can be 0) 00274 PointEdgeWave 00275 ( 00276 const pointMesh& pMesh, 00277 const labelList& initialPoints, 00278 const List<Type>& initialPointsInfo, 00279 List<Type>& allPointInfo, 00280 List<Type>& allEdgeInfo, 00281 const label maxIter 00282 ); 00283 00284 00285 // Destructor 00286 00287 ~PointEdgeWave(); 00288 00289 00290 // Member Functions 00291 00292 //- Get allPointInfo 00293 const List<Type>& allPointInfo() const 00294 { 00295 return allPointInfo_; 00296 } 00297 00298 //- Get allEdgeInfo 00299 const List<Type>& allEdgeInfo() const 00300 { 00301 return allEdgeInfo_; 00302 } 00303 00304 //- Get number of unvisited edges, i.e. edges that were not (yet) 00305 // reached from walking across mesh. This can happen from 00306 // - not enough iterations done 00307 // - a disconnected mesh 00308 // - a mesh without walls in it 00309 label getUnsetEdges() const; 00310 00311 label getUnsetPoints() const; 00312 00313 //- Copy initial data into allPointInfo_ 00314 void setPointInfo 00315 ( 00316 const labelList& changedPoints, 00317 const List<Type>& changedPointsInfo 00318 ); 00319 00320 //- Propagate from point to edge. Returns total number of edges 00321 // (over all processors) changed. 00322 label pointToEdge(); 00323 00324 //- Propagate from edge to point. Returns total number of points 00325 // (over all processors) changed. 00326 label edgeToPoint(); 00327 00328 //- Iterate until no changes or maxIter reached. Returns actual 00329 // number of iterations. 00330 label iterate(const label maxIter); 00331 }; 00332 00333 00334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00335 00336 /*---------------------------------------------------------------------------*\ 00337 Class listUpdateOp Declaration 00338 \*---------------------------------------------------------------------------*/ 00339 00340 00341 template <class Type> 00342 class listUpdateOp 00343 { 00344 00345 public: 00346 00347 void operator()(List<Type>& x, const List<Type>& y) const 00348 { 00349 forAll(x, i) 00350 { 00351 x[i].updatePoint(y[i], PointEdgeWave<Type>::propagationTol()); 00352 } 00353 } 00354 }; 00355 00356 00357 00358 00359 00360 } // End namespace Foam 00361 00362 00363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00364 00365 #ifdef NoRepository 00366 # include "PointEdgeWave.C" 00367 #endif 00368 00369 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00370 00371 #endif 00372 00373 // ************************************************************************* // |