initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / sets / topoSets / pointSet.C
blob1e4884450cb88b1db2979bcc5c3ed3443cfbeb51
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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 "pointSet.H"
28 #include "mapPolyMesh.H"
29 #include "polyMesh.H"
30 #include "syncTools.H"
32 #include "addToRunTimeSelectionTable.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 defineTypeNameAndDebug(pointSet, 0);
43 addToRunTimeSelectionTable(topoSet, pointSet, word);
44 addToRunTimeSelectionTable(topoSet, pointSet, size);
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 pointSet::pointSet(const IOobject& obj)
51     topoSet(obj, typeName)
55 pointSet::pointSet
57     const polyMesh& mesh,
58     const word& name,
59     readOption r,
60     writeOption w
63     topoSet(mesh, typeName, name, r, w)
65     check(mesh.nPoints());
69 pointSet::pointSet
71     const polyMesh& mesh,
72     const word& name,
73     const label size,
74     writeOption w
77     topoSet(mesh, name, size, w)
81 pointSet::pointSet
83     const polyMesh& mesh,
84     const word& name,
85     const labelHashSet& set,
86     writeOption w
89     topoSet(mesh, name, set, w)
93 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
95 pointSet::~pointSet()
99 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
101 void pointSet::sync(const polyMesh& mesh)
103     // Convert to boolList
105     boolList contents(mesh.nPoints(), false);
107     forAllConstIter(pointSet, *this, iter)
108     {
109         contents[iter.key()] = true;
110     }
111     syncTools::syncPointList
112     (
113         mesh,
114         contents,
115         orEqOp<bool>(),
116         false,          // null value
117         false           // no separation
118     );
120     // Convert back to labelHashSet
122     labelHashSet newContents(size());
124     forAll(contents, pointI)
125     {
126         if (contents[pointI])
127         {
128             newContents.insert(pointI);
129         }
130     }
132     transfer(newContents);
136 label pointSet::maxSize(const polyMesh& mesh) const
138     return mesh.nPoints();
142 void pointSet::updateMesh(const mapPolyMesh& morphMap)
144     updateLabels(morphMap.reversePointMap());
148 void pointSet::writeDebug
150     Ostream& os,
151     const primitiveMesh& mesh,
152     const label maxLen
153 ) const
155     topoSet::writeDebug(os, mesh.points(), maxLen);
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 } // End namespace Foam
162 // ************************************************************************* //