meshUntanglerCutRegionEdges.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 "meshUntangler.H"
30 
31 //#define DEBUGSmooth
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
41 {
42  #ifdef DEBUGSmooth
43  Info << "Creating new edgesPtr_" << endl;
44  #endif
45 
47  DynList<edge, 128>& cEdges = *cEdgesPtr_;
48 
49  const DynList<point, 64>& pts = *pointsPtr_;
50  const DynList<edge, 128>& edges = *edgesPtr_;
51 
52  newEdgeLabel_.setSize(edges.size());
53  newEdgeLabel_ = -1;
54 
55  forAll(edges, eI)
56  {
57  const edge& e = edges[eI];
58  const label start = e.start();
59  const label end = e.end();
60  const label newStartLabel = newVertexLabel_[start];
61  const label newEndLabel = newVertexLabel_[end];
62 
63  if( (newStartLabel != -1) && (newEndLabel != -1) )
64  {
65  newEdgeLabel_[eI] = cEdges.size();
66  cEdges.append(edge(newStartLabel, newEndLabel));
67  }
68  else if( (newEndLabel != -1) && (vertexTypes_[end] & KEEP) )
69  {
70  //- start edge vertex is not visible, but the other one is
71  newEdgeLabel_[eI] = cEdges.size();
72  cEdges.append(edge(newEndLabel, cPtsPtr_->size()));
73 
74  const scalar t =
75  -vertexDistance_[start] /
76  (vertexDistance_[end] - vertexDistance_[start]);
77 
78  const point newP = (1.0 - t) * pts[start] + t * pts[end];
79  cPtsPtr_->append(newP);
80  }
81  else if( (newStartLabel != -1) && (vertexTypes_[start] & KEEP) )
82  {
83  //- end edge vertex is not visible, but the other one is
84  newEdgeLabel_[eI] = cEdges.size();
85  cEdges.append(edge(newStartLabel, cPtsPtr_->size()));
86 
87  const scalar t =
88  -vertexDistance_[end] /
89  (vertexDistance_[start] - vertexDistance_[end]);
90 
91  const point newP = (1.0 - t) * pts[end] + t * pts[start];
92  cPtsPtr_->append(newP);
93  }
94 
95  # ifdef DEBUGSmooth
96  if( newEdgeLabel_[eI] != -1 )
97  {
98  Info << nl << "Edge " << eI << "consisting of " << e
99  << " has been replaced with edge " << newEdgeLabel_[eI] << " "
100  << cEdges[newEdgeLabel_[eI]] << endl;
101  }
102  else
103  {
104  Info << "Edge " << e << " has been deleted!" << endl;
105  }
106  # endif
107  }
108 
109  #ifdef DEBUGSmooth
110  Info << "Found " << cEdges.size() << " new edges" << endl;
111  #endif
112 }
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 } // End namespace Foam
117 
118 // ************************************************************************* //
Foam::meshUntangler::cutRegion::vertexTypes_
DynList< direction, 64 > vertexTypes_
Definition: meshUntangler.H:74
Foam::meshUntangler::cutRegion::KEEP
@ KEEP
Definition: meshUntangler.H:99
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::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::meshUntangler::cutRegion::edgesPtr_
DynList< edge, 128 > * edgesPtr_
Definition: meshUntangler.H:64
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::meshUntangler::cutRegion::newEdgeLabel_
DynList< label, 128 > newEdgeLabel_
Definition: meshUntangler.H:75
meshUntangler.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::DynList
Definition: DynList.H:53
Foam::meshUntangler::cutRegion::cEdgesPtr_
DynList< edge, 128 > * cEdgesPtr_
Definition: meshUntangler.H:69
Foam::meshUntangler::cutRegion::cPtsPtr_
DynList< point, 64 > * cPtsPtr_
helper data
Definition: meshUntangler.H:68
Foam::meshUntangler::cutRegion::findNewEdges
void findNewEdges()
Definition: meshUntanglerCutRegionEdges.C:40
Foam::Vector< scalar >
Foam::DynList::setSize
void setSize(const label)
Reset size of List.
Definition: DynListI.H:263
Foam::meshUntangler::cutRegion::pointsPtr_
DynList< point, 64 > * pointsPtr_
Definition: meshUntangler.H:63
Foam::meshUntangler::cutRegion::newVertexLabel_
DynList< label, 64 > newVertexLabel_
Definition: meshUntangler.H:72
Foam::DynList::size
label size() const
Definition: DynListI.H:235
Foam::meshUntangler::cutRegion::vertexDistance_
DynList< scalar, 64 > vertexDistance_
Definition: meshUntangler.H:73
Foam::DynList::append
void append(const T &e)
Append an element at the end of the list.
Definition: DynListI.H:304