""" Makro Abaqus Start """ from abaqus import * from abaqus import getInputs import testUtils testUtils.setBackwardCompatibility() from abaqusConstants import * import sketch import part # -*- coding: mbcs -*- from part import * from material import * from section import * from assembly import * from step import * from interaction import * from load import * from mesh import * from job import * from sketch import * from visualization import * from connectorBehavior import * import odbAccess #------------------------------------------------- fields = (('Name of the Job ?','DiaLoad'), ('Name of the Model ?','Liver9kTet10RespiratoryPropagated'),('Name of the Step ?','CustomLoad'),('Name of the instance ?','LIVER9KTET10-INSTANCE'), ) inFile, NameModel, NameStep,NameInstance = getInputs(fields=fields, label=' ', dialogTitle='Creation of VTK files', ) inFile = str(inFile) NameModel = str(NameModel) NameStep = str(NameStep) NameInstance = str(NameInstance) NameFile = inFile NameODB = NameFile+'.odb' o1 = session.openOdb(name=NameODB) session.viewports['Viewport: 1'].setValues(displayedObject=o1) myOdb = session.odbs[NameODB] # to CHANGE !!! mySteps = myOdb.steps numStep = len(mySteps) myStep = myOdb.steps[NameStep] # to CHANGE !!! numFrames = len(myStep.frames) #VTK FILE #------------------------------------------------------------------------------------------- print '\nWritting of the VTK File' #Initial Frame #------------------------------------------------------------------------------------------- dataframe = myStep.frames[0] dispField = dataframe.fieldOutputs['U'] outFile = open( NameFile+'Ini.vtk' , 'w' ) # to CHANGE !!! # write vtk header outFile.write( '# vtk DataFile Version 3.0' ) outFile.write( '\nvtk output' ) outFile.write( '\nASCII' ) outFile.write( '\nDATASET UNSTRUCTURED_GRID' ) # write points print o1.rootAssembly.instances myInstance = mdb.models[NameModel].rootAssembly.instances[NameInstance] # to CHANGE !!! numNodesTotal = len( myInstance.nodes ) #numNodesTotal = 2125 outFile.write( '\n\nPOINTS ' + str( numNodesTotal ) + ' float' ) for i in range( numNodesTotal ): curNode = myInstance.nodes[i] defNodePos = curNode.coordinates + dispField.values[i].data outFile.write( '\n' ) for j in range( 3 ): outFile.write( str( defNodePos[j] ) + ' ' ) # write cells numElementsTotal = len(myInstance.elements ) outFile.write( '\n\nCELLS ' + str( numElementsTotal ) + ' ' + str( numElementsTotal * 5 ) ) for i in range( numElementsTotal ): curElement = list( [4] + list( myInstance.elements[i].connectivity ) ) outFile.write( '\n' ) for j in range( 5 ): outFile.write( str( curElement[j] ) + ' ' ) # write cell types outFile.write( '\n\nCELL_TYPES ' + str( numElementsTotal ) ) for i in range( numElementsTotal ): outFile.write( '\n10' ) # write cell data outFile.write( '\n\nCELL_DATA ' + str( numElementsTotal ) ) # write point data outFile.write( '\n\nPOINT_DATA ' + str( numNodesTotal ) ) outFile.close() #o1.close() #Last frame VTK #-------------------------------------------------------------------------------------------- dataframe = myStep.frames[numFrames-1] dispField = dataframe.fieldOutputs['U'] outFile = open( NameFile+'.vtk' , 'w' ) # to CHANGE !!! # write vtk header outFile.write( '# vtk DataFile Version 3.0' ) outFile.write( '\nvtk output' ) outFile.write( '\nASCII' ) outFile.write( '\nDATASET UNSTRUCTURED_GRID' ) # write points myInstance = mdb.models[NameModel].rootAssembly.instances[NameInstance] # to CHANGE !!! numNodesTotal = len( myInstance.nodes ) #numNodesTotal = 2125 outFile.write( '\n\nPOINTS ' + str( numNodesTotal ) + ' float' ) for i in range( numNodesTotal ): curNode = myInstance.nodes[i] defNodePos = curNode.coordinates + dispField.values[i].data outFile.write( '\n' ) for j in range( 3 ): outFile.write( str( defNodePos[j] ) + ' ' ) # write cells numElementsTotal = len(myInstance.elements ) outFile.write( '\n\nCELLS ' + str( numElementsTotal ) + ' ' + str( numElementsTotal * 5 ) ) for i in range( numElementsTotal ): curElement = list( [4] + list( myInstance.elements[i].connectivity ) ) outFile.write( '\n' ) for j in range( 5 ): outFile.write( str( curElement[j] ) + ' ' ) # write cell types outFile.write( '\n\nCELL_TYPES ' + str( numElementsTotal ) ) for i in range( numElementsTotal ): outFile.write( '\n10' ) # write cell data outFile.write( '\n\nCELL_DATA ' + str( numElementsTotal ) ) # write point data outFile.write( '\n\nPOINT_DATA ' + str( numNodesTotal ) ) outFile.close() #o1.close()