Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / meshTools / sets / cellSources / cellToCell / cellToCell.C
blob1e40d84009200d17c048e6eea76aaa0c92ddc71b
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 "cellToCell.H"
27 #include "polyMesh.H"
28 #include "cellSet.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace Foam
37 defineTypeNameAndDebug(cellToCell, 0);
39 addToRunTimeSelectionTable(topoSetSource, cellToCell, word);
41 addToRunTimeSelectionTable(topoSetSource, cellToCell, istream);
46 Foam::topoSetSource::addToUsageTable Foam::cellToCell::usage_
48     cellToCell::typeName,
49     "\n    Usage: cellToCell <cellSet>\n\n"
50     "    Select all cells in the cellSet\n\n"
54 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
56 // Construct from components
57 Foam::cellToCell::cellToCell
59     const polyMesh& mesh,
60     const word& setName
63     topoSetSource(mesh),
64     setName_(setName)
68 // Construct from dictionary
69 Foam::cellToCell::cellToCell
71     const polyMesh& mesh,
72     const dictionary& dict
75     topoSetSource(mesh),
76     setName_(dict.lookup("set"))
80 // Construct from Istream
81 Foam::cellToCell::cellToCell
83     const polyMesh& mesh,
84     Istream& is
87     topoSetSource(mesh),
88     setName_(checkIs(is))
92 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
94 Foam::cellToCell::~cellToCell()
98 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
100 void Foam::cellToCell::applyToSet
102     const topoSetSource::setAction action,
103     topoSet& set
104 ) const
106     if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW))
107     {
108         Info<< "    Adding all elements of cellSet " << setName_ << " ..."
109             << endl;
111         // Load the set
112         cellSet loadedSet(mesh_, setName_);
114         set.addSet(loadedSet);
115     }
116     else if (action == topoSetSource::DELETE)
117     {
118         Info<< "    Removing all elements of cellSet " << setName_ << " ..."
119             << endl;
121         // Load the set
122         cellSet loadedSet(mesh_, setName_);
124         set.deleteSet(loadedSet);
125     }
129 // ************************************************************************* //