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 "ListOps.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 Foam::hexMatcher Foam::degenerateMatcher::hex;
34 Foam::wedgeMatcher Foam::degenerateMatcher::wedge;
35 Foam::prismMatcher Foam::degenerateMatcher::prism;
36 Foam::tetWedgeMatcher Foam::degenerateMatcher::tetWedge;
37 Foam::pyrMatcher Foam::degenerateMatcher::pyr;
38 Foam::tetMatcher Foam::degenerateMatcher::tet;
39 
40 
41 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
42 
43 Foam::cellShape Foam::degenerateMatcher::match
44 (
45  const faceList& faces,
46  const labelList& owner,
47  const label celli,
48  const labelList& cellFaces
49 )
50 {
51  // Recognize in order of assumed occurrence.
52 
53  if (hex.matchShape(false, faces, owner, celli, cellFaces))
54  {
55  return cellShape(hex.model(), hex.vertLabels());
56  }
57  if (tet.matchShape(false, faces, owner, celli, cellFaces))
58  {
59  return cellShape(tet.model(), tet.vertLabels());
60  }
61  if (prism.matchShape(false, faces, owner, celli, cellFaces))
62  {
63  return cellShape(prism.model(), prism.vertLabels());
64  }
65  if (pyr.matchShape(false, faces, owner, celli, cellFaces))
66  {
67  return cellShape(pyr.model(), pyr.vertLabels());
68  }
69  if (wedge.matchShape(false, faces, owner, celli, cellFaces))
70  {
71  return cellShape(wedge.model(), wedge.vertLabels());
72  }
73  if (tetWedge.matchShape(false, faces, owner, celli, cellFaces))
74  {
75  return cellShape(tetWedge.model(), tetWedge.vertLabels());
76  }
77 
78  return cellShape(cellModel::ref(cellModel::UNKNOWN), labelList());
79 }
80 
81 
82 Foam::cellShape Foam::degenerateMatcher::match(const faceList& faces)
83 {
84  // Do as if single cell mesh; all faces are referenced by a single cell
85 
86  return match
87  (
88  faces,
89  labelList(faces.size(), Zero), // cell 0 is owner of all faces
90  0, // cell 0
91  identity(faces.size()) // cell 0 consists of all faces
92  );
93 }
94 
95 
96 Foam::cellShape Foam::degenerateMatcher::match(const cellShape& shape)
97 {
98  return match(shape.collapsedFaces());
99 }
100 
101 
102 Foam::cellShape Foam::degenerateMatcher::match
103 (
104  const primitiveMesh& mesh,
105  const label celli
106 )
107 {
108  return match
109  (
110  mesh.faces(),
111  mesh.faceOwner(),
112  celli,
113  mesh.cells()[celli]
114  );
115 }
116 
117 
118 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
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:57
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
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:55
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:138
Foam::tetMatcher
A cellMatcher for tet cells (cellModel::TET)
Definition: tetMatcher.H:53
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:55
Foam::cellMatcher::vertLabels
const labelList & vertLabels() const
Definition: cellMatcherI.H:75
Foam::pyrMatcher
A cellMatcher for pyr cells (cellModel::PYR)
Definition: pyrMatcher.H:53
Foam::hexMatcher
A cellMatcher for hex cells (cellModel::HEX).
Definition: hexMatcher.H:53
Foam::label
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:62
degenerateMatcher.H
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1076
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:71
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:58
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:75
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
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:53
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:205
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:87
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:57
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78