-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOasisParticleTracking.py
62 lines (40 loc) · 2.23 KB
/
OasisParticleTracking.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from dolfin import *
from utilities import *
import argparse
import vtk
class OasisParticleTracking():
def __init__(self,args):
self.Args=args
self.Args.dt=self.Args.Period/(self.Args.Stop-self.Args.Start)
def Main(self):
#Read the mesh
Mesh=ReadFenicsMesh(self.Args.InputMeshFile)
print ("Mesh Loaded...")
#Read the velocity data
f = HDF5File(MPI.comm_world, self.Args.InputVelocityFile, "r")
# Get names of data to extract
Start = 0
if MPI.rank(MPI.comm_world) == 0:
print("The post processing Starts from", Start)
dataset_names = get_dataset_names(f, Start=self.Args.Start,num_files=self.Args.Stop)
# Create Function space
print ("Creating Function Spaces")
V = VectorFunctionSpace(mesh, "CG", velocity_degree)
u = Function(V)
#Loop over the velocity field
dt=self.Args.dt
for dataset_name_ in dataset_names:
f.read(u,dataset_name_)
if __name__=="__main__":
#Description
parser = argparse.ArgumentParser(description="This script will seed points near the given surface and track them until they reach the outlets.")
parser.add_argument('-InputVelocityFile', '--InputVelocityFile', type=str, required=True, dest="InputVelocityFile",help="The h5 file containing the velocity field.")
parser.add_argument('-VelocityOrder', '--VelocityOrder', type=int, required=False, default=1, dest="VelocityOrder",help="The polynomial order for the velocity field.")
parser.add_argument('-InputMeshFile', '--InputMeshFile', type=str, required=True, dest="InputMeshFile",help="The file contains the mesh in vtu format.")
parser.add_argument('-Start', '--Start', type=int, required=False, dest="Start",default=1,help="The Starting time step")
parser.add_argument('-Stop', '--Stop', type=int, required=False, dest="Stop",default=1000,help="The ending time step")
parser.add_argument('-Period', '--Period', type=float, required=False, dest="Perioid",default=0.951,help="The length of the cardiac cycle.")
#Output Filename
parser.add_argument('-OutputFile', '--OutputFile', type=str, required=False, dest="OutputFile",help="The output file in which to store the dolfin mesh.")
args=parser.parse_args()
OasisParticleTracking(args).Main()