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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
e02840df
Commit
e02840df
authored
13 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
cleanup
parent
28d5ade2
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Geo/GRbf.cpp
+78
-234
78 additions, 234 deletions
Geo/GRbf.cpp
Geo/gmshLevelset.cpp
+258
-153
258 additions, 153 deletions
Geo/gmshLevelset.cpp
with
336 additions
and
387 deletions
Geo/GRbf.cpp
+
78
−
234
View file @
e02840df
...
...
@@ -86,8 +86,9 @@ static void exportParametrizedMesh(fullMatrix<double> &UV, int nbNodes)
GRbf
::
GRbf
(
double
sizeBox
,
int
variableEps
,
int
rbfFun
,
std
::
map
<
MVertex
*
,
SVector3
>
_normals
,
std
::
set
<
MVertex
*>
allNodes
,
std
::
vector
<
MVertex
*>
bcNodes
,
bool
_isLocal
)
:
sBox
(
sizeBox
),
variableShapeParam
(
variableEps
),
radialFunctionIndex
(
rbfFun
),
_inUV
(
0
),
isLocal
(
_isLocal
)
:
isLocal
(
_isLocal
),
_inUV
(
0
),
sBox
(
sizeBox
),
variableShapeParam
(
variableEps
),
radialFunctionIndex
(
rbfFun
)
{
#if defined (HAVE_ANN)
XYZkdtree
=
0
;
...
...
@@ -125,7 +126,6 @@ GRbf::GRbf(double sizeBox, int variableEps, int rbfFun,
normals
.
resize
(
nbNodes
,
3
);
int
index
=
0
;
double
dist_min
=
1.e6
;
double
dist_max
=
1.e-6
;
for
(
std
::
set
<
MVertex
*>::
iterator
itv
=
myNodes
.
begin
();
itv
!=
myNodes
.
end
();
++
itv
){
MVertex
*
v1
=
*
itv
;
centers
(
index
,
0
)
=
v1
->
x
()
/
sBox
;
...
...
@@ -223,7 +223,6 @@ void GRbf::buildOctree(double radius)
if
(
l
.
size
()
==
1
)
printf
(
"*** WARNING: Found only %d sphere !
\n
"
,
(
int
)
l
.
size
());
for
(
std
::
vector
<
void
*>::
iterator
it
=
l
.
begin
();
it
!=
l
.
end
();
it
++
)
{
Sphere
*
sph
=
(
Sphere
*
)
*
it
;
std
::
vector
<
int
>
&
pts
=
nodesInSphere
[
i
];
if
(
sph
->
index
!=
i
)
nodesInSphere
[
i
].
push_back
(
sph
->
index
);
}
//printf("size node i =%d = %d \n", i , nodesInSphere[i].size());
...
...
@@ -285,7 +284,7 @@ void GRbf::computeLocalCurvature(const fullMatrix<double> &cntrs,
fullMatrix
<
double
>
nodes_in_sph
(
pts
.
size
(),
3
);
fullMatrix
<
double
>
LocalOper
;
for
(
int
k
=
0
;
k
<
pts
.
size
();
k
++
){
for
(
unsigned
int
k
=
0
;
k
<
pts
.
size
();
k
++
){
nodes_in_sph
(
k
,
0
)
=
cntrs
(
pts
[
k
],
0
);
nodes_in_sph
(
k
,
1
)
=
cntrs
(
pts
[
k
],
1
);
nodes_in_sph
(
k
,
2
)
=
cntrs
(
pts
[
k
],
2
);
...
...
@@ -336,6 +335,7 @@ double GRbf::evalRadialFnDer (int p, double dx, double dy, double dz, double ep)
case
222
:
return
ep
*
ep
*
(
3
+
ep
*
ep
*
2
*
r2
)
/
sqrt
((
1
+
ep
*
ep
*
r2
)
*
(
1
+
ep
*
ep
*
r2
)
*
(
1
+
ep
*
ep
*
r2
));
}
}
return
0.
;
}
fullMatrix
<
double
>
GRbf
::
generateRbfMat
(
int
p
,
...
...
@@ -477,7 +477,7 @@ void GRbf::RbfLapSurface_local_projection(const fullMatrix<double> &cntrs,
LocalOper
.
setAll
(
0.0
);
for
(
int
k
=
0
;
k
<
pts
.
size
();
k
++
){
for
(
unsigned
int
k
=
0
;
k
<
pts
.
size
();
k
++
){
nodes_in_sph
(
k
,
0
)
=
cntrs
(
pts
[
k
],
0
);
nodes_in_sph
(
k
,
1
)
=
cntrs
(
pts
[
k
],
1
);
nodes_in_sph
(
k
,
2
)
=
cntrs
(
pts
[
k
],
2
);
...
...
@@ -488,7 +488,7 @@ void GRbf::RbfLapSurface_local_projection(const fullMatrix<double> &cntrs,
RbfLapSurface_global_projection
(
nodes_in_sph
,
local_normals
,
LocalOper
);
for
(
int
j
=
0
;
j
<
pts
.
size
()
;
j
++
)
for
(
unsigned
int
j
=
0
;
j
<
pts
.
size
();
j
++
)
Oper
(
i
,
pts
[
j
])
=
LocalOper
(
0
,
j
);
}
}
...
...
@@ -614,13 +614,13 @@ void GRbf::RbfLapSurface_local_CPM_sparse(std::vector<MVertex*> &bndVertices, bo
std
::
vector
<
int
>
&
pts
=
nodesInSphere
[
i
];
if
(
bndIndices
.
count
(
i
)
>
0
)
{
sys
.
insertInSparsityPattern
(
i
,
i
);
for
(
int
j
=
0
;
j
<
pts
.
size
();
++
j
)
{
for
(
unsigned
int
j
=
0
;
j
<
pts
.
size
();
++
j
)
{
sys
.
insertInSparsityPattern
(
i
+
numNodes
,
pts
[
j
]);
sys
.
insertInSparsityPattern
(
i
+
2
*
numNodes
,
pts
[
j
]);
}
}
else
{
for
(
int
j
=
0
;
j
<
pts
.
size
();
++
j
)
{
for
(
unsigned
int
j
=
0
;
j
<
pts
.
size
();
++
j
)
{
sys
.
insertInSparsityPattern
(
i
,
pts
[
j
]);
sys
.
insertInSparsityPattern
(
i
+
numNodes
,
pts
[
j
]);
sys
.
insertInSparsityPattern
(
i
+
2
*
numNodes
,
pts
[
j
]);
...
...
@@ -833,8 +833,8 @@ void GRbf::RbfLapSurface_global_CPM_low(const fullMatrix<double> &cntrs,
for
(
int
j
=
0
;
j
<
nnTot
;
++
j
){
Oper
(
i
,
j
)
=
PLap
(
i
,
j
);
double
del
=
(
i
==
j
)
?
-
1.0
:
0.0
;
double
pos1
=
(
i
+
numNodes
==
j
)
?
1.0
:
0.0
;
double
pos2
=
(
i
+
2
*
numNodes
==
j
)
?
1.0
:
0.0
;
//
double pos1 = (i+numNodes == j) ? 1.0: 0.0;
//
double pos2 = (i+2*numNodes == j) ? 1.0: 0.0;
Oper
(
i
+
numNodes
,
j
)
=
del
+
Ix2extX
(
i
,
j
);
//+ pos1; //
Oper
(
i
+
2
*
numNodes
,
j
)
=
del
+
Ix2extX
(
i
+
numNodes
,
j
);
//+ pos2; //
}
...
...
@@ -854,7 +854,7 @@ void GRbf::solveHarmonicMap_sparse(linearSystem<double> &sys, int numNodes,
for
(
int
j
=
0
;
j
<
2
;
++
j
)
{
sys
.
zeroRightHandSide
();
//UNIT CIRCLE
for
(
int
i
=
0
;
i
<
bcNodes
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
bcNodes
.
size
();
i
++
)
{
std
::
set
<
MVertex
*>::
iterator
itN
=
myNodes
.
find
(
bcNodes
[
i
]);
if
(
itN
!=
myNodes
.
end
()){
std
::
map
<
MVertex
*
,
int
>::
iterator
itm
=
_mapV
.
find
(
bcNodes
[
i
]);
...
...
@@ -954,7 +954,7 @@ void GRbf::solveHarmonicMap(fullMatrix<double> Oper,
F
.
scale
(
0.0
);
//UNIT CIRCLE
for
(
int
i
=
0
;
i
<
bcNodes
.
size
();
i
++
){
for
(
unsigned
int
i
=
0
;
i
<
bcNodes
.
size
();
i
++
){
std
::
set
<
MVertex
*>::
iterator
itN
=
myNodes
.
find
(
bcNodes
[
i
]);
if
(
itN
!=
myNodes
.
end
()){
std
::
map
<
MVertex
*
,
int
>::
iterator
itm
=
_mapV
.
find
(
bcNodes
[
i
]);
...
...
@@ -1112,159 +1112,3 @@ bool GRbf::UVStoXYZ(const double u_eval, const double v_eval,
lastDXDV
=
dXdv
;
return
true
;
}
// bool GRbf::UVStoXYZ(const double u_eval, const double v_eval,
// double &XX, double &YY, double &ZZ,
// SVector3 &dXdu, SVector3& dXdv, int num_neighbours){
// //Finds the U,V,S (in the 0-level set) that are the 'num_neighbours' closest to u_eval and v_eval.
// //Thus in total, we're working with '3*num_neighbours' nodes
// //Say that the vector 'index' gives us the indices of the closest points
// bool converged = true;
// num_neighbours = 30;
// #if defined (HAVE_ANN)
// double uvw[3] = { u_eval, v_eval, 0.0 };
// ANNidxArray index = new ANNidx[num_neighbours];
// ANNdistArray dist = new ANNdist[num_neighbours];
// UVkdtree->annkSearch(uvw, num_neighbours, index, dist);
// int N_nbr = 5;//num_neighbours;
// fullMatrix<double> ux(N_nbr,3), uy(N_nbr,3), uz(N_nbr,3), u_temp(N_nbr,3);
// fullMatrix<double> nodes_eval(N_nbr,3),temp_nodes_eval(1,3),temp_u_temp(1,3);
// fullMatrix<double> u_vec(3*num_neighbours,3);
// fullMatrix<double> xyz_local(3*num_neighbours,3);
// // u_vec = [u v s] : These are the u,v,s that are on the surface *and* outside of it also!
// for (int i = 0; i < num_neighbours; i++){
// u_vec(i,0) = UV(index[i],0);
// u_vec(i,1) = UV(index[i],1);
// u_vec(i,2) = 0.0;
// u_vec(i+num_neighbours,0) = UV(index[i]+nbNodes,0);
// u_vec(i+num_neighbours,1) = UV(index[i]+nbNodes,1);
// u_vec(i+num_neighbours,2) = surfInterp(index[i]+nbNodes,0)*deltaUV;
// u_vec(i+2*num_neighbours,0) = UV(index[i]+2*nbNodes,0);
// u_vec(i+2*num_neighbours,1) = UV(index[i]+2*nbNodes,1);
// u_vec(i+2*num_neighbours,2) = surfInterp(index[i]+2*nbNodes,0)*deltaUV;
// xyz_local(i,0) = extendedX(index[i],0);
// xyz_local(i,1) = extendedX(index[i],1);
// xyz_local(i,2) = extendedX(index[i],2);
// xyz_local(i+num_neighbours,0) = extendedX(index[i]+nbNodes,0);
// xyz_local(i+num_neighbours,1) = extendedX(index[i]+nbNodes,1);
// xyz_local(i+num_neighbours,2) = extendedX(index[i]+nbNodes,2);
// xyz_local(i+2*num_neighbours,0) = extendedX(index[i]+2*nbNodes,0);
// xyz_local(i+2*num_neighbours,1) = extendedX(index[i]+2*nbNodes,1);
// xyz_local(i+2*num_neighbours,2) = extendedX(index[i]+2*nbNodes,2);
// }
// // u_vec_eval = [u_eval v_eval s_eval]
// fullMatrix<double> u_vec_eval(1, 3),nodes_vec_eval(1,3),u_test_vec_eval(1,3);
// u_vec_eval(0,0) = u_eval;
// u_vec_eval(0,1) = v_eval;
// u_vec_eval(0,2) = 0.0;
// //we will use a local interpolation to find the corresponding XYZ point to (u_eval,v_eval).
// _inUV = 1;
// evalRbfDer(0, u_vec, u_vec_eval,xyz_local, temp_nodes_eval);
// nodes_eval(0,0) = temp_nodes_eval(0,0);
// nodes_eval(0,1) = temp_nodes_eval(0,1);
// nodes_eval(0,2) = temp_nodes_eval(0,2);
// _inUV= 0;
// evalRbfDer(0,xyz_local,nodes_eval,u_vec,temp_u_temp);
// u_temp(0,0) = temp_u_temp(0,0);
// u_temp(0,1) = temp_u_temp(0,1);
// u_temp(0,2) = temp_u_temp(0,2);
// //we use the closest point
// for (int i_nbr = 1; i_nbr < N_nbr; i_nbr++){
// nodes_eval(i_nbr,0) = extendedX(index[i_nbr-1],0);
// nodes_eval(i_nbr,1) = extendedX(index[i_nbr-1],1);
// nodes_eval(i_nbr,2) = extendedX(index[i_nbr-1],2);
// u_temp(i_nbr,0) = UV(index[i_nbr-1],0);
// u_temp(i_nbr,1) = UV(index[i_nbr-1],1);
// u_temp(i_nbr,2) = 0.0;
// }
// delete [] index;
// delete [] dist;
// int incr = 0;
// double norm = 0.0;
// double norm_temp = 0.0;
// double dist_test = 0.0;
// fullMatrix<double> Jac(3,3),best_Jac(3,3);
// fullMatrix<double> normDist(N_nbr,1);
// fullMatrix<double> nodes_eval_temp(N_nbr,3);
// double norm_treshhold = 8.0;
// std::vector<fullMatrix<double> >JacV;
// while(norm < norm_treshhold && incr < 10){
// // Find the entries of the m Jacobians
// evalRbfDer(1,xyz_local,nodes_eval,u_vec,ux);
// evalRbfDer(2,xyz_local,nodes_eval,u_vec,uy);
// evalRbfDer(3,xyz_local,nodes_eval,u_vec,uz);
// for (int i_nbr = 0; i_nbr < N_nbr; i_nbr++){
// // Jacobian of the UVS coordinate system w.r.t. XYZ
// for (int k = 0; k < 3;k++){
// Jac(k,0) = ux(i_nbr,k);
// Jac(k,1) = uy(i_nbr,k);
// Jac(k,2) = uz(i_nbr,k);
// }
// Jac.invertInPlace();
// JacV.push_back(Jac);
// for (int j = 0; j< 3;j++)
// nodes_eval(i_nbr,j) = nodes_eval(i_nbr,j)
// + Jac(j,0)*( u_vec_eval(0,0) - u_temp(i_nbr,0))
// + Jac(j,1)*( u_vec_eval(0,1) - u_temp(i_nbr,1))
// + Jac(j,2)*( 0.0 - u_temp(i_nbr,2));
// }
// // Find the corresponding u, v, s
// evalRbfDer(0,xyz_local,nodes_eval,u_vec,u_temp);
// norm = 0;
// for (int i_nbr = 0; i_nbr < N_nbr; i_nbr++){
// normDist(i_nbr,0) = sqrt((u_temp(i_nbr,0)-u_vec_eval(0,0))*(u_temp(i_nbr,0)-u_vec_eval(0,0))+(u_temp(i_nbr,1)-u_vec_eval(0,1))*(u_temp(i_nbr,1)-u_vec_eval(0,1))+(u_temp(i_nbr,2)*u_temp(i_nbr,2)));
// norm_temp = -(log10(normDist(i_nbr,0)));
// if (norm_temp>norm_treshhold){
// norm = norm_temp;
// nodes_vec_eval(0,0)=nodes_eval(i_nbr,0);
// nodes_vec_eval(0,1)=nodes_eval(i_nbr,1);
// nodes_vec_eval(0,2)=nodes_eval(i_nbr,2);
// u_test_vec_eval(0,0)=u_temp(i_nbr,0);
// u_test_vec_eval(0,1)=u_temp(i_nbr,1);
// u_test_vec_eval(0,2)=u_temp(i_nbr,2);
// best_Jac = JacV[i_nbr];
// dist_test = normDist(i_nbr,0);
// i_nbr=N_nbr; //To get out of the for loof and thus also to get out of the while loop
// }
// }
// incr++;
// }
// if (norm < norm_treshhold ){
// printf("Newton not converged (norm=%g, dist=%g) for uv=(%g,%g) UVS=(%g,%g,%g) NB=%d \n", norm, dist_test,u_eval, v_eval, u_test_vec_eval(0,0), u_test_vec_eval(0,1), u_test_vec_eval(0,2), num_neighbours);
// if (num_neighbours+5 < nbNodes)
// return UVStoXYZ(u_eval, v_eval, XX, YY,ZZ, dXdu, dXdv, num_neighbours+5);
// else converged = false;
// }
// XX = nodes_vec_eval(0,0)*sBox;
// YY = nodes_vec_eval(0,1)*sBox;
// ZZ = nodes_vec_eval(0,2)*sBox;
// dXdu = SVector3(best_Jac(0,0)*sBox, best_Jac(1,0)*sBox, best_Jac(2,0)*sBox);
// dXdv = SVector3(best_Jac(0,1)*sBox, best_Jac(1,1)*sBox, best_Jac(2,1)*sBox);
// return converged;
// #endif
// }
This diff is collapsed.
Click to expand it.
Geo/gmshLevelset.cpp
+
258
−
153
View file @
e02840df
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