#NEWLINE# def initialize( self ) : #NEWLINE# #INDENT# '\n        Initialize the grid and variables for diffusion and set the initial\n        conditions for the chosen problem.\n        ' #NEWLINE# my_grid = grid_setup ( self . rp , ng = 1 ) #NEWLINE# xlb_type = self . rp . get_param ( 'mesh.xlboundary' ) #NEWLINE# xrb_type = self . rp . get_param ( 'mesh.xrboundary' ) #NEWLINE# ylb_type = self . rp . get_param ( 'mesh.ylboundary' ) #NEWLINE# yrb_type = self . rp . get_param ( 'mesh.yrboundary' ) #NEWLINE# bcparam = [ ] #NEWLINE# for bc in [ xlb_type , xrb_type , ylb_type , yrb_type ] : #NEWLINE# #INDENT# if ( bc == 'periodic' ) : #NEWLINE# #INDENT# bcparam . append ( 'periodic' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( bc == 'neumann' ) : #NEWLINE# #INDENT# bcparam . append ( 'neumann' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( bc == 'dirichlet' ) : #NEWLINE# #INDENT# bcparam . append ( 'dirichlet' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg . fail ( 'invalid BC' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# bc = patch . BCObject ( xlb = bcparam [ 0 ] , xrb = bcparam [ 1 ] , ylb = bcparam [ 2 ] , yrb = bcparam [ 3 ] ) #NEWLINE# my_data = patch . CellCenterData2d ( my_grid ) #NEWLINE# my_data . register_var ( 'phi' , bc ) #NEWLINE# my_data . create ( ) #NEWLINE# self . cc_data = my_data #NEWLINE# exec ( ( self . problem_name + '.init_data(self.cc_data, self.rp)' ) )