|
|
|
calcPointCells.CGo 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-2009 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 Description 00026 Create intermediate mesh files from PROSTAR files 00027 00028 \*---------------------------------------------------------------------------*/ 00029 00030 #include "starMesh.H" 00031 00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00033 00034 void starMesh::calcPointCells() const 00035 { 00036 const static label UNIT_POINT_CELLS = 12; 00037 00038 if (pointCellsPtr_) 00039 { 00040 FatalErrorIn("starMesh::calcPointCells() const") 00041 << "pointCells already calculated" 00042 << abort(FatalError); 00043 } 00044 00045 00046 pointCellsPtr_ = new labelListList(points_.size()); 00047 00048 labelListList& pc = *pointCellsPtr_; 00049 00050 forAll(pc, i) 00051 { 00052 pc[i].setSize(UNIT_POINT_CELLS); 00053 } 00054 00055 // Initialise the list of labels which will hold the count the 00056 // actual number of cells per point during the analysis 00057 labelList cellCount(points_.size()); 00058 00059 forAll(cellCount, i) 00060 { 00061 cellCount[i] = 0; 00062 } 00063 00064 // Note. Unlike the standard point-cell algorithm, which asks the cell for 00065 // the supporting point labels, we need to work based on the cell faces. 00066 // This is because some of the faces for meshes with arbitrary interfaces 00067 // do not come from the cell shape, but from the slaves of the coupled 00068 // match. It is also adventageous to remove the duplicates from the 00069 // point-cell addressing, because this removes a lot of waste later. 00070 // 00071 00072 // For each cell 00073 forAll(cellShapes_, cellI) 00074 { 00075 const faceList& faces = cellFaces_[cellI]; 00076 00077 forAll (faces, i) 00078 { 00079 // For each vertex 00080 const labelList& labels = faces[i]; 00081 00082 forAll(labels, j) 00083 { 00084 // Set working point label 00085 label curPoint = labels[j]; 00086 labelList& curPointCells = pc[curPoint]; 00087 label curCount = cellCount[curPoint]; 00088 00089 // check if the cell has been added before 00090 bool found = false; 00091 00092 for (label f = 0; f < curCount; f++) 00093 { 00094 if (curPointCells[f] == cellI) 00095 { 00096 found = true; 00097 00098 break; 00099 } 00100 } 00101 00102 if (!found) 00103 { 00104 00105 // If the list of pointCells is not big enough, double it 00106 if (curPointCells.size() <= curCount) 00107 { 00108 curPointCells.setSize(curPointCells.size()*2); 00109 } 00110 00111 // Enter the cell label in the point's cell list 00112 curPointCells[curCount] = cellI; 00113 00114 // Increment the cell count for the point addressed 00115 cellCount[curPoint]++; 00116 } 00117 } 00118 } 00119 } 00120 00121 // Finally, truncate the lists made to their active size 00122 forAll(pc, i) 00123 { 00124 pc[i].setSize(cellCount[i]); 00125 } 00126 } 00127 00128 00129 const labelListList& starMesh::pointCells() const 00130 { 00131 if (!pointCellsPtr_) 00132 { 00133 calcPointCells(); 00134 } 00135 00136 return *pointCellsPtr_; 00137 } 00138 00139 00140 // ************************************************************************* // |