createPolyBoundary.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 | Copyright (C) 2011-2016 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25  Create intermediate mesh files from SAMM files
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "sammMesh.H"
30 #include "polyPatch.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 void Foam::sammMesh::createPolyBoundary()
35 {
36  label nBoundaryFacesFound = 0;
37 
38  polyBoundaryPatchStartIndices_.setSize(boundary_.size());
39 
40  label nCreatedFaces = nInternalFaces_;
41 
42  const labelListList& PointCells = pointCells();
43 
44  forAll(boundary_, patchi)
45  {
46  const faceList& curShapePatch = boundary_[patchi];
47 
48  polyBoundaryPatchStartIndices_[patchi] = nCreatedFaces;
49 
50  forAll(curShapePatch, facei)
51  {
52  bool found = false;
53 
54  const face& curFace = curShapePatch[facei];
55 
56  meshFaces_[nCreatedFaces] = curFace;
57 
58  // Must find which cell this face belongs to in order to
59  // mark it in the cellPolys_
60  const labelList& facePoints = curFace;
61 
62  forAll(facePoints, pointi)
63  {
64  const labelList& facePointCells =
65  PointCells[facePoints[pointi]];
66 
67  forAll(facePointCells, celli)
68  {
69  const faceList& curCellFaces =
70  cellFaces_[facePointCells[celli]];
71 
72  forAll(curCellFaces, cellFacei)
73  {
74  if (curCellFaces[cellFacei] == curFace)
75  {
76  // Found the cell face corresponding to this face
77  found = true;
78 
79  // Debugging
80  if
81  (
82  cellPolys_[facePointCells[celli]][cellFacei]
83  != -1
84  )
85  {
87  << "This looks like an already detected "
88  << "internal face"
89  << abort(FatalError);
90  }
91 
92  cellPolys_[facePointCells[celli]][cellFacei] =
93  nCreatedFaces;
94 
95  nBoundaryFacesFound++;
96  }
97  if (found) break;
98  }
99  if (found) break;
100  }
101  if (found) break;
102  }
103 
104  nCreatedFaces++;
105  }
106  }
107 
108  // reset the size of the face list
109  meshFaces_.setSize(nCreatedFaces);
110 
111  Info<< "Number of boundary faces: " << nBoundaryFacesFound << endl;
112  Info<< "Total number of faces: " << nCreatedFaces << endl;
113 }
114 
115 
116 Foam::List<Foam::polyPatch* > Foam::sammMesh::polyBoundaryPatches
117 (
118  const polyMesh& pMesh
119 )
120 {
121  List<polyPatch* > p(boundary_.size());
122 
123  forAll(boundary_, patchi)
124  {
125  const faceList& curShapePatch = boundary_[patchi];
126 
128  (
129  patchTypes_[patchi],
130  patchNames_[patchi],
131  curShapePatch.size(),
132  polyBoundaryPatchStartIndices_[patchi],
133  patchi,
134  pMesh.boundaryMesh()
135  ).ptr();
136 
137  p[patchi]->physicalType() = patchPhysicalTypes_[patchi];
138  }
139 
140  return p;
141 }
142 
143 
144 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
List< face > faceList
Definition: faceListFwd.H:43
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void setSize(const label)
Reset size of List.
Definition: List.C:295
label patchi
messageStream Info
static autoPtr< polyPatch > New(const word &patchType, const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm)
Return a pointer to a new patch created on freestore from.
Definition: polyPatchNew.C:32
volScalarField & p