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
edf78661
Commit
edf78661
authored
20 years ago
by
Jean-François Remacle
Browse files
Options
Downloads
Patches
Plain Diff
*** empty log message ***
parent
5c463426
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Common/AdaptiveViews.cpp
+96
-18
96 additions, 18 deletions
Common/AdaptiveViews.cpp
Common/GmshMatrix.h
+117
-11
117 additions, 11 deletions
Common/GmshMatrix.h
Common/Views.h
+2
-0
2 additions, 0 deletions
Common/Views.h
with
215 additions
and
29 deletions
Common/AdaptiveViews.cpp
+
96
−
18
View file @
edf78661
...
@@ -64,6 +64,7 @@ void _triangle::clean ()
...
@@ -64,6 +64,7 @@ void _triangle::clean ()
}
}
void
_triangle
::
Create
(
int
maxlevel
,
Double_Matrix
*
coeffs
,
Double_Matrix
*
eexps
)
void
_triangle
::
Create
(
int
maxlevel
,
Double_Matrix
*
coeffs
,
Double_Matrix
*
eexps
)
{
{
printf
(
"creating the sub-elements
\n
"
);
int
level
=
0
;
int
level
=
0
;
clean
();
clean
();
_point
*
p1
=
_point
::
New
(
0
,
0
,
0
,
coeffs
,
eexps
);
_point
*
p1
=
_point
::
New
(
0
,
0
,
0
,
coeffs
,
eexps
);
...
@@ -71,6 +72,8 @@ void _triangle::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexp
...
@@ -71,6 +72,8 @@ void _triangle::Create (int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexp
_point
*
p3
=
_point
::
New
(
1
,
0
,
0
,
coeffs
,
eexps
);
_point
*
p3
=
_point
::
New
(
1
,
0
,
0
,
coeffs
,
eexps
);
_triangle
*
t
=
new
_triangle
(
p1
,
p2
,
p3
);
_triangle
*
t
=
new
_triangle
(
p1
,
p2
,
p3
);
Recur_Create
(
t
,
maxlevel
,
level
,
coeffs
,
eexps
)
;
Recur_Create
(
t
,
maxlevel
,
level
,
coeffs
,
eexps
)
;
printf
(
"%d _triangle and %d _point created
\n
"
,
_triangle
::
all_triangles
.
size
(),
_point
::
all_points
.
size
());
}
}
void
_triangle
::
Recur_Create
(
_triangle
*
t
,
int
maxlevel
,
int
level
,
Double_Matrix
*
coeffs
,
Double_Matrix
*
eexps
)
void
_triangle
::
Recur_Create
(
_triangle
*
t
,
int
maxlevel
,
int
level
,
Double_Matrix
*
coeffs
,
Double_Matrix
*
eexps
)
{
{
...
@@ -93,6 +96,7 @@ void _triangle::Recur_Create (_triangle *t, int maxlevel, int level , Double_Mat
...
@@ -93,6 +96,7 @@ void _triangle::Recur_Create (_triangle *t, int maxlevel, int level , Double_Mat
_triangle
*
t4
=
new
_triangle
(
p12
,
p23
,
p13
);
_triangle
*
t4
=
new
_triangle
(
p12
,
p23
,
p13
);
Recur_Create
(
t4
,
maxlevel
,
level
,
coeffs
,
eexps
);
Recur_Create
(
t4
,
maxlevel
,
level
,
coeffs
,
eexps
);
t
->
t
[
0
]
=
t1
;
t
->
t
[
1
]
=
t2
;
t
->
t
[
2
]
=
t3
;
t
->
t
[
3
]
=
t4
;
t
->
t
[
0
]
=
t1
;
t
->
t
[
1
]
=
t2
;
t
->
t
[
2
]
=
t3
;
t
->
t
[
3
]
=
t4
;
}
}
void
_triangle
::
Error
(
double
AVG
,
double
tol
)
void
_triangle
::
Error
(
double
AVG
,
double
tol
)
...
@@ -173,31 +177,63 @@ void _triangle::Recur_Error ( _triangle *t, double AVG, double tol )
...
@@ -173,31 +177,63 @@ void _triangle::Recur_Error ( _triangle *t, double AVG, double tol )
}
}
}
}
static
double
t0
,
t1
,
t2
,
t3
;
void
Adaptive_Post_View
::
zoomElement
(
Post_View
*
view
,
void
Adaptive_Post_View
::
zoomElement
(
Post_View
*
view
,
int
ielem
,
int
level
,
GMSH_Post_Plugin
*
plug
)
int
ielem
,
int
level
,
GMSH_Post_Plugin
*
plug
)
{
{
std
::
set
<
_point
>::
iterator
it
=
_point
::
all_points
.
begin
();
std
::
set
<
_point
>::
iterator
it
=
_point
::
all_points
.
begin
();
std
::
set
<
_point
>::
iterator
ite
=
_point
::
all_points
.
end
();
std
::
set
<
_point
>::
iterator
ite
=
_point
::
all_points
.
end
();
clock_t
c0
=
clock
();
const
int
N
=
_coefs
->
size1
();
Double_Vector
val
(
N
),
res
(
_point
::
all_points
.
size
());
Double_Matrix
xyz
(
3
,
3
);
Double_Matrix
XYZ
(
_point
::
all_points
.
size
(),
3
);
for
(
int
k
=
0
;
k
<
3
;
++
k
)
{
xyz
(
k
,
0
)
=
(
*
_STposX
)
(
ielem
,
k
);
xyz
(
k
,
1
)
=
(
*
_STposY
)
(
ielem
,
k
);
xyz
(
k
,
2
)
=
(
*
_STposZ
)
(
ielem
,
k
);
}
for
(
int
k
=
0
;
k
<
N
;
++
k
)
{
val
(
k
)
=
(
*
_STval
)(
ielem
,
k
);
}
_Interpolate
->
mult
(
val
,
res
);
_Geometry
->
mult
(
xyz
,
XYZ
);
clock_t
c1
=
clock
();
int
kk
=
0
;
for
(
;
it
!=
ite
;
++
it
)
for
(
;
it
!=
ite
;
++
it
)
{
{
_point
*
p
=
(
_point
*
)
&
(
*
it
);
_point
*
p
=
(
_point
*
)
&
(
*
it
);
p
->
val
=
0
;
p
->
val
=
res
(
kk
);
for
(
int
k
=
0
;
k
<
_coefs
->
size1
();
++
k
)
// for ( int k=0;k<N;++k)
{
// {
p
->
val
+=
it
->
shape_functions
[
k
]
*
(
*
_STval
)(
ielem
,
k
);
// p->val += p->shape_functions[k] * (*_STval )( ielem , k );
}
// }
p
->
X
=
(
*
_STposX
)
(
ielem
,
0
)
*
(
1.
-
p
->
x
-
p
->
y
)
+
(
*
_STposX
)
(
ielem
,
1
)
*
p
->
x
+
(
*
_STposX
)
(
ielem
,
2
)
*
p
->
y
;
// p->X = (*_STposX) ( ielem , 0 ) * ( 1.-p->x-p->y) + (*_STposX) ( ielem , 1 ) * p->x + (*_STposX) ( ielem , 2 ) * p->y;
p
->
Y
=
(
*
_STposY
)
(
ielem
,
0
)
*
(
1.
-
p
->
x
-
p
->
y
)
+
(
*
_STposY
)
(
ielem
,
1
)
*
p
->
x
+
(
*
_STposY
)
(
ielem
,
2
)
*
p
->
y
;
// p->Y = (*_STposY) ( ielem , 0 ) * ( 1.-p->x-p->y) + (*_STposY) ( ielem , 1 ) * p->x + (*_STposY) ( ielem , 2 ) * p->y;
p
->
Z
=
(
*
_STposZ
)
(
ielem
,
0
)
*
(
1.
-
p
->
x
-
p
->
y
)
+
(
*
_STposZ
)
(
ielem
,
1
)
*
p
->
x
+
(
*
_STposZ
)
(
ielem
,
2
)
*
p
->
y
;
// p->Z = (*_STposZ) ( ielem , 0 ) * ( 1.-p->x-p->y) + (*_STposZ) ( ielem , 1 ) * p->x + (*_STposZ) ( ielem , 2 ) * p->y;
if
(
level
==
0
)
p
->
X
=
XYZ
(
kk
,
0
);
{
p
->
Y
=
XYZ
(
kk
,
1
);
if
(
min
>
p
->
val
)
min
=
p
->
val
;
p
->
Z
=
XYZ
(
kk
,
2
);
if
(
max
<
p
->
val
)
max
=
p
->
val
;
}
if
(
min
>
p
->
val
)
min
=
p
->
val
;
if
(
max
<
p
->
val
)
max
=
p
->
val
;
kk
++
;
}
}
clock_t
c2
=
clock
();
std
::
list
<
_triangle
*>::
iterator
itt
=
_triangle
::
all_triangles
.
begin
();
std
::
list
<
_triangle
*>::
iterator
itt
=
_triangle
::
all_triangles
.
begin
();
std
::
list
<
_triangle
*>::
iterator
itte
=
_triangle
::
all_triangles
.
end
();
std
::
list
<
_triangle
*>::
iterator
itte
=
_triangle
::
all_triangles
.
end
();
...
@@ -210,8 +246,9 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
...
@@ -210,8 +246,9 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
if
(
plug
)
if
(
plug
)
plug
->
assign_specific_visibility
();
plug
->
assign_specific_visibility
();
else
else
_triangle
::
Error
(
max
-
min
,
tol
);
_triangle
::
Error
(
max
-
min
,
tol
);
clock_t
c3
=
clock
();
itt
=
_triangle
::
all_triangles
.
begin
();
itt
=
_triangle
::
all_triangles
.
begin
();
for
(
;
itt
!=
itte
;
itt
++
)
for
(
;
itt
!=
itte
;
itt
++
)
{
{
...
@@ -235,6 +272,13 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
...
@@ -235,6 +272,13 @@ void Adaptive_Post_View:: zoomElement (Post_View * view ,
view
->
NbST
++
;
view
->
NbST
++
;
}
}
}
}
clock_t
c4
=
clock
();
t0
+=
(
double
)(
c1
-
c0
)
/
CLOCKS_PER_SEC
;
t1
+=
(
double
)(
c2
-
c1
)
/
CLOCKS_PER_SEC
;
t2
+=
(
double
)(
c3
-
c2
)
/
CLOCKS_PER_SEC
;
t3
+=
(
double
)(
c4
-
c3
)
/
CLOCKS_PER_SEC
;
}
}
void
Adaptive_Post_View
::
setAdaptiveResolutionLevel
(
Post_View
*
view
,
int
level
,
GMSH_Post_Plugin
*
plug
)
void
Adaptive_Post_View
::
setAdaptiveResolutionLevel
(
Post_View
*
view
,
int
level
,
GMSH_Post_Plugin
*
plug
)
...
@@ -245,17 +289,48 @@ void Adaptive_Post_View:: setAdaptiveResolutionLevel (Post_View * view , int lev
...
@@ -245,17 +289,48 @@ void Adaptive_Post_View:: setAdaptiveResolutionLevel (Post_View * view , int lev
_triangle
::
Create
(
level
,
_coefs
,
_eexps
);
_triangle
::
Create
(
level
,
_coefs
,
_eexps
);
std
::
set
<
_point
>::
iterator
it
=
_point
::
all_points
.
begin
();
std
::
set
<
_point
>::
iterator
ite
=
_point
::
all_points
.
end
();
const
int
N
=
_coefs
->
size1
();
if
(
_Interpolate
)
delete
_Interpolate
;
if
(
_Geometry
)
delete
_Geometry
;
_Interpolate
=
new
Double_Matrix
(
_point
::
all_points
.
size
(),
N
);
_Geometry
=
new
Double_Matrix
(
_point
::
all_points
.
size
(),
3
);
int
kk
=
0
;
for
(
;
it
!=
ite
;
++
it
)
{
_point
*
p
=
(
_point
*
)
&
(
*
it
);
for
(
int
k
=
0
;
k
<
N
;
++
k
)
{
(
*
_Interpolate
)(
kk
,
k
)
=
p
->
shape_functions
[
k
];
}
(
*
_Geometry
)(
kk
,
0
)
=
(
1.
-
p
->
x
-
p
->
y
);
(
*
_Geometry
)(
kk
,
1
)
=
p
->
x
;
(
*
_Geometry
)(
kk
,
2
)
=
p
->
y
;
kk
++
;
}
List_Delete
(
view
->
ST
);
view
->
ST
=
0
;
List_Delete
(
view
->
ST
);
view
->
ST
=
0
;
view
->
NbST
=
0
;
view
->
NbST
=
0
;
/// for now, that's all we do, 1 TS
/// for now, that's all we do, 1 TS
view
->
NbTimeStep
=
1
;
view
->
NbTimeStep
=
1
;
int
nbelm
=
_STposX
->
size1
();
int
nbelm
=
_STposX
->
size1
();
view
->
ST
=
List_Create
(
nbelm
*
(
int
)
pow
(
4.
,
level
),
nbelm
*
12
,
sizeof
(
double
));
view
->
ST
=
List_Create
(
nbelm
*
4
,
nbelm
,
sizeof
(
double
));
t0
=
t1
=
t2
=
t3
=
0
;
for
(
int
i
=
0
;
i
<
nbelm
;
++
i
)
for
(
int
i
=
0
;
i
<
nbelm
;
++
i
)
{
{
zoomElement
(
view
,
i
,
level
,
plug
);
zoomElement
(
view
,
i
,
level
,
plug
);
}
}
printf
(
"finished %g %g %g %g
\n
"
,
t0
,
t1
,
t2
,
t3
);
view
->
Changed
=
1
;
view
->
Changed
=
1
;
presentZoomLevel
=
level
;
presentZoomLevel
=
level
;
presentTol
=
tol
;
presentTol
=
tol
;
...
@@ -322,6 +397,7 @@ Adaptive_Post_View:: Adaptive_Post_View (Post_View *view, List_T *_c , List_T *_
...
@@ -322,6 +397,7 @@ Adaptive_Post_View:: Adaptive_Post_View (Post_View *view, List_T *_c , List_T *_
:
tol
(
1.e-3
)
:
tol
(
1.e-3
)
{
{
_Interpolate
=
_Geometry
=
0
;
_coefs
=
new
Double_Matrix
(
List_Nbr
(
_c
)
,
List_Nbr
(
_c
)
);
_coefs
=
new
Double_Matrix
(
List_Nbr
(
_c
)
,
List_Nbr
(
_c
)
);
_eexps
=
new
Double_Matrix
(
List_Nbr
(
_c
)
,
3
);
_eexps
=
new
Double_Matrix
(
List_Nbr
(
_c
)
,
3
);
...
@@ -359,5 +435,7 @@ Adaptive_Post_View::~Adaptive_Post_View()
...
@@ -359,5 +435,7 @@ Adaptive_Post_View::~Adaptive_Post_View()
delete
_STposY
;
delete
_STposY
;
delete
_STposZ
;
delete
_STposZ
;
delete
_STval
;
delete
_STval
;
if
(
_Interpolate
)
delete
_Interpolate
;
if
(
_Geometry
)
delete
_Geometry
;
_triangle
::
clean
();
_triangle
::
clean
();
}
}
This diff is collapsed.
Click to expand it.
Common/GmshMatrix.h
+
117
−
11
View file @
edf78661
#ifndef _GMSH_BOOSTMATRIX_
#ifndef _GMSH_BOOSTMATRIX_
#define _GMSH_BOOSTMATRIX_
#define _GMSH_BOOSTMATRIX_
#ifndef HAVE_BOOST
template
<
class
SCALAR
>
template
<
class
SCALAR
>
class
Gmsh_Matrix
class
Gmsh_Matrix
{
{
...
@@ -46,17 +45,124 @@ public:
...
@@ -46,17 +45,124 @@ public:
}
}
};
};
typedef
Gmsh_Matrix
<
double
>
Double_Matrix
;
template
<
class
SCALAR
>
typedef
Gmsh_Matrix
<
int
>
Int_Matrix
;
class
Gmsh_Vector
{
private:
int
r
;
public:
inline
int
size
()
const
{
return
r
;}
SCALAR
*
data
;
~
Gmsh_Vector
()
{
delete
[]
data
;}
Gmsh_Vector
(
int
R
)
:
r
(
R
)
{
data
=
new
SCALAR
[
r
];
scal
(
0
);
}
Gmsh_Vector
(
const
Gmsh_Vector
<
SCALAR
>
&
other
)
:
r
(
other
.
r
)
{
data
=
new
double
[
r
];
copy
(
other
.
data
)
;
}
inline
SCALAR
operator
()
(
int
i
)
const
{
return
data
[
i
];
}
inline
SCALAR
&
operator
()
(
int
i
)
{
return
data
[
i
];
}
inline
SCALAR
operator
*
(
const
Gmsh_Vector
<
SCALAR
>
&
other
)
{
throw
;
}
inline
void
scal
(
const
SCALAR
s
)
{
for
(
int
i
=
0
;
i
<
r
;
++
i
)
data
[
i
]
*=
s
;
}
inline
void
copy
(
const
SCALAR
**
other
)
{
for
(
int
i
=
0
;
i
<
r
;
++
i
)
data
[
i
]
=
other
.
data
[
i
];
}
};
#ifdef HAVE_GSL
#include
<gsl/gsl_matrix.h>
#include
<gsl/gsl_blas.h>
class
GSL_Vector
{
private:
int
r
,
c
;
public:
inline
int
size
()
const
{
return
r
;}
gsl_vector
*
data
;
~
GSL_Vector
()
{
gsl_vector_free
(
data
);}
GSL_Vector
(
int
R
)
:
r
(
R
)
{
data
=
gsl_vector_calloc
(
r
);
}
GSL_Vector
(
const
GSL_Vector
&
other
)
:
r
(
other
.
r
)
{
data
=
gsl_vector_calloc
(
r
);
gsl_vector_memcpy
(
data
,
other
.
data
);
}
inline
double
operator
()
(
int
i
)
const
{
return
gsl_vector_get
(
data
,
i
);
}
inline
double
&
operator
()
(
int
i
)
{
return
*
gsl_vector_ptr
(
data
,
i
);
}
};
class
GSL_Matrix
{
private:
int
r
,
c
;
public:
inline
int
size1
()
const
{
return
r
;}
inline
int
size2
()
const
{
return
c
;}
gsl_matrix
*
data
;
~
GSL_Matrix
()
{
gsl_matrix_free
(
data
);}
GSL_Matrix
(
int
R
,
int
C
)
:
r
(
R
),
c
(
C
)
{
data
=
gsl_matrix_calloc
(
r
,
c
);
}
GSL_Matrix
(
const
GSL_Matrix
&
other
)
:
r
(
other
.
r
),
c
(
other
.
c
)
{
data
=
gsl_matrix_calloc
(
r
,
c
);
gsl_matrix_memcpy
(
data
,
other
.
data
);
}
inline
double
operator
()
(
int
i
,
int
j
)
const
{
return
gsl_matrix_get
(
data
,
i
,
j
);
}
inline
double
&
operator
()
(
int
i
,
int
j
)
{
return
*
gsl_matrix_ptr
(
data
,
i
,
j
);
}
inline
void
mult
(
const
GSL_Matrix
&
x
,
const
GSL_Matrix
&
b
)
{
gsl_blas_dgemm
(
CblasNoTrans
,
CblasNoTrans
,
1.0
,
data
,
x
.
data
,
1.0
,
b
.
data
);
}
inline
void
mult
(
const
GSL_Vector
&
x
,
GSL_Vector
&
b
)
{
gsl_blas_dgemv
(
CblasNoTrans
,
1.0
,
data
,
x
.
data
,
1.0
,
b
.
data
);
}
};
typedef
GSL_Matrix
Double_Matrix
;
typedef
GSL_Vector
Double_Vector
;
#else
#else
#include
<boost/numeric/ublas/vector.hpp>
typedef
Gmsh_Matrix
<
double
>
Double_Matrix
;
#include
<boost/numeric/ublas/matrix.hpp>
typedef
Gmsh_Vector
<
double
>
Double_Vector
;
#include
<boost/numeric/ublas/blas.hpp>
#include
<boost/numeric/ublas/io.hpp>
typedef
numerics
::
matrix
<
double
,
numerics
::
column_major
>
Double_Matrix
;
typedef
numerics
::
vector
<
double
>
Double_Vector
;
typedef
numerics
::
matrix
<
int
,
numerics
::
column_major
>
Int_Matrix
;
typedef
numerics
::
vector
<
int
>
Int_Vector
;
#endif
#endif
typedef
Gmsh_Matrix
<
int
>
Int_Matrix
;
typedef
Gmsh_Vector
<
int
>
Int_Vector
;
#endif
#endif
This diff is collapsed.
Click to expand it.
Common/Views.h
+
2
−
0
View file @
edf78661
...
@@ -108,6 +108,8 @@ class Adaptive_Post_View
...
@@ -108,6 +108,8 @@ class Adaptive_Post_View
Double_Matrix
*
_STposY
;
Double_Matrix
*
_STposY
;
Double_Matrix
*
_STposZ
;
Double_Matrix
*
_STposZ
;
Double_Matrix
*
_STval
;
Double_Matrix
*
_STval
;
Double_Matrix
*
_Interpolate
;
Double_Matrix
*
_Geometry
;
public:
public:
Adaptive_Post_View
(
Post_View
*
view
,
List_T
*
_coeffs
,
List_T
*
_eexps
);
Adaptive_Post_View
(
Post_View
*
view
,
List_T
*
_coeffs
,
List_T
*
_eexps
);
~
Adaptive_Post_View
();
~
Adaptive_Post_View
();
...
...
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