polyMeshGenAddressingFaceEdges.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Copyright held by the original author
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "polyMeshGenAddressing.H"
27 #include "VRWGraphSMPModifier.H"
28 
29 # ifdef USE_OMP
30 #include <omp.h>
31 # endif
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
41 {
42  if( fePtr_ )
43  {
44  FatalErrorIn("polyMeshGenAddressing::calcFaceEdges() const")
45  << "faceEdges already calculated"
46  << abort(FatalError);
47  }
48  else
49  {
50  fePtr_ = new VRWGraph();
51  VRWGraph& faceEdgesAddr = *fePtr_;
52 
53  const edgeList& edges = this->edges();
54 
55  const VRWGraph& pointFaces = this->pointFaces();
56  const faceListPMG& faces = mesh_.faces();
57 
58  labelList nfe(faces.size());
59 
60  # ifdef USE_OMP
61  const label nThreads = 3 * omp_get_num_procs();
62  # endif
63 
64  # ifdef USE_OMP
65  # pragma omp parallel num_threads(nThreads) if( faces.size() > 10000 )
66  # endif
67  {
68  # ifdef USE_OMP
69  # pragma omp for schedule(static)
70  # endif
71  forAll(faces, faceI)
72  nfe[faceI] = faces[faceI].size();
73 
74  # ifdef USE_OMP
75  # pragma omp barrier
76 
77  # pragma omp master
78  # endif
79  VRWGraphSMPModifier(faceEdgesAddr).setSizeAndRowSize(nfe);
80 
81  # ifdef USE_OMP
82  # pragma omp barrier
83 
84  # pragma omp for schedule(static)
85  # endif
86  forAll(edges, edgeI)
87  {
88  const edge ee = edges[edgeI];
89  const label s = ee.start();
90 
91  forAllRow(pointFaces, s, pfI)
92  {
93  const label faceI = pointFaces(s, pfI);
94 
95  const face& f = faces[faceI];
96  forAll(f, eI)
97  {
98  if( f.faceEdge(eI) == ee )
99  {
100  faceEdgesAddr[faceI][eI] = edgeI;
101  break;
102  }
103  }
104  }
105  }
106  }
107  }
108 }
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
113 {
114  if( !fePtr_ )
115  {
116  # ifdef USE_OMP
117  if( omp_in_parallel() )
119  (
120  "const VRWGraph& polyMeshGenAddressing::faceEdges() const"
121  ) << "Calculating addressing inside a parallel region."
122  << " This is not thread safe" << exit(FatalError);
123  # endif
124 
125  calcFaceEdges();
126  }
127 
128  return *fePtr_;
129 }
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 } // End namespace Foam
134 
135 // ************************************************************************* //
Foam::polyMeshGenAddressing::calcFaceEdges
void calcFaceEdges() const
Calculate face-edge addressing.
Definition: polyMeshGenAddressingFaceEdges.C:40
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::polyMeshGenAddressing::mesh_
const polyMeshGenCells & mesh_
reference to the mesh
Definition: polyMeshGenAddressing.H:74
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::polyMeshGenAddressing::faceEdges
const VRWGraph & faceEdges() const
Definition: polyMeshGenAddressingFaceEdges.C:112
Foam::polyMeshGenFaces::faces
const faceListPMG & faces() const
access to faces
Definition: polyMeshGenFacesI.H:43
Foam::polyMeshGenAddressing::pointFaces
const VRWGraph & pointFaces() const
Definition: polyMeshGenAddressingPointFaces.C:60
VRWGraphSMPModifier.H
Foam::polyMeshGenAddressing::fePtr_
VRWGraph * fePtr_
Face-edges.
Definition: polyMeshGenAddressing.H:103
Foam::label
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
forAllRow
#define forAllRow(graph, rowI, index)
Definition: VRWGraph.H:277
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::polyMeshGenAddressing::edges
const edgeList & edges() const
Return mesh edges.
Definition: polyMeshGenAddressingEdges.C:157
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::edge::start
label start() const
Return start vertex label.
Definition: edgeI.H:81
f
labelList f(nPoints)
Foam::faceListPMG::size
label size() const
return the number of used elements
Definition: faceListPMGI.H:73
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::VRWGraphSMPModifier
Definition: VRWGraphSMPModifier.H:50
Foam::faceListPMG
Definition: faceListPMG.H:50
Foam::VRWGraph
Definition: VRWGraph.H:101
polyMeshGenAddressing.H
Foam::VRWGraphSMPModifier::setSizeAndRowSize
void setSizeAndRowSize(const ListType &)
set the size and row sizes
Definition: VRWGraphSMPModifierTemplates.C:41