createBoundaryFaces.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 bool Foam::sammMesh::sammEqualFace
34 (
35  const face& boundaryFace,
36  const face& cellFace
37 ) const
38 {
39  // A PROSTAR boundary face is defined by 4 vertices irrespective
40  // of its topology.
41  // In order to deal with all possibilities, two faces will be
42  // considered equal if three of the vertices are the same.
43  label nEqual = 0;
44 
45  forAll(cellFace, cellFaceLabelI)
46  {
47  const label curCellFaceLabel = cellFace[cellFaceLabelI];
48 
49  forAll(boundaryFace, bouFaceLabelI)
50  {
51  if (boundaryFace[bouFaceLabelI] == curCellFaceLabel)
52  {
53  nEqual++;
54 
55  break;
56  }
57  }
58  }
59 
60  if (nEqual >= 3)
61  {
62  return true;
63  }
64  else
65  {
66  return false;
67  }
68 }
69 
70 
71 void Foam::sammMesh::createBoundaryFaces()
72 {
73  forAll(boundary_, patchi)
74  {
75  faceList& patchFaces = boundary_[patchi];
76 
77  const labelListList& PointCells = pointCells();
78 
79  forAll(patchFaces, facei)
80  {
81  bool found = false;
82 
83  face& curFace = patchFaces[facei];
84  const labelList& facePoints = curFace;
85 
86  forAll(facePoints, pointi)
87  {
88  const labelList& facePointCells =
89  PointCells[facePoints[pointi]];
90 
91  forAll(facePointCells, celli)
92  {
93  const faceList& curCellFaces =
94  cellFaces_[facePointCells[celli]];
95 
96  forAll(curCellFaces, cellFacei)
97  {
98  if (sammEqualFace(curCellFaces[cellFacei], curFace))
99  {
100  // Found the cell face corresponding to this face
101  found = true;
102 
103  // Set boundary face to the corresponding cell face
104  // which guarantees it is outward-pointing
105  curFace = curCellFaces[cellFacei];
106  }
107  if (found) break;
108  }
109  if (found) break;
110  }
111  if (found) break;
112  }
113  if (!found)
114  {
116  << "Face " << facei
117  << " does not have neighbour cell." << endl
118  << " face : " << endl << curFace
119  << abort(FatalError);
120  }
121  }
122  }
123 }
124 
125 
126 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
List< face > faceList
Definition: faceListFwd.H:43
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label patchi