FreeFOAM The Cross-Platform CFD Toolkit
createBoundaryFaces.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) 1991-2010 OpenCFD Ltd.
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 // Specialist version of face comparison to deal with
34 // PROSTAR boundary format idiosyncracies
35 bool sammMesh::sammEqualFace
36 (
37  const face& boundaryFace,
38  const face& cellFace
39 ) const
40 {
41  // A PROSTAR boundary face is defined by 4 vertices irrespective
42  // of its topology.
43  // In order to deal with all possibilities, two faces will be
44  // considered equal if three of the vertices are the same.
45  label nEqual = 0;
46 
47  forAll (cellFace, cellFaceLabelI)
48  {
49  const label curCellFaceLabel = cellFace[cellFaceLabelI];
50 
51  forAll (boundaryFace, bouFaceLabelI)
52  {
53  if (boundaryFace[bouFaceLabelI] == curCellFaceLabel)
54  {
55  nEqual++;
56 
57  break;
58  }
59  }
60  }
61 
62  if (nEqual >= 3)
63  {
64  return true;
65  }
66  else
67  {
68  return false;
69  }
70 }
71 
72 
73 void sammMesh::createBoundaryFaces()
74 {
75  forAll(boundary_, patchI)
76  {
77  faceList& patchFaces = boundary_[patchI];
78 
79  const labelListList& PointCells = pointCells();
80 
81  forAll(patchFaces, faceI)
82  {
83  bool found = false;
84 
85  face& curFace = patchFaces[faceI];
86  const labelList& facePoints = curFace;
87 
88  forAll(facePoints, pointI)
89  {
90  const labelList& facePointCells =
91  PointCells[facePoints[pointI]];
92 
93  forAll(facePointCells, cellI)
94  {
95  const faceList& curCellFaces =
96  cellFaces_[facePointCells[cellI]];
97 
98  forAll(curCellFaces, cellFaceI)
99  {
100  if (sammEqualFace(curCellFaces[cellFaceI], curFace))
101  {
102  // Found the cell face corresponding to this face
103  found = true;
104 
105  // Set boundary face to the corresponding cell face
106  // which guarantees it is outward-pointing
107  curFace = curCellFaces[cellFaceI];
108  }
109  if (found) break;
110  }
111  if (found) break;
112  }
113  if (found) break;
114  }
115  if (!found)
116  {
117  FatalErrorIn("sammMesh::createBoundaryFaces()")
118  << "Face " << faceI
119  << " does not have neighbour cell." << endl
120  << " face : " << endl << curFace
121  << abort(FatalError);
122  }
123  }
124  }
125 }
126 
127 
128 // ************************ vim: set sw=4 sts=4 et: ************************ //