def cfe_readDiderot(p_out, app, pos): #read diderot template ftemplate = open(template, 'r') ftemplate.readline() #write diderot program f = open(p_out+".diderot", 'w+') oty = app.oty dim = oty.dim args = apply.get_all_Fields(app) #output type for line in ftemplate: # is it initial field line? a0 = re.search(foo_in, line) if a0: #replace field input line cfe_defineField(f,args, app, dim) # put each argument s continue # is it output tensor line? b0 = re.search(foo_outTen, line) if b0: #print "outline" outLine(f, app) continue # operation on field c0 = re.search(foo_op,line) if c0: #print "replace op" replaceOp(f, app) cfe_makeCFE(f,args,oty,const_probeG_cfe,const_probeG_conv) continue # index field at position d0 = re.search(foo_probe,line) if d0: #print "update_method" cfe_update_method(f, args, pos, app) continue # length number of positions e0=re.search(foo_length, line) if e0: #print "Set length" nc_setLength(f,len(pos)) continue # nothing is being replaced else: f.write(line) ftemplate.close() f.close()
def prog_readDiderot(p_out, oty, program, fields, pos): print "oty", oty.name #read diderot template ftemplate = open(template, 'r') ftemplate.readline() #write diderot program f = open(p_out + ".diderot", 'w+') for line in ftemplate: # is it initial field line? a0 = re.search(foo_in, line) if a0: #replace field input line inShape_base(f, fields) continue # is it output tensor line? b0 = re.search(foo_outTen, line) if b0: #print "outline" prog_outLine(f, oty) continue # operation on field c0 = re.search(foo_op, line) if c0: #print "replace op" prog_printline(f, program.lines1) continue # index field at position d0 = re.search(foo_probe, line) if d0: #print "update_method" prog_update_method(f, oty, pos, program) continue # length number of positions e0 = re.search(foo_length, line) if e0: #print "Set length" nc_setLength(f, len(pos)) continue # nothing is being replaced else: f.write(line) ftemplate.close() f.close()
def readDiderot(p_out, app, pos): #read diderot template ftemplate = open(template, 'r') ftemplate.readline() #write diderot program f = open(p_out + ".diderot", 'w+') #output type for line in ftemplate: # is it initial field line? a0 = re.search(foo_in, line) if a0: #replace field input line inShape(f, app) continue # is it output tensor line? b0 = re.search(foo_outTen, line) if b0: #print "outline" outLine(f, app) continue # operation on field c0 = re.search(foo_op, line) if c0: #print "replace op" replaceOp(f, app) continue # index field at position d0 = re.search(foo_probe, line) if d0: #print "update_method" cte_update_method(f, pos, app) continue # length number of positions e0 = re.search(foo_length, line) if e0: #print "Set length" nc_setLength(f, len(pos)) continue # nothing is being replaced else: f.write(line) ftemplate.close() f.close()
def readDiderot(p_out, app, pos, template, core_fields): #read diderot template # FIXME hardcode different fem limit here ftemplate = open(template, 'r') ftemplate.readline() #write diderot program f = open(p_out + ".diderot", 'w+') oty = app.oty dim = oty.dim basis = "\ntensor[2] e1 = [1,0];\ntensor[2] e2 = [0,1];" if dim == 2 else "\ntensor[3] e1 = [1,0,0];\ntensor[3] e2 = [0,1,0];\ntensor[3] e3 = [0,0,1];\n" #output type for line in ftemplate: # is it initial field line? z0 = re.search(foo_basis, line) if z0: f.write(basis) continue a0 = re.search(foo_in, line) if a0: #replace field input line fem_inShape(f, core_fields) continue # is it output tensor line? b0 = re.search(foo_outTen, line) if b0: #print "outline" outLine(f, app) continue # operation on field c0 = re.search(foo_op, line) if c0: #print "replace op" replaceOp(f, app) continue # index field at position d0 = re.search(foo_probe, line) if d0: #print "update_method" cte_update_method(f, pos, app) continue # length number of positions e0 = re.search(foo_length, line) if e0: #print "Set length" nc_setLength(f, len(pos)) continue f0 = re.search(foo_limits, line) if f0: fem_limits(f, dim, 0) continue # nothing is being replaced g0 = re.search(foo_posIn, line) if g0: posIn(f, dim) continue g0 = re.search(foo_posLast, line) if g0: posLast(f, dim) continue else: f.write(line) ftemplate.close() f.close()
def readDiderot(p_out, app, pos, template, core_fields): #read diderot template # FIXME hardcode different fem limit here ftemplate = open(template, 'r') ftemplate.readline() #write diderot program f = open(p_out + ".diderot", 'w+') oty = app.oty dim = oty.dim #output type for line in ftemplate: # is it initial field line? a0 = re.search(foo_in, line) if a0: #replace field input line fem_inShape(f, core_fields) continue # is it output tensor line? b0 = re.search(foo_outTen, line) if b0: ##print "outline" outLine(f, app) continue # operation on field c0 = re.search(foo_op, line) if c0: if ((app.opr.id == op_none.id)): if (app.isrootlhs): getConvertLine(f, oty, opfieldname1, 0) else: if (app.lhs.opr.id == op_none.id): getConvertLine(f, oty, opfieldname1, 0) else: replaceOp(f, app) else: replaceOp(f, app) continue if c0: ##print "replace op" replaceOp(f, app) continue # index field at position d0 = re.search(foo_probe, line) if d0: ##print "update_method" cte_update_method(f, pos, app) continue # length number of positions e0 = re.search(foo_length, line) if e0: ##print "Set length" nc_setLength(f, len(pos)) continue f0 = re.search(foo_limits, line) if f0: fem_limits(f, dim) continue # nothing is being replaced g0 = re.search(foo_posIn, line) if g0: posIn(f, dim) continue g0 = re.search(foo_posLast, line) if g0: posLast(f, dim) continue else: f.write(line) ftemplate.close() f.close()