OutputData Namespace Reference

Functions

def ParaviewOutputPebblesAnimated (OPT, DATA)
 
def ParaviewOutputPebblesStatic (OPT, DATA)
 
def SaveClumpMDPM (OPT, DATA)
 
def OutputClumpData (OPT, DATA)
 

Function Documentation

◆ OutputClumpData()

def OutputData.OutputClumpData (   OPT,
  DATA 
)
120 def OutputClumpData(OPT, DATA):
121  # Output clump data for MDPM + additional output (vtu, stl)
122  import os
123 
124  # MDPM output
125  OPT, DATA = SaveClumpMDPM(OPT, DATA)
126 
127  # Paraview output
128  if OPT['paraviewOutput']:
129  if OPT['verbose']: print("Output vtu data")
130  if (OPT['animate']): ParaviewOutputPebblesAnimated(OPT, DATA)
131  if not (OPT['animate']): ParaviewOutputPebblesStatic(OPT, DATA)
132 
133  # Pebble stl output
134  if OPT['PebbleStlOutput']:
135  if OPT['verbose']: print("Output pebble stl data")
136  path = './Clumps/' + OPT['clumpName']
137  if not os.path.exists(path):
138  os.mkdir(path)
139 
140  path += '/' + OPT['stlOutputDir'] + '/'
141  if not os.path.exists(path):
142  os.mkdir(path)
143 
144  filename = path + OPT['outStlFileName']
145  pebbles = DATA['pebbles']
146  N_theta = OPT['stlThetaRes']
147  N_phi = OPT['stlPhiRes']
148  SavePebblesStl(filename, pebbles, N_theta, N_phi)
149 
150  # Voxel grid stl output
151  if OPT['mode'] == 2 and OPT['VoxelStlOutput']:
152  if OPT['verbose']: print("Output voxel grid stl data")
153  path = './Clumps/' + OPT['clumpName']
154  if not os.path.exists(path):
155  os.mkdir(path)
156 
157  path += '/' + OPT['voxelStlOutputDir'] + '/'
158  if not os.path.exists(path):
159  os.mkdir(path)
160 
161  filename = path + OPT['voxStlFileName']
162  vox, bbox, span = DATA['voxelGrid']
163  SaveVoxelGridStl(filename, vox, bbox, span)
164 
165  return OPT, DATA
166 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet print(const Packet &a)
Definition: GenericPacketMath.h:1166
def OutputClumpData(OPT, DATA)
Definition: OutputData.py:120
def SaveClumpMDPM(OPT, DATA)
Definition: OutputData.py:98
def ParaviewOutputPebblesAnimated(OPT, DATA)
Definition: OutputData.py:17
def ParaviewOutputPebblesStatic(OPT, DATA)
Definition: OutputData.py:66
def SavePebblesStl(filename, pebbles, N_phi, N_theta)
Definition: SaveToStl.py:53
def SaveVoxelGridStl(filename, vox, bbox, span)
Definition: SaveToStl.py:63

References ParaviewOutputPebblesAnimated(), ParaviewOutputPebblesStatic(), Eigen::internal.print(), SaveClumpMDPM(), SaveToStl.SavePebblesStl(), and SaveToStl.SaveVoxelGridStl().

Referenced by MClump.main().

◆ ParaviewOutputPebblesAnimated()

def OutputData.ParaviewOutputPebblesAnimated (   OPT,
  DATA 
)
17 def ParaviewOutputPebblesAnimated(OPT, DATA):
18  import os
19  pebbles = DATA['pebbles']
20  num_timesteps = OPT['numTimesteps']
21 
22  filename = './Clumps/' + OPT['clumpName']
23  if not os.path.exists(filename):
24  os.mkdir(filename)
25 
26  filename += '/' + OPT['paraviewOutputDir']
27  if not os.path.exists(filename):
28  os.mkdir(filename)
29 
30  filename += '/' + OPT['vtuFileName']
31  if not os.path.exists(filename):
32  os.mkdir(filename)
33 
34  positions = np.zeros([len(pebbles), num_timesteps, 3])
35  velocities = np.zeros([len(pebbles), num_timesteps, 3])
36  v1t = np.zeros([num_timesteps, 3])
37  v2t = np.zeros([num_timesteps, 3])
38  v3t = np.zeros([num_timesteps, 3])
39 
40  radii = np.zeros([len(pebbles), num_timesteps])
41 
42  for k in range(num_timesteps):
43 
44  v1 = np.array([np.cos(k * (2. * np.pi / (num_timesteps + 0.))), -np.sin(k * (2. * np.pi / (num_timesteps + 0.))), 0.0])
45  v2 = np.array([np.sin(k * (2. * np.pi / (num_timesteps + 0.))), np.cos(k * (2. * np.pi / (num_timesteps + 0.))), 0.0])
46  v3 = np.array([0.0, 0.0, 1.0])
47 
48  v1c = np.array([np.cos(-k * (2. * np.pi / (num_timesteps + 0.))), -np.sin(-k * (2. * np.pi / (num_timesteps + 0.))), 0.0])
49  v2c = np.array([np.sin(-k * (2. * np.pi / (num_timesteps + 0.))), np.cos(-k * (2. * np.pi / (num_timesteps + 0.))), 0.0])
50  v3c = np.array([0.0, 0.0, 1.0])
51 
52  r_pebbles = RotateToPDPebbles(pebbles, v1, v2, v3)
53  v1t[k][:] = v1c
54  v2t[k][:] = v2c
55  v3t[k][:] = v3c
56 
57  for i in range(len(pebbles)):
58  positions[i][k][:] = r_pebbles[i][:3]
59  radii[i][k] = r_pebbles[i][3]
60 
61  SavePebblesToVtu(filename, positions, velocities, radii)
62  SavePDToVtu(filename, v1t, v2t, v3t)
63 
64  return
65 
def RotateToPDPebbles(pebbles, v1, v2, v3)
Definition: InertiaComputationsPebbles.py:60
def SavePebblesToVtu(filename, positions, velocities, rad)
Definition: SaveToVtu.py:11
def SavePDToVtu(filename, v1, v2, v3)
Definition: SaveToVtu.py:76

References InertiaComputationsPebbles.RotateToPDPebbles(), SaveToVtu.SavePDToVtu(), and SaveToVtu.SavePebblesToVtu().

Referenced by OutputClumpData().

◆ ParaviewOutputPebblesStatic()

def OutputData.ParaviewOutputPebblesStatic (   OPT,
  DATA 
)
66 def ParaviewOutputPebblesStatic(OPT, DATA):
67  import os
68  pebbles = DATA['pebbles']
69 
70  filename = './Clumps/' + OPT['clumpName']
71  if not os.path.exists(filename):
72  os.mkdir(filename)
73 
74  filename += '/' + OPT['paraviewOutputDir']
75  if not os.path.exists(filename):
76  os.mkdir(filename)
77 
78  filename += '/' + OPT['vtuFileName']
79  if not os.path.exists(filename):
80  os.mkdir(filename)
81 
82  if os.path.exists(OPT['paraviewOutputDir']): # Remove vtu files from the previous run
83  os.chdir(OPT['paraviewOutputDir'])
84  os.remove('*.vtu')
85 
86  positions = np.zeros([len(pebbles), 1, 3])
87  velocities = np.zeros([len(pebbles), 1, 3])
88  radii = np.zeros([len(pebbles), 1])
89 
90  for i in range(len(pebbles)):
91  positions[i][0][:] = pebbles[i][:3]
92  radii[i][0] = pebbles[i][3]
93 
94  SavePebblesToVtu(filename, positions, velocities, radii)
95  return
96 
97 

References SaveToVtu.SavePebblesToVtu().

Referenced by OutputClumpData().

◆ SaveClumpMDPM()

def OutputData.SaveClumpMDPM (   OPT,
  DATA 
)
98 def SaveClumpMDPM(OPT, DATA):
99  import os
100 
101  path = './Clumps/' + OPT['clumpName']
102  if not os.path.exists(path):
103  os.mkdir(path)
104 
105  pathI = path + '/' + OPT['inertiaOutputDir'] + '/'
106  if not os.path.exists(pathI):
107  os.mkdir(pathI)
108 
109  pathC = path + '/' + OPT['clumpOutputDir'] + '/'
110  if not os.path.exists(pathC):
111  os.mkdir(pathC)
112 
113  np.savetxt(pathI + OPT['inertiaFileName'], DATA['toi'], delimiter=',')
114  np.savetxt(pathI + OPT['pdFileName'], DATA['pd'], delimiter=',')
115  np.savetxt(pathI + OPT['massFileName'], [DATA['mass']], delimiter=',')
116  np.savetxt(pathC + OPT['outClumpFileName'], DATA['pebbles'], delimiter=',')
117  return OPT, DATA
118 
119 

Referenced by OutputClumpData().