<s> """<STR_LIT>""" <EOL> from openmdao . lib . datatypes . domain import Vector , read_plot3d_grid <EOL> from openmdao . util . log import NullLogger <EOL> from openmdao . util . stream import Stream <EOL> def read_q ( grid_file , q_file , multiblock = True , blanking = False , logger = None ) : <EOL> """<STR_LIT>""" <EOL> logger = logger or NullLogger ( ) <EOL> domain = read_plot3d_grid ( grid_file , multiblock , dim = <NUM_LIT:3> , blanking = blanking , <EOL> planes = False , binary = True , big_endian = False , <EOL> single_precision = False , unformatted = True , <EOL> logger = logger ) <EOL> with open ( q_file , '<STR_LIT:rb>' ) as inp : <EOL> logger . info ( "<STR_LIT>" , q_file ) <EOL> stream = Stream ( inp , binary = True , big_endian = False , <EOL> single_precision = False , integer_8 = False , <EOL> unformatted = True , recordmark_8 = False ) <EOL> if multiblock : <EOL> nblocks = stream . read_int ( full_record = True ) <EOL> else : <EOL> nblocks = <NUM_LIT:1> <EOL> if nblocks != len ( domain . zones ) : <EOL> raise RuntimeError ( '<STR_LIT>' % ( nblocks , len ( domain . zones ) ) ) <EOL> reclen = stream . read_recordmark ( ) <EOL> expected = stream . reclen_ints ( <NUM_LIT:3> * nblocks + <NUM_LIT:2> ) <EOL> if reclen != expected : <EOL> logger . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , reclen , expected ) <EOL> for zone in domain . zones : <EOL> name = domain . zone_name ( zone ) <EOL> imax , jmax , kmax = stream . read_ints ( <NUM_LIT:3> ) <EOL> if imax < <NUM_LIT:1> or jmax < <NUM_LIT:1> or kmax < <NUM_LIT:1> : <EOL> raise ValueError ( "<STR_LIT>" % ( imax , jmax , kmax ) ) <EOL> logger . debug ( '<STR_LIT>' , name , imax , jmax , kmax ) <EOL> zone_i , zone_j , zone_k = zone . shape <EOL> if imax != zone_i or jmax != zone_j or kmax != zone_k : <EOL> raise RuntimeError ( '<STR_LIT>' % ( name , imax , jmax , kmax , <EOL> zone_i , zone_j , zone_k ) ) <EOL> nq , nqc = stream . read_ints ( <NUM_LIT:2> ) <EOL> logger . debug ( '<STR_LIT>' , nq , nqc ) <EOL> reclen2 = stream . read_recordmark ( ) <EOL> if reclen2 != reclen : <EOL> logger . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , reclen2 , reclen ) <EOL> for zone in domain . zones : <EOL> name = domain . zone_name ( zone ) <EOL> logger . debug ( '<STR_LIT>' , name ) <EOL> _read_scalars ( zone , nqc , stream , logger ) <EOL> _read_vars ( zone , nq , nqc , stream , logger ) <EOL> return domain <EOL> def _read_scalars ( zone , nqc , stream , logger ) : <EOL> """<STR_LIT>""" <EOL> reclen = stream . read_recordmark ( ) <EOL> expected = stream . reclen_floats ( <NUM_LIT:7> ) + stream . reclen_ints ( <NUM_LIT:1> ) + stream . reclen_floats ( <NUM_LIT:3> ) + stream . reclen_floats ( max ( <NUM_LIT:2> , nqc ) ) + stream . reclen_floats ( <NUM_LIT:3> ) <EOL> if reclen != expected : <EOL> logger . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , reclen , expected ) <EOL> refmach , alpha , rey , time , gaminf , beta , tinf = stream . read_floats ( <NUM_LIT:7> ) <EOL> igam = stream . read_int ( ) <EOL> htinf , ht1 , ht2 = stream . read_floats ( <NUM_LIT:3> ) <EOL> rgas = stream . read_floats ( max ( <NUM_LIT:2> , nqc ) ) , <EOL> fsmach , tvref , dtvref = stream . read_floats ( <NUM_LIT:3> ) <EOL> logger . debug ( '<STR_LIT>' , <EOL> refmach , fsmach , alpha , beta , rey , time ) <EOL> logger . debug ( '<STR_LIT>' , <EOL> gaminf , igam , tinf , htinf , ht1 , ht2 ) <EOL> logger . debug ( '<STR_LIT>' , rgas ) <EOL> logger . debug ( '<STR_LIT>' , tvref , dtvref ) <EOL> flow = zone . flow_solution <EOL> flow . refmach = refmach <EOL> flow . fsmach = fsmach <EOL> flow . alpha = alpha <EOL> flow . beta = beta <EOL> flow . reynolds = rey <EOL> flow . time = time <EOL> flow . gaminf = gaminf <EOL> flow . igam = igam <EOL> flow . tinf = tinf <EOL> flow . htinf = htinf <EOL> flow . ht1 = ht1 <EOL> flow . ht2 = ht2 <EOL> flow . rgas = rgas <EOL> flow . tvref = tvref <EOL> flow . dtvref = dtvref <EOL> reclen2 = stream . read_recordmark ( ) <EOL> if reclen2 != reclen : <EOL> logger . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , reclen2 , reclen ) <EOL> def _read_vars ( zone , nq , nqc , stream , logger ) : <EOL> """<STR_LIT>""" <EOL> shape = zone . shape <EOL> imax , jmax , kmax = shape <EOL> reclen = stream . read_recordmark ( ) <EOL> expected = stream . reclen_floats ( nq * imax * jmax * kmax ) <EOL> if reclen != expected : <EOL> logger . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , reclen , expected ) <EOL> name = '<STR_LIT>' <EOL> arr = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , name , arr . min ( ) , arr . max ( ) ) <EOL> zone . flow_solution . add_array ( name , arr ) <EOL> vec = Vector ( ) <EOL> vec . x = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , vec . x . min ( ) , vec . x . max ( ) ) <EOL> vec . y = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , vec . y . min ( ) , vec . y . max ( ) ) <EOL> vec . z = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , vec . z . min ( ) , vec . z . max ( ) ) <EOL> zone . flow_solution . add_vector ( '<STR_LIT>' , vec ) <EOL> name = '<STR_LIT>' <EOL> arr = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , name , arr . min ( ) , arr . max ( ) ) <EOL> zone . flow_solution . add_array ( name , arr ) <EOL> name = '<STR_LIT>' <EOL> arr = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , name , arr . min ( ) , arr . max ( ) ) <EOL> zone . flow_solution . add_array ( name , arr ) <EOL> for i in range ( nqc ) : <EOL> name = '<STR_LIT>' % ( i + <NUM_LIT:1> ) <EOL> arr = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , name , arr . min ( ) , arr . max ( ) ) <EOL> zone . flow_solution . add_array ( name , arr ) <EOL> for i in range ( nq - ( <NUM_LIT:6> + nqc ) ) : <EOL> name = '<STR_LIT>' % ( i + <NUM_LIT:1> ) <EOL> arr = stream . read_floats ( shape , order = '<STR_LIT>' ) <EOL> logger . debug ( '<STR_LIT>' , name , arr . min ( ) , arr . max ( ) ) <EOL> zone . flow_solution . add_array ( name , arr ) <EOL> if stream . unformatted : <EOL> reclen2 = stream . read_recordmark ( ) <EOL> if reclen2 != reclen : <EOL> logger . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , reclen2 , reclen ) </s>
