ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / polyMesh / zones / pointZone / pointZone.C
bloba93587d6767ec00de4b99356db2fa04c536cc498
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 "pointZone.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "pointZoneMesh.H"
29 #include "polyMesh.H"
30 #include "primitiveMesh.H"
31 #include "demandDrivenData.H"
32 #include "syncTools.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 namespace Foam
38     defineTypeNameAndDebug(pointZone, 0);
39     defineRunTimeSelectionTable(pointZone, dictionary);
40     addToRunTimeSelectionTable(pointZone, pointZone, dictionary);
43 const char* const Foam::pointZone::labelsName = "pointLabels";
45 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
47 Foam::pointZone::pointZone
49     const word& name,
50     const labelUList& addr,
51     const label index,
52     const pointZoneMesh& zm
55     zone(name, addr, index),
56     zoneMesh_(zm)
60 Foam::pointZone::pointZone
62     const word& name,
63     const Xfer<labelList>& addr,
64     const label index,
65     const pointZoneMesh& zm
68     zone(name, addr, index),
69     zoneMesh_(zm)
73 Foam::pointZone::pointZone
75     const word& name,
76     const dictionary& dict,
77     const label index,
78     const pointZoneMesh& zm
81     zone(name, dict, this->labelsName, index),
82     zoneMesh_(zm)
86 Foam::pointZone::pointZone
88     const pointZone& pz,
89     const labelUList& addr,
90     const label index,
91     const pointZoneMesh& zm
94     zone(pz, addr, index),
95     zoneMesh_(zm)
99 Foam::pointZone::pointZone
101     const pointZone& pz,
102     const Xfer<labelList>& addr,
103     const label index,
104     const pointZoneMesh& zm
107     zone(pz, addr, index),
108     zoneMesh_(zm)
112 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
114 Foam::pointZone::~pointZone()
118 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
120 const Foam::pointZoneMesh& Foam::pointZone::zoneMesh() const
122     return zoneMesh_;
126 Foam::label Foam::pointZone::whichPoint(const label globalPointID) const
128     return zone::localID(globalPointID);
132 bool Foam::pointZone::checkDefinition(const bool report) const
134     return zone::checkDefinition(zoneMesh_.mesh().points().size(), report);
138 bool Foam::pointZone::checkParallelSync(const bool report) const
140     const polyMesh& mesh = zoneMesh().mesh();
142     labelList maxZone(mesh.nPoints(), -1);
143     labelList minZone(mesh.nPoints(), labelMax);
144     forAll(*this, i)
145     {
146         label pointI = operator[](i);
147         maxZone[pointI] = index();
148         minZone[pointI] = index();
149     }
150     syncTools::syncPointList(mesh, maxZone, maxEqOp<label>(), -1);
151     syncTools::syncPointList(mesh, minZone, minEqOp<label>(), labelMax);
153     bool error = false;
155     forAll(maxZone, pointI)
156     {
157         // Check point in zone on both sides
158         if (maxZone[pointI] != minZone[pointI])
159         {
160             if (report && !error)
161             {
162                 Info<< " ***Problem with pointZone " << index()
163                     << " named " << name()
164                     << ". Point " << pointI
165                     << " at " << mesh.points()[pointI]
166                     << " is in zone "
167                     << (minZone[pointI] == labelMax ? -1 : minZone[pointI])
168                     << " on some processors and in zone "
169                     << maxZone[pointI]
170                     << " on some other processors."
171                     << endl;
172             }
173             error = true;
174         }
175     }
177     return error;
181 void Foam::pointZone::writeDict(Ostream& os) const
183     os  << nl << name_ << nl << token::BEGIN_BLOCK << nl
184         << "    type " << type() << token::END_STATEMENT << nl;
186     writeEntry(this->labelsName, os);
188     os  << token::END_BLOCK << endl;
192 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
194 void Foam::pointZone::operator=(const pointZone& zn)
196     clearAddressing();
197     labelList::operator=(zn);
201 void Foam::pointZone::operator=(const labelUList& addr)
203     clearAddressing();
204     labelList::operator=(addr);
208 void Foam::pointZone::operator=(const Xfer<labelList>& addr)
210     clearAddressing();
211     labelList::operator=(addr);
215 // * * * * * * * * * * * * * * * Ostream Operator  * * * * * * * * * * * * * //
217 Foam::Ostream& Foam::operator<<(Ostream& os, const pointZone& zn)
219     zn.write(os);
220     os.check("Ostream& operator<<(Ostream&, const pointZone&");
221     return os;
225 // ************************************************************************* //