pointZone.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "pointZone.H"
27 #include "pointZoneList.H"
28 #include "polyMesh.H"
29 #include "polyTopoChangeMap.H"
30 #include "syncTools.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
39 
42 }
43 
44 const char* const Foam::pointZone::labelsName = "pointLabels";
45 
46 
47 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
48 
50 {
51  return zones_.mesh().points();
52 }
53 
54 
55 bool Foam::pointZone::checkDefinition(const bool report) const
56 {
58  (
59  meshCentres().size(),
60  report
61  );
62 }
63 
64 
65 bool Foam::pointZone::checkParallelSync(const bool report) const
66 {
67  const polyMesh& mesh = zones().mesh();
68 
69  const label index = zones_.findIndex(name());
70 
71  labelList maxZone(mesh.nPoints(), -1);
72  labelList minZone(mesh.nPoints(), labelMax);
73  forAll(*this, i)
74  {
75  const label pointi = operator[](i);
76  maxZone[pointi] = index;
77  minZone[pointi] = index;
78  }
79  syncTools::syncPointList(mesh, maxZone, maxEqOp<label>(), label(-1));
81 
82  bool error = false;
83 
84  forAll(maxZone, pointi)
85  {
86  // Check point in same (or no) zone on all processors
87  if
88  (
89  (
90  maxZone[pointi] != -1
91  || minZone[pointi] != labelMax
92  )
93  && (maxZone[pointi] != minZone[pointi])
94  )
95  {
96  if (report && !error)
97  {
98  Info<< " ***Problem with pointZone " << name()
99  << ". Point " << pointi
100  << " at " << mesh.points()[pointi]
101  << " is in zone "
102  << (minZone[pointi] == labelMax ? -1 : minZone[pointi])
103  << " on some processors and in zone "
104  << maxZone[pointi]
105  << " on some other processors." << nl
106  << "(suppressing further warnings)"
107  << endl;
108  }
109  error = true;
110  }
111  }
112 
113  return error;
114 }
115 
116 
118 {
120 }
121 
122 
124 {
125  os << nl << name_ << nl << token::BEGIN_BLOCK << nl
126  << " type " << type() << token::END_STATEMENT << nl;
127 
128  writeEntry(os, this->labelsName, *this);
129 
130  os << token::END_BLOCK << endl;
131 }
132 
133 
134 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
const MeshType & mesh() const
Return the mesh reference.
Definition: ZoneList.H:109
void topoChange(const labelList &map, const labelList &reverseMap)
Update the addressing using the maps provided.
Definition: Zone.C:79
bool checkDefinition(const label maxSize, const bool report=false) const
Check zone definition with max size given. Return true if in error.
Definition: Zone.C:280
const pointZoneList & zones_
Reference to zone list.
Definition: Zone.H:77
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:71
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list.
Definition: pointZone.H:59
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: pointZone.C:55
const pointField & meshCentres() const
Return the mesh points.
Definition: pointZone.C:49
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: pointZone.H:66
virtual void writeDict(Ostream &) const
Write dictionary.
Definition: pointZone.C:123
bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries. Return.
Definition: pointZone.C:65
virtual void topoChange(const polyTopoChangeMap &map)
Update zone using the given map.
Definition: pointZone.C:117
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1313
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
const labelList & pointMap() const
Old point map.
label nPoints() const
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronise values on all mesh points.
@ BEGIN_BLOCK
Definition: token.H:113
@ END_BLOCK
Definition: token.H:114
@ END_STATEMENT
Definition: token.H:108
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
messageStream Info
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
Zone< pointZone, pointZoneList > pointZoneType
Definition: pointZone.C:37
defineTemplateRunTimeSelectionTable(fvLabelFieldSource, null)
static const label labelMax
Definition: label.H:62
static const char nl
Definition: Ostream.H:266
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Foam::pointZoneList.