Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating the solution q at the end of each time step in a more effici…

…nt way in case of use_Petsc = True
  • Loading branch information...
commit beebdc62d0891d62e209d72f8621fa544d6fc90c 1 parent 0b41891
@amal-ghamdi amal-ghamdi authored
View
11 src/petclaw/solver.py
@@ -48,6 +48,17 @@ def append_ghost_cells(self,state):
q_dim.insert(0,state.meqn)
ghosted_q=state.lqVec.getArray().reshape(q_dim, order = 'F')
return ghosted_q
+
+ def update_global_q(self,state,ghosted_q):
+ """
+ update the value of q. for PetSolver, if ghosted_q address is the same
+ as the address of the local vector array, this is a local to global
+ communication, otherwise it will be setting the value of q
+ """
+ state.lqVec.placeArray(ghosted_q)
+ state.q_da.localToGlobal(state.lqVec,state.gqVec)
+ state.lqVec.resetArray() # This call is required because placeArray is
+ # intended to be temporarly placement
def append_ghost_cells_to_aux(self,state):
"""
View
2  src/pyclaw/clawpack.py
@@ -698,7 +698,7 @@ def homogeneous_step(self,solutions):
self.aux1,self.aux2,self.aux3,self.work)
self.cfl = cfl
- state.q=q[:,mbc:mx+mbc,mbc:my+mbc]
+ self.update_global_q(state, q)
else:
raise NotImplementedError("No python implementation for homogeneous_step in case of 2D.")
View
13 src/pyclaw/solver.py
@@ -289,6 +289,19 @@ def append_ghost_cells(self,state):
qbc[:,mbc:-mbc,mbc:-mbc,mbc:-mbc] = state.q
return qbc
+ def update_global_q(self,state,ghosted_q):
+ """
+ update the value of q. for PySolver, it is only setting the
+ value of q with proper slice of ghosted_q
+ """
+ grid = state.grid
+ if grid.ndim == 2:
+ mbc, mx, my = self.mbc, grid.ng[0],grid.ng[1]
+ state.q=ghosted_q[:,mbc:mx+mbc,mbc:my+mbc]
+ else:
+ raise NotImplementedError("The case of 1d,3D is not handled in "\
+ +"this function yet")
+
def append_ghost_cells_to_aux(self,state):
"""
Returns aux with ghost cells attached. For the serial Solver, this means
Please sign in to comment.
Something went wrong with that request. Please try again.