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 #include "midPointAndFaceSet.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00029
00030
00031
00032
00033 namespace Foam
00034 {
00035 defineTypeNameAndDebug(midPointAndFaceSet, 0);
00036 addToRunTimeSelectionTable(sampledSet, midPointAndFaceSet, word);
00037 }
00038
00039
00040
00041
00042
00043
00044 void Foam::midPointAndFaceSet::genSamples()
00045 {
00046
00047
00048 List<point> newSamplePoints(3*size());
00049 labelList newSampleCells(3*size());
00050 labelList newSampleFaces(3*size());
00051 labelList newSampleSegments(3*size());
00052 scalarList newSampleCurveDist(3*size());
00053
00054 label newSampleI = 0;
00055
00056 label sampleI = 0;
00057
00058 while(true && size()>0)
00059 {
00060
00061
00062
00063 newSamplePoints[newSampleI] = operator[](sampleI);
00064 newSampleCells[newSampleI] = cells_[sampleI];
00065 newSampleFaces[newSampleI] = faces_[sampleI];
00066 newSampleSegments[newSampleI] = segments_[sampleI];
00067 newSampleCurveDist[newSampleI] = curveDist_[sampleI];
00068 newSampleI++;
00069
00070 while
00071 (
00072 (sampleI < size() - 1)
00073 && (segments_[sampleI] == segments_[sampleI+1])
00074 )
00075 {
00076
00077 const point mid = 0.5*(operator[](sampleI) + operator[](sampleI+1));
00078
00079 label cell1 = getCell(faces_[sampleI], mid);
00080 label cell2 = getCell(faces_[sampleI+1], mid);
00081
00082 if (cell1 != cell2)
00083 {
00084 FatalErrorIn("midPointAndFaceSet::genSamples()")
00085 << " sampleI:" << sampleI
00086 << " newSampleI:" << newSampleI
00087 << " pts[sampleI]:" << operator[](sampleI)
00088 << " face[sampleI]:" << faces_[sampleI]
00089 << " pts[sampleI+1]:" << operator[](sampleI+1)
00090 << " face[sampleI+1]:" << faces_[sampleI+1]
00091 << " cell1:" << cell1
00092 << " cell2:" << cell2
00093 << abort(FatalError);
00094 }
00095
00096 newSamplePoints[newSampleI] = mid;
00097 newSampleCells[newSampleI] = cell1;
00098 newSampleFaces[newSampleI] = -1;
00099 newSampleSegments[newSampleI] = segments_[sampleI];
00100 newSampleCurveDist[newSampleI] =
00101 mag(newSamplePoints[newSampleI] - start());
00102
00103 newSampleI++;
00104
00105
00106 newSamplePoints[newSampleI] = operator[](sampleI+1);
00107 newSampleCells[newSampleI] = cells_[sampleI+1];
00108 newSampleFaces[newSampleI] = faces_[sampleI+1];
00109 newSampleSegments[newSampleI] = segments_[sampleI+1];
00110 newSampleCurveDist[newSampleI] =
00111 mag(newSamplePoints[newSampleI] - start());
00112
00113 newSampleI++;
00114
00115 sampleI++;
00116 }
00117
00118 if (sampleI == size() - 1)
00119 {
00120 break;
00121 }
00122 sampleI++;
00123 }
00124
00125 newSamplePoints.setSize(newSampleI);
00126 newSampleCells.setSize(newSampleI);
00127 newSampleFaces.setSize(newSampleI);
00128 newSampleSegments.setSize(newSampleI);
00129 newSampleCurveDist.setSize(newSampleI);
00130
00131 setSamples
00132 (
00133 newSamplePoints,
00134 newSampleCells,
00135 newSampleFaces,
00136 newSampleSegments,
00137 newSampleCurveDist
00138 );
00139 }
00140
00141
00142
00143 Foam::midPointAndFaceSet::midPointAndFaceSet
00144 (
00145 const word& name,
00146 const polyMesh& mesh,
00147 meshSearch& searchEngine,
00148 const word& axis,
00149 const point& start,
00150 const point& end
00151 )
00152 :
00153 faceOnlySet(name, mesh, searchEngine, axis, start, end)
00154 {
00155 genSamples();
00156
00157 if (debug)
00158 {
00159 write(Info);
00160 }
00161 }
00162
00163
00164 Foam::midPointAndFaceSet::midPointAndFaceSet
00165 (
00166 const word& name,
00167 const polyMesh& mesh,
00168 meshSearch& searchEngine,
00169 const dictionary& dict
00170 )
00171 :
00172 faceOnlySet(name, mesh, searchEngine, dict)
00173 {
00174 genSamples();
00175
00176 if (debug)
00177 {
00178 write(Info);
00179 }
00180 }
00181
00182
00183
00184
00185 Foam::midPointAndFaceSet::~midPointAndFaceSet()
00186 {}
00187
00188
00189