1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "midPointAndFaceSet.H"
28 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(midPointAndFaceSet, 0);
36 addToRunTimeSelectionTable(sampledSet, midPointAndFaceSet, word);
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 // Rework faceOnlySet samples.
43 // Take two consecutive samples
44 void Foam::midPointAndFaceSet::genSamples()
46 // Generate midpoints and add to face points
48 List<point> newSamplePoints(3*size());
49 labelList newSampleCells(3*size());
50 labelList newSampleFaces(3*size());
51 labelList newSampleSegments(3*size());
52 scalarList newSampleCurveDist(3*size());
58 while(true && size()>0)
60 // sampleI is start of segment
63 newSamplePoints[newSampleI] = operator[](sampleI);
64 newSampleCells[newSampleI] = cells_[sampleI];
65 newSampleFaces[newSampleI] = faces_[sampleI];
66 newSampleSegments[newSampleI] = segments_[sampleI];
67 newSampleCurveDist[newSampleI] = curveDist_[sampleI];
72 (sampleI < size() - 1)
73 && (segments_[sampleI] == segments_[sampleI+1])
77 const point mid = 0.5*(operator[](sampleI) + operator[](sampleI+1));
79 label cell1 = getCell(faces_[sampleI], mid);
80 label cell2 = getCell(faces_[sampleI+1], mid);
84 FatalErrorIn("midPointAndFaceSet::genSamples()")
85 << " sampleI:" << sampleI
86 << " newSampleI:" << newSampleI
87 << " pts[sampleI]:" << operator[](sampleI)
88 << " face[sampleI]:" << faces_[sampleI]
89 << " pts[sampleI+1]:" << operator[](sampleI+1)
90 << " face[sampleI+1]:" << faces_[sampleI+1]
96 newSamplePoints[newSampleI] = mid;
97 newSampleCells[newSampleI] = cell1;
98 newSampleFaces[newSampleI] = -1;
99 newSampleSegments[newSampleI] = segments_[sampleI];
100 newSampleCurveDist[newSampleI] =
101 mag(newSamplePoints[newSampleI] - start());
106 newSamplePoints[newSampleI] = operator[](sampleI+1);
107 newSampleCells[newSampleI] = cells_[sampleI+1];
108 newSampleFaces[newSampleI] = faces_[sampleI+1];
109 newSampleSegments[newSampleI] = segments_[sampleI+1];
110 newSampleCurveDist[newSampleI] =
111 mag(newSamplePoints[newSampleI] - start());
118 if (sampleI == size() - 1)
125 newSamplePoints.setSize(newSampleI);
126 newSampleCells.setSize(newSampleI);
127 newSampleFaces.setSize(newSampleI);
128 newSampleSegments.setSize(newSampleI);
129 newSampleCurveDist.setSize(newSampleI);
141 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
143 Foam::midPointAndFaceSet::midPointAndFaceSet
146 const polyMesh& mesh,
147 meshSearch& searchEngine,
153 faceOnlySet(name, mesh, searchEngine, axis, start, end)
164 Foam::midPointAndFaceSet::midPointAndFaceSet
167 const polyMesh& mesh,
168 meshSearch& searchEngine,
169 const dictionary& dict
172 faceOnlySet(name, mesh, searchEngine, dict)
183 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
185 Foam::midPointAndFaceSet::~midPointAndFaceSet()
189 // ************************************************************************* //