Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Romin Tomasetti
gmsh
Commits
7d9bf480
Commit
7d9bf480
authored
13 years ago
by
Amaury Johnen
Browse files
Options
Downloads
Patches
Plain Diff
clean up
parent
592b2e2e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Mesh/meshGFaceRecombine.cpp
+35
-59
35 additions, 59 deletions
Mesh/meshGFaceRecombine.cpp
Mesh/meshGFaceRecombine.h
+23
-22
23 additions, 22 deletions
Mesh/meshGFaceRecombine.h
with
58 additions
and
81 deletions
Mesh/meshGFaceRecombine.cpp
+
35
−
59
View file @
7d9bf480
...
...
@@ -10,7 +10,7 @@
#define REC2D_WAIT_TIME .01
#define REC2D_NUM_ACTIO 1000
#define REC2D_SMOOTH
//
#define REC2D_SMOOTH
#define REC2D_DRAW
#include
"meshGFaceRecombine.h"
...
...
@@ -41,7 +41,6 @@ int otherParity(int a) {
/*******************/
Recombine2D
::
Recombine2D
(
GFace
*
gf
)
:
_gf
(
gf
)
{
laplaceSmoothing
(
_gf
,
100
);
if
(
Recombine2D
::
_current
!=
NULL
)
{
Msg
::
Warning
(
"[Recombine2D] An instance already in execution"
);
return
;
...
...
@@ -50,15 +49,10 @@ Recombine2D::Recombine2D(GFace *gf) : _gf(gf)
backgroundMesh
::
set
(
_gf
);
_bgm
=
backgroundMesh
::
current
();
_data
=
new
Rec2DData
(
gf
->
triangles
.
size
(),
gf
->
quadrangles
.
size
()
);
_data
=
new
Rec2DData
();
Rec2DVertex
::
initStaticTable
();
_numChange
=
0
;
#ifdef REC2D_DRAW
//_data->_tri = _gf->triangles;
//_data->_quad = _gf->quadrangles;
#endif
// Be able to compute geometrical angle at corners
std
::
map
<
MVertex
*
,
AngleData
>
mapCornerVert
;
{
...
...
@@ -220,6 +214,8 @@ bool Recombine2D::recombine()
std
::
vector
<
Rec2DVertex
*>
newPar
;
nextAction
->
apply
(
newPar
);
// forall v in newPar : check obsoletes action;
#ifdef REC2D_DRAW
_gf
->
triangles
=
_data
->
_tri
;
_gf
->
quadrangles
=
_data
->
_quad
;
...
...
@@ -312,8 +308,9 @@ bool Recombine2D::_remainAllQuad(Rec2DAction *action)
int
p
[
4
];
action
->
getAssumedParities
(
p
);
if
(
!
p
[
0
]
&&
!
p
[
1
]
&&
!
p
[
2
]
&&
!
p
[
3
])
{
Msg
::
Info
(
"is isolated"
);
if
(
p
[
0
]
&&
!
p
[
1
]
&&
!
p
[
2
]
&&
!
p
[
3
])
{
static
int
a
=
-
1
;
if
(
++
a
<
1
)
Msg
::
Warning
(
"FIXME isoleted should be check ? Think not"
);
return
true
;
}
...
...
@@ -325,21 +322,12 @@ bool Recombine2D::_remainAllQuad(Rec2DAction *action)
}
}
if
(
p
[
0
]
&&
!
p
[
1
]
&&
!
p
[
2
]
&&
!
p
[
3
])
{
Msg
::
Info
(
"is isolated"
);
static
int
a
=
-
1
;
if
(
++
a
<
1
)
Msg
::
Warning
(
"FIXME isoleted should be check ? Think not"
);
return
true
;
}
//Msg::Info("Passsed through there, [%d %d %d %d] -> min %d", p[0], p[1], p[2], p[3], min);
std
::
set
<
Rec2DElement
*>
neighbours
;
std
::
vector
<
Rec2DVertex
*>
touched
;
for
(
int
i
=
0
;
i
<
4
;
i
+=
2
)
{
static
int
a
=
-
1
;
if
(
++
a
<
1
)
Msg
::
Info
(
"FIXME depend de l'action"
);
if
(
++
a
<
1
)
Msg
::
Warning
(
"FIXME depend de l'action"
);
int
par
;
if
((
index
/
2
)
*
2
==
i
)
par
=
min
;
...
...
@@ -356,34 +344,35 @@ bool Recombine2D::_remainAllQuad(Rec2DAction *action)
}
}
for
(
unsigned
int
i
=
0
;
i
<
touched
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
<
touched
.
size
();
++
i
)
touched
[
i
]
->
getTriangles
(
neighbours
);
}
touched
.
clear
();
while
(
neighbours
.
size
()
>
0
)
{
//Msg::Info("num neigh %d", neighbours.size());
return
_remainAllQuad
(
neighbours
);
}
std
::
set
<
Rec2DElement
*>::
iterator
itTri
=
neighbours
.
begin
();
bool
Recombine2D
::
_remainAllQuad
(
std
::
set
<
Rec2DElement
*>
&
elem
)
{
std
::
vector
<
Rec2DVertex
*>
touched
;
while
(
elem
.
size
()
>
0
)
{
std
::
set
<
Rec2DElement
*>::
iterator
itTri
=
elem
.
begin
();
int
p
[
3
];
(
*
itTri
)
->
getAssumedParities
(
p
);
//Msg::Info("tri %d [%d %d %d]", (*itel)->getNum(), p[0], p[1], p[2]);
bool
hasIdentical
=
false
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
p
[
i
]
&&
p
[
i
]
==
p
[(
i
+
1
)
%
3
])
hasIdentical
=
true
;
}
if
(
!
hasIdentical
)
{
neighbours
.
erase
(
itTri
);
elem
.
erase
(
itTri
);
continue
;
}
if
(
p
[
0
]
==
p
[
1
]
&&
p
[
0
]
==
p
[
2
])
{
Msg
::
Info
(
"3 identical par"
);
Rec2DData
::
revertAssumedParities
();
return
false
;
}
//Msg::Info("has identical");
bool
hasAction
=
false
;
std
::
map
<
Rec2DVertex
*
,
std
::
vector
<
int
>
>
suggestions
;
...
...
@@ -392,11 +381,9 @@ bool Recombine2D::_remainAllQuad(Rec2DAction *action)
hasAction
=
true
;
}
if
(
!
hasAction
)
{
//Msg::Info("No action %d", (*itTri)->getNum());
Rec2DData
::
revertAssumedParities
();
return
false
;
}
//Msg::Info("suggest %d", suggestions.size());
std
::
map
<
Rec2DVertex
*
,
std
::
vector
<
int
>
>::
iterator
itSug
;
itSug
=
suggestions
.
begin
();
...
...
@@ -414,14 +401,11 @@ bool Recombine2D::_remainAllQuad(Rec2DAction *action)
Rec2DVertex
*
v
=
itSug
->
first
;
int
oldPar
=
v
->
getAssumedParity
();
//Msg::Info("a %d, %d", par, oldPar);
if
(
!
oldPar
)
{
//Msg::Info("b");
v
->
setAssumedParity
(
par
);
v
->
getTriangles
(
neighbours
);
v
->
getTriangles
(
elem
);
}
else
if
((
par
/
2
)
*
2
!=
(
oldPar
/
2
)
*
2
)
{
//Msg::Info("c");
if
(
oldPar
<
par
)
{
int
a
=
oldPar
;
oldPar
=
par
;
...
...
@@ -429,28 +413,26 @@ bool Recombine2D::_remainAllQuad(Rec2DAction *action)
}
Rec2DData
::
associateAssumedParity
(
oldPar
,
par
,
touched
);
for
(
unsigned
int
i
=
0
;
i
<
touched
.
size
();
++
i
)
{
touched
[
i
]
->
getTriangles
(
neighbours
);
touched
[
i
]
->
getTriangles
(
elem
);
}
touched
.
clear
();
}
else
if
(
par
%
2
!=
oldPar
%
2
)
{
Msg
::
Error
(
"SHOULD NOT HAPPEN"
);
Msg
::
Info
(
"not all quad"
);
Rec2DData
::
revertAssumedParities
();
return
false
;
}
}
}
neighbours
.
erase
(
itTri
);
elem
.
erase
(
itTri
);
}
//Msg::Info("all quad");
return
true
;
}
/** Rec2DData **/
/*****************/
Rec2DData
::
Rec2DData
(
int
numTri
,
int
numQuad
)
Rec2DData
::
Rec2DData
()
{
if
(
Rec2DData
::
_current
!=
NULL
)
{
Msg
::
Error
(
"[Rec2DData] An instance in execution"
);
...
...
@@ -459,10 +441,6 @@ Rec2DData::Rec2DData(int numTri, int numQuad)
Rec2DData
::
_current
=
this
;
_numEdge
=
_numVert
=
0
;
_valEdge
=
_valVert
=
.0
;
//_elements.reserve((int) (numTri + numQuad) * 1.1);
//_edges.reserve((int) (numTri * 1.8 + numQuad * 2.4));
//_vertices.reserve((int) (numTri * .6 + numQuad * 1.2));
}
Rec2DData
::~
Rec2DData
()
...
...
@@ -543,7 +521,7 @@ void Rec2DData::remove(Rec2DElement *rel)
return
;
}
}
Msg
::
Info
(
"[Rec2DData] Didn't erased mtriangle :("
);
Msg
::
Warning
(
"[Rec2DData] Didn't erased mtriangle :("
);
}
MQuadrangle
*
q
=
rel
->
getMQuadrangle
();
if
(
q
)
{
...
...
@@ -554,7 +532,7 @@ void Rec2DData::remove(Rec2DElement *rel)
return
;
}
}
Msg
::
Info
(
"[Rec2DData] Didn't erased mquadrangle :("
);
Msg
::
Warning
(
"[Rec2DData] Didn't erased mquadrangle :("
);
}
#endif
}
...
...
@@ -671,7 +649,7 @@ void Rec2DData::associateParity(int pOld, int pNew)
{
it
=
_current
->
_parities
.
find
(
pOld
);
if
(
it
==
_current
->
_parities
.
end
())
{
Msg
::
Warning
(
"[Rec2DData] What ?"
);
Msg
::
Error
(
"[Rec2DData] What ?"
);
return
;
}
vect
=
&
it
->
second
;
...
...
@@ -763,7 +741,7 @@ void Rec2DData::associateAssumedParity(int pOld, int pNew,
{
it
=
_current
->
_parities
.
find
(
pOld
);
if
(
it
==
_current
->
_parities
.
end
())
{
Msg
::
Warning
(
"[Rec2DData] What ?"
);
Msg
::
Error
(
"[Rec2DData] What ?"
);
return
;
}
vect
=
&
it
->
second
;
...
...
@@ -824,7 +802,6 @@ bool lessRec2DAction::operator()(Rec2DAction *ra1, Rec2DAction *ra2) const
return
*
ra1
<
*
ra2
;
}
bool
Rec2DAction
::
operator
<
(
Rec2DAction
&
other
)
{
return
getReward
()
<
other
.
getReward
();
...
...
@@ -952,7 +929,6 @@ void Rec2DTwoTri2Quad::apply(std::vector<Rec2DVertex*> &newPar)
delete
_edges
[
4
];
/*new Rec2DCollapse(*/
new
Rec2DElement
(
_edges
)
/*)*/
;
}
bool
Rec2DTwoTri2Quad
::
isObsolete
()
...
...
@@ -1231,7 +1207,7 @@ Rec2DEdge* Rec2DVertex::getCommonEdge(Rec2DVertex *rv0, Rec2DVertex *rv1)
if
(
rv1
->
has
(
rv0
->
_edges
[
i
]))
return
rv0
->
_edges
[
i
];
}
//
Msg::Warning("[Rec2DVertex] didn't find edge, returning NULL");
Msg
::
Warning
(
"[Rec2DVertex] didn't find edge, returning NULL"
);
return
NULL
;
}
...
...
@@ -1443,7 +1419,7 @@ void Rec2DVertex::add(Rec2DEdge *re)
{
for
(
unsigned
int
i
=
0
;
i
<
_edges
.
size
();
++
i
)
{
if
(
_edges
[
i
]
==
re
)
{
Msg
::
Warning
(
"[Rec2DVertex] Edge was already there"
);
Msg
::
Error
(
"[Rec2DVertex] Edge was already there"
);
return
;
}
}
...
...
@@ -1470,14 +1446,14 @@ void Rec2DVertex::remove(Rec2DEdge *re)
}
++
i
;
}
Msg
::
Warning
(
"[Rec2DVertex] Didn't removed edge, didn't have it"
);
Msg
::
Error
(
"[Rec2DVertex] Didn't removed edge, didn't have it"
);
}
void
Rec2DVertex
::
add
(
Rec2DElement
*
rel
)
{
for
(
unsigned
int
i
=
0
;
i
<
_elements
.
size
();
++
i
)
{
if
(
_elements
[
i
]
==
rel
)
{
Msg
::
Warning
(
"[Rec2DVertex] Element was already there"
);
Msg
::
Error
(
"[Rec2DVertex] Element was already there"
);
return
;
}
}
...
...
@@ -1508,7 +1484,7 @@ void Rec2DVertex::remove(Rec2DElement *rel)
}
++
i
;
}
Msg
::
Warning
(
"[Rec2DVertex] Didn't removed element, didn't have it"
);
Msg
::
Error
(
"[Rec2DVertex] Didn't removed element, didn't have it"
);
}
...
...
@@ -1574,7 +1550,7 @@ void Rec2DElement::add(Rec2DEdge *re)
int
i
;
for
(
i
=
0
;
i
<
_numEdge
;
++
i
)
{
if
(
_edges
[
i
]
==
re
)
{
Msg
::
Warning
(
"[Rec2DElement] Edge was already there"
);
Msg
::
Error
(
"[Rec2DElement] Edge was already there"
);
return
;
}
if
(
_edges
[
i
]
==
NULL
)
{
...
...
@@ -1604,7 +1580,7 @@ void Rec2DElement::add(Rec2DAction *ra)
{
for
(
unsigned
int
i
=
0
;
i
<
_actions
.
size
();
++
i
)
{
if
(
_actions
[
i
]
==
ra
)
{
Msg
::
Warning
(
"[Rec2DElement] Action was already there"
);
Msg
::
Error
(
"[Rec2DElement] Action was already there"
);
return
;
}
}
...
...
@@ -1622,7 +1598,7 @@ void Rec2DElement::remove(Rec2DAction *ra)
}
++
i
;
}
Msg
::
Warning
(
"[Rec2DElement] Didn't removed action, didn't have it"
);
Msg
::
Error
(
"[Rec2DElement] Didn't removed action, didn't have it"
);
}
void
Rec2DElement
::
addNeighbour
(
Rec2DEdge
*
re
,
Rec2DElement
*
rel
)
...
...
This diff is collapsed.
Click to expand it.
Mesh/meshGFaceRecombine.h
+
23
−
22
View file @
7d9bf480
...
...
@@ -50,13 +50,13 @@ class Recombine2D {
static
inline
GFace
*
getGFace
()
{
return
_current
->
_gf
;}
static
inline
int
getNumChange
()
{
return
_current
->
_numChange
;}
static
inline
backgroundMesh
*
bgm
()
{
return
_current
->
_bgm
;}
//recombine : if _current==this ok !
private
:
double
_geomAngle
(
MVertex
*
,
std
::
vector
<
GEdge
*>&
,
std
::
vector
<
MElement
*>&
);
bool
_remainAllQuad
(
Rec2DAction
*
action
);
bool
_remainAllQuad
(
std
::
set
<
Rec2DElement
*>&
);
};
class
Rec2DData
{
...
...
@@ -70,12 +70,13 @@ class Rec2DData {
std
::
set
<
Rec2DElement
*>
_elements
;
std
::
list
<
Rec2DAction
*>
_actions
;
std
::
map
<
int
,
std
::
vector
<
Rec2DVertex
*>
>
_parities
;
std
::
map
<
int
,
std
::
vector
<
Rec2DVertex
*>
>
_assumedParities
;
std
::
map
<
Rec2DVertex
*
,
int
>
_oldParity
;
public
:
Rec2DData
(
int
numTri
,
int
numQuad
);
Rec2DData
();
~
Rec2DData
();
void
printState
();
...
...
@@ -87,6 +88,15 @@ class Rec2DData {
static
double
getGlobalValue
();
static
double
getGlobalValue
(
int
numEdge
,
double
valEdge
,
int
numVert
,
double
valVert
);
static
inline
void
addVert
(
int
num
,
double
val
)
{
_current
->
_numVert
+=
num
;
_current
->
_valVert
+=
val
;
}
static
inline
void
addValVert
(
double
val
)
{
_current
->
_valVert
+=
val
;}
static
inline
void
addEdge
(
int
num
,
double
val
)
{
_current
->
_numEdge
+=
num
;
_current
->
_valEdge
+=
val
;
}
static
Rec2DAction
*
getBestAction
();
...
...
@@ -128,16 +138,6 @@ class Rec2DData {
std
::
vector
<
Rec2DVertex
*>&
);
static
inline
void
clearAssumedParities
()
{
_current
->
_oldParity
.
clear
();}
static
void
revertAssumedParities
();
static
inline
void
addVert
(
int
num
,
double
val
)
{
_current
->
_numVert
+=
num
;
_current
->
_valVert
+=
val
;
}
static
inline
void
addValVert
(
double
val
)
{
_current
->
_valVert
+=
val
;}
static
inline
void
addEdge
(
int
num
,
double
val
)
{
_current
->
_numEdge
+=
num
;
_current
->
_valEdge
+=
val
;
}
};
struct
lessRec2DAction
{
...
...
@@ -248,10 +248,8 @@ class Rec2DVertex {
Rec2DVertex
(
Rec2DVertex
*
,
double
angle
);
~
Rec2DVertex
();
static
void
initStaticTable
();
static
Rec2DEdge
*
getCommonEdge
(
Rec2DVertex
*
,
Rec2DVertex
*
);
static
void
getCommonElements
(
Rec2DVertex
*
,
Rec2DVertex
*
,
std
::
vector
<
Rec2DElement
*>&
);
double
getQual
(
int
numEl
=
-
1
)
const
;
double
getGain
(
int
)
const
;
inline
void
setOnBoundary
();
inline
bool
getOnBoundary
()
const
{
return
_onWhat
<
1
;}
...
...
@@ -278,9 +276,6 @@ class Rec2DVertex {
inline
double
u
()
const
{
return
_param
[
0
];}
inline
double
v
()
const
{
return
_param
[
1
];}
double
getQual
(
int
numEl
=
-
1
)
const
;
double
getGain
(
int
)
const
;
void
add
(
Rec2DEdge
*
);
bool
has
(
Rec2DEdge
*
)
const
;
void
remove
(
Rec2DEdge
*
);
...
...
@@ -289,6 +284,11 @@ class Rec2DVertex {
bool
has
(
Rec2DElement
*
)
const
;
void
remove
(
Rec2DElement
*
);
static
void
initStaticTable
();
static
Rec2DEdge
*
getCommonEdge
(
Rec2DVertex
*
,
Rec2DVertex
*
);
static
void
getCommonElements
(
Rec2DVertex
*
,
Rec2DVertex
*
,
std
::
vector
<
Rec2DElement
*>&
);
private
:
bool
_recursiveBoundParity
(
Rec2DVertex
*
prev
,
int
p0
,
int
p1
);
};
...
...
@@ -309,12 +309,14 @@ class Rec2DElement {
bool
inline
isTri
()
{
return
_numEdge
==
3
;}
bool
inline
isQuad
()
{
return
_numEdge
==
4
;}
void
add
(
Rec2DEdge
*
);
bool
has
(
Rec2DEdge
*
)
const
;
void
add
(
Rec2DAction
*
);
void
remove
(
Rec2DAction
*
);
void
addNeighbour
(
Rec2DEdge
*
,
Rec2DElement
*
);
void
removeNeighbour
(
Rec2DEdge
*
,
Rec2DElement
*
);
inline
MElement
*
getMElement
()
const
{
return
_mEl
;}
#ifdef REC2D_DRAW
MTriangle
*
getMTriangle
()
{
...
...
@@ -338,13 +340,12 @@ class Rec2DElement {
inline
int
getNumActions
()
const
{
return
_actions
.
size
();}
inline
Rec2DAction
*
getAction
(
int
i
)
const
{
return
_actions
[
i
];}
void
getUniqueActions
(
std
::
vector
<
Rec2DAction
*>&
)
const
;
void
getAssumedParities
(
int
*
)
const
;
void
getMoreEdges
(
std
::
vector
<
Rec2DEdge
*>&
)
const
;
void
getVertices
(
std
::
vector
<
Rec2DVertex
*>&
)
const
;
void
getUniqueActions
(
std
::
vector
<
Rec2DAction
*>&
)
const
;
static
Rec2DEdge
*
getCommonEdge
(
Rec2DElement
*
,
Rec2DElement
*
);
Rec2DVertex
*
getOtherVertex
(
Rec2DVertex
*
,
Rec2DVertex
*
)
const
;
static
Rec2DEdge
*
getCommonEdge
(
Rec2DElement
*
,
Rec2DElement
*
);
private
:
MQuadrangle
*
_createQuad
()
const
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment