Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / sets / topoSets / pointSet.C
bloba4e59f52a997fc291153c585da2ab4578ea57077
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 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
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
19     for more details.
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 "pointSet.H"
27 #include "mapPolyMesh.H"
28 #include "polyMesh.H"
29 #include "syncTools.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 defineTypeNameAndDebug(pointSet, 0);
42 addToRunTimeSelectionTable(topoSet, pointSet, word);
43 addToRunTimeSelectionTable(topoSet, pointSet, size);
44 addToRunTimeSelectionTable(topoSet, pointSet, set);
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 topoSet& set,
86     writeOption w
89     topoSet(mesh, name, set, w)
93 pointSet::pointSet
95     const polyMesh& mesh,
96     const word& name,
97     const labelHashSet& set,
98     writeOption w
101     topoSet(mesh, name, set, w)
105 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
107 pointSet::~pointSet()
111 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
113 void pointSet::sync(const polyMesh& mesh)
115     // Convert to boolList
117     boolList contents(mesh.nPoints(), false);
119     forAllConstIter(pointSet, *this, iter)
120     {
121         contents[iter.key()] = true;
122     }
123     syncTools::syncPointList
124     (
125         mesh,
126         contents,
127         orEqOp<bool>(),
128         false           // null value
129     );
131     // Convert back to labelHashSet
133     labelHashSet newContents(size());
135     forAll(contents, pointI)
136     {
137         if (contents[pointI])
138         {
139             newContents.insert(pointI);
140         }
141     }
143     transfer(newContents);
147 label pointSet::maxSize(const polyMesh& mesh) const
149     return mesh.nPoints();
153 void pointSet::updateMesh(const mapPolyMesh& morphMap)
155     updateLabels(morphMap.reversePointMap());
159 void pointSet::writeDebug
161     Ostream& os,
162     const primitiveMesh& mesh,
163     const label maxLen
164 ) const
166     topoSet::writeDebug(os, mesh.points(), maxLen);
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 } // End namespace Foam
173 // ************************************************************************* //