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-2020 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  // Potentially wasteful of space, but adjusts zones and
57  // invalidates the faceIds
58  surf.triangulate();
59 
60  this->storedPoints().transfer(surf.storedPoints());
61  this->storedZones().transfer(surf.storedZones());
62 
63  // Transcribe from face -> triFace
64  const List<face>& origFaces = surf.surfFaces();
65  List<triFace> newFaces(origFaces.size());
66  forAll(origFaces, facei)
67  {
68  newFaces[facei] = triFace
69  (
70  static_cast<const labelUList&>(origFaces[facei])
71  );
72  }
73  surf.clear();
74 
75  this->storedFaces().transfer(newFaces);
76  this->addZonesToFaces(); // currently a no-op
77  }
78 
79 
80  // Transcribe 'face' to 'labelledTri'
81  // Transfer points/zones and triangulate faces
82  template<>
84  (
86  )
87  {
88  // First triangulate.
89  // Potentially wasteful of space, but adjusts zones and
90  // invalidates the faceIds
91  surf.triangulate();
92 
93  this->storedPoints().transfer(surf.storedPoints());
94  this->storedZones().transfer(surf.storedZones());
95 
96  // Transcribe from face -> labelledTri (via triFace)
97  const List<face>& origFaces = surf.surfFaces();
98  List<labelledTri> newFaces(origFaces.size());
99  forAll(origFaces, facei)
100  {
101  newFaces[facei] = triFace
102  (
103  static_cast<const labelUList&>(origFaces[facei])
104  );
105  }
106  surf.clear();
107 
108  this->storedFaces().transfer(newFaces);
109  this->addZonesToFaces(); // for labelledTri
110  }
111 
112 
113  // Propagate zone information on face regions for labelledTri.
114  template<>
116  {
117  List<labelledTri>& faceLst = this->storedFaces();
118  const surfZoneList& zones = this->surfZones();
119 
120  forAll(zones, zoneI)
121  {
122  const surfZone& zone = zones[zoneI];
123 
124  label faceI = zone.start();
125  forAll(zone, i)
126  {
127  faceLst[faceI++].region() = zoneI;
128  }
129  }
130 
131  return true;
132  }
133 
134 
135 } // End namespace Foam
136 
137 
138 // ************************************************************************* //
Foam::MeshedSurface::triangulate
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
Definition: MeshedSurface.C:1015
Foam::MeshedSurface::storedPoints
pointField & storedPoints()
Non-const access to global points.
Definition: MeshedSurface.H:167
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:413
Foam::MeshedSurface::clear
virtual void clear()
Clear all storage.
Definition: MeshedSurface.C:598
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:243
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::MeshedSurface::storedZones
surfZoneList & storedZones()
Non-const access to the zones.
Definition: MeshedSurface.H:185
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::List< face >
Foam::surfZone
A surface zone on a MeshedSurface.
Definition: surfZone.H:56
Foam::UList< label >
Foam::MeshedSurface< face >
triFace
face triFace(3)
MeshedSurface.H