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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "degenerateMatcher.H"
29 #include "primitiveMesh.H"
30 #include "ListOps.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 Foam::hexMatcher Foam::degenerateMatcher::hex;
35 Foam::wedgeMatcher Foam::degenerateMatcher::wedge;
36 Foam::prismMatcher Foam::degenerateMatcher::prism;
37 Foam::tetWedgeMatcher Foam::degenerateMatcher::tetWedge;
38 Foam::pyrMatcher Foam::degenerateMatcher::pyr;
39 Foam::tetMatcher Foam::degenerateMatcher::tet;
40 
41 
42 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
43 
44 Foam::cellShape Foam::degenerateMatcher::match
45 (
46  const faceList& faces,
47  const labelList& owner,
48  const label celli,
49  const labelList& cellFaces
50 )
51 {
52  // Recognize in order of assumed occurrence.
53 
54  if (hex.matchShape(false, faces, owner, celli, cellFaces))
55  {
56  return cellShape(hex.model(), hex.vertLabels());
57  }
58  if (tet.matchShape(false, faces, owner, celli, cellFaces))
59  {
60  return cellShape(tet.model(), tet.vertLabels());
61  }
62  if (prism.matchShape(false, faces, owner, celli, cellFaces))
63  {
64  return cellShape(prism.model(), prism.vertLabels());
65  }
66  if (pyr.matchShape(false, faces, owner, celli, cellFaces))
67  {
68  return cellShape(pyr.model(), pyr.vertLabels());
69  }
70  if (wedge.matchShape(false, faces, owner, celli, cellFaces))
71  {
72  return cellShape(wedge.model(), wedge.vertLabels());
73  }
74  if (tetWedge.matchShape(false, faces, owner, celli, cellFaces))
75  {
76  return cellShape(tetWedge.model(), tetWedge.vertLabels());
77  }
78 
79  return cellShape(cellModel::ref(cellModel::UNKNOWN), labelList());
80 }
81 
82 
83 Foam::cellShape Foam::degenerateMatcher::match(const faceList& faces)
84 {
85  // Do as if single cell mesh; all faces are referenced by a single cell
86 
87  return match
88  (
89  faces,
90  labelList(faces.size(), Zero), // cell 0 is owner of all faces
91  0, // cell 0
92  identity(faces.size()) // cell 0 consists of all faces
93  );
94 }
95 
96 
97 Foam::cellShape Foam::degenerateMatcher::match(const cellShape& shape)
98 {
99  return match(shape.collapsedFaces());
100 }
101 
102 
103 Foam::cellShape Foam::degenerateMatcher::match
104 (
105  const primitiveMesh& mesh,
106  const label celli
107 )
108 {
109  return match
110  (
111  mesh.faces(),
112  mesh.faceOwner(),
113  celli,
114  mesh.cells()[celli]
115  );
116 }
117 
118 
119 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::prismMatcher
A cellMatcher for prism cells (cellModel::PRISM)
Definition: prismMatcher.H:53
Foam::pyrMatcher::matchShape
virtual bool matchShape(const bool checkOnly, const faceList &faces, const labelList &faceOwner, const label celli, const labelList &myFaces)
Low level shape recognition. Return true if matches.
Definition: pyrMatcher.C:142
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::tetWedgeMatcher
A cellMatcher for tetWedge cells (cellModel::TETWEDGE).
Definition: tetWedgeMatcher.H:53
Foam::wedgeMatcher::matchShape
virtual bool matchShape(const bool checkOnly, const faceList &faces, const labelList &faceOwner, const label celli, const labelList &myFaces)
Low level shape recognition. Return true if matches.
Definition: wedgeMatcher.C:49
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:138
Foam::tetMatcher
A cellMatcher for tet cells (cellModel::TET)
Definition: tetMatcher.H:54
primitiveMesh.H
Foam::hexMatcher::matchShape
virtual bool matchShape(const bool checkOnly, const faceList &faces, const labelList &faceOwner, const label celli, const labelList &myFaces)
Low level shape recognition. Return true if matches.
Definition: hexMatcher.C:115
Foam::cellMatcher::vertLabels
const labelList & vertLabels() const
Definition: cellMatcherI.H:72
Foam::pyrMatcher
A cellMatcher for pyr cells (cellModel::PYR)
Definition: pyrMatcher.H:54
Foam::hexMatcher
A cellMatcher for hex cells (cellModel::HEX).
Definition: hexMatcher.H:54
degenerateMatcher.H
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1107
Foam::cellModel::ref
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
Definition: cellModels.C:157
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:69
Foam::tetMatcher::matchShape
virtual bool matchShape(const bool checkOnly, const faceList &faces, const labelList &faceOwner, const label celli, const labelList &myFaces)
Low level shape recognition. Return true if matches.
Definition: tetMatcher.C:118
Foam::stringOps::match
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
Definition: stringOps.H:76
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1094
Foam::wedgeMatcher
A cellMatcher for wedge cells (cellModel::WEDGE).
Definition: wedgeMatcher.H:53
Foam::faceList
List< face > faceList
A List of faces.
Definition: faceListFwd.H:47
Foam::prismMatcher::matchShape
virtual bool matchShape(const bool checkOnly, const faceList &faces, const labelList &faceOwner, const label celli, const labelList &myFaces)
Low level shape recognition. Return true if matches.
Definition: prismMatcher.C:49
Foam::List< face >
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::cellShape::collapsedFaces
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:233
Foam::cellModel::UNKNOWN
unknown
Definition: cellModel.H:80
ListOps.H
Various functions to operate on Lists.
Foam::cellMatcher::model
const cellModel & model() const
Definition: cellMatcherI.H:84
Foam::tetWedgeMatcher::matchShape
virtual bool matchShape(const bool checkOnly, const faceList &faces, const labelList &faceOwner, const label celli, const labelList &myFaces)
Low level shape recognition. Return true if matches.
Definition: tetWedgeMatcher.C:51
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78