degenerateMatcher.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
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 
26 #include "degenerateMatcher.H"
27 #include "ListOps.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 Foam::hexMatcher Foam::degenerateMatcher::hex;
32 Foam::wedgeMatcher Foam::degenerateMatcher::wedge;
33 Foam::prismMatcher Foam::degenerateMatcher::prism;
34 Foam::tetWedgeMatcher Foam::degenerateMatcher::tetWedge;
35 Foam::pyrMatcher Foam::degenerateMatcher::pyr;
36 Foam::tetMatcher Foam::degenerateMatcher::tet;
37 
38 
39 Foam::cellShape Foam::degenerateMatcher::match
40 (
41  const faceList& faces,
42  const labelList& owner,
43  const label celli,
44  const labelList& cellFaces
45 )
46 {
47  // Recognise in order of assumed occurrence.
48 
49  if (hex.matchShape(false, faces, owner, celli, cellFaces))
50  {
51  return cellShape(hex.model(), hex.vertLabels());
52  }
53  else if (tet.matchShape(false, faces, owner, celli, cellFaces))
54  {
55  return cellShape(tet.model(), tet.vertLabels());
56  }
57  else if (prism.matchShape(false, faces, owner, celli, cellFaces))
58  {
59  return cellShape(prism.model(), prism.vertLabels());
60  }
61  else if (pyr.matchShape(false, faces, owner, celli, cellFaces))
62  {
63  return cellShape(pyr.model(), pyr.vertLabels());
64  }
65  else if (wedge.matchShape(false, faces, owner, celli, cellFaces))
66  {
67  return cellShape(wedge.model(), wedge.vertLabels());
68  }
69  else if (tetWedge.matchShape(false, faces, owner, celli, cellFaces))
70  {
71  return cellShape(tetWedge.model(), tetWedge.vertLabels());
72  }
73  else
74  {
75  return cellShape(*(cellModeller::lookup(0)), labelList(0));
76  }
77 }
78 
79 
80 Foam::cellShape Foam::degenerateMatcher::match(const faceList& faces)
81 {
82  // Do as if single cell mesh; all faces are referenced by a single cell
83 
84  return match
85  (
86  faces,
87  labelList(faces.size(), 0), // cell 0 is owner of all faces
88  0, // cell 0
89  identity(faces.size()) // cell 0 consists 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 // ************************************************************************* //
const labelList & vertLabels() const
Definition: cellMatcherI.H:74
A cellMatcher for tet cells.
Definition: tetMatcher.H:51
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:59
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or nullptr.
Definition: cellModeller.C:100
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:64
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
An analytical geometric cellShape.
Definition: cellShape.H:69
A cellMatcher for prism cells.
Definition: prismMatcher.H:51
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
List< face > faceList
Definition: faceListFwd.H:43
A cellMatcher for pyr cells.
Definition: pyrMatcher.H:51
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
A cellMatcher for hex cells.
Definition: hexMatcher.H:51
const cellList & cells() const
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:60
Various functions to operate on Lists.
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:58
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:63
List< label > labelList
A List of labels.
Definition: labelList.H:56
faceList collapsedFaces() const
Collapsed faces of this cell.
Definition: cellShapeI.H:186
const cellModel & model() const
Definition: cellMatcherI.H:86
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.
Definition: wedgeMatcher.H:51
A cellMatcher for tetWedge cells.
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:60
virtual const faceList & faces() const =0
Return faces.
virtual const labelList & faceOwner() const =0
Face face-owner addressing.