indexedCellOpsTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "indexedCellOps.H"
29 #include "Pstream.H"
30 
31 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
32 
33 template<class CellType>
34 Foam::label CGAL::indexedCellOps::dualVertexMasterProc(const CellType& c)
35 {
36  if (!c->parallelDualVertex())
37  {
38  return -1;
39  }
40 
41  // The master processor is the lowest numbered of the four on this tet.
42 
43  int masterProc = Foam::Pstream::nProcs() + 1;
44 
45  for (Foam::label vI = 0; vI < 4; ++vI)
46  {
47  if (c->vertex(vI)->referred())
48  {
49  masterProc = min(masterProc, c->vertex(vI)->procIndex());
50  }
51  else
52  {
53  masterProc = min(masterProc, Foam::Pstream::myProcNo());
54  }
55  }
56 
57  return masterProc;
58 }
59 
60 
61 template<class CellType>
64 {
66 
67  if (!c->parallelDualVertex())
68  {
69  return procsAttached;
70  }
71 
72  for (Foam::label vI = 0; vI < 4; ++vI)
73  {
74  if (c->vertex(vI)->referred())
75  {
76  procsAttached[vI] = c->vertex(vI)->procIndex();
77  }
78  }
79 
80  return procsAttached;
81 }
82 
83 
84 // ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:107
Foam::label dualVertexMasterProc(const CellType &c)
Does the Dual vertex form part of a processor patch.
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
Definition: UPstream.H:1086
static label nProcs(const label communicator=worldComm)
Number of ranks in parallel run (for given communicator). It is 1 for serial run. ...
Definition: UPstream.H:1077
Foam::FixedList< Foam::label, 4 > processorsAttached(const CellType &c)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
const dimensionedScalar c
Speed of light in a vacuum.