OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

pointSet.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "pointSet.H"
00028 #include "mapPolyMesh.H"
00029 #include "polyMesh.H"
00030 #include "syncTools.H"
00031 
00032 #include "addToRunTimeSelectionTable.H"
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 defineTypeNameAndDebug(pointSet, 0);
00042 
00043 addToRunTimeSelectionTable(topoSet, pointSet, word);
00044 addToRunTimeSelectionTable(topoSet, pointSet, size);
00045 
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 pointSet::pointSet(const IOobject& obj)
00050 :
00051     topoSet(obj, typeName)
00052 {}
00053 
00054 
00055 pointSet::pointSet
00056 (
00057     const polyMesh& mesh,
00058     const word& name,
00059     readOption r,
00060     writeOption w
00061 )
00062 :
00063     topoSet(mesh, typeName, name, r, w)
00064 {
00065     check(mesh.nPoints());
00066 }
00067 
00068 
00069 pointSet::pointSet
00070 (
00071     const polyMesh& mesh,
00072     const word& name,
00073     const label size,
00074     writeOption w
00075 )
00076 :
00077     topoSet(mesh, name, size, w)
00078 {}
00079 
00080 
00081 pointSet::pointSet
00082 (
00083     const polyMesh& mesh,
00084     const word& name,
00085     const labelHashSet& set,
00086     writeOption w
00087 )
00088 :
00089     topoSet(mesh, name, set, w)
00090 {}
00091 
00092 
00093 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00094 
00095 pointSet::~pointSet()
00096 {}
00097 
00098 
00099 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00100 
00101 void pointSet::sync(const polyMesh& mesh)
00102 {
00103     // Convert to boolList
00104 
00105     boolList contents(mesh.nPoints(), false);
00106 
00107     forAllConstIter(pointSet, *this, iter)
00108     {
00109         contents[iter.key()] = true;
00110     }
00111     syncTools::syncPointList
00112     (
00113         mesh,
00114         contents,
00115         orEqOp<bool>(),
00116         false,          // null value
00117         false           // no separation
00118     );
00119 
00120     // Convert back to labelHashSet
00121 
00122     labelHashSet newContents(size());
00123 
00124     forAll(contents, pointI)
00125     {
00126         if (contents[pointI])
00127         {
00128             newContents.insert(pointI);
00129         }
00130     }
00131 
00132     transfer(newContents);
00133 }
00134 
00135 
00136 label pointSet::maxSize(const polyMesh& mesh) const
00137 {
00138     return mesh.nPoints();
00139 }
00140 
00141 
00142 void pointSet::updateMesh(const mapPolyMesh& morphMap)
00143 {
00144     updateLabels(morphMap.reversePointMap());
00145 }
00146 
00147 
00148 void pointSet::writeDebug
00149 (
00150     Ostream& os,
00151     const primitiveMesh& mesh,
00152     const label maxLen
00153 ) const
00154 {
00155     topoSet::writeDebug(os, mesh.points(), maxLen);
00156 }
00157 
00158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00159 
00160 } // End namespace Foam
00161 
00162 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd