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
ac1cc6af
Commit
ac1cc6af
authored
Nov 06, 2020
by
Kirill Terekhov
Browse files
tweaks to streamlines in DrawGrid
parent
fe3dcd2f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Examples/DrawGrid/main.cpp
View file @
ac1cc6af
...
@@ -839,7 +839,7 @@ void keyboard(unsigned char key, int x, int y)
...
@@ -839,7 +839,7 @@ void keyboard(unsigned char key, int x, int y)
}
}
else
if
(
key
==
't'
)
else
if
(
key
==
't'
)
{
{
screenshot
(
4
);
screenshot
(
1
);
std
::
fstream
fout
(
"screenshot.svg"
,
std
::
ios
::
out
);
std
::
fstream
fout
(
"screenshot.svg"
,
std
::
ios
::
out
);
svg_draw
(
fout
);
svg_draw
(
fout
);
fout
.
close
();
fout
.
close
();
...
...
Examples/DrawGrid/streamline.cpp
View file @
ac1cc6af
...
@@ -132,8 +132,9 @@ namespace INMOST
...
@@ -132,8 +132,9 @@ namespace INMOST
return
;
return
;
}
}
printf
(
"preparing octree around mesh, was sets %d
\n
"
,
mesh
->
NumberOfSets
());
printf
(
"preparing octree around mesh, was sets %d
\n
"
,
mesh
->
NumberOfSets
());
Octree
octsearch
=
Octree
(
mesh
->
CreateSet
(
"octsearch"
).
first
);
SearchKDTree
octsearch
(
mesh
);
octsearch
.
Construct
(
vel_def
,
false
);
//auto-detect octree or quadtree
//~ Octree octsearch = Octree(mesh->CreateSet("octsearch").first);
//~ octsearch.Construct(vel_def, false); //auto-detect octree or quadtree
printf
(
"done, sets %d
\n
"
,
mesh
->
NumberOfSets
());
printf
(
"done, sets %d
\n
"
,
mesh
->
NumberOfSets
());
printf
(
"building streamlines
\n
"
);
printf
(
"building streamlines
\n
"
);
Tag
cell_size
=
mesh
->
CreateTag
(
"STREAMLINES_TEMPORARY_CELL_SIZES"
,
DATA_REAL
,
CELL
,
NONE
,
1
);
Tag
cell_size
=
mesh
->
CreateTag
(
"STREAMLINES_TEMPORARY_CELL_SIZES"
,
DATA_REAL
,
CELL
,
NONE
,
1
);
...
@@ -258,13 +259,13 @@ namespace INMOST
...
@@ -258,13 +259,13 @@ namespace INMOST
mesh
->
DeleteTag
(
cell_size
);
mesh
->
DeleteTag
(
cell_size
);
printf
(
"done, total streamlines = %lu
\n
"
,
output
.
size
());
printf
(
"done, total streamlines = %lu
\n
"
,
output
.
size
());
printf
(
"killing octree, was sets %d
\n
"
,
mesh
->
NumberOfSets
());
printf
(
"killing octree, was sets %d
\n
"
,
mesh
->
NumberOfSets
());
octsearch
.
Destroy
();
//~
octsearch.Destroy();
printf
(
"done, sets %d
\n
"
,
mesh
->
NumberOfSets
());
printf
(
"done, sets %d
\n
"
,
mesh
->
NumberOfSets
());
}
}
Streamline
::
Streamline
(
const
Oct
ree
&
octsearch
,
coord
pos
,
Tag
velocity_tag
,
ElementType
velocity_defined
,
Tag
cell_size
,
Storage
::
real
velocity_min
,
Storage
::
real
velocity_max
,
Storage
::
real
sign
,
MarkerType
visited
)
Streamline
::
Streamline
(
SearchKDT
ree
&
octsearch
,
coord
pos
,
Tag
velocity_tag
,
ElementType
velocity_defined
,
Tag
cell_size
,
Storage
::
real
velocity_min
,
Storage
::
real
velocity_max
,
Storage
::
real
sign
,
MarkerType
visited
)
{
{
Storage
::
real
coef
,
len
,
size
;
Storage
::
real
coef
,
len
,
size
;
coord
next
=
pos
,
vel
;
coord
next
=
pos
,
vel
;
...
@@ -276,7 +277,8 @@ namespace INMOST
...
@@ -276,7 +277,8 @@ namespace INMOST
velarr
.
push_back
(
0
);
velarr
.
push_back
(
0
);
while
(
points
.
size
()
<
maxsteps
)
while
(
points
.
size
()
<
maxsteps
)
{
{
c
=
octsearch
.
FindClosestCell
(
next
.
data
());
//c = octsearch.FindClosestCell(next.data());
c
=
octsearch
.
SearchCell
(
next
.
data
());
if
(
!
c
.
isValid
())
break
;
if
(
!
c
.
isValid
())
break
;
//if( !c.getAsCell().Inside(next.data()) ) break;
//if( !c.getAsCell().Inside(next.data()) ) break;
//check we are inside mesh
//check we are inside mesh
...
@@ -290,10 +292,10 @@ namespace INMOST
...
@@ -290,10 +292,10 @@ namespace INMOST
c
.
SetMarker
(
visited
);
c
.
SetMarker
(
visited
);
GetVelocity
(
c
,
velocity_tag
,
velocity_defined
,
next
,
vel
);
GetVelocity
(
c
,
velocity_tag
,
velocity_defined
,
next
,
vel
);
len
=
vel
.
length
();
len
=
vel
.
length
();
if
(
len
<
1.0e-
7
)
break
;
if
(
len
<
1.0e-
8
)
break
;
//size = GetSize(c, cell_size);// c->RealDF(cell_size);
//size = GetSize(c, cell_size);// c->RealDF(cell_size);
size
=
GetSizeProj
(
c
,
vel
);
size
=
GetSizeProj
(
c
,
vel
);
coef
=
0.0
1
*
size
/
len
;
coef
=
0.0
5
*
size
/
len
;
next
+=
vel
*
coef
*
sign
;
next
+=
vel
*
coef
*
sign
;
points
.
push_back
(
next
);
points
.
push_back
(
next
);
velarr
.
push_back
((
log
(
len
+
1.0e-25
)
-
velocity_min
)
/
(
velocity_max
-
velocity_min
));
velarr
.
push_back
((
log
(
len
+
1.0e-25
)
-
velocity_min
)
/
(
velocity_max
-
velocity_min
));
...
...
Examples/DrawGrid/streamline.h
View file @
ac1cc6af
...
@@ -17,7 +17,7 @@ namespace INMOST
...
@@ -17,7 +17,7 @@ namespace INMOST
std
::
vector
<
double
>
velarr
;
std
::
vector
<
double
>
velarr
;
public:
public:
Streamline
()
{}
Streamline
()
{}
Streamline
(
const
Oct
ree
&
octsearch
,
coord
pos
,
Tag
velocity_tag
,
ElementType
velocity_defined
,
Tag
cell_size
,
Storage
::
real
velocity_min
,
Storage
::
real
velocity_max
,
Storage
::
real
sign
,
MarkerType
visited
);
Streamline
(
SearchKDT
ree
&
octsearch
,
coord
pos
,
Tag
velocity_tag
,
ElementType
velocity_defined
,
Tag
cell_size
,
Storage
::
real
velocity_min
,
Storage
::
real
velocity_max
,
Storage
::
real
sign
,
MarkerType
visited
);
Streamline
(
const
Streamline
&
other
)
{
points
=
other
.
points
;
velarr
=
other
.
velarr
;
}
Streamline
(
const
Streamline
&
other
)
{
points
=
other
.
points
;
velarr
=
other
.
velarr
;
}
Streamline
&
operator
=
(
Streamline
const
&
other
)
{
points
=
other
.
points
;
velarr
=
other
.
velarr
;
return
*
this
;
}
Streamline
&
operator
=
(
Streamline
const
&
other
)
{
points
=
other
.
points
;
velarr
=
other
.
velarr
;
return
*
this
;
}
~
Streamline
()
{
points
.
clear
();
velarr
.
clear
();
}
~
Streamline
()
{
points
.
clear
();
velarr
.
clear
();
}
...
@@ -27,4 +27,4 @@ namespace INMOST
...
@@ -27,4 +27,4 @@ namespace INMOST
void
BuildStreamlines
(
Mesh
*
m
,
Tag
vel
,
ElementType
vel_def
,
std
::
vector
<
Streamline
>
&
output
);
void
BuildStreamlines
(
Mesh
*
m
,
Tag
vel
,
ElementType
vel_def
,
std
::
vector
<
Streamline
>
&
output
);
}
}
#endif
#endif
\ No newline at end of file
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