def main(): print "" print '=====================================' print '# STARFiSh_v0.3 Visualisation #' print '=====================================' print "" optionsDict = parseOptions(['f','n','v'], visualisationOnly = True) networkName = optionsDict['networkName'] dataSetNumber = optionsDict['dataSetNumber'] dataNumber = optionsDict['dataNumber'] vizOutput = optionsDict['vizOutput'] if vizOutput == 'non': vizOutput = "2D+3D" string1 = ' '.join(['python',cur+'/Visualisation/class2dVisualisation.py','-f',networkName, '-n',dataNumber, '-c']) string2 = ' '.join(['python',cur+'/Visualisation/class3dVisualisation.py','-f',networkName, '-n',dataNumber, '-c True']) if vizOutput == "2D": viz2d = subprocess.Popen(string1, shell = True ) if vizOutput == "3D": viz3d = subprocess.Popen(string2, shell = True ) if vizOutput == "2D+3D": viz2d = subprocess.Popen(string1, shell = True ) viz3d = subprocess.Popen(string2, shell = True ) while True: if viz2d.poll() != None: viz3d.terminate() exit() if viz3d.poll() != None: viz2d.terminate() exit()
def main(): print "" print '=====================================' print '# STARFiSh_v0.3 #' print '=====================================' optionsDict = parseOptions(['f','n','d','s','v','r']) networkName = optionsDict['networkName'] save = optionsDict['save'] dataNumber = optionsDict['dataNumber'] simulationDescription = optionsDict['simulationDescription'] vizOutput = optionsDict['vizOutput'] resimulate = optionsDict['resimulate'] filename = str(networkName+'.xml') print '____________Simulation_______________' print '%-20s %s' % ('Network name',networkName) print '%-20s %s' % ('Data number', dataNumber) print '%-20s %s' % ('Save simulation', save) print '%-20s %s' % ('Case description', simulationDescription) print '%-20s %s' % ('Resimulate', resimulate) print '%-20s %s' % ('Visualisationmode', vizOutput) # load network from the path! if resimulate == False: vascularNetwork = loadNetworkFromXML(filename=filename) else: vascularNetwork,solutionDataSets,simulationCaseDescriptions = loadSolutionDataFile(networkName, [dataNumber]) simulationDescription = simulationCaseDescriptions[0][0] print simulationCaseDescriptions print simulationDescription,type(simulationDescription) if vascularNetwork == None: exit() vascularNetwork.evaluateConnections() timeSolverInitStart = time.clock() #initialize Solver flowSolver = FlowSolver(vascularNetwork) timeSolverInit = time.clock()-timeSolverInitStart timeSolverSolveStart = time.clock() #solve the system P,Q,A,c = flowSolver.solve() timeSolverSolve = time.clock()-timeSolverSolveStart minutesInit = int(timeSolverInit/60.) secsInit = timeSolverInit-minutesInit*60. minutesSolve = int(timeSolverSolve/60.) secsSolve = timeSolverSolve-minutesSolve*60. #print '=====================================' print '____________ Solver time _____________' print 'Initialisation: {} min {} sec'.format(minutesInit,secsInit) print 'Solving: {} min {} sec'.format(minutesSolve,secsSolve) print '=====================================' solutionDataSave = [{'Pressure': P, 'Flow': Q, 'Area': A, 'WaveSpeed':c, 'Name': str('simulation_'+dataNumber) }] networkName = filename.split('.')[0] saveSolutionDataFile(networkName,dataNumber,vascularNetwork,solutionDataSave,simulationDescription) del flowSolver gc.collect() updateSimulationDescriptions(networkName,dataNumber) gc.collect() if vizOutput == "2D": string = ' '.join(['python',cur+'/Visualisation/class2dVisualisation.py','-f',vascularNetwork.name, '-n',str(dataNumber)]) subprocess.Popen(string, shell=True) if vizOutput == "3D": string = ' '.join(['python',cur+'/Visualisation/class3dVisualisation.py','-f',vascularNetwork.name, '-n',str(dataNumber), '-c True']) subprocess.Popen(string, shell=True) if vizOutput == "2D+3D": string1 = ' '.join(['python',cur+'/Visualisation/class2dVisualisation.py','-f',vascularNetwork.name, '-n',str(dataNumber), '-c True']) string2 = ' '.join(['python',cur+'/Visualisation/class3dVisualisation.py','-f',vascularNetwork.name, '-n',str(dataNumber), '-c True']) viz2d = subprocess.Popen(string1, shell = True ) viz3d = subprocess.Popen(string2, shell = True ) while True: if viz2d.poll() != None: viz3d.terminate() exit() if viz3d.poll() != None: viz2d.terminate() exit()
import cPickle import numpy as np from pprint import pprint as pp __author__ = "Vinzenz Gregor Eck" __version__ = "0.3" ### file to help user post processing ### 1. open solution data file after a simulation ## use -f and -n to define solution file you want to open, or use the inbulid menu optionsDict = parseOptions(["f", "n", "c"], visualisationOnly=True) networkName = optionsDict["networkName"] dataSetNumber = optionsDict["dataNumber"] ## open data file choosed above try: print " Try to open network {} with data number {}".format(networkName, dataSetNumber) vascularNetwork, solutionDataSets, simulationCaseDescriptions = loadSolutionDataFile(networkName, [dataSetNumber]) solutionData = solutionDataSets[0] except: print "Error could not open solution data with data number {} of network {}".format(dataSetNumber, networkName) exit() ### 2. available data
# create RGB color vector for each vector of the vessel geometry color = np.repeat(colorSolution,nPointsPerCircle*leftRightColoringFactor,axis=0).ravel() # update color self.vertexList.colors = color ## 5.0 update normal vertices if self.viewNormals: ## create normal lines to visualize them normalEndpoint = vertices[nPointsPerCircle:nPointsPerCircle*(N-1)]+(normals*0.2) normalLines = np.append(vertices[nPointsPerCircle:nPointsPerCircle*(N-1)].ravel(),normalEndpoint.ravel()) self.vertexList2.vertices[nPointsPerCircle*3:nPointsPerCircle*(N-1)*3] = normalLines.ravel() if __name__ == '__main__': optionsDict = parseOptions(['f','n','c'], visualisationOnly = True) networkName = optionsDict['networkName'] dataSetNumber = optionsDict['dataSetNumber'] connect = optionsDict['connect'] if networkName == None: #Visualisation3DGUI Visualisation3D() else: visualisation3D = Visualisation3D(networkName, dataSetNumber, connect) pyglet.app.run()