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

boxToFace.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 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "boxToFace.H"
00030 #include "polyMesh.H"
00031 
00032 #include "addToRunTimeSelectionTable.H"
00033 
00034 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 defineTypeNameAndDebug(boxToFace, 0);
00040 
00041 addToRunTimeSelectionTable(topoSetSource, boxToFace, word);
00042 
00043 addToRunTimeSelectionTable(topoSetSource, boxToFace, istream);
00044 
00045 }
00046 
00047 
00048 Foam::topoSetSource::addToUsageTable Foam::boxToFace::usage_
00049 (
00050     boxToFace::typeName,
00051     "\n    Usage: boxToFace ((minx miny minz) (maxx maxy maxz))\n\n"
00052     "    Select all face with faceCentre within bounding box\n\n"
00053 );
00054 
00055 
00056 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00057 
00058 void Foam::boxToFace::combine(topoSet& set, const bool add) const
00059 {
00060     const pointField& ctrs = mesh_.faceCentres();
00061 
00062     forAll(ctrs, faceI)
00063     {
00064         if (bb_.contains(ctrs[faceI]))
00065         {
00066             addOrDelete(set, faceI, add);
00067         }
00068     }
00069 }
00070 
00071 
00072 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00073 
00074 // Construct from components
00075 Foam::boxToFace::boxToFace
00076 (
00077     const polyMesh& mesh,
00078     const treeBoundBox& bb
00079 )
00080 :
00081     topoSetSource(mesh),
00082     bb_(bb)
00083 {}
00084 
00085 
00086 // Construct from dictionary
00087 Foam::boxToFace::boxToFace
00088 (
00089     const polyMesh& mesh,
00090     const dictionary& dict
00091 )
00092 :
00093     topoSetSource(mesh),
00094     bb_(dict.lookup("box"))
00095 {}
00096 
00097 
00098 // Construct from Istream
00099 Foam::boxToFace::boxToFace
00100 (
00101     const polyMesh& mesh,
00102     Istream& is
00103 )
00104 :
00105     topoSetSource(mesh),
00106     bb_(checkIs(is))
00107 {}
00108 
00109 
00110 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00111 
00112 Foam::boxToFace::~boxToFace()
00113 {}
00114 
00115 
00116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00117 
00118 void Foam::boxToFace::applyToSet
00119 (
00120     const topoSetSource::setAction action,
00121     topoSet& set
00122 ) const
00123 {
00124     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
00125     {
00126         Info<< "    Adding faces with centre within box " << bb_ << endl;
00127 
00128         combine(set, true);
00129     }
00130     else if (action == topoSetSource::DELETE)
00131     {
00132         Info<< "    Removing faces with centre within box " << bb_ << endl;
00133 
00134         combine(set, false);
00135     }
00136 }
00137 
00138 
00139 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd