1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Copyright held by the original author
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "polyMeshGenAddressing.H"
27 #include "VRWGraphSMPModifier.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 void polyMeshGenAddressing::calcPointPoints() const
44 FatalErrorIn("polyMeshGenAddressing::calcPointPoints() const")
45 << "pointPoints already calculated"
50 ppPtr_ = new VRWGraph();
51 VRWGraph& pp = *ppPtr_;
53 const faceListPMG& faces = mesh_.faces();
54 const VRWGraph& pointFaces = this->pointFaces();
56 labelList nPoints(pointFaces.size());
59 const label nThreads = 3 * omp_get_num_procs();
60 # pragma omp parallel num_threads(nThreads) if( nPoints.size() > 10000 )
64 # pragma omp for schedule(static)
70 # pragma omp for schedule(static)
72 forAll(pointFaces, pointI)
74 DynList<label, 32> helper;
76 forAllRow(pointFaces, pointI, pfI)
78 const face& f = faces[pointFaces(pointI, pfI)];
80 const label pos = f.which(pointI);
81 helper.appendIfNotIn(f.prevLabel(pos));
82 helper.appendIfNotIn(f.nextLabel(pos));
85 nPoints[pointI] = helper.size();
93 VRWGraphSMPModifier(pp).setSizeAndRowSize(nPoints);
98 # pragma omp for schedule(static)
100 forAll(pointFaces, pointI)
102 DynList<label, 32> helper;
104 forAllRow(pointFaces, pointI, pfI)
106 const face& f = faces[pointFaces(pointI, pfI)];
108 const label pos = f.which(pointI);
109 const label pLabel = f.prevLabel(pos);
110 const label nLabel = f.nextLabel(pos);
112 helper.appendIfNotIn(nLabel);
113 helper.appendIfNotIn(pLabel);
116 pp.setRow(pointI, helper);
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 const VRWGraph& polyMeshGenAddressing::pointPoints() const
129 if( omp_in_parallel() )
132 "const VRWGraph& polyMeshGenAddressing::pointPoints() const"
133 ) << "Calculating addressing inside a parallel region."
134 << " This is not thread safe" << exit(FatalError);
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 } // End namespace Foam
147 // ************************************************************************* //