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-------------------------------------------------------------------------------
10License
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
34Foam::hexMatcher Foam::degenerateMatcher::hex;
36Foam::prismMatcher Foam::degenerateMatcher::prism;
37Foam::tetWedgeMatcher Foam::degenerateMatcher::tetWedge;
38Foam::pyrMatcher Foam::degenerateMatcher::pyr;
39Foam::tetMatcher Foam::degenerateMatcher::tet;
40
41
42// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
43
44Foam::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
83Foam::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
97Foam::cellShape Foam::degenerateMatcher::match(const cellShape& shape)
98{
99 return match(shape.collapsedFaces());
100}
101
102
103Foam::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// ************************************************************************* //
Various functions to operate on Lists.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
const cellModel & model() const
Definition: cellMatcherI.H:84
const labelList & vertLabels() const
Definition: cellMatcherI.H:72
@ UNKNOWN
unknown
Definition: cellModel.H:80
An analytical geometric cellShape.
Definition: cellShape.H:72
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:233
reference ref() const
A reference to the entry (Error if not found)
Definition: dictionary.H:225
Extrudes by rotating a surface symmetrically around axis by 1 layer.
Definition: wedge.H:57
A cellMatcher for hex cells (cellModel::HEX).
Definition: hexMatcher.H:57
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
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1108
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1121
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79
const cellList & cells() const
A cellMatcher for prism cells (cellModel::PRISM)
Definition: prismMatcher.H:56
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
A cellMatcher for pyr cells (cellModel::PYR)
Definition: pyrMatcher.H:57
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
A cellMatcher for tet cells (cellModel::TET)
Definition: tetMatcher.H:57
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
A cellMatcher for tetWedge cells (cellModel::TETWEDGE).
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.
A cellMatcher for wedge cells (cellModel::WEDGE).
Definition: wedgeMatcher.H:56
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
dynamicFvMesh & mesh
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i)
Definition: labelList.C:38
List< label > labelList
A List of labels.
Definition: List.H:66
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131