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-2025 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"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37 }
38 
39 const char* const Foam::pointZone::labelsName = "pointLabels";
40 
41 
42 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 
44 bool Foam::pointZone::checkDefinition(const bool report) const
45 {
47  (
48  zones_.allSize(),
49  report
50  );
51 }
52 
53 
54 bool Foam::pointZone::checkParallelSync(const bool report) const
55 {
56  const polyMesh& mesh = zones().mesh();
57 
58  const label index = zones_.findIndex(name());
59 
60  labelList maxZone(mesh.nPoints(), -1);
61  labelList minZone(mesh.nPoints(), labelMax);
62  forAll(*this, i)
63  {
64  const label pointi = operator[](i);
65  maxZone[pointi] = index;
66  minZone[pointi] = index;
67  }
70 
71  bool error = false;
72 
73  forAll(maxZone, pointi)
74  {
75  // Check point in same (or no) zone on all processors
76  if
77  (
78  (
79  maxZone[pointi] != -1
80  || minZone[pointi] != labelMax
81  )
82  && (maxZone[pointi] != minZone[pointi])
83  )
84  {
85  if (report && !error)
86  {
87  Info<< " ***Problem with pointZone " << name()
88  << ". Point " << pointi
89  << " at " << mesh.points()[pointi]
90  << " is in zone "
91  << (minZone[pointi] == labelMax ? -1 : minZone[pointi])
92  << " on some processors and in zone "
93  << maxZone[pointi]
94  << " on some other processors." << nl
95  << "(suppressing further warnings)"
96  << endl;
97  }
98  error = true;
99  }
100  }
101 
102  return error;
103 }
104 
105 
107 {
108  if (!topoUpdate_)
109  {
111  }
112 }
113 
114 
116 {
117  os << nl << name_ << nl << token::BEGIN_BLOCK << nl;
118  writeEntry(os, this->labelsName, *this);
119  os << token::END_BLOCK << endl;
120 }
121 
122 
123 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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:261
const pointZoneList & zones_
Reference to zone list.
Definition: Zone.H:78
Class to handle errors and exceptions in a simple, consistent stream-based manner.
Definition: error.H:71
const polyMesh & mesh() const
Return reference to polyMesh.
Definition: fvMesh.H:443
label allSize() const
Return number of points in the mesh.
Definition: pointZoneList.C:39
Named list of point indices representing a sub-set of the mesh faces.
Definition: pointZone.H:60
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: pointZone.C:44
static const char *const labelsName
The name associated with the zone-labels dictionary entry.
Definition: pointZone.H:67
void writeDict(Ostream &) const
Write dictionary.
Definition: pointZone.C:115
bool checkParallelSync(const bool report=false) const
Check whether zone is synchronised across coupled boundaries. Return.
Definition: pointZone.C:54
void topoChange(const polyTopoChangeMap &map)
Update zone using the given map.
Definition: pointZone.C:106
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1331
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
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
static const label labelMax
Definition: label.H:62
static const char nl
Definition: Ostream.H:267
Foam::pointZoneList.