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

zoneToPoint.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 "zoneToPoint.H"
00028 #include "polyMesh.H"
00029 
00030 #include "addToRunTimeSelectionTable.H"
00031 
00032 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 defineTypeNameAndDebug(zoneToPoint, 0);
00038 
00039 addToRunTimeSelectionTable(topoSetSource, zoneToPoint, word);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, zoneToPoint, istream);
00042 
00043 }
00044 
00045 
00046 Foam::topoSetSource::addToUsageTable Foam::zoneToPoint::usage_
00047 (
00048     zoneToPoint::typeName,
00049     "\n    Usage: zoneToPoint zone\n\n"
00050     "    Select all points in the pointZone."
00051     " Note:accepts wildcards for zone.\n\n"
00052 );
00053 
00054 
00055 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00056 
00057 void Foam::zoneToPoint::combine(topoSet& set, const bool add) const
00058 {
00059     bool hasMatched = false;
00060 
00061     forAll(mesh_.pointZones(), i)
00062     {
00063         const pointZone& zone = mesh_.pointZones()[i];
00064 
00065         if (zoneName_.match(zone.name()))
00066         {
00067             const labelList& pointLabels = mesh_.pointZones()[i];
00068 
00069             Info<< "    Found matching zone " << zone.name()
00070                 << " with " << pointLabels.size() << " points." << endl;
00071 
00072             hasMatched = true;
00073 
00074             forAll(pointLabels, i)
00075             {
00076                 // Only do active points
00077                 if (pointLabels[i] < mesh_.nPoints())
00078                 {
00079                     addOrDelete(set, pointLabels[i], add);
00080                 }
00081             }
00082         }
00083     }
00084 
00085     if (!hasMatched)
00086     {
00087         WarningIn("zoneToPoint::combine(topoSet&, const bool)")
00088             << "Cannot find any pointZone named " << zoneName_ << endl
00089             << "Valid names are " << mesh_.pointZones().names() << endl;
00090     }
00091 }
00092 
00093 
00094 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00095 
00096 // Construct from components
00097 Foam::zoneToPoint::zoneToPoint
00098 (
00099     const polyMesh& mesh,
00100     const word& zoneName
00101 )
00102 :
00103     topoSetSource(mesh),
00104     zoneName_(zoneName)
00105 {}
00106 
00107 
00108 // Construct from dictionary
00109 Foam::zoneToPoint::zoneToPoint
00110 (
00111     const polyMesh& mesh,
00112     const dictionary& dict
00113 )
00114 :
00115     topoSetSource(mesh),
00116     zoneName_(dict.lookup("name"))
00117 {}
00118 
00119 
00120 // Construct from Istream
00121 Foam::zoneToPoint::zoneToPoint
00122 (
00123     const polyMesh& mesh,
00124     Istream& is
00125 )
00126 :
00127     topoSetSource(mesh),
00128     zoneName_(checkIs(is))
00129 {}
00130 
00131 
00132 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00133 
00134 Foam::zoneToPoint::~zoneToPoint()
00135 {}
00136 
00137 
00138 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00139 
00140 void Foam::zoneToPoint::applyToSet
00141 (
00142     const topoSetSource::setAction action,
00143     topoSet& set
00144 ) const
00145 {
00146     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00147     {
00148         Info<< "    Adding all points of pointZone " << zoneName_ << " ..."
00149             << endl;
00150 
00151         combine(set, true);
00152     }
00153     else if (action == topoSetSource::DELETE)
00154     {
00155         Info<< "    Removing all points of pointZone " << zoneName_ << " ..."
00156             << endl;
00157 
00158         combine(set, false);
00159     }
00160 }
00161 
00162 
00163 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd