Skip to content

Commit

Permalink
Merge pull request #467 from ketch/wall_indices
Browse files Browse the repository at this point in the history
Allow specification of which field to reflect for wall BCs.
  • Loading branch information
mandli committed Sep 28, 2014
2 parents 4579f68 + f82e646 commit a1adba1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/pyclaw/classic/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ def __init__(self, riemann_solver=None, claw_package=None):
See :class:`ClawSolver1D` for more info.
"""
self.num_dim = 1
self.reflect_index = [1]

super(ClawSolver1D,self).__init__(riemann_solver, claw_package)

Expand Down Expand Up @@ -448,6 +449,7 @@ def __init__(self,riemann_solver=None, claw_package=None):
self.transverse_waves = self.trans_inc

self.num_dim = 2
self.reflect_index = [1,2]

self.aux1 = None
self.aux2 = None
Expand Down Expand Up @@ -610,6 +612,7 @@ def __init__(self, riemann_solver=None, claw_package=None):
self.transverse_waves = self.trans_cor

self.num_dim = 3
self.reflect_index = [1,2,3]

self.aux1 = None
self.aux2 = None
Expand Down
3 changes: 3 additions & 0 deletions src/pyclaw/sharpclaw/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ def __init__(self,riemann_solver=None,claw_package=None):
See :class:`SharpClawSolver1D` for more info.
"""
self.num_dim = 1
self.reflect_index = [1]
super(SharpClawSolver1D,self).__init__(riemann_solver,claw_package)


Expand Down Expand Up @@ -755,6 +756,7 @@ def __init__(self,riemann_solver=None,claw_package=None):
See :class:`SharpClawSolver2D` for more info.
"""
self.num_dim = 2
self.reflect_index = [1,2]

super(SharpClawSolver2D,self).__init__(riemann_solver,claw_package)

Expand Down Expand Up @@ -826,6 +828,7 @@ def __init__(self,riemann_solver=None,claw_package=None):
See :class:`SharpClawSolver3D` for more info.
"""
self.num_dim = 3
self.reflect_index = [1,2,3]

super(SharpClawSolver3D,self).__init__(riemann_solver,claw_package)

Expand Down
4 changes: 2 additions & 2 deletions src/pyclaw/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def _bc_lower(self, bc_type, state, dim, t, array, idim, name):
if name == 'q':
for i in xrange(self.num_ghost):
array[:,i,...] = array[:,2*self.num_ghost-1-i,...]
array[idim+1,i,...] = -array[idim+1,2*self.num_ghost-1-i,...] # Negate normal velocity
array[self.reflect_index[idim],i,...] = -array[self.reflect_index[idim],2*self.num_ghost-1-i,...] # Negate normal velocity
else:
for i in xrange(self.num_ghost):
array[:,i,...] = array[:,2*self.num_ghost-1-i,...]
Expand Down Expand Up @@ -489,7 +489,7 @@ def _bc_upper(self, bc_type, state, dim, t, array, idim, name):
if name == 'q':
for i in xrange(self.num_ghost):
array[:,-i-1,...] = array[:,-2*self.num_ghost+i,...]
array[idim+1,-i-1,...] = -array[idim+1,-2*self.num_ghost+i,...] # Negate normal velocity
array[self.reflect_index[idim],-i-1,...] = -array[self.reflect_index[idim],-2*self.num_ghost+i,...] # Negate normal velocity
else:
for i in xrange(self.num_ghost):
array[:,-i-1,...] = array[:,-2*self.num_ghost+i,...]
Expand Down

0 comments on commit a1adba1

Please sign in to comment.