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
fd782ee2
Commit
fd782ee2
authored
Nov 27, 2020
by
Jonathan Lambrechts
Browse files
fix import_vtk
parent
97dd40d5
Pipeline
#8771
passed with stages
in 5 minutes and 17 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
fluid/fluid_problem.c
View file @
fd782ee2
...
...
@@ -1742,19 +1742,6 @@ void fluid_problem_adapt_mesh(FluidProblem *problem, Mesh *new_mesh, int old_n_p
free
(
old_particle_uvw
);
}
void
fluid_problem_after_import
(
FluidProblem
*
problem
)
{
if
(
problem
->
mesh_tree
)
mesh_tree_free
(
problem
->
mesh_tree
);
problem
->
mesh_tree
=
mesh_tree_create
(
problem
->
mesh
);
for
(
int
i
=
0
;
i
<
problem
->
n_particles
;
++
i
)
problem
->
particle_element_id
[
i
]
=
-
1
;
mesh_tree_particle_to_mesh
(
problem
->
mesh_tree
,
problem
->
n_particles
,
problem
->
particle_position
,
problem
->
particle_element_id
,
problem
->
particle_uvw
);
fluid_problem_compute_node_volume
(
problem
);
compute_porosity
(
problem
->
mesh
,
problem
->
node_volume
,
problem
->
porosity
,
problem
->
n_particles
,
problem
->
particle_position
,
problem
->
particle_volume
,
problem
->
particle_element_id
,
problem
->
particle_uvw
,
NULL
);
}
void
fluid_problem_set_particles
(
FluidProblem
*
problem
,
int
n
,
double
*
mass
,
double
*
volume
,
double
*
position
,
double
*
velocity
,
double
*
contact
)
{
if
(
problem
->
n_particles
!=
n
)
{
problem
->
n_particles
=
n
;
...
...
python/_tools.py
View file @
fd782ee2
...
...
@@ -21,4 +21,8 @@ def timeit(func):
return
r
return
wrapper
atexit
.
register
(
print
,
timers
)
def
timeprint
(
timers
)
:
if
len
(
timers
)
!=
0
:
print
(
timers
)
atexit
.
register
(
timeprint
,
timers
)
python/fluid.py
View file @
fd782ee2
...
...
@@ -33,7 +33,7 @@ import numpy as np
import
os
import
sys
from
.
import
VTK
from
._tools
import
gmsh
from
._tools
import
gmsh
,
timeit
try
:
from
.petsclsys
import
LinearSystem
except
:
...
...
@@ -182,7 +182,8 @@ class FluidProblem :
Keyword argument:
mesh_file_name -- Name of the mesh.msh file containing information about the domain
"""
self
.
_lib
.
fluid_problem_set_mesh
(
self
.
_fp
,
_load_msh
(
mesh_file_name
,
self
.
_lib
,
self
.
dimension
()))
mesh
=
_load_msh
(
mesh_file_name
,
self
.
_lib
,
self
.
dimension
())
self
.
_lib
.
fluid_problem_set_mesh
(
self
.
_fp
,
mesh
)
self
.
sys
=
None
gmsh
.
model
.
remove
()
...
...
@@ -372,31 +373,14 @@ class FluidProblem :
bnds
=
np
.
vstack
(
list
(
mesh_boundaries
.
values
()))
bnd_tags
=
np
.
repeat
(
list
(
range
(
nbnd
)),
list
([
v
.
shape
[
0
]
for
v
in
mesh_boundaries
.
values
()]))
bnd_tags
=
np
.
require
(
bnd_tags
,
np
.
int32
,
"C"
)
# self._lib.fluid_problem_set_elements(self._fp,
# c_int(x.shape[0]),_np2c(x,np.float64),
# c_int(el.shape[0]),_np2c(el,np.int32),
# c_int(bnds.shape[0]),c_void_p(bnds.ctypes.data),c_void_p(bnd_tags.ctypes.data),c_int(len(cbnd_names)),cbnd_names
# )
# lib.mesh_new_from_elements.restype = c_void_p
# return c_void_p(lib.mesh_new_from_elements(
# c_int(x.shape[0]),_np2c(x,np.float64),
# c_int(el.shape[0]),_np2c(el,np.int32),
# c_int(bnd.shape[0]),_np2c(bnd,np.int32),
# _np2c(btag,np.int32),c_int(len(cbname)),cbname,
# _np2c(periodic_parent,np.int32)))
self
.
parent_nodes
()[:]
=
np
.
require
(
data
[
"parent_node_id"
],
np
.
int32
,
"C"
)
self
.
_lib
.
mesh_new_from_elements
.
restype
=
c_void_p
_mesh
=
c_void_p
(
self
.
_lib
.
mesh_new_from_elements
(
c_int
(
x
.
shape
[
0
]),
_np2c
(
x
,
np
.
float64
),
c_int
(
el
.
shape
[
0
]),
_np2c
(
el
,
np
.
int32
),
c_int
(
bnds
.
shape
[
0
]),
_np2c
(
bnds
,
np
.
int32
),
_np2c
(
bnd_tags
,
np
.
int32
),
c_int
(
len
(
cbnd_names
)),
cbnd_names
,
_np2c
(
data
[
"parent_node_id"
],
np
.
int32
)))
self
.
_lib
.
fluid_problem_set_mesh
.
restype
=
None
_np2c
(
data
[
"parent_node_id"
],
np
.
int32
)
if
"parent_node_id"
in
data
else
None
))
self
.
_lib
.
fluid_problem_set_mesh
(
self
.
_fp
,
_mesh
)
sol
=
self
.
solution
()
sol
[:,:
self
.
_dim
]
=
data
[
"velocity"
][:,:
self
.
_dim
]
sol
[:,[
self
.
_dim
]]
=
data
[
"pressure"
]
...
...
@@ -404,7 +388,6 @@ class FluidProblem :
self
.
concentration_dg
()[:]
=
cdata
[
"concentration"
]
self
.
porosity
()[:]
=
data
[
"porosity"
]
self
.
old_porosity
()[:]
=
data
[
"old_porosity"
]
self
.
_lib
.
fluid_problem_after_import
(
self
.
_fp
)
self
.
sys
=
None
def
compute_node_force
(
self
,
dt
)
:
...
...
@@ -428,7 +411,6 @@ class FluidProblem :
self
.
_lib
.
fluid_problem_compute_node_particle_torque
(
self
.
_fp
,
c_double
(
dt
),
c_void_p
(
torques
.
ctypes
.
data
))
return
torques
def
implicit_euler
(
self
,
dt
,
check_residual_norm
=-
1
,
reduced_gravity
=
0
,
stab_param
=
0.
)
:
"""Solves the fluid equations.
...
...
testcases/periodicTest/2D/testVTK.py
View file @
fd782ee2
...
...
@@ -73,10 +73,10 @@ outf = 10 # number of iterations between o
fluid
=
mbfluid
.
FluidProblem
(
2
,
g
,
nu
*
rho
,
rho
,
petsc_solver_type
=
"-pc_type lu"
)
# fluid.load_msh("mesh.msh") # a retirer
fluid
.
import_vtk
(
"outputPoiseuille/fluid_%05d.vtu"
%
ii
)
fluid
.
set_wall_boundary
(
"Bottom"
,
velocity
=
[
0
,
0
])
fluid
.
set_wall_boundary
(
"Top"
,
velocity
=
[
0
,
0
])
print
(
"Import done !"
)
ii
=
0
t
=
ii
*
dt
...
...
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