Skip to content

Commit

Permalink
Merged in prabhuramachandran/pysph/gmsh (pull request #148)
Browse files Browse the repository at this point in the history
Adding some simple tools for gmsh and VTK support
  • Loading branch information
kunal-puri committed Mar 17, 2015
2 parents 6db7f8f + 5eb19ae commit f1a5ee2
Show file tree
Hide file tree
Showing 2 changed files with 434 additions and 9 deletions.
29 changes: 20 additions & 9 deletions examples/db_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def __init__(
fluid_column_height=0.55, fluid_column_width=1.0, fluid_column_length=1.228,
obstacle_center_x=2.5, obstacle_center_y=0,
obstacle_length=0.16, obstacle_height=0.161, obstacle_width=0.4,
nboundary_layers=5, dx=0.02, hdx=1.2, rho0=1000.0):
nboundary_layers=5, with_obstacle=True, dx=0.02, hdx=1.2, rho0=1000.0):

# save the geometry details
self.container_width = container_width
Expand All @@ -260,6 +260,7 @@ def __init__(

self.hdx = hdx
self.rho0 = rho0
self.with_obstacle = with_obstacle

def get_max_speed(self, g=9.81):
return numpy.sqrt( 2 * g * self.fluid_column_height )
Expand Down Expand Up @@ -336,9 +337,10 @@ def create_particles(self, **kwargs):
fluid = pa.extract_particles(fa)
fluid.set_name('fluid')

oa = LongArray(len(oindices)); oa.set_data(numpy.array(oindices))
obstacle = pa.extract_particles(oa)
obstacle.set_name('obstacle')
if self.with_obstacle:
oa = LongArray(len(oindices)); oa.set_data(numpy.array(oindices))
obstacle = pa.extract_particles(oa)
obstacle.set_name('obstacle')

indices = concatenate( (where( y <= -cw2 )[0],
where( y >= cw2 )[0],
Expand All @@ -354,7 +356,10 @@ def create_particles(self, **kwargs):
boundary.set_name('boundary')

# create the particles
particles = [fluid, boundary, obstacle]
if self.with_obstacle:
particles = [fluid, boundary, obstacle]
else:
particles = [fluid, boundary]

# set up particle properties
h0 = self.hdx * dx
Expand All @@ -370,9 +375,13 @@ def create_particles(self, **kwargs):

nf = fluid.num_real_particles
nb = boundary.num_real_particles
no = obstacle.num_real_particles

print "3D dam break with %d fluid, %d boundary, %d obstacle particles"%(nf, nb, no)
if self.with_obstacle:
no = obstacle.num_real_particles
print "3D dam break with %d fluid, %d boundary, %d obstacle particles"%(nf, nb, no)
else:
print "3D dam break with %d fluid, %d boundary particles"%(nf, nb)


# load balancing props for the arrays
#fluid.set_lb_props(['x', 'y', 'z', 'u', 'v', 'w', 'rho', 'h', 'm', 'gid',
Expand All @@ -382,11 +391,13 @@ def create_particles(self, **kwargs):
#boundary.set_lb_props(['x', 'y', 'z', 'rho', 'h', 'm', 'gid', 'rho0'])
#obstacle.set_lb_props(['x', 'y', 'z', 'rho', 'h', 'm', 'gid', 'rho0'])
boundary.set_lb_props( boundary.properties.keys() )
obstacle.set_lb_props( obstacle.properties.keys() )

# boundary and obstacle particles can do with a reduced list of properties
# to be saved to disk since they are fixed
boundary.set_output_arrays( ['x', 'y', 'z', 'rho', 'm', 'h', 'p', 'tag', 'pid', 'gid'] )
obstacle.set_output_arrays( ['x', 'y', 'z', 'rho', 'm', 'h', 'p', 'tag', 'pid', 'gid'] )

if self.with_obstacle:
obstacle.set_lb_props( obstacle.properties.keys() )
obstacle.set_output_arrays( ['x', 'y', 'z', 'rho', 'm', 'h', 'p', 'tag', 'pid', 'gid'] )

return particles

0 comments on commit f1a5ee2

Please sign in to comment.