27 raise(
Exception(
"This code needs at least two arguments, e.g. \n\t./ConvertRestartToData.py name.restart wall_id [wall_id_end]"))
29 wall_id_begin =
int(sys.argv[2])
31 wall_id_end =
int(sys.argv[3])
33 wall_id_end = wall_id_begin
36 restart_file_name = sys.argv[1]
37 data_file_name = restart_file_name.replace(
".restart",
".data")
38 fstat_file_name = restart_file_name.replace(
".restart",
".fstat")
41 data_file = open(data_file_name,
'w')
42 fstat_file = open(fstat_file_name,
'w')
43 restart_file = open(restart_file_name)
44 print(
"Reading %s" % restart_file_name)
45 restart_file = restart_file.readlines()
49 while not restart_file[i].startswith(
'Walls '): i += 1
50 num_walls =
int(restart_file[i].
split()[1])
52 index_walls_end = index_walls + num_walls
54 wall0 = restart_file[index_walls].
split()
55 torque_index = wall0.index(
'torque')
60 for i
in range(index_walls, index_walls_end):
61 wall = restart_file[i].
split()
62 wall_id =
int(wall[2])
63 if wall_id<=wall_id_end
and wall_id>=wall_id_begin:
64 torque_x += float(wall[torque_index+1])
65 torque_y += float(wall[torque_index+2])
66 torque_z += float(wall[torque_index+3])
67 print(
"Torque %r %r %r" % (torque_x,torque_y,torque_z))
def main()
Definition: ComputeWallTorque.py:23
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet print(const Packet &a)
Definition: GenericPacketMath.h:1166
void split(const DoubleVector &in_vector, Vector< DoubleVector * > &out_vector_pt)
Definition: double_vector.cc:1413