1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh 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 3 of the License, or (at your
14 option) any later version.
16 cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
28 #include "polyMeshGenPoints.H"
29 #include "pointIOField.H"
30 #include "IOobjectList.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 polyMeshGenPoints::polyMeshGenPoints(const Time& runTime)
57 //- Construct from time and points
58 polyMeshGenPoints::polyMeshGenPoints
61 const pointField& points
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 polyMeshGenPoints::~polyMeshGenPoints()
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
88 label polyMeshGenPoints::addPointSubset(const word& subsetName)
90 label id = pointSubsetIndex(subsetName);
93 Warning << "Point subset " << subsetName << " already exists!" << endl;
98 std::map<label, meshSubset>::const_iterator it;
99 for(it=pointSubsets_.begin();it!=pointSubsets_.end();++it)
100 id = Foam::max(id, it->first+1);
107 meshSubset(subsetName, meshSubset::POINTSUBSET)
114 void polyMeshGenPoints::removePointSubset(const label subsetID)
116 if( pointSubsets_.find(subsetID) == pointSubsets_.end() )
119 pointSubsets_.erase(subsetID);
122 word polyMeshGenPoints::pointSubsetName(const label subsetID) const
124 std::map<label, meshSubset>::const_iterator it =
125 pointSubsets_.find(subsetID);
126 if( it == pointSubsets_.end() )
128 Warning << "Subset " << subsetID << " is not a point subset" << endl;
132 return it->second.name();
135 label polyMeshGenPoints::pointSubsetIndex(const word& subsetName) const
137 std::map<label, meshSubset>::const_iterator it;
138 for(it=pointSubsets_.begin();it!=pointSubsets_.end();++it)
140 if( it->second.name() == subsetName )
147 void polyMeshGenPoints::read()
162 //- read point subsets
170 wordList setNames = allSets.names("pointSet");
171 forAll(setNames, setI)
173 IOobject* obj = allSets.lookup(setNames[setI]);
177 const labelList content = pSet.toc();
178 const label id = addPointSubset(setNames[setI]);
180 pointSubsets_[id].updateSubset(content);
184 void polyMeshGenPoints::write() const
188 std::map<label, meshSubset>::const_iterator setIt;
189 labelLongList containedElements;
191 //- write point selections
192 for(setIt=pointSubsets_.begin();setIt!=pointSubsets_.end();++setIt)
198 setIt->second.name(),
207 setIt->second.containedElements(containedElements);
209 forAll(containedElements, i)
210 set.insert(containedElements[i]);
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //