Skip to content

Commit

Permalink
Merge bf53a38 into 4c06b7a
Browse files Browse the repository at this point in the history
  • Loading branch information
ketch committed Jul 25, 2014
2 parents 4c06b7a + bf53a38 commit 42c9252
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 273 deletions.
4 changes: 2 additions & 2 deletions examples/advection_2d_annulus/advection_annulus.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def qinit(state):
+ A2*np.exp(-beta2*(np.square(R-r2) + np.square(Theta-theta2)))


def ghost_velocities_upper(state,dim,t,auxbc,num_ghost):
def ghost_velocities_upper(state,dim,t,qbc,auxbc,num_ghost):
"""
Set the velocities for the ghost cells outside the outer radius of the annulus.
In the computational domain, these are the cells at the top of the grid.
Expand All @@ -77,7 +77,7 @@ def ghost_velocities_upper(state,dim,t,auxbc,num_ghost):
raise Exception('Custom BC for this boundary is not appropriate!')


def ghost_velocities_lower(state,dim,t,auxbc,num_ghost):
def ghost_velocities_lower(state,dim,t,qbc,auxbc,num_ghost):
"""
Set the velocities for the ghost cells outside the inner radius of the annulus.
In the computational domain, these are the cells at the bottom of the grid.
Expand Down
2 changes: 1 addition & 1 deletion examples/euler_2d/shock_bubble_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def auxinit(state):
state.aux[0,:,j] = r


def incoming_shock(state,dim,t,qbc,num_ghost):
def incoming_shock(state,dim,t,qbc,auxbc,num_ghost):
"""
Incoming shock at left boundary.
"""
Expand Down
4 changes: 1 addition & 3 deletions examples/iso_c_advection/iso_c_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ def step_hyperbolic(self,solution):
state = solution.states[0]
grid = state.grid

self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)

num_eqn,num_ghost = state.num_eqn,self.num_ghost

Expand Down
22 changes: 12 additions & 10 deletions examples/psystem_2d/psystem_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def gauge_stress(q,aux):
p = np.exp(q[0]*aux[1])-1
return [p,10*p]


def setup(kernel_language='Fortran',
use_petsc=False,outdir='./_output',solver_type='classic',
disable_output=False, cells_per_layer=30, tfinal=18.):
Expand All @@ -148,13 +149,9 @@ def setup(kernel_language='Fortran',
y0=0.25 # Center of initial perturbation
varx=0.5; vary=0.5 # Width of initial perturbation

# Boundary conditions
bc_x_lower=pyclaw.BC.wall; bc_x_upper=pyclaw.BC.extrap
bc_y_lower=pyclaw.BC.wall; bc_y_upper=pyclaw.BC.extrap

num_output_times=10
num_output_times = 10

if solver_type=='classic':
if solver_type == 'classic':
solver = pyclaw.ClawSolver2D(riemann.psystem_2D)
solver.dimensional_split=False
solver.cfl_max = 0.9
Expand All @@ -166,10 +163,15 @@ def setup(kernel_language='Fortran',
if kernel_language != 'Fortran':
raise Exception('Unrecognized value of kernel_language for 2D psystem')

solver.bc_lower = [bc_x_lower, bc_y_lower]
solver.bc_upper = [bc_x_upper, bc_y_upper]
solver.aux_bc_lower = [bc_x_lower, bc_y_lower]
solver.aux_bc_upper = [bc_x_upper, bc_y_upper]
# Boundary conditions
solver.bc_lower[0] = pyclaw.BC.wall
solver.bc_upper[0] = pyclaw.BC.extrap
solver.bc_lower[1] = pyclaw.BC.wall
solver.bc_upper[1] = pyclaw.BC.extrap
solver.aux_bc_lower[0] = pyclaw.BC.wall
solver.aux_bc_upper[0] = pyclaw.BC.extrap
solver.aux_bc_lower[1] = pyclaw.BC.wall
solver.aux_bc_upper[1] = pyclaw.BC.extrap

solver.fwave = True
solver.before_step = b4step
Expand Down
8 changes: 5 additions & 3 deletions examples/psystem_2d/test_2d_psystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ def verify(controller):
for i, gauge in enumerate(gauge_files):
test_gauge_data_io = np.loadtxt(gauge.name)
verify_file = os.path.join(thisdir,'verify_' +
gauge.name.split('/')[-1])
gauge.name.split('/')[-1])
expected_gauges.append(np.loadtxt(verify_file))
return_value_mem = check_diff(expected_gauges[i],
test_gauge_data_mem[i], reltol=1e-4)
test_gauge_data_mem[i],
reltol=1e-4)
return_value_io = check_diff(expected_gauges[i],
test_gauge_data_io, reltol=1e-4)
test_gauge_data_io,
reltol=1e-4)

if (return_value_mem is not None or
return_value_io is not None):
Expand Down
8 changes: 4 additions & 4 deletions examples/shallow_sphere/Rossby_wave.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def qinit(state,mx,my):
state.q[3,i,j] = state.q[0,i,j]*Uout[2]


def qbc_lower_y(state,dim,t,qbc,num_ghost):
def qbc_lower_y(state,dim,t,qbc,auxbc,num_ghost):
"""
Impose periodic boundary condition to q at the bottom boundary for the
sphere. This function does not work in parallel.
Expand All @@ -315,7 +315,7 @@ def qbc_lower_y(state,dim,t,qbc,num_ghost):
qbc[:,:,j] = qbc1D[:,::-1]


def qbc_upper_y(state,dim,t,qbc,num_ghost):
def qbc_upper_y(state,dim,t,qbc,auxbc,num_ghost):
"""
Impose periodic boundary condition to q at the top boundary for the sphere.
This function does not work in parallel.
Expand All @@ -326,7 +326,7 @@ def qbc_upper_y(state,dim,t,qbc,num_ghost):
qbc[:,:,my+num_ghost+j] = qbc1D[:,::-1]


def auxbc_lower_y(state,dim,t,auxbc,num_ghost):
def auxbc_lower_y(state,dim,t,qbc,auxbc,num_ghost):
"""
Impose periodic boundary condition to aux at the bottom boundary for the
sphere.
Expand All @@ -344,7 +344,7 @@ def auxbc_lower_y(state,dim,t,auxbc,num_ghost):
auxtemp = problem.setaux(mx,my,num_ghost,mx,my,xlower,ylower,dx,dy,auxtemp,Rsphere)
auxbc[:,:,:num_ghost] = auxtemp[:,:,:num_ghost]

def auxbc_upper_y(state,dim,t,auxbc,num_ghost):
def auxbc_upper_y(state,dim,t,qbc,auxbc,num_ghost):
"""
Impose periodic boundary condition to aux at the top boundary for the
sphere.
Expand Down
4 changes: 2 additions & 2 deletions examples/stegoton_1d/stegoton.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ def b4step(solver,state):
solver.aux_bc_upper[0]=2


def zero_bc(state,dim,t,qbc,num_ghost):
def zero_bc(state,dim,t,qbc,auxbc,num_ghost):
"""Set everything to zero"""
if dim.on_upper_boundary:
qbc[:,-num_ghost:]=0.

def moving_wall_bc(state,dim,t,qbc,num_ghost):
def moving_wall_bc(state,dim,t,qbc,auxbc,num_ghost):
"""Initial pulse generated at left boundary by prescribed motion"""
if dim.on_lower_boundary:
qbc[0,:num_ghost]=qbc[0,num_ghost]
Expand Down
12 changes: 3 additions & 9 deletions src/pyclaw/classic/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ def step_hyperbolic(self,solution):
state = solution.states[0]
grid = state.grid

self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)

num_eqn,num_ghost = state.num_eqn,self.num_ghost

Expand Down Expand Up @@ -517,9 +515,7 @@ def step_hyperbolic(self,solution):
mx,my = grid.num_cells
maxm = max(mx,my)

self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)
qold = self.qbc.copy('F')

rpn2 = self.rp.rpn2._cpointer
Expand Down Expand Up @@ -668,9 +664,7 @@ def step_hyperbolic(self,solution):
mx,my,mz = grid.num_cells
maxm = max(mx,my,mz)

self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)
qnew = self.qbc
qold = qnew.copy('F')

Expand Down
12 changes: 3 additions & 9 deletions src/pyclaw/sharpclaw/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,7 @@ def dq_hyperbolic(self,state):

import numpy as np

self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)
q = self.qbc

grid = state.grid
Expand Down Expand Up @@ -766,9 +764,7 @@ def dq_hyperbolic(self,state):
values are in the cell.
"""
self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)
q = self.qbc

grid = state.grid
Expand Down Expand Up @@ -846,9 +842,7 @@ def dq_hyperbolic(self,state):
values are in the cell.
"""
self._apply_q_bcs(state)
if state.num_aux > 0:
self._apply_aux_bcs(state)
self._apply_bcs(state)
q = self.qbc

grid = state.grid
Expand Down
Loading

0 comments on commit 42c9252

Please sign in to comment.