twoPhaseEulerFoam:frictionalStressModel/Schaeffer: Correct mut on processor boundaries
[OpenFOAM-1.7.x.git] / src / meshTools / sets / cellSources / pointToCell / pointToCell.C
blobbfdf1284c3e60f11b953c64aa4fafafb57f85518
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-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 "pointToCell.H"
27 #include "polyMesh.H"
28 #include "pointSet.H"
30 #include "addToRunTimeSelectionTable.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace Foam
37 defineTypeNameAndDebug(pointToCell, 0);
39 addToRunTimeSelectionTable(topoSetSource, pointToCell, word);
41 addToRunTimeSelectionTable(topoSetSource, pointToCell, istream);
46 Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
48     pointToCell::typeName,
49     "\n    Usage: pointToCell <pointSet> any\n\n"
50     "    Select all cells with any point in the pointSet\n\n"
53 template<>
54 const char* Foam::NamedEnum<Foam::pointToCell::pointAction, 1>::names[] =
56     "any"
60 const Foam::NamedEnum<Foam::pointToCell::pointAction, 1>
61     Foam::pointToCell::pointActionNames_;
64 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
66 void Foam::pointToCell::combine(topoSet& set, const bool add) const
68     // Load the set
69     pointSet loadedSet(mesh_, setName_);
72     // Handle any selection
73     if (option_ == ANY)
74     {
75         for
76         (
77             pointSet::const_iterator iter = loadedSet.begin();
78             iter != loadedSet.end();
79             ++iter
80         )
81         {
82             label pointI = iter.key();
84             const labelList& pCells = mesh_.pointCells()[pointI];
86             forAll(pCells, pCellI)
87             {
88                 addOrDelete(set, pCells[pCellI], add);
89             }
90         }
91     }
95 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
97 // Construct from components
98 Foam::pointToCell::pointToCell
100     const polyMesh& mesh,
101     const word& setName,
102     const pointAction option
105     topoSetSource(mesh),
106     setName_(setName),
107     option_(option)
111 // Construct from dictionary
112 Foam::pointToCell::pointToCell
114     const polyMesh& mesh,
115     const dictionary& dict
118     topoSetSource(mesh),
119     setName_(dict.lookup("set")),
120     option_(pointActionNames_.read(dict.lookup("option")))
124 // Construct from Istream
125 Foam::pointToCell::pointToCell
127     const polyMesh& mesh,
128     Istream& is
131     topoSetSource(mesh),
132     setName_(checkIs(is)),
133     option_(pointActionNames_.read(checkIs(is)))
137 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
139 Foam::pointToCell::~pointToCell()
143 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
145 void Foam::pointToCell::applyToSet
147     const topoSetSource::setAction action,
148     topoSet& set
149 ) const
151     if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
152     {
153         Info<< "    Adding cells according to pointSet " << setName_
154             << " ..." << endl;
156         combine(set, true);
157     }
158     else if (action == topoSetSource::DELETE)
159     {
160         Info<< "    Removing cells according to pointSet " << setName_
161             << " ..." << endl;
163         combine(set, false);
164     }
168 // ************************************************************************* //