Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
757bd2a2
Commit
757bd2a2
authored
Sep 21, 2020
by
Kirill Terekhov
Browse files
tweaks to DrawGrid
parent
744dbea5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Examples/ADMFD/diffusion.cpp
View file @
757bd2a2
...
...
@@ -97,18 +97,18 @@ int main(int argc,char ** argv)
}
#endif
{
// prepare geometrical data on the mesh
ttt
=
Timer
();
Mesh
::
GeomParam
table
;
table
[
CENTROID
]
=
CELL
|
FACE
;
//Compute averaged center of mass
table
[
NORMAL
]
=
FACE
;
//Compute normals
table
[
ORIENTATION
]
=
FACE
;
//Check and fix normal orientation
table
[
MEASURE
]
=
CELL
|
FACE
;
//Compute volumes and areas
table
[
BARYCENTER
]
=
CELL
|
FACE
;
//Compute volumetric center of mass
m
->
PrepareGeometricData
(
table
);
//Ask to precompute the data
BARRIER
if
(
m
->
GetProcessorRank
()
==
0
)
std
::
cout
<<
"Prepare geometric data: "
<<
Timer
()
-
ttt
<<
std
::
endl
;
}
//
{ // prepare geometrical data on the mesh
ttt
=
Timer
();
Mesh
::
GeomParam
table
;
//~
table[CENTROID] = CELL | FACE; //Compute averaged center of mass
table
[
NORMAL
]
=
FACE
;
//Compute normals
table
[
ORIENTATION
]
=
FACE
;
//Check and fix normal orientation
table
[
MEASURE
]
=
CELL
|
FACE
;
//Compute volumes and areas
table
[
BARYCENTER
]
=
CELL
|
FACE
;
//Compute volumetric center of mass
m
->
PrepareGeometricData
(
table
);
//Ask to precompute the data
BARRIER
if
(
m
->
GetProcessorRank
()
==
0
)
std
::
cout
<<
"Prepare geometric data: "
<<
Timer
()
-
ttt
<<
std
::
endl
;
//
}
// data tags for
Tag
tag_P
;
// Pressure
...
...
@@ -136,18 +136,18 @@ int main(int argc,char ** argv)
if
(
!
tag_K
.
isValid
()
||
!
tag_K
.
isDefined
(
CELL
)
)
// diffusion tensor was not initialized or was not defined on cells.
{
tag_K
=
m
->
CreateTag
(
"PERM"
,
DATA_REAL
,
CELL
,
NONE
,
6
);
// create a new tag for symmetric diffusion tensor K
tag_K
=
m
->
CreateTag
(
"PERM"
,
DATA_REAL
,
CELL
,
NONE
,
1
);
// create a new tag for symmetric diffusion tensor K
for
(
int
q
=
0
;
q
<
m
->
CellLastLocalID
();
++
q
)
if
(
m
->
isValidCell
(
q
)
)
// loop over mesh cells
{
Cell
cell
=
m
->
CellByLocalID
(
q
);
real_array
K
=
cell
->
RealArray
(
tag_K
);
// assign a symmetric positive definite tensor K
K
[
0
]
=
1.0
;
//XX
K
[
1
]
=
0.0
;
//XY
K
[
2
]
=
0.0
;
//XZ
K
[
3
]
=
1.0
;
//YY
K
[
4
]
=
0.0
;
//YZ
K
[
5
]
=
1.0
;
//ZZ
//~
K[1] = 0.0; //XY
//~
K[2] = 0.0; //XZ
//~
K[3] = 1.0; //YY
//~
K[4] = 0.0; //YZ
//~
K[5] = 1.0; //ZZ
}
m
->
ExchangeData
(
tag_K
,
CELL
,
0
);
//Exchange diffusion tensor
...
...
@@ -572,6 +572,12 @@ int main(int argc,char ** argv)
}
else
std
::
cout
<<
"Reference solution was not defined on faces"
<<
std
::
endl
;
}
tag_W
=
m
->
DeleteTag
(
tag_W
);
tag_WG
=
m
->
DeleteTag
(
tag_WG
);
tag_K
=
m
->
DeleteTag
(
tag_K
);
tag_BC
=
m
->
DeleteTag
(
tag_BC
);
m
->
RemoveGeometricData
(
table
);
if
(
m
->
GetProcessorsNumber
()
==
1
)
m
->
Save
(
"out.vtk"
);
...
...
Examples/DrawGrid/main.cpp
View file @
757bd2a2
...
...
@@ -2005,12 +2005,12 @@ void draw_screen()
if
(
current_picker
!=
NULL
)
{
delete
current_picker
;
current_picker
=
NULL
;}
if
(
!
clip_boundary
.
empty
()
)
current_picker
=
new
picker
(
clip_boundary
);
if
(
pick_element
&&
!
clip_boundary
.
empty
()
)
current_picker
=
new
picker
(
clip_boundary
);
}
if
(
current_picker
!=
NULL
)
if
(
pick_element
&&
current_picker
!=
NULL
)
{
pick_mouse
(
pickp
,
pickd
);
picked
=
current_picker
->
select
(
pickp
,
pickd
);
...
...
@@ -2054,14 +2054,14 @@ void draw_screen()
{
glPrintError
();
if
(
!
(
drawedges
==
2
||
drawedges
==
3
))
draw_faces
(
clip_boundary
,
picked
);
draw_faces
(
clip_boundary
,
pick_element
?
picked
:
-
1
);
//~ std::cout << "draw faces passed" << std::endl;
glPrintError
();
glColor4f
(
0.
,
0.
,
0.
,
1.
);
//~ std::cout << "set color passed" << std::endl;
glPrintError
();
if
(
drawedges
&&
drawedges
!=
2
)
draw_edges
(
clip_boundary
,
pick
ed
);
draw_edges
(
clip_boundary
,
pick
_element
?
picked
:
-
1
);
//~ std::cout << "draw edges passed" << std::endl;
glPrintError
();
}
...
...
Examples/DrawGrid/streamline.cpp
View file @
757bd2a2
...
...
@@ -163,6 +163,11 @@ namespace INMOST
for
(
Mesh
::
iteratorElement
f
=
mesh
->
BeginElement
(
vel_def
);
f
!=
mesh
->
EndElement
();
++
f
)
if
(
f
->
Boundary
())
{
if
(
k
%
5
!=
0
)
//every tenth face!
{
k
++
;
continue
;
}
coord
v
(
f
->
RealArray
(
vel
).
data
());
if
(
v
.
length
()
>
1.0e-4
)
{
...
...
@@ -216,11 +221,12 @@ namespace INMOST
printf
(
"done from boundary faces, total streamlines = %lu
\n
"
,
output
.
size
());
printf
(
"started building streamlines from unvisited cells
\n
"
);
tot
=
0
;
for
(
Mesh
::
iteratorCell
it
=
mesh
->
BeginCell
();
it
!=
mesh
->
EndCell
();
++
it
)
if
(
!
it
->
GetMarker
(
visited
))
tot
++
;
/*
printf("total elements: %d\n", tot);
k = 0;
...
...
@@ -244,8 +250,9 @@ namespace INMOST
}
}
printf("done from unvisited cells, total streamlines = %lu\n", output.size());
*/
mesh
->
ReleaseMarker
(
visited
,
vel_def
);
}
mesh
->
DeleteTag
(
cell_size
);
...
...
@@ -283,7 +290,7 @@ namespace INMOST
c
.
SetMarker
(
visited
);
GetVelocity
(
c
,
velocity_tag
,
velocity_defined
,
next
,
vel
);
len
=
vel
.
length
();
if
(
len
<
1.0e-
12
)
break
;
if
(
len
<
1.0e-
7
)
break
;
//size = GetSize(c, cell_size);// c->RealDF(cell_size);
size
=
GetSizeProj
(
c
,
vel
);
coef
=
0.01
*
size
/
len
;
...
...
@@ -310,7 +317,7 @@ namespace INMOST
glTranslated
(
a
[
0
],
a
[
1
],
a
[
2
]);
get_matrix
(
a
,
b
,
matrix
);
glMultMatrixd
(
matrix
);
gluCylinder
(
cylqs
,
width
,
width
,
sqrt
((
b
-
a
)
^
(
b
-
a
)),
4
,
2
);
gluCylinder
(
cylqs
,
width
,
width
,
sqrt
((
b
-
a
)
^
(
b
-
a
)),
4
,
1
);
glPopMatrix
();
}
...
...
@@ -331,7 +338,7 @@ namespace INMOST
else
for
(
unsigned
int
i
=
0
;
i
<
points
.
size
()
-
1
;
i
++
)
{
glColor3f
(
velarr
[
i
+
1
]
*
0.65
,
0.65
*
(
velarr
[
i
+
1
]
<
0.5
?
velarr
[
i
]
:
1.0
-
velarr
[
i
]),
0.65
*
(
1
-
velarr
[
i
+
1
]));
drawcylinder
(
points
[
i
],
points
[
i
+
1
],
0.
5
*
abs
(
points
[
i
+
1
]
-
points
[
i
]));
drawcylinder
(
points
[
i
],
points
[
i
+
1
],
0.
2
*
abs
(
points
[
i
+
1
]
-
points
[
i
]));
}
}
...
...
Examples/DrawGrid/vector.cpp
View file @
757bd2a2
...
...
@@ -26,6 +26,19 @@ namespace INMOST
gluCylinder
(
cylqs
,
width
,
width
,
sqrt
((
b
-
a
)
^
(
b
-
a
)),
4
,
2
);
glPopMatrix
();
}
void
Vectors
::
InitArrow
()
{
quadObj
=
gluNewQuadric
();
gluQuadricDrawStyle
((
GLUquadricObj
*
)
quadObj
,
GLU_FILL
);
gluQuadricOrientation
((
GLUquadricObj
*
)
quadObj
,
GLU_OUTSIDE
);
gluQuadricNormals
((
GLUquadricObj
*
)
quadObj
,
GLU_SMOOTH
);
}
void
Vectors
::
DeleteArrow
()
{
gluDeleteQuadric
((
GLUquadricObj
*
)
quadObj
);
}
Vectors
::
Vectors
(
Mesh
*
m
,
TagRealArray
t
,
ElementType
etype
)
:
m
(
m
),
etype
(
etype
)
{
...
...
@@ -64,14 +77,52 @@ namespace INMOST
}
scale
=
diag
/
100.0
;
std
::
cout
<<
"scale: "
<<
scale
<<
std
::
endl
;
InitArrow
();
}
void
Vectors
::
DrawArrow
(
const
coord
&
v1
,
const
coord
&
v2
)
const
{
double
matrix
[
16
];
double
x
=
v2
[
0
]
-
v1
[
0
];
double
y
=
v2
[
1
]
-
v1
[
1
];
double
z
=
v2
[
2
]
-
v1
[
2
];
double
L
=
sqrt
(
x
*
x
+
y
*
y
+
z
*
z
);
double
D
=
0.025
*
L
;
glPushMatrix
();
glTranslated
(
v1
[
0
],
v1
[
1
],
v1
[
2
]);
get_matrix
(
v1
,
v2
,
matrix
);
glMultMatrixd
(
matrix
);
int
res
=
4
;
glTranslated
(
0
,
0
,
L
-
6
*
D
);
//arrow
gluCylinder
((
GLUquadricObj
*
)
quadObj
,
3
*
D
,
0.0
,
6
*
D
,
res
,
1
);
gluDisk
((
GLUquadricObj
*
)
quadObj
,
0.0
,
3
*
D
,
res
,
1
);
glTranslated
(
0
,
0
,
-
L
+
6
*
D
);
//cylinder
gluCylinder
((
GLUquadricObj
*
)
quadObj
,
D
,
D
,
L
-
6
*
D
,
res
,
1
);
gluDisk
((
GLUquadricObj
*
)
quadObj
,
0.0
,
D
,
res
,
1
);
glPopMatrix
();
}
void
Vectors
::
Draw
(
int
reduced
)
{
glBegin
(
GL_LINES
);
glColor3f
(
0.25
,
0.25
,
0.25
);
int
pace
=
1
;
if
(
reduced
)
{
pace
=
std
::
max
<
INMOST_DATA_ENUM_TYPE
>
(
1
,
std
::
min
<
INMOST_DATA_ENUM_TYPE
>
(
15
,(
unsigned
)
vecs
.
size
()
/
100
));
glBegin
(
GL_LINES
);
for
(
unsigned
int
i
=
0
;
i
<
vecs
.
size
();
i
+=
pace
)
{
if
(
isColorBarEnabled
())
...
...
@@ -82,7 +133,20 @@ namespace INMOST
glVertex3dv
(
vecs
[
i
].
cnt
.
data
());
glVertex3dv
((
vecs
[
i
].
cnt
+
vecs
[
i
].
dir
*
scale
*
vecs
[
i
].
length
/
max_length
).
data
());
}
glEnd
();
glEnd
();
}
else
{
for
(
unsigned
int
i
=
0
;
i
<
vecs
.
size
();
++
i
)
{
if
(
isColorBarEnabled
())
{
color_t
c
=
GetColorBar
()
->
pick_color
(
m
->
ElementByLocalID
(
etype
,
vecs
[
i
].
eid
)
->
RealDF
(
GetVisualizationTag
()));
c
.
set_color
();
}
DrawArrow
(
vecs
[
i
].
cnt
,
vecs
[
i
].
cnt
+
vecs
[
i
].
dir
*
scale
*
vecs
[
i
].
length
/
max_length
);
}
}
}
...
...
Examples/DrawGrid/vector.h
View file @
757bd2a2
...
...
@@ -23,10 +23,11 @@ namespace INMOST
Mesh
*
m
;
ElementType
etype
;
std
::
vector
<
vec_t
>
vecs
;
void
*
quadObj
;
public:
Vectors
(
Mesh
*
m
,
TagRealArray
t
,
ElementType
etype
);
Vectors
(
const
Vectors
&
b
)
:
max_length
(
b
.
max_length
),
scale
(
b
.
scale
),
m
(
b
.
m
),
etype
(
b
.
etype
),
vecs
(
b
.
vecs
){}
:
max_length
(
b
.
max_length
),
scale
(
b
.
scale
),
m
(
b
.
m
),
etype
(
b
.
etype
),
vecs
(
b
.
vecs
){
InitArrow
();
}
Vectors
&
operator
=
(
Vectors
const
&
b
)
{
max_length
=
b
.
max_length
;
...
...
@@ -34,12 +35,20 @@ namespace INMOST
m
=
b
.
m
;
etype
=
b
.
etype
;
vecs
=
b
.
vecs
;
InitArrow
();
return
*
this
;
}
void
SetScale
(
double
s
)
{
scale
=
s
;}
~
Vectors
()
{
vecs
.
clear
();
}
~
Vectors
()
{
vecs
.
clear
();
DeleteArrow
();
}
void
DrawArrow
(
const
coord
&
v1
,
const
coord
&
v2
)
const
;
void
Draw
(
int
reduced
);
void
SVGDraw
(
std
::
ostream
&
file
,
double
modelview
[
16
],
double
projection
[
16
],
int
viewport
[
4
]);
void
InitArrow
();
void
DeleteArrow
();
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment