FreeFOAM The Cross-Platform CFD Toolkit
degenerateMatcher.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 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 Foam::hexMatcher Foam::degenerateMatcher::hex;
31 Foam::wedgeMatcher Foam::degenerateMatcher::wedge;
32 Foam::prismMatcher Foam::degenerateMatcher::prism;
33 Foam::tetWedgeMatcher Foam::degenerateMatcher::tetWedge;
34 Foam::pyrMatcher Foam::degenerateMatcher::pyr;
35 Foam::tetMatcher Foam::degenerateMatcher::tet;
36 
37 
38 Foam::cellShape Foam::degenerateMatcher::match
39 (
40  const faceList& faces,
41  const labelList& owner,
42  const label cellI,
43  const labelList& cellFaces
44 )
45 {
46  // Recognize in order of assumed occurrence.
47 
48  if (hex.matchShape(false, faces, owner, cellI, cellFaces))
49  {
50  return cellShape(hex.model(), hex.vertLabels());
51  }
52  else if (tet.matchShape(false, faces, owner, cellI, cellFaces))
53  {
54  return cellShape(tet.model(), tet.vertLabels());
55  }
56  else if (prism.matchShape(false, faces, owner, cellI, cellFaces))
57  {
58  return cellShape(prism.model(), prism.vertLabels());
59  }
60  else if (pyr.matchShape(false, faces, owner, cellI, cellFaces))
61  {
62  return cellShape(pyr.model(), pyr.vertLabels());
63  }
64  else if (wedge.matchShape(false, faces, owner, cellI, cellFaces))
65  {
66  return cellShape(wedge.model(), wedge.vertLabels());
67  }
68  else if (tetWedge.matchShape(false, faces, owner, cellI, cellFaces))
69  {
70  return cellShape(tetWedge.model(), tetWedge.vertLabels());
71  }
72  else
73  {
74  return cellShape(*(cellModeller::lookup(0)), labelList(0));
75  }
76 }
77 
78 
79 Foam::cellShape Foam::degenerateMatcher::match(const faceList& faces)
80 {
81  // Do as if single cell mesh; all faces are referenced by a single cell
82 
83  return match
84  (
85  faces,
86  labelList(faces.size(), 0), // Cell 0 is owner of all faces
87  0, // cell 0
88  labelList(cellMatcher::makeIdentity(faces.size())) // cell 0 consists
89  // of all faces
90  );
91 }
92 
93 
94 Foam::cellShape Foam::degenerateMatcher::match(const cellShape& shape)
95 {
96  return match(shape.collapsedFaces());
97 }
98 
99 
100 Foam::cellShape Foam::degenerateMatcher::match
101 (
102  const primitiveMesh& mesh,
103  const label cellI
104 )
105 {
106  return match
107  (
108  mesh.faces(),
109  mesh.faceOwner(),
110  cellI,
111  mesh.cells()[cellI]
112  );
113 }
114 
115 
116 // ************************ vim: set sw=4 sts=4 et: ************************ //