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
Model registry
Operate
Environments
Monitor
Incidents
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
Larry Price
gmsh
Commits
567a33ae
Commit
567a33ae
authored
13 years ago
by
Jean-François Remacle
Browse files
Options
Downloads
Patches
Plain Diff
Touchy commit : regularize the 1D mesh size
parent
f4d7ff4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Mesh/meshGEdge.cpp
+71
-8
71 additions, 8 deletions
Mesh/meshGEdge.cpp
with
71 additions
and
8 deletions
Mesh/meshGEdge.cpp
+
71
−
8
View file @
567a33ae
...
@@ -19,9 +19,65 @@
...
@@ -19,9 +19,65 @@
typedef
struct
{
typedef
struct
{
int
Num
;
int
Num
;
double
t
,
lc
,
p
;
// t is the local coordinate of the point
// lc is x'(t)/h((x(t))
// p is the value of the primitive
// xp is the norm of the tangent vector
double
t
,
lc
,
p
,
xp
;
}
IntPoint
;
}
IntPoint
;
static
double
smoothPrimitive
(
GEdge
*
ge
,
double
alpha
,
std
::
vector
<
IntPoint
>
&
Points
)
{
for
(
int
i
=
0
;
i
<
Points
.
size
();
i
++
){
IntPoint
&
pt
=
Points
[
i
];
SVector3
der
=
ge
->
firstDer
(
pt
.
t
);
pt
.
xp
=
der
.
norm
();
}
int
ITER
=
0
;
while
(
1
){
int
count1
=
0
;
int
count2
=
0
;
// use a gauss-seidel iteration
// iterate forward and then backward
// convergence is usually very fast.
for
(
int
i
=
1
;
i
<
Points
.
size
();
i
++
){
double
hprime
;
hprime
=
((
Points
[
i
].
xp
/
Points
[
i
].
lc
)
-
(
Points
[
i
-
1
].
xp
/
Points
[
i
-
1
].
lc
))
/
(
Points
[
i
].
t
-
Points
[
i
-
1
].
t
);
if
(
hprime
*
Points
[
i
].
xp
>
alpha
*
1.01
){
double
hnew
=
Points
[
i
-
1
].
xp
/
Points
[
i
-
1
].
lc
+
(
Points
[
i
].
t
-
Points
[
i
-
1
].
t
)
*
alpha
/
Points
[
i
].
xp
;
Points
[
i
].
lc
=
Points
[
i
].
xp
/
hnew
;
count1
++
;
}
}
for
(
int
i
=
Points
.
size
()
-
1
;
i
>
0
;
i
--
){
double
hprime
;
hprime
=
((
Points
[
i
].
xp
/
Points
[
i
].
lc
)
-
(
Points
[
i
-
1
].
xp
/
Points
[
i
-
1
].
lc
))
/
(
Points
[
i
].
t
-
Points
[
i
-
1
].
t
);
if
(
-
hprime
*
Points
[
i
].
xp
>
alpha
*
1.01
){
double
hnew
=
Points
[
i
].
xp
/
Points
[
i
].
lc
+
(
Points
[
i
].
t
-
Points
[
i
-
1
].
t
)
*
alpha
/
Points
[
i
-
1
].
xp
;
Points
[
i
-
1
].
lc
=
Points
[
i
-
1
].
xp
/
hnew
;
count2
++
;
}
}
++
ITER
;
if
(
ITER
>
1000
){
printf
(
"OUUUUUH
\n
"
);
break
;}
if
(
!
(
count1
+
count2
))
break
;
}
// recompute the primitive
for
(
int
i
=
1
;
i
<
Points
.
size
();
i
++
){
IntPoint
&
pt2
=
Points
[
i
];
IntPoint
&
pt1
=
Points
[
i
-
1
];
pt2
.
p
=
pt1
.
p
+
(
pt2
.
t
-
pt1
.
t
)
*
0.5
*
(
pt2
.
lc
+
pt1
.
lc
);
}
return
Points
[
Points
.
size
()
-
1
].
p
;
}
static
double
F_Lc
(
GEdge
*
ge
,
double
t
)
static
double
F_Lc
(
GEdge
*
ge
,
double
t
)
{
{
GPoint
p
=
ge
->
point
(
t
);
GPoint
p
=
ge
->
point
(
t
);
...
@@ -39,13 +95,13 @@ static double F_Lc(GEdge *ge, double t)
...
@@ -39,13 +95,13 @@ static double F_Lc(GEdge *ge, double t)
lc_here
=
BGM_MeshSize
(
ge
,
t
,
0
,
p
.
x
(),
p
.
y
(),
p
.
z
());
lc_here
=
BGM_MeshSize
(
ge
,
t
,
0
,
p
.
x
(),
p
.
y
(),
p
.
z
());
SVector3
der
=
ge
->
firstDer
(
t
);
SVector3
der
=
ge
->
firstDer
(
t
);
//
const double d = norm(der);
const
double
d
=
norm
(
der
);
//
return d / lc_here;
return
d
/
lc_here
;
SMetric3
metric
(
1.
/
(
lc_here
*
lc_here
));
//
SMetric3 metric(1. / (lc_here * lc_here));
double
lSquared
=
dot
(
der
,
metric
,
der
);
//
double lSquared = dot(der, metric, der);
return
sqrt
(
lSquared
);
//
return sqrt(lSquared);
}
}
static
double
F_Lc_aniso
(
GEdge
*
ge
,
double
t
)
static
double
F_Lc_aniso
(
GEdge
*
ge
,
double
t
)
...
@@ -245,7 +301,7 @@ static void printFandPrimitive(int tag, std::vector<IntPoint> &Points)
...
@@ -245,7 +301,7 @@ static void printFandPrimitive(int tag, std::vector<IntPoint> &Points)
FILE
*
f
=
fopen
(
name
,
"w"
);
FILE
*
f
=
fopen
(
name
,
"w"
);
for
(
unsigned
int
i
=
0
;
i
<
Points
.
size
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
Points
.
size
();
i
++
){
const
IntPoint
&
P
=
Points
[
i
];
const
IntPoint
&
P
=
Points
[
i
];
fprintf
(
f
,
"%g %g %g
\n
"
,
P
.
t
,
1.
/
P
.
lc
,
P
.
p
);
fprintf
(
f
,
"%g %g
%g
%g
\n
"
,
P
.
t
,
1.
/
P
.
lc
,
P
.
p
,
P
.
lc
);
}
}
fclose
(
f
);
fclose
(
f
);
}
}
...
@@ -330,11 +386,18 @@ void meshGEdge::operator() (GEdge *ge)
...
@@ -330,11 +386,18 @@ void meshGEdge::operator() (GEdge *ge)
if
(
CTX
::
instance
()
->
mesh
.
algo2d
==
ALGO_2D_BAMG
||
blf
if
(
CTX
::
instance
()
->
mesh
.
algo2d
==
ALGO_2D_BAMG
||
blf
/* FIXME || CTX::instance()->mesh.algo2d == ALGO_2D_FRONTAL_QUAD */
)
{
/* FIXME || CTX::instance()->mesh.algo2d == ALGO_2D_FRONTAL_QUAD */
)
{
a
=
Integration
(
ge
,
t_begin
,
t_end
,
F_Lc_aniso
,
Points
,
a
=
Integration
(
ge
,
t_begin
,
t_end
,
F_Lc_aniso
,
Points
,
CTX
::
instance
()
->
mesh
.
lcIntegrationPrecision
);
CTX
::
instance
()
->
mesh
.
lcIntegrationPrecision
);
// printFandPrimitive(ge->tag()+10000, Points);
}
}
else
else
a
=
Integration
(
ge
,
t_begin
,
t_end
,
F_Lc
,
Points
,
a
=
Integration
(
ge
,
t_begin
,
t_end
,
F_Lc
,
Points
,
CTX
::
instance
()
->
mesh
.
lcIntegrationPrecision
);
CTX
::
instance
()
->
mesh
.
lcIntegrationPrecision
);
// FIXME JF : MAYBE WE SHOULD NOT ALWAYS SMOOTH THE 1D MESH SIZE FIELD ??
printFandPrimitive
(
ge
->
tag
(),
Points
);
a
=
smoothPrimitive
(
ge
,
CTX
::
instance
()
->
mesh
.
smoothRatio
*
CTX
::
instance
()
->
mesh
.
smoothRatio
,
Points
);
printFandPrimitive
(
ge
->
tag
()
+
10000
,
Points
);
N
=
std
::
max
(
ge
->
minimumMeshSegments
()
+
1
,
(
int
)(
a
+
1.
));
N
=
std
::
max
(
ge
->
minimumMeshSegments
()
+
1
,
(
int
)(
a
+
1.
));
}
}
...
...
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