substructure

main
harvo 8 months ago
parent bfb7fa29c9
commit 949061a8f4

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,234 +0,0 @@
# -*- 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 optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
mdb.jobs['Thermal'].setValues(userSubroutine=
'C:\\Users\\OPTX\\Downloads\\Digital-Twin\\substructure\\dflux.for')
mdb.jobs['Thermal'].submit(consistencyChecking=OFF)
mdb.jobs['Thermal']._Message(STARTED, {'phase': BATCHPRE_PHASE,
'clientHost': 'DESKTOP-21KKJMM', 'handle': 0, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(ODB_FILE, {'phase': BATCHPRE_PHASE,
'file': 'C:\\Users\\OPTX\\Downloads\\Digital-Twin\\substructure\\Thermal.odb',
'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(COMPLETED, {'phase': BATCHPRE_PHASE,
'message': 'Analysis phase complete', 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STARTED, {'phase': STANDARD_PHASE,
'clientHost': 'DESKTOP-21KKJMM', 'handle': 4980, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STEP, {'stepName': 'this is a welding step',
'phase': STANDARD_PHASE, 'stepId': 1, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 0, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(MEMORY_ESTIMATE, {'phase': STANDARD_PHASE,
'jobName': 'Thermal', 'memory': 46.0})
mdb.jobs['Thermal']._Message(PHYSICAL_MEMORY, {'phase': STANDARD_PHASE,
'physical_memory': 16347.0, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(MINIMUM_MEMORY, {'minimum_memory': 23.0,
'phase': STANDARD_PHASE, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.1, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 1, 'stepTime': 0.1, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 8,
'phase': STANDARD_PHASE, 'equilibrium': 8})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 1, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.2, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 2, 'stepTime': 0.2, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 5,
'phase': STANDARD_PHASE, 'equilibrium': 5})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 2, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.3, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 3, 'stepTime': 0.3, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 3, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.4, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 4, 'stepTime': 0.4, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 4, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.55, 'attempts': 1,
'timeIncrement': 0.15, 'increment': 5, 'stepTime': 0.55, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 5, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.75, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 6, 'stepTime': 0.75, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 6, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 0.95, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 7, 'stepTime': 0.95, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 7, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 1.15, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 8, 'stepTime': 1.15, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 8, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 1.35, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 9, 'stepTime': 1.35, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 9, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 1.55, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 10, 'stepTime': 1.55, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 10, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 1.75, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 11, 'stepTime': 1.75, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 11, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 1.95, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 12, 'stepTime': 1.95, 'step': 1,
'jobName': 'Thermal', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 12, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 0,
'frame': 13, 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(STATUS, {'totalTime': 2.0, 'attempts': 1,
'timeIncrement': 0.0500000000000002, 'increment': 13, 'stepTime': 2.0,
'step': 1, 'jobName': 'Thermal', 'severe': 0, 'iterations': 2,
'phase': STANDARD_PHASE, 'equilibrium': 2})
mdb.jobs['Thermal']._Message(END_STEP, {'phase': STANDARD_PHASE, 'stepId': 1,
'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(COMPLETED, {'phase': STANDARD_PHASE,
'message': 'Analysis phase complete', 'jobName': 'Thermal'})
mdb.jobs['Thermal']._Message(JOB_COMPLETED, {
'time': 'Wed May 17 09:05:07 2023', 'jobName': 'Thermal'})
mdb.Model(name='Model-1-s2', objectToCopy=mdb.models['Model-1'])
mdb.models['Model-1-s2'].setValues(restartJob='Thermal', restartStep='Welding')
mdb.models['Model-1-s2'].HeatTransferStep(deltmx=1500.0, initialInc=0.01,
maxInc=2.0, maxNumInc=100000, minInc=1e-05, name='Welding-2', previous=
'Welding', timePeriod=2.0)
mdb.models['Model-1-s2'].steps['Welding-2'].setValues(initialInc=0.1,
maxNumInc=100000, minInc=0.01)
mdb.models['Model-1-s2'].steps['Welding-2'].setValues(maxInc=0.2)
mdb.Job(atTime=None, contactPrint=OFF, description='', echoPrint=OFF,
explicitPrecision=SINGLE, getMemoryFromAnalysis=True, historyPrint=OFF,
memory=90, memoryUnits=PERCENTAGE, model='Model-1-s2', modelPrint=OFF,
multiprocessingMode=DEFAULT, name='Thermal-2', nodalOutputPrecision=SINGLE,
numCpus=1, numGPUs=0, queue=None, resultsFormat=ODB, scratch='', type=
RESTART, userSubroutine=
'C:\\Users\\OPTX\\Downloads\\Digital-Twin\\substructure\\dflux.for',
waitHours=0, waitMinutes=0)
mdb.jobs['Thermal-2'].submit(consistencyChecking=OFF)
mdb.jobs['Thermal-2']._Message(STARTED, {'phase': BATCHPRE_PHASE,
'clientHost': 'DESKTOP-21KKJMM', 'handle': 0, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(ODB_FILE, {'phase': BATCHPRE_PHASE,
'file': 'C:\\Users\\OPTX\\Downloads\\Digital-Twin\\substructure\\Thermal-2.odb',
'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(COMPLETED, {'phase': BATCHPRE_PHASE,
'message': 'Analysis phase complete', 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STARTED, {'phase': STANDARD_PHASE,
'clientHost': 'DESKTOP-21KKJMM', 'handle': 7044, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STEP, {'phase': STANDARD_PHASE, 'stepId': 2,
'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 0, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(MEMORY_ESTIMATE, {'phase': STANDARD_PHASE,
'jobName': 'Thermal-2', 'memory': 54.0})
mdb.jobs['Thermal-2']._Message(PHYSICAL_MEMORY, {'phase': STANDARD_PHASE,
'physical_memory': 16347.0, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(MINIMUM_MEMORY, {'minimum_memory': 29.0,
'phase': STANDARD_PHASE, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 1, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 2.1, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 1, 'stepTime': 0.1, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 2, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 2.2, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 2, 'stepTime': 0.2, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 3, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 2.3, 'attempts': 1,
'timeIncrement': 0.1, 'increment': 3, 'stepTime': 0.3, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 4, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 2.45, 'attempts': 1,
'timeIncrement': 0.15, 'increment': 4, 'stepTime': 0.45, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 5, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 2.65, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 5, 'stepTime': 0.65, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 6, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 2.85, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 6, 'stepTime': 0.85, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 4,
'phase': STANDARD_PHASE, 'equilibrium': 4})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 7, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 3.05, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 7, 'stepTime': 1.05, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 8, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 3.25, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 8, 'stepTime': 1.25, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 9, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 3.45, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 9, 'stepTime': 1.45, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 10, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 3.65, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 10, 'stepTime': 1.65, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 11, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 3.85, 'attempts': 1,
'timeIncrement': 0.2, 'increment': 11, 'stepTime': 1.85, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(ODB_FRAME, {'phase': STANDARD_PHASE, 'step': 1,
'frame': 12, 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(STATUS, {'totalTime': 4.0, 'attempts': 1,
'timeIncrement': 0.15, 'increment': 12, 'stepTime': 2.0, 'step': 2,
'jobName': 'Thermal-2', 'severe': 0, 'iterations': 3,
'phase': STANDARD_PHASE, 'equilibrium': 3})
mdb.jobs['Thermal-2']._Message(END_STEP, {'phase': STANDARD_PHASE, 'stepId': 2,
'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(COMPLETED, {'phase': STANDARD_PHASE,
'message': 'Analysis phase complete', 'jobName': 'Thermal-2'})
mdb.jobs['Thermal-2']._Message(JOB_COMPLETED, {
'time': 'Wed May 17 09:25:27 2023', 'jobName': 'Thermal-2'})

@ -0,0 +1,34 @@
<Description>
*** ABAQUS/ABQcaeG rank 0 received the SIGABRT signal
</Description>
<Callstack>
1) ucrtbase.dll abort
2) ucrtbase.dll terminate
3) VCRUNTIME140.dll is_exception_typeof
4) VCRUNTIME140.dll is_exception_typeof
5) VCRUNTIME140.dll _CxxFrameHandler3
6) ntdll.dll RtlFindCharInUnicodeString
7) ntdll.dll RtlRaiseException
8) KERNELBASE.dll RaiseException
9) VCRUNTIME140.dll CxxThrowException
10) ABQSMAInbVwrIPC.dll ipc_Socket::Close
</Callstack>
<Memory>
<Current> 93 MB </Current>
<Physical> 10203 MB </Physical>
<Limit> 0 MB </Limit>
<Virtual> 134217728 MB </Virtual>
<Accessible> 10203 MB </Accessible>
<Allocator> DL </Allocator>
</Memory>
<Directories>
<current> C:\Users\Harvo\Downloads\Digital-Twin\thermal </current>
<temp> C:\Users\Harvo\AppData\Local\Temp </temp>
</Directories>
<Installation>
</Installation>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -0,0 +1,27 @@
SUBROUTINE DFLUX(FLUX,SOL,KSTEP,KINC,TIME,NOEL,NPT,COORDS,JLTYP, TEMP, PRESS, SNAME)
INCLUDE 'ABA_PARAM.INC'
DIMENSION COORDS(3),FLUX(2),TIME(2)
CHARACTER*80 SNAME
real U,AI,v,yita,R0,qm
U=16.5
AI=60.
v=250./60.
yita=0.75
R0=5.
qm=yita*U*AI*1000./3.14/R0/R0
dx=v*TIME(1)
dy=0.
rr= (COORDS(1)-dx)**2 + (COORDS(2)-dy)**2
FLUX(1)=3.*qm*exp(-3.*rr/R0/R0)
! write(*,*) time,dx
! write(*,*) COORDS,rr
! write(*,*) FLUX
! write(*,*)
RETURN
END

@ -0,0 +1,5 @@
---------- RUNTIME EXCEPTION HAS OCCURED ----------
*** ABAQUS/ABQcaeG rank 0 received the SIGABRT signal

@ -0,0 +1,145 @@
from odbAccess import openOdb
from abaqus import *
from abaqusConstants import *
from utils_odb2vtk import Physical_Quantity
class CAE_Model(Physical_Quantity, object):
def __init__(self):
super(CAE_Model, self).__init__()
# print('self.var_type', self.var_type)
self.nodes = {}
self.elements = {}
self.physical_quantity = {}
def read_inp(self, INPPATH):
# 0 - nothing
# 1 - node
# 2 - hexahedron
state = 0
# read input file
with open(INPPATH, 'r') as input_file:
for line in input_file:
if line.strip() == '*Node':
state = 1
elif line.startswith('*Element, type=C3D8R'):
state = 2
else:
if line.startswith("*") and (not line.startswith("**")):
state = 0
elif state == 1:
nid, x, y, z = line.strip().split(',')
# insertNode(uid, x, y, z)
self.nodes[int(nid)] = [float(x), float(y), float(z)]
elif state == 2:
eid, n0, n1, n2, n3, n4, n5, n6, n7 = line.strip().split(',')
# insertHexa(el, n0, n1, n2, n3, n4, n5, n6, n7)
self.elements[int(eid)] = [int(n0), int(n1), int(
n2), int(n3), int(n4), int(n5), int(n6), int(n7)]
else:
pass
def read_odb(self, ODBPATH):
# Open the odb
myodb = openOdb(ODBPATH)
# Get the frame repository for the step, find number of frames (starts at frame 0)
stepName = myodb.steps.keys()[0]
frames = myodb.steps[stepName].frames
numFrames = len(frames)
print("num Frame %d" % (numFrames))
# Isolate the instance, get the number of nodes and elements
instanceName = myodb.rootAssembly.instances.keys()[0]
myInstance = myodb.rootAssembly.instances[instanceName]
numNodes = len(myInstance.nodes)
numElements = len(myInstance.elements)
print("num Element %d, num Node %d" % (numElements, numNodes))
for var_id in ['U', 'A', 'V', 'RF', 'S', 'LE', 'PE', 'PEEQ', 'NT11', 'HFL', 'RFL11']:
# try:
if var_id == 'NT11':
# S=myodb.steps[stepName].frames[-1].fieldOutputs['S'].getSubset(position=INTEGRATION_POINT)
var_data = myodb.steps[stepName].frames[-1].fieldOutputs[var_id].values
print(var_id+": %d" % (len(var_data)))
self.pq_update(var_id)
self.physical_quantity[var_id] = self.insert(var_data)
# except:
# print('jump ', var_id)
def write_vtk(self, OUTPATH, var_ids):
self.nids = sorted(self.nodes.keys())
self.eids = sorted(self.elements.keys())
with open(OUTPATH, 'w') as ofs:
ofs.write('<?xml version="1.0"?>')
ofs.write(
'<VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian" header_type="UInt32">')
ofs.write(
'<StructuredGrid> WholeExtent="x1 x2 x3 y1 y2 y3 z1 z2 z3">')
ofs.write('<Piece Extent="x1 x2 x3 y1 y2 y3 z1 z2 z3">')
### define Points element ###
ofs.write('<Points>')
ofs.write(
'<DataArray type="Float32" Name="Points" NumberOfComponents="3" format="ascii">')
for key in self.nids:
x, y, z = self.nodes[key]
ofs.write("%f %f %f " % (x, y, z))
ofs.write('</DataArray>')
ofs.write('</Points>')
### define Cells element ###
ofs.write('<Cells>')
ofs.write(
'<DataArray type="Int64" Name="connectivity" format="ascii">')
for key in self.eids:
ns = self.elements[key]
nns = map(lambda x: str(x - 1), ns)
cons = " ".join(nns)
ofs.write(cons + ' ')
ofs.write('</DataArray>')
ofs.write('<DataArray type="Int64" Name="offsets" format="ascii">')
for key in self.eids:
ofs.write("%d " % (key * 8))
ofs.write('</DataArray>')
ofs.write('<DataArray type="UInt8" Name="types" format="ascii">')
for key in self.eids:
ofs.write("10 ")
ofs.write('</DataArray>')
ofs.write('</Cells>')
# node data/element data
for var_id in var_ids:
self.pq_update(var_id)
# var_name = var_stress.__name__
var_name = var_id
var_type = self.var_type
NumberOfComponents = str(self.NumberOfComponents)
ofs.write('<'+var_type+'Data '+var_type+'="' + var_name + '">')
ofs.write('<DataArray type="Float32" format="ascii" Name="' +
var_name+'" NumberOfComponents="'+NumberOfComponents+'" >')
self.write(self.physical_quantity[var_id], ofs)
ofs.write('</DataArray>')
ofs.write('</'+var_type+'Data>')
# finshed
ofs.write('</Piece>')
ofs.write('</StructuredGrid>')
ofs.write('</VTKFile>')
ofs.close()
INPPATH = 'C:/Users/Harvo/Downloads/Digital-Twin/thermal/Thermal.inp'
ODBPATH = 'C:/Users/Harvo/Downloads/Digital-Twin/thermal/Thermal.odb'
OUTPATH = 'C:/Users/Harvo/Downloads/Digital-Twin/thermal/Thermal.vtk'
my_model = CAE_Model()
my_model.read_inp(INPPATH)
print('finish read_inp')
my_model.read_odb(ODBPATH)
print('finish read_odb')
my_model.write_vtk(OUTPATH, var_ids=['NT11'])
print('finish write_vtk')

Binary file not shown.

Binary file not shown.

@ -0,0 +1,144 @@
class Physical_Quantity(object):
def __init__(self):
pass
# Scalars NT11,RFL11
# Vectors displacement,HFL
# Tensors Stress,spstress
def pq_update(self, var_id):
if var_id == 'S':
self.pq_class = Stress()
if var_id == 'SPS':
self.pq_class = Spstress()
if var_id == 'DISP':
self.pq_class = Displacement()
if var_id == 'NT11':
self.pq_class = Temperature()
self.var_type = self.pq_class.var_type
self.NumberOfComponents = self.pq_class.NumberOfComponents
def insert(self, var_data):
return self.pq_class.insertData(var_data)
def write(self, *args):
# print(args)
self.pq_class.writeData(self.nids, self.eids, args)
class Stress:
def __init__(self):
self.var_type = 'Tensors'
self.NumberOfComponents = 9
def insertData(self, var_data):
this_pq = {}
for var_line in var_data:
eid = var_line.elementLabel
sxx = var_line.data[0]
syy = var_line.data[1]
szz = var_line.data[2]
sxy = var_line.data[3]
sxz = var_line.data[4]
syz = var_line.data[5]
this_pq[int(eid)] = [float(sxx), float(syy), float(
szz), float(sxy), float(sxz), float(syz)]
return this_pq
def writeData(self, stress, ofs):
for key in self.eids:
s11, s22, s33, s12, s13, s23 = stress[key][0:]
ofs.write("%f %f %f %f %f %f %f %f %f " %
(s11, s12, s13, s12, s22, s23, s13, s23, s33))
class Spstress:
def __init__(self):
self.var_type = 'Vectors'
self.NumberOfComponents = 3
def insertData(self, var_data):
this_pq = {}
for var_line in var_data:
eid = var_line.elementLabel
smin = var_line.maxPrincipal
smin = var_line.midPrincipal
smin = var_line.minPrincipal
this_pq[int(eid)] = [float(smin), float(smin), float(smin)]
return this_pq
def writeData(self, nids, eids, args):
spstress, ofs = args
for key in eids:
sp1, sp2, sp3 = spstress[key][0:]
ofs.write("%f %f %f " % (sp1, sp2, sp3))
class Displacement:
def __init__(self):
self.var_type = 'Vectors'
self.NumberOfComponents = 3
def insertData(self, var_data):
this_pq = {}
for var_line in var_data:
nid = var_line.nodeLabel
ux = var_line.data[0]
uy = var_line.data[1]
uz = var_line.data[2]
this_pq[int(nid)] = [float(ux), float(uy), float(uz)]
return this_pq
def writeData(self, nids, eids, args):
displacement, ofs = args
for key in nids:
ux, uy, uz = displacement[key]
ofs.write("%f %f %f " % (ux, uy, uz))
class Temperature(object):
def __init__(self):
self.var_type = 'Scalars'
self.NumberOfComponents = 1
def insertData(self, var_data):
this_pq = {}
for var_line in var_data:
nid = var_line.nodeLabel
temp = var_line.data
this_pq[int(nid)] = [float(temp)]
return this_pq
def writeData(self, nids, eids, args):
temperature, ofs = args
for key in nids:
temp = temperature[key][0]
# print(temp)
ofs.write("%f " % (temp,))
# ### define PointsData element ###
# ofs.write('<PointData Vectors="displacement">')
# ofs.write('<DataArray type="Float32" NumberOfComponents="3" format="ascii" Name="displacement">')
# for key in self.nids:
# ux, uy, uz = self.displacement[key]
# ofs.write("%f %f %f " % (ux, uy, uz))
# ofs.write('</DataArray>')
# ofs.write('</PointData>')
# ### define CellData element ###
# ofs.write('<CellData Vectors="PrincipalStress" Tensors="Stress">')
# ofs.write('<DataArray type="Float32" Name="PrincipalStress" NumberOfComponents="3" format="ascii">')
# for key in self.eids:
# sp1, sp2, sp3 = self.spstress[key][0:]
# ofs.write("%f %f %f " % (sp1, sp2, sp3))
# ofs.write('</DataArray>')
# ofs.write('<DataArray type="Float32" Name="Stress" NumberOfComponents="9" format="ascii">')
# for key in self.eids:
# s11, s22, s33, s12, s13, s23 = self.stress[key][0:]
# ofs.write("%f %f %f %f %f %f %f %f %f " % (s11, s12, s13, s12, s22, s23, s13, s23, s33))
# ofs.write('</DataArray>')
# ofs.write('</CellData>')
# ofs.write('</Piece>')
# ofs.write('</StructuredGrid>')
# ofs.write('</VTKFile>')
# ofs.close()
Loading…
Cancel
Save