Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fluidparticles
MigFlow
Commits
67d68b84
Commit
67d68b84
authored
Oct 08, 2021
by
tleyssens6
Browse files
new mesh + bubble inside
parent
8b4abd2e
Pipeline
#9823
passed with stages
in 3 minutes and 38 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
testcases/xmesh/.DS_Store
0 → 100644
View file @
67d68b84
File added
testcases/xmesh/bubble.py
View file @
67d68b84
...
@@ -33,7 +33,7 @@ class Poiseuille(unittest.TestCase) :
...
@@ -33,7 +33,7 @@ class Poiseuille(unittest.TestCase) :
if
not
os
.
path
.
isdir
(
outputdir
)
:
if
not
os
.
path
.
isdir
(
outputdir
)
:
os
.
makedirs
(
outputdir
)
os
.
makedirs
(
outputdir
)
subprocess
.
call
([
"gmsh"
,
"-2"
,
"mesh.geo"
,
"-clscale"
,
"2"
])
subprocess
.
call
([
"gmsh"
,
"-2"
,
"mesh
2
.geo"
,
"-clscale"
,
"2"
])
t
=
0
t
=
0
ii
=
0
ii
=
0
...
@@ -50,29 +50,53 @@ class Poiseuille(unittest.TestCase) :
...
@@ -50,29 +50,53 @@ class Poiseuille(unittest.TestCase) :
return
Uin
return
Uin
else
:
else
:
return
0
return
0
def
setInitialConcentration
(
r
):
concentration
=
np
.
full
(
fluid
.
n_nodes
(),
0
)
#tags, x, _ = gmsh.model.mesh.get_nodes(includeBoundary=False)
x
=
fluid
.
coordinates
()
print
(
x
.
shape
)
#x = x.reshape([-1,3])
# circle centered at (0,0.15), radius r
for
i
in
range
(
fluid
.
n_nodes
()):
if
(
x
[
i
,
0
]
-
0
)
**
2
+
(
x
[
i
,
1
]
-
0.15
)
**
2
<
r
**
2
:
concentration
[
i
]
=
1
fluid
.
set_concentration_cg
(
concentration
)
#numerical parameters
#numerical parameters
lcmin
=
.
1
# mesh size
lcmin
=
.
1
# mesh size
dt
=
0.00
0
1
# time step
dt
=
0.001
# time step
alpha
=
1e-4
# stabilization coefficient
alpha
=
1e-4
# stabilization coefficient
shutil
.
copy
(
"mesh.msh"
,
outputdir
+
"/mesh.msh"
)
shutil
.
copy
(
"mesh
2
.msh"
,
outputdir
+
"/mesh
2
.msh"
)
outf
=
1
# number of iterations between output files
outf
=
1
# number of iterations between output files
#Object fluid creation + Boundary condition of the fluid (field 0 is horizontal velocity; field 1 is vertical velocity; field 2 is pressure)
#Object fluid creation + Boundary condition of the fluid (field 0 is horizontal velocity; field 1 is vertical velocity; field 2 is pressure)
fluid
=
mbfluid
.
FluidProblem
(
2
,
g
,[
nu0
*
rho0
,
nu1
*
rho1
],[
rho0
,
rho1
])
fluid
=
mbfluid
.
FluidProblem
(
2
,
g
,[
nu0
*
rho0
,
nu1
*
rho1
],[
rho0
,
rho1
])
fluid
.
load_msh
(
"mesh.msh"
)
fluid
.
load_msh
(
"mesh
2
.msh"
)
fluid
.
set_open_boundary
(
"BottomMiddle"
,
velocity
=
[
0
,
boundaryV
],
concentration
=
1
)
#fluid.set_open_boundary("BottomMiddle", velocity=[0, boundaryV], concentration=1)
#fluid.set_wall_boundary("BottomLeft",velocity=[0,0])
#fluid.set_wall_boundary("BottomRight",velocity=[0,0])
fluid
.
set_wall_boundary
(
"BottomMiddle"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"BottomLeft"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"BottomLeft"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"BottomRight"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"BottomRight"
,
velocity
=
[
0
,
0
])
#fluid.set_open_boundary("BottomMiddle", velocity=[0, boundaryV], concentration=1)
#fluid.set_open_boundary("BottomLeft",velocity=[0, boundaryV], concentration=1)
#fluid.set_open_boundary("BottomRight",velocity=[0, boundaryV], concentration=1)
# fluid.set_open_boundary("Insert", velocity=[0, boundaryV], concentration=1)
# fluid.set_open_boundary("Insert", velocity=[0, boundaryV], concentration=1)
fluid
.
set_open_boundary
(
"Top"
,
pressure
=
0
,
concentration
=
0
)
fluid
.
set_open_boundary
(
"Top"
,
pressure
=
0
,
concentration
=
0
)
fluid
.
set_wall_boundary
(
"Right"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"Right"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"Left"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"Left"
,
velocity
=
[
0
,
0
])
setInitialConcentration
(
0.04
)
ii
=
0
ii
=
0
t
=
0
t
=
0
...
@@ -80,22 +104,24 @@ class Poiseuille(unittest.TestCase) :
...
@@ -80,22 +104,24 @@ class Poiseuille(unittest.TestCase) :
fluid
.
write_vtk
(
outputdir
,
0
,
0
)
fluid
.
write_vtk
(
outputdir
,
0
,
0
)
mesh
,
x
=
xmesh2d
.
Mesh
.
import_from_file
(
"mesh.msh"
)
mesh
,
x
=
xmesh2d
.
Mesh
.
import_from_file
(
"mesh
2
.msh"
)
tracker
=
xmesh2d
.
FrontTracker
(
mesh
,
x
)
tracker
=
xmesh2d
.
FrontTracker
(
mesh
,
x
)
ii
=
0
ii
=
0
tic
=
time
.
time
()
tic
=
time
.
time
()
while
ii
<
10
00
:
while
ii
<
2
00
:
#Fluid solver
#Fluid solver
time_integration
.
iterate
(
fluid
,
None
,
dt
)
time_integration
.
iterate
(
fluid
,
None
,
dt
)
t
+=
dt
t
+=
dt
concentration
=
fluid
.
concentration_cg
().
reshape
((
fluid
.
n_nodes
(),))
concentration
=
fluid
.
concentration_cg
().
reshape
((
fluid
.
n_nodes
(),))
print
(
concentration
)
level
=
concentration
-
0.5
;
level
=
concentration
-
0.5
;
#level = np.where(concentration < 0.5, -1, 1)
newx
=
np
.
copy
(
fluid
.
coordinates
()[:])
newx
=
np
.
copy
(
fluid
.
coordinates
()[:])
newx
=
tracker
.
move_front
(
newx
,
level
[:,])
newx
=
tracker
.
move_front
(
newx
,
level
[:,])
newx
=
tracker
.
relax
(
newx
,
dt
*
5
)
newx
=
tracker
.
relax
(
newx
,
1
)
print
(
x
[:,:
2
].
shape
)
print
(
x
[:,:
2
].
shape
)
print
(
np
.
sum
(
newx
-
fluid
.
coordinates
()))
print
(
np
.
sum
(
newx
-
fluid
.
coordinates
()))
fluid
.
mesh_velocity
()[:]
=
(
newx
[:,:
2
]
-
fluid
.
coordinates
()[:,:
2
])
/
dt
fluid
.
mesh_velocity
()[:]
=
(
newx
[:,:
2
]
-
fluid
.
coordinates
()[:,:
2
])
/
dt
...
...
testcases/xmesh/mesh2.geo
0 → 100644
View file @
67d68b84
L = 0.3;
H = 0.4;
y = 0;
lc = .01;
Point(1) = {-L, H, 0, lc};
Point(2) = {-L, 0, 0, lc};
Point(3) = {L, 0, 0, lc};
Point(4) = {L, H, 0, lc};
Point(5) = {-L/10, 0, 0, lc};
Point(6) = {L/10, 0, 0, lc};
Line(1) = {1, 2};
Line(2) = {2, 5};
Line(3) = {5, 6};
Line(4) = {6, 3};
Line(5) = {3, 4};
Line(6) = {4, 1};
Line Loop(1) = {1:6};
Plane Surface(1) = {1};
Physical Line("Left") = {1};
Physical Line("BottomLeft") = {2};
Physical Line("BottomMiddle") = {3};
Physical Line("BottomRight") = {4};
Physical Line("Right") = {5};
Physical Line("Top") = {6};
Physical Surface("Domain") = {1};
Physical Point("PtFix") = {1};
Mesh.MshFileVersion = 2;
testcases/xmesh/xmesh2d.py
View file @
67d68b84
...
@@ -117,7 +117,7 @@ class Mesh():
...
@@ -117,7 +117,7 @@ class Mesh():
model
=
gmsh
.
model
.
get_current
()
model
=
gmsh
.
model
.
get_current
()
self
.
tritags
,
tri
=
gmsh
.
model
.
mesh
.
get_elements_by_type
(
2
)
self
.
tritags
,
tri
=
gmsh
.
model
.
mesh
.
get_elements_by_type
(
2
)
self
.
tri
=
tri
.
reshape
([
-
1
,
3
])
self
.
tri
=
tri
.
reshape
([
-
1
,
3
])
tags
,
x
,
_
=
gmsh
.
model
.
mesh
.
get_nodes
()
tags
,
x
,
_
=
gmsh
.
model
.
mesh
.
get_nodes
(
includeBoundary
=
False
)
order
=
np
.
argsort
(
tags
)
order
=
np
.
argsort
(
tags
)
self
.
nodetags
=
tags
[
order
]
self
.
nodetags
=
tags
[
order
]
x
=
x
.
reshape
([
-
1
,
3
])[
order
]
x
=
x
.
reshape
([
-
1
,
3
])[
order
]
...
@@ -147,6 +147,7 @@ class FrontTracker():
...
@@ -147,6 +147,7 @@ class FrontTracker():
self
.
previous_sign
=
np
.
full
(
x
.
shape
[
0
],
1
)
self
.
previous_sign
=
np
.
full
(
x
.
shape
[
0
],
1
)
def
move_front
(
self
,
x
,
levelset
):
def
move_front
(
self
,
x
,
levelset
):
print
(
"in xmesh"
)
def
move_node
(
tn
)
:
def
move_node
(
tn
)
:
all_neighbours
=
neigh
[
neigh_start
[
tn
]:
neigh_start
[
tn
+
1
]]
all_neighbours
=
neigh
[
neigh_start
[
tn
]:
neigh_start
[
tn
+
1
]]
...
@@ -170,6 +171,7 @@ class FrontTracker():
...
@@ -170,6 +171,7 @@ class FrontTracker():
return
False
return
False
neigh
=
self
.
mesh
.
neigh
neigh
=
self
.
mesh
.
neigh
boundary_nodes
=
self
.
mesh
.
boundary_nodes
neigh_start
=
self
.
mesh
.
neigh_start
neigh_start
=
self
.
mesh
.
neigh_start
front
=
self
.
front
front
=
self
.
front
sign
=
np
.
where
(
levelset
>
0
,
1
,
-
1
)
sign
=
np
.
where
(
levelset
>
0
,
1
,
-
1
)
...
@@ -181,6 +183,7 @@ class FrontTracker():
...
@@ -181,6 +183,7 @@ class FrontTracker():
nsign
=
sign
[
all_neighbours
]
nsign
=
sign
[
all_neighbours
]
nsign
[
front
[
all_neighbours
]]
=
0
nsign
[
front
[
all_neighbours
]]
=
0
nsign
=
np
.
r_
[
sign
[
tn
],
nsign
]
nsign
=
np
.
r_
[
sign
[
tn
],
nsign
]
print
(
nsign
)
if
nsign
.
max
()
-
nsign
.
min
()
!=
2
:
if
nsign
.
max
()
-
nsign
.
min
()
!=
2
:
front
[
tn
]
=
False
front
[
tn
]
=
False
# move the nodes already in the front
# move the nodes already in the front
...
...
Write
Preview
Supports
Markdown
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