MeshedSurfaceCore.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "MeshedSurface.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36  // Transcribe 'face' to 'face' (ie, just transfer)
37  template<>
39  (
41  )
42  {
43  this->transfer(surf);
44  this->addZonesToFaces(); // currently a no-op
45  }
46 
47  // Transcribe 'face' to 'triFace'
48  // Transfer points/zones and triangulate faces
49  template<>
51  (
53  )
54  {
55  // First triangulate
56  // - slightly wasteful for space, but adjusts the zones too!
57  surf.triangulate();
58  this->storedPoints().transfer(surf.storedPoints());
59  this->storedZones().transfer(surf.storedZones());
60 
61  // transcribe from face -> triFace
62  const List<face>& origFaces = surf.surfFaces();
63  List<triFace> newFaces(origFaces.size());
64  forAll(origFaces, facei)
65  {
66  newFaces[facei] = triFace
67  (
68  static_cast<const labelUList&>(origFaces[facei])
69  );
70  }
71  surf.clear();
72 
73  this->storedFaces().transfer(newFaces);
74  this->addZonesToFaces(); // currently a no-op
75  }
76 
77 
78  // Transcribe 'face' to 'labelledTri'
79  // Transfer points/zones and triangulate faces
80  template<>
82  (
84  )
85  {
86  // First triangulate
87  // - slightly wasteful for space, but adjusts the zones too!
88  surf.triangulate();
89  this->storedPoints().transfer(surf.storedPoints());
90  this->storedZones().transfer(surf.storedZones());
91 
92  // transcribe from face -> labelledTri (via triFace)
93  const List<face>& origFaces = surf.surfFaces();
94  List<labelledTri> newFaces(origFaces.size());
95  forAll(origFaces, facei)
96  {
97  newFaces[facei] = triFace
98  (
99  static_cast<const labelUList&>(origFaces[facei])
100  );
101  }
102  surf.clear();
103 
104  this->storedFaces().transfer(newFaces);
105  this->addZonesToFaces(); // for labelledTri
106  }
107 
108 
109  // Propagate zone information on face regions for labelledTri.
110  template<>
112  {
113  List<labelledTri>& faceLst = this->storedFaces();
114  const surfZoneList& zones = this->surfZones();
115 
116  forAll(zones, zoneI)
117  {
118  const surfZone& zone = zones[zoneI];
119 
120  label faceI = zone.start();
121  forAll(zone, i)
122  {
123  faceLst[faceI++].region() = zoneI;
124  }
125  }
126 
127  return true;
128  }
129 
130 
131 } // End namespace Foam
132 
133 
134 // ************************************************************************* //
Foam::MeshedSurface::triangulate
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
Definition: MeshedSurface.C:864
Foam::MeshedSurface::storedPoints
pointField & storedPoints()
Non-const access to global points.
Definition: MeshedSurface.H:151
Foam::zone
Base class for mesh zones.
Definition: zone.H:63
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:362
Foam::MeshedSurface::clear
virtual void clear()
Clear all storage.
Definition: MeshedSurface.C:514
Foam::MeshedSurface::transcribe
void transcribe(MeshedSurface< face > &surf)
Transfer points/zones from 'face' to other other shapes.
Foam::MeshedSurface::addZonesToFaces
bool addZonesToFaces()
Propagate zone information on face regions.
Definition: MeshedSurfaceZones.C:192
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::MeshedSurface::storedZones
surfZoneList & storedZones()
Non-const access to the zones.
Definition: MeshedSurface.H:163
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:62
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::List< face >
Foam::surfZone
A surface zone on a MeshedSurface.
Definition: surfZone.H:65
Foam::UList< label >
Foam::MeshedSurface< face >
triFace
face triFace(3)
MeshedSurface.H