1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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"
30 #include "primitiveMesh.H"
31 #include "demandDrivenData.H"
32 #include "syncTools.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
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
50 const labelUList& addr,
52 const pointZoneMesh& zm
55 zone(name, addr, index),
60 Foam::pointZone::pointZone
63 const Xfer<labelList>& addr,
65 const pointZoneMesh& zm
68 zone(name, addr, index),
73 Foam::pointZone::pointZone
76 const dictionary& dict,
78 const pointZoneMesh& zm
81 zone(name, dict, this->labelsName, index),
86 Foam::pointZone::pointZone
89 const labelUList& addr,
91 const pointZoneMesh& zm
94 zone(pz, addr, index),
99 Foam::pointZone::pointZone
102 const Xfer<labelList>& addr,
104 const pointZoneMesh& zm
107 zone(pz, addr, index),
112 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
114 Foam::pointZone::~pointZone()
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
120 const Foam::pointZoneMesh& Foam::pointZone::zoneMesh() const
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);
146 label pointI = operator[](i);
147 maxZone[pointI] = index();
148 minZone[pointI] = index();
150 syncTools::syncPointList(mesh, maxZone, maxEqOp<label>(), -1);
151 syncTools::syncPointList(mesh, minZone, minEqOp<label>(), labelMax);
155 forAll(maxZone, pointI)
157 // Check point in zone on both sides
158 if (maxZone[pointI] != minZone[pointI])
160 if (report && !error)
162 Info<< " ***Problem with pointZone " << index()
163 << " named " << name()
164 << ". Point " << pointI
165 << " at " << mesh.points()[pointI]
167 << (minZone[pointI] == labelMax ? -1 : minZone[pointI])
168 << " on some processors and in zone "
170 << " on some other processors."
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)
197 labelList::operator=(zn);
201 void Foam::pointZone::operator=(const labelUList& addr)
204 labelList::operator=(addr);
208 void Foam::pointZone::operator=(const Xfer<labelList>& addr)
211 labelList::operator=(addr);
215 // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
217 Foam::Ostream& Foam::operator<<(Ostream& os, const pointZone& zn)
220 os.check("Ostream& operator<<(Ostream&, const pointZone&");
225 // ************************************************************************* //