<s> import copy <EOL> from openmdao . lib . datatypes . domain . flow import FlowSolution <EOL> from openmdao . lib . datatypes . domain . grid import GridCoordinates <EOL> CARTESIAN = '<STR_LIT>' <EOL> CYLINDRICAL = '<STR_LIT>' <EOL> _COORD_SYSTEMS = ( CARTESIAN , CYLINDRICAL ) <EOL> class Zone ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . grid_coordinates = GridCoordinates ( ) <EOL> self . flow_solution = FlowSolution ( ) <EOL> self . reference_state = None <EOL> self . _coordinate_system = CARTESIAN <EOL> self . right_handed = True <EOL> self . symmetry = None <EOL> self . symmetry_axis = None <EOL> self . symmetry_instances = <NUM_LIT:1> <EOL> @ property <EOL> def shape ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . grid_coordinates . shape <EOL> @ property <EOL> def extent ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . grid_coordinates . extent <EOL> def _get_coord_sys ( self ) : <EOL> return self . _coordinate_system <EOL> def _set_coord_sys ( self , sys ) : <EOL> if sys in _COORD_SYSTEMS : <EOL> self . _coordinate_system = sys <EOL> else : <EOL> raise ValueError ( '<STR_LIT>' % sys ) <EOL> coordinate_system = property ( _get_coord_sys , _set_coord_sys , <EOL> doc = '<STR_LIT>' ) <EOL> def copy ( self ) : <EOL> """<STR_LIT>""" <EOL> return copy . deepcopy ( self ) <EOL> def is_equivalent ( self , other , logger , tolerance = <NUM_LIT:0.> ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( other , Zone ) : <EOL> logger . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if self . coordinate_system != other . coordinate_system : <EOL> logger . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if self . right_handed != other . right_handed : <EOL> logger . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if self . symmetry != other . symmetry : <EOL> logger . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if self . symmetry_axis != other . symmetry_axis : <EOL> logger . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if self . symmetry_instances != other . symmetry_instances : <EOL> logger . debug ( '<STR_LIT>' ) <EOL> return False <EOL> if not self . grid_coordinates . is_equivalent ( other . grid_coordinates , <EOL> logger , tolerance ) : <EOL> return False <EOL> if not self . flow_solution . is_equivalent ( other . flow_solution , logger , <EOL> tolerance ) : <EOL> return False <EOL> return True <EOL> def extract ( self , imin , imax , jmin = None , jmax = None , kmin = None , kmax = None , <EOL> grid_ghosts = None , flow_ghosts = None ) : <EOL> """<STR_LIT>""" <EOL> zone = Zone ( ) <EOL> zone . grid_coordinates = self . grid_coordinates . extract ( imin , imax , jmin , jmax , kmin , kmax , <EOL> grid_ghosts ) <EOL> zone . flow_solution = self . flow_solution . extract ( imin , imax , jmin , jmax , kmin , kmax , <EOL> flow_ghosts ) <EOL> if self . reference_state is not None : <EOL> zone . reference_state = self . reference_state . copy ( ) <EOL> zone . coordinate_system = self . coordinate_system <EOL> zone . right_handed = self . right_handed <EOL> zone . symmetry = self . symmetry <EOL> zone . symmetry_axis = self . symmetry_axis <EOL> zone . symmetry_instances = self . symmetry_instances <EOL> return zone <EOL> def extend ( self , axis , delta , grid_points , flow_points , normal = None ) : <EOL> """<STR_LIT>""" <EOL> zone = Zone ( ) <EOL> if grid_points > <NUM_LIT:0> : <EOL> zone . grid_coordinates = self . grid_coordinates . extend ( axis , delta , grid_points , normal ) <EOL> else : <EOL> zone . grid_coordinates = self . grid_coordinates . copy ( ) <EOL> if flow_points > <NUM_LIT:0> : <EOL> zone . flow_solution = self . flow_solution . extend ( axis , delta , flow_points ) <EOL> else : <EOL> zone . flow_solution = self . flow_solution . copy ( ) <EOL> if self . reference_state is not None : <EOL> zone . reference_state = self . reference_state . copy ( ) <EOL> zone . coordinate_system = self . coordinate_system <EOL> zone . right_handed = self . right_handed <EOL> zone . symmetry = self . symmetry <EOL> zone . symmetry_axis = self . symmetry_axis <EOL> zone . symmetry_instances = self . symmetry_instances <EOL> return zone <EOL> def make_cartesian ( self , axis = '<STR_LIT:z>' ) : <EOL> """<STR_LIT>""" <EOL> if self . coordinate_system != CARTESIAN : <EOL> self . flow_solution . make_cartesian ( self . grid_coordinates , axis ) <EOL> self . grid_coordinates . make_cartesian ( axis ) <EOL> self . coordinate_system = CARTESIAN <EOL> def make_cylindrical ( self , axis = '<STR_LIT:z>' ) : <EOL> """<STR_LIT>""" <EOL> if self . coordinate_system != CYLINDRICAL : <EOL> self . grid_coordinates . make_cylindrical ( axis ) <EOL> self . flow_solution . make_cylindrical ( self . grid_coordinates , axis ) <EOL> self . coordinate_system = CYLINDRICAL <EOL> def make_left_handed ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . right_handed : <EOL> self . grid_coordinates . flip_z ( ) <EOL> self . flow_solution . flip_z ( ) <EOL> self . right_handed = False <EOL> def make_right_handed ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . right_handed : <EOL> self . grid_coordinates . flip_z ( ) <EOL> self . flow_solution . flip_z ( ) <EOL> self . right_handed = True <EOL> def translate ( self , delta_x , delta_y , delta_z ) : <EOL> """<STR_LIT>""" <EOL> if self . coordinate_system == CARTESIAN : <EOL> self . grid_coordinates . translate ( delta_x , delta_y , delta_z ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def rotate_about_x ( self , deg ) : <EOL> """<STR_LIT>""" <EOL> if self . coordinate_system == CARTESIAN : <EOL> self . grid_coordinates . rotate_about_x ( deg ) <EOL> self . flow_solution . rotate_about_x ( deg ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def rotate_about_y ( self , deg ) : <EOL> """<STR_LIT>""" <EOL> if self . coordinate_system == CARTESIAN : <EOL> self . grid_coordinates . rotate_about_y ( deg ) <EOL> self . flow_solution . rotate_about_y ( deg ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def rotate_about_z ( self , deg ) : <EOL> """<STR_LIT>""" <EOL> if self . coordinate_system == CARTESIAN : <EOL> self . grid_coordinates . rotate_about_z ( deg ) <EOL> self . flow_solution . rotate_about_z ( deg ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def promote ( self ) : <EOL> """<STR_LIT>""" <EOL> self . grid_coordinates . promote ( ) <EOL> self . flow_solution . promote ( ) <EOL> def demote ( self ) : <EOL> """<STR_LIT>""" <EOL> self . grid_coordinates . demote ( ) <EOL> self . flow_solution . demote ( ) </s>
