topologyCleanerNonConsecutiveBoundaryVertices.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "demandDrivenData.H"
29 #include "topologicalCleaner.H"
30 #include "decomposeFaces.H"
31 
32 //#define DEBUGCleaner
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
42 {
43  Info << "Checking for invalid face connections" << endl;
44 
45  const faceListPMG& faces = mesh_.faces();
46  const labelList& owner = mesh_.owner();
47  const cellListPMG& cells = mesh_.cells();
48 
49  const label nIntFaces = mesh_.nInternalFaces();
50 
51  boolList decomposeFace(faces.size(), false);
52  bool changed(false);
53 
54  const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
55  forAll(boundaries, patchI)
56  {
57  const label start = boundaries[patchI].patchStart();
58  const label end = start + boundaries[patchI].patchSize();
59 
60  for(label faceI=start;faceI<end;++faceI)
61  {
62  # ifdef USE_OMP
63  # pragma omp task shared(decomposeFace,faces,cells,owner,faceI)
64  # endif
65  {
66  const face& bf = faces[faceI];
67 
68  # ifdef DEBUGCleaner
69  Info << "Checking boundary face " << faceI << " with vertices "
70  << bf << endl;
71  # endif
72 
73  const cell& c = cells[owner[faceI]];
74 
75  forAll(c, fI)
76  if(
77  (c[fI] < nIntFaces) ||
78  (mesh_.faceIsInProcPatch(c[fI]) != -1)
79  )
80  {
81  const face& f = faces[c[fI]];
82 
83  DynList<label> shN;
84 
85  forAll(bf, pI)
86  forAll(f, pJ)
87  if( bf[pI] == f[pJ] )
88  {
89  shN.append(pI);
90  }
91 
92  # ifdef DEBUGCleaner
93  Info << "Shared vertices with internal face " << f
94  << " are " << shN << endl;
95  # endif
96 
97  if( shN.size() > 2 )
98  {
99  # ifdef DEBUGCleaner
100  Info << "1. Face has to be split" << endl;
101  # endif
102 
103  decomposeFace[faceI] = true;
104  decomposeCell_[owner[faceI]] = true;
105  changed = true;
106  }
107  else if( shN.size() == 2 )
108  {
109  if( !(
110  (shN[0] == bf.fcIndex(shN[1])) ||
111  (shN[0] == bf.rcIndex(shN[1]))
112  )
113  )
114  {
115  # ifdef DEBUGCleaner
116  Info << "2. Face has to be split" << endl;
117  # endif
118 
119  decomposeFace[faceI] = true;
120  decomposeCell_[owner[faceI]] = true;
121  changed = true;
122  }
123  }
124  }
125  }
126  }
127  }
128 
129  if( Pstream::parRun() )
130  reduce(changed, maxOp<bool>());
131 
132  if( changed )
133  {
134  changed_ = true;
135  decomposeFaces(mesh_).decomposeMeshFaces(decomposeFace);
136  }
137 
138  Info << "Finished checking for invalid face connections" << endl;
139 }
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace Foam
144 
145 // ************************************************************************* //
Foam::polyMeshGenFaces::owner
const labelList & owner() const
owner and neighbour cells for faces
Definition: polyMeshGenFacesI.H:67
Foam::maxOp
Definition: ops.H:172
Foam::decomposeFaces
Definition: decomposeFaces.H:47
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::topologicalCleaner::changed_
bool changed_
Definition: topologicalCleaner.H:55
decomposeFaces.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::cellListPMG
Definition: cellListPMG.H:49
topologicalCleaner.H
Foam::polyMeshGenFaces::faces
const faceListPMG & faces() const
access to faces
Definition: polyMeshGenFacesI.H:43
Foam::polyMeshGenFaces::nInternalFaces
label nInternalFaces() const
return number of internal faces
Definition: polyMeshGenFacesI.H:48
Foam::topologicalCleaner::decomposeCell_
boolList decomposeCell_
Definition: topologicalCleaner.H:57
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
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:59
Foam::polyMeshGenFaces::faceIsInProcPatch
label faceIsInProcPatch(const label faceLabel) const
return processor patch label for the given face label
Definition: polyMeshGenFaces.C:168
Foam::Info
messageStream Info
Foam::polyMeshGenCells::cells
const cellListPMG & cells() const
access to cells
Definition: polyMeshGenCellsI.H:39
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::topologicalCleaner::checkNonConsecutiveBoundaryVertices
void checkNonConsecutiveBoundaryVertices()
check and fix incorrectly connected faces
Definition: topologyCleanerNonConsecutiveBoundaryVertices.C:41
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::topologicalCleaner::mesh_
polyMeshGen & mesh_
Definition: topologicalCleaner.H:53
Foam::DynList< label >
Foam::decomposeFaces::decomposeMeshFaces
void decomposeMeshFaces(const boolList &decomposeFace)
decompose selected faces into triangles using midnode subdivision
Definition: decomposeFaces.C:62
f
labelList f(nPoints)
Foam::faceListPMG::size
label size() const
return the number of used elements
Definition: faceListPMGI.H:73
Foam::polyMeshGenFaces::boundaries
const PtrList< boundaryPatch > & boundaries() const
ordinary boundaries
Definition: polyMeshGenFacesI.H:111
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::DynList::size
label size() const
Definition: DynListI.H:235
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::faceListPMG
Definition: faceListPMG.H:50
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Foam::DynList::append
void append(const T &e)
Append an element at the end of the list.
Definition: DynListI.H:304