1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "midPointSet.H"
29 #include "addToRunTimeSelectionTable.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(midPointSet, 0);
36 addToRunTimeSelectionTable(sampledSet, midPointSet, word);
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 // Rework faceOnlySet samples.
43 // Take two consecutive samples
44 void Foam::midPointSet::genSamples()
46 // Generate midpoints.
48 List<point> midPoints(2*size());
49 labelList midCells(2*size());
50 labelList midSegments(2*size());
51 scalarList midCurveDist(2*size());
59 // calculate midpoint between sampleI and sampleI+1 (if in same segment)
62 (sampleI < size() - 1)
63 && (segments_[sampleI] == segments_[sampleI+1])
67 0.5*(operator[](sampleI) + operator[](sampleI+1));
69 label cell1 = getCell(faces_[sampleI], midPoints[midI]);
70 label cell2 = getCell(faces_[sampleI+1], midPoints[midI]);
74 FatalErrorIn("midPointSet::genSamples()")
75 << " sampleI:" << sampleI
77 << " sampleI:" << sampleI
78 << " pts[sampleI]:" << operator[](sampleI)
79 << " face[sampleI]:" << faces_[sampleI]
80 << " pts[sampleI+1]:" << operator[](sampleI+1)
81 << " face[sampleI+1]:" << faces_[sampleI+1]
87 midCells[midI] = cell1;
88 midSegments[midI] = segments_[sampleI];
89 midCurveDist[midI] = mag(midPoints[midI] - start());
95 if (sampleI == size() - 1)
102 midPoints.setSize(midI);
103 midCells.setSize(midI);
104 midSegments.setSize(midI);
105 midCurveDist.setSize(midI);
110 labelList(midCells.size(), -1),
116 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
118 Foam::midPointSet::midPointSet
121 const polyMesh& mesh,
122 meshSearch& searchEngine,
128 faceOnlySet(name, mesh, searchEngine, axis, start, end)
139 Foam::midPointSet::midPointSet
142 const polyMesh& mesh,
143 meshSearch& searchEngine,
144 const dictionary& dict
147 faceOnlySet(name, mesh, searchEngine, dict)
158 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
160 Foam::midPointSet::~midPointSet()
164 // ************************************************************************* //