tetIndices.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) 2011-2016 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 "tetIndices.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  celli_(-1),
33  facei_(-1),
34  faceBasePtI_(-1),
35  facePtAI_(-1),
36  facePtBI_(-1),
37  tetPtI_(-1)
38 {}
39 
40 
42 (
43  label celli,
44  label facei,
45  label faceBasePtI,
46  label facePtAI,
47  label facePtBI,
48  label tetPtI
49 )
50 :
51  celli_(celli),
52  facei_(facei),
53  faceBasePtI_(faceBasePtI),
54  facePtAI_(facePtAI),
55  facePtBI_(facePtBI),
56  tetPtI_(tetPtI)
57 {}
58 
59 
61 (
62  label celli,
63  label facei,
64  label tetPtI,
65  const polyMesh& mesh
66 )
67 :
68  celli_(celli),
69  facei_(facei),
70  faceBasePtI_(-1),
71  facePtAI_(-1),
72  facePtBI_(-1),
73  tetPtI_(tetPtI)
74 {
75  const faceList& pFaces = mesh.faces();
76  const labelList& pOwner = mesh.faceOwner();
77 
78  const Foam::face& f = pFaces[facei_];
79 
80  bool own = (pOwner[facei_] == celli_);
81 
82  faceBasePtI_ = mesh.tetBasePtIs()[facei_];
83 
84  label facePtI = (tetPtI_ + faceBasePtI_) % f.size();
85  label otherFacePtI = f.fcIndex(facePtI);
86 
87  if (own)
88  {
89  facePtAI_ = facePtI;
90  facePtBI_ = otherFacePtI;
91  }
92  else
93  {
94  facePtAI_ = otherFacePtI;
95  facePtBI_ = facePtI;
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
107 
109 {
110  is >> tI.cell()
111  >> tI.face()
112  >> tI.faceBasePt()
113  >> tI.facePtA()
114  >> tI.facePtB()
115  >> tI.tetPt();
116 
117  // Check state of Istream
118  is.check
119  (
120  "Foam::Istream& Foam::operator>>(Foam::Istream&, Foam::tetIndices&)"
121  );
122 
123  return is;
124 }
125 
126 
128 {
129  os << tI.cell() << token::SPACE
130  << tI.face() << token::SPACE
131  << tI.faceBasePt() << token::SPACE
132  << tI.facePtA() << token::SPACE
133  << tI.facePtB() << token::SPACE
134  << tI.tetPt() << token::SPACE
135  << endl;
136 
137  // Check state of Ostream
138  os.check
139  (
140  "Foam::Ostream& Foam::operator<<(Foam::Ostream&, "
141  "const Foam::tetIndices&)"
142  );
143 
144  return os;
145 }
146 
147 
148 // ************************************************************************* //
label cell() const
Return the cell.
Definition: tetIndicesI.H:30
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
label facePtA() const
Return face point A.
Definition: tetIndicesI.H:48
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
~tetIndices()
Destructor.
Definition: tetIndices.C:102
label tetPt() const
Return the characterising tetPtI.
Definition: tetIndicesI.H:60
label faceBasePt() const
Return the face base point.
Definition: tetIndicesI.H:42
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
Definition: UListI.H:58
label facePtB() const
Return face point B.
Definition: tetIndicesI.H:54
Istream & operator>>(Istream &, directionInfo &)
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints,-1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){pointMap[i]=i;}for(label i=0;i< nPoints;i++){if(f[i] > 0.0){hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei){if(edges[ei].mag(points)< SMALL){label start=pointMap[edges[ei].start()];while(start!=pointMap[start]){start=pointMap[start];}label end=pointMap[edges[ei].end()];while(end!=pointMap[end]){end=pointMap[end];}label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;}}cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){cellShape &cs=cellShapes[celli];forAll(cs, i){cs[i]=pointMap[cs[i]];}cs.collapse();}label bcIDs[11]={-1, 0, 2, 4,-1, 5,-1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={&wallPolyPatch::typeName,&wallPolyPatch::typeName,&wallPolyPatch::typeName,&wallPolyPatch::typeName,&symmetryPolyPatch::typeName,&wedgePolyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&polyPatch::typeName,&symmetryPolyPatch::typeName,&oldCyclicPolyPatch::typeName};enum patchTypeNames{PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={"piston","valve","liner","cylinderHead","axis","wedge","inflow","outflow","presin","presout","symmetryPlane","cyclic"};List< SLList< face > > pFaces[nBCs]
Definition: readKivaGrid.H:235
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
label face() const
Return the face.
Definition: tetIndicesI.H:36
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const labelList & tetBasePtIs() const
Return the tetBasePtIs.
Definition: polyMesh.C:818
labelList f(nPoints)
Ostream & operator<<(Ostream &, const ensightPart &)
tetIndices()
Construct null.
Definition: tetIndices.C:30
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1017
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1004