ich hab folgendes Problem:
Ich habe eine Datei, bei der ein Teil so aussieht:
- Boundary Condition 5 ! Block oben
Target Boundaries = 6
Velocity 1 = Equals Mesh Velocity 1
Velocity 2 = Equals Mesh Velocity 2
Mesh Update 2 = Variable Coordinate 1
Real
include pandas_disp_x_bc_t_1_iter_1.dat
End
- Boundary Condition 5 ! Block oben
Target Boundaries = 6
Velocity 1 = 0.0
Velocity 2 = 0.0
Mesh Update 2 = 0.0
End
Code: Alles auswählen
#!/user/bin/py
# -*- coding: utf-8 -*-
feld_iter = 1
time_step = 1
elmer_init_file = "fsi.sif"
target = 'include pandas'
if feld_iter==1 and time_step==1:
with open(elmer_init_file,'r') as init_sif_file:
with open("mesh_update_t_"+str(time_step)+"iter_"+str(feld_iter)+"_.sif",'w') as new_sif_file:
for line in init_sif_file:
#print line,
if target in line:
new_include = line.replace(line,'')
new_sif_file.write(new_include)
else:
new_sif_file.write(line)Aber wie bekomme ich es hin, dass er nun von der gefunden Zeile aus, z.B. die 4 vor und die 4 Zeilen nach danach nach u.a. "Velocity 1" sucht und ersetzt?
Oder sollte ich es komplett anders angehen?
Gruß
