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