surfaceMorpherCells.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 "surfaceMorpherCells.H"
29 #include "demandDrivenData.H"
30 
31 //#define DEBUGMorph
32 
33 # ifdef DEBUGMorph
34 #include <sstream>
35 #include "polyMeshGenAddressing.H"
36 # endif
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
46 {
48  patchNames[0] = "defaultFaces";
49 
51  (
52  patchNames,
56  );
57 }
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
62 (
64 )
65  :
66  mesh_(mesh),
67  nIntFaces_(0),
68  boundaryVertex_(mesh.points().size()),
69  cellFlags_(mesh.cells().size()),
70  newBoundaryFaces_(),
71  newBoundaryOwners_(),
72  newBoundaryPatches_()
73 {
74 }
75 
77 {}
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
82 {
83  //- perform surface morphing
84  bool changed;
85 
86  # ifdef DEBUGMorph
87  label iter(0);
88  # endif
89 
90  do
91  {
92  changed = false;
93  # ifdef DEBUGMorph
94  Info << "Iteration " << ++iter << endl;
95  # endif
96 
98 
100 
102  {
103  changed = true;
104  continue;
105  }
106 
107  if( morphInternalFaces() )
108  {
109  changed = true;
110  continue;
111  }
112 
113  if( morphBoundaryFaces() )
114  {
115  changed = true;
116  continue;
117  }
118 
119  # ifdef DEBUGMorph
120  mesh_.write();
121  mesh_.addressingData().checkMesh(true);
122  fileName name("morphedMesh");
123  std::ostringstream ss;
124  ss << iter;
125  name += ss.str();
126  Info << "name " << name << endl;
127  ++iter;
128 
129  const cellListPMG& cells = mesh_.cells();
130  const faceListPMG& faces = mesh_.faces();
131  forAll(cells, cellI)
132  {
133  const cell& c = cells[cellI];
134 
135  const edgeList edges = c.edges(faces);
136  List<direction> nAppearances(edges.size(), direction(0));
137 
138  forAll(c, fI)
139  {
140  const edgeList fEdges = faces[c[fI]].edges();
141 
142  forAll(fEdges, eI)
143  forAll(edges, eJ)
144  if( fEdges[eI] == edges[eJ] )
145  {
146  ++nAppearances[eJ];
147  break;
148  }
149  }
150 
151  bool closed(true);
152  forAll(nAppearances, eI)
153  if( nAppearances[eI] != 2 )
154  {
155  closed = false;
156  Info << "Edge " << edges[eI] << " appears "
157  << label(nAppearances[eI]) << " times in cell "
158  << cellI << endl;
159  }
160 
161  if( !closed )
162  {
163  Info << "Cell " << cellI << " consists of faces " << c << endl;
164  forAll(c, fI)
165  Info << "Face " << c[fI] << " is " << faces[c[fI]] << endl;
167  (
168  "void surfaceMorpherCells::morphMesh()"
169  ) << "Cell " << cellI << " is not topologically closed"
170  << abort(FatalError);
171  }
172  }
173  # endif
174 
175  } while( changed );
176 
178 }
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace Foam
183 
184 // ************************************************************************* //
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:979
Foam::polyMeshGenCells::addressingData
const polyMeshGenAddressing & addressingData() const
addressing which may be needed
Definition: polyMeshGenCells.C:327
Foam::surfaceMorpherCells::mesh_
polyMeshGen & mesh_
mesh modifier
Definition: surfaceMorpherCells.H:55
Foam::surfaceMorpherCells::findBoundaryCells
void findBoundaryCells()
find boundary cells
Definition: surfaceMorpherCellsMorphInternalFaces.C:160
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::surfaceMorpherCells::findBoundaryVertices
void findBoundaryVertices()
find surface vertices
Definition: surfaceMorpherCellsMorphInternalFaces.C:46
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::primitiveMesh::cells
const cellList & cells() const
Definition: primitiveMeshCells.C:136
Foam::polyMeshGenModifier::replaceBoundary
void replaceBoundary(const wordList &patchNames, const VRWGraph &boundaryFaces, const labelLongList &faceOwners, const labelLongList &facePatches)
replace the boundary with new boundary faces
Definition: polyMeshGenModifierReplaceBoundary.C:42
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::cellListPMG
Definition: cellListPMG.H:49
Foam::polyMeshGenFaces::faces
const faceListPMG & faces() const
access to faces
Definition: polyMeshGenFacesI.H:43
Foam::surfaceMorpherCells::removeCellsWithAllVerticesAtTheBoundary
bool removeCellsWithAllVerticesAtTheBoundary()
remove cells with all vertices at the boundary
Definition: surfaceMorpherCellsCreateBoundaryFaces.C:46
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::Info
messageStream Info
Foam::surfaceMorpherCells::newBoundaryFaces_
VRWGraph newBoundaryFaces_
new boundary faces and owner cells
Definition: surfaceMorpherCells.H:67
Foam::polyMeshGenCells::cells
const cellListPMG & cells() const
access to cells
Definition: polyMeshGenCellsI.H:39
Foam::surfaceMorpherCells::morphBoundaryFaces
bool morphBoundaryFaces()
morph boundary faces
Definition: surfaceMorpherCellsCreateBoundaryFaces.C:130
surfaceMorpherCells.H
Foam::surfaceMorpherCells::morphInternalFaces
bool morphInternalFaces()
morph internal faces
Definition: surfaceMorpherCellsMorphInternalFaces.C:179
patchNames
wordList patchNames(nPatches)
Foam::polyMeshGenModifier::removeUnusedVertices
void removeUnusedVertices()
remove unused vertices
Definition: polyMeshGenModifierRemoveUnusedVertices.C:37
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::surfaceMorpherCells::newBoundaryPatches_
labelLongList newBoundaryPatches_
Definition: surfaceMorpherCells.H:69
Foam::surfaceMorpherCells::morphMesh
void morphMesh()
Definition: surfaceMorpherCells.C:81
Foam::surfaceMorpherCells::surfaceMorpherCells
surfaceMorpherCells(const surfaceMorpherCells &)
Disallow default bitwise copy construct.
Foam::polyMeshGenModifier
Definition: polyMeshGenModifier.H:52
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::polyMeshGen::write
void write() const
Definition: polyMeshGen.C:126
Foam::surfaceMorpherCells::newBoundaryOwners_
labelLongList newBoundaryOwners_
Definition: surfaceMorpherCells.H:68
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::surfaceMorpherCells::~surfaceMorpherCells
~surfaceMorpherCells()
Definition: surfaceMorpherCells.C:76
Foam::faceListPMG
Definition: faceListPMG.H:50
polyMeshGenAddressing.H
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:56
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::surfaceMorpherCells::replaceMeshBoundary
void replaceMeshBoundary()
replace the boundary of the mesh with the newly created one
Definition: surfaceMorpherCells.C:45