primitiveMeshPointPoints.C
Go to the documentation of this file.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 #include "primitiveMesh.H"
00028
00029
00030
00031 void Foam::primitiveMesh::calcPointPoints() const
00032 {
00033 if (debug)
00034 {
00035 Pout<< "primitiveMesh::calcPointPoints() : "
00036 << "calculating pointPoints"
00037 << endl;
00038
00039 if (debug == -1)
00040 {
00041
00042
00043 FatalErrorIn("primitiveMesh::calcPointPoints()")
00044 << abort(FatalError);
00045 }
00046 }
00047
00048
00049
00050 if (ppPtr_)
00051 {
00052 FatalErrorIn("primitiveMesh::calcPointPoints() const")
00053 << "pointPoints already calculated"
00054 << abort(FatalError);
00055 }
00056 else
00057 {
00058 const edgeList& e = edges();
00059 const labelListList& pe = pointEdges();
00060
00061 ppPtr_ = new labelListList(pe.size());
00062 labelListList& pp = *ppPtr_;
00063
00064 forAll (pe, pointI)
00065 {
00066 pp[pointI].setSize(pe[pointI].size());
00067
00068 forAll (pe[pointI], ppi)
00069 {
00070 if (e[pe[pointI][ppi]].start() == pointI)
00071 {
00072 pp[pointI][ppi] = e[pe[pointI][ppi]].end();
00073 }
00074 else if (e[pe[pointI][ppi]].end() == pointI)
00075 {
00076 pp[pointI][ppi] = e[pe[pointI][ppi]].start();
00077 }
00078 else
00079 {
00080 FatalErrorIn("primitiveMesh::calcPointPoints() const")
00081 << "something wrong with edges"
00082 << abort(FatalError);
00083 }
00084 }
00085 }
00086 }
00087 }
00088
00089
00090
00091
00092 const Foam::labelListList& Foam::primitiveMesh::pointPoints() const
00093 {
00094 if (!ppPtr_)
00095 {
00096 calcPointPoints();
00097 }
00098
00099 return *ppPtr_;
00100 }
00101
00102
00103 const Foam::labelList& Foam::primitiveMesh::pointPoints
00104 (
00105 const label pointI,
00106 DynamicList<label>& storage
00107 ) const
00108 {
00109 if (hasPointPoints())
00110 {
00111 return pointPoints()[pointI];
00112 }
00113 else
00114 {
00115 const edgeList& edges = this->edges();
00116 const labelList& pEdges = pointEdges()[pointI];
00117
00118 storage.clear();
00119
00120 if (pEdges.size() > storage.capacity())
00121 {
00122 storage.setCapacity(pEdges.size());
00123 }
00124
00125 forAll(pEdges, i)
00126 {
00127 storage.append(edges[pEdges[i]].otherVertex(pointI));
00128 }
00129
00130 return storage;
00131 }
00132 }
00133
00134
00135 const Foam::labelList& Foam::primitiveMesh::pointPoints
00136 (
00137 const label pointI
00138 ) const
00139 {
00140 return pointPoints(pointI, labels_);
00141 }
00142
00143
00144
00145
00146
Copyright © 2000-2009 OpenCFD Ltd