예제 #1
0
from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput, Identity_like

data11 = [0., 0., 1.]
data22 = [0., 0., -1]
data12 = [1., 2., 0.]
labels = range(1, len(data11) + 1)
fo11 = FieldOutput(labels=labels, data=data11, position='node')
fo22 = FieldOutput(labels=labels, data=data22, position='node')
fo12 = FieldOutput(labels=labels, data=data12, position='node')
tensor = TensorFieldOutput(data11=fo11, data22=fo22, data12=fo12)
tresca = tensor.tresca()
print(tresca)
예제 #2
0
from abapy.postproc import FieldOutput, VectorFieldOutput
data1 = [1, 2, 3, 5, 6, 0]
data2 = [1. for i in data1]
labels = range(1, len(data1) + 1)
fo1, fo2 = FieldOutput(labels=labels, data=data1,
                       position='node'), FieldOutput(labels=labels,
                                                     data=data2,
                                                     position='node')
vector = VectorFieldOutput(data1=fo1, data2=fo2)
vector2 = VectorFieldOutput(data2=fo2)
vector  # short description
print(vector)  # long description
print(vector[6])  # Returns a VectorFieldOutput instance
print(vector[1, 4, 6])  # Picking label by label
print(vector[1:6:2])  # Slicing
print(vector.get_data(6))  # Returns 3 floats
print(vector.norm())  # Returns norm
print(vector.sum())  # returns the sum of coords
print(vector * vector2)  # Itemwise product (like numpy, unlike matlab)
print(vector.dot(vector2))  # Dot/Scalar product
print(vector.cross(vector2))  # Cross/Vector product
print(vector + 2)  # Itemwise addition
print(vector * 2)  # Itemwise multiplication
print(vector)  # Itemwise division
# print(vector / vector2)  # Itemwise division between vectors (numpy way)
# print(abs(vector))  # Absolute value
# print(vector ** 2)  # Power
# print(vector ** vector)  # Itemwize power
예제 #3
0
from abapy.postproc import FieldOutput
data = [-1., 5., 3.]
labels = [1, 3, 2]
fo = FieldOutput(data=data, labels=labels, position='node')
print(fo)  # data is sorted by labels
print(fo[1:2])  # slicing
print(fo[2])  # indexing
print(fo[1, 3])  # multiple indexing
print(fo * 2)  # multiplication
fo2 = fo**2  # power
print(fo2)
print(fo * fo2)
print(fo + fo2)
print(abs(fo))
예제 #4
0
from abapy.postproc import FieldOutput
data = [1,2,3,5,6,0]
labels = range(1,len(data)+1)
fo = FieldOutput(data=data, labels = labels)
print fo.get_data(6)
print fo.get_data(10)
예제 #5
0
grain_diameter = (grain_volume * 6./np.pi)**(1. / 3.)   
elem_grain_diameter = grain_diameter[elem_flags]
  

# Hall-Petch
sy = sigma_0_hp + k_hp / elem_grain_diameter**.5

E  = E * np.ones(Ne) # Young's modulus
nu = nu * np.ones(Ne) # Poisson's ratio
n = n * np.ones(Ne)


labels = ['mat_{0}'.format(i+1) for i in xrange(len(sy))]
material = [materials.Bilinear(labels = labels[i],E = E[i], nu = nu[i], n = n[i],sy = sy[i]) for i in xrange(Ne)]
model.material = material
sy_field = FieldOutput(labels = mesh.labels, data = sy, position = "element")

if Run_simu:
  model.MakeInp()
  model.Run()
  model.MakePostProc()
  model.RunPostProc()
else:
  model.LoadResults()
# Plotting results
if model.outputs['completed']:
  U = model.outputs['field']['U'][0]
  mesh.nodes.apply_displacement(U)
  f = open("cuboidTest_voronoi.vtk", "w")
  f.write(mesh.dump2vtk())
  f.write(sy_field.dump2vtk(name = "Yield_Stress"))
예제 #6
0
from abapy.postproc import FieldOutput, VectorFieldOutput
data1 = [1,2,3,5,6,0]
data2 = [1. for i in data1]
labels = range(1,len(data1)+1)
fo1, fo2 = FieldOutput(data=data1, labels = labels), FieldOutput(data=data2, labels = labels)
vector = VectorFieldOutput(data1 = fo1, data2 = fo2 )
print vector.get_data(6)
x, y, z = vector.get_data(5)
print x, y, z
print vector.get_data(10)
norm = vector.get_norm()

예제 #7
0
ymin, ymax = nodes_postion[:, 1].min(), nodes_postion[:, 1].max()
zmin, zmax = nodes_postion[:, 2].min(), nodes_postion[:, 2].max()

# Seeds
seeds = np.random.rand(Nseed, 3) * np.array(
    [[xmax - xmin, ymax - ymin, zmax - zmin]]) + np.array([[xmin, ymin, zmin]])
seed_flags = np.arange(Nseed)
elem_flags = interpolate.griddata(seeds,
                                  seed_flags,
                                  centroids,
                                  method="nearest")

# Building sets
elabels = np.array(mesh.labels)
grain_sets = []
for i in xrange(len(seed_flags)):
    flag = seed_flags[i]
    grain_sets.append(elabels[np.where(elem_flags == flag)[0]])
    mesh.add_set(label="G{0}".format(i),
                 elements=elabels[np.where(elem_flags == flag)[0]])

labels = ['mat_{0}'.format(i + 1) for i in xrange(len(sy))]
material = [
    materials.Bilinear(labels=labels[i], E=E[i], nu=nu[i], n=n[i], sy=sy[i])
    for i in xrange(Ne)
]
model.material = material
sy_field = FieldOutput(labels=mesh.labels, data=sy, position="element")

model.MakeInp()
예제 #8
0
  grain_volume[i] = ((elem_flags == flag) * elem_volume).sum()
grain_diameter = (grain_volume * 6./np.pi)**(1. / 3.)   
elem_grain_diameter = grain_diameter[elem_flags]
  

# Hall-Petch (not mandatory)
sy = sigma_0_hp + k_hp / elem_grain_diameter**.5
E  = E * np.ones(Ne) # Young's modulus
nu = nu * np.ones(Ne) # Poisson's ratio
n = n * np.ones(Ne)


labels = ['mat_{0}'.format(i+1) for i in xrange(len(sy))]
material = [materials.Bilinear(labels = labels[i],E = E[i], nu = nu[i], n = n[i],sy = sy[i]) for i in xrange(Ne)]
model.material = material
sy_field = FieldOutput(labels = mesh.labels, data = sy, position = "element")


if Run_simu:
  model.MakeInp()
  model.Run()
  model.MakePostProc()
  model.RunPostProc()
else:
  model.LoadResults()
# Plotting results
if model.outputs['completed']:
  U = model.outputs['field']['U'][0]
  mesh.nodes.apply_displacement(U)
  f = open(label + ".vtk", "w")
  f.write(mesh.dump2vtk())
예제 #9
0
from abapy.postproc import FieldOutput
from abapy.mesh import Mesh, Nodes
x = [0.,1.,0.]
y = [0.,0.,1.]
z = [0.,0.,0.]
labels = [1,2,3]
nodes = Nodes(x=x,y=y,z=z, labels=labels)
mesh = Mesh(nodes=nodes)
mesh.add_element(label = 1 , connectivity = [1,2,3], space = 2 , name = 'tri3') # triangle element
nodeField = FieldOutput()
nodeField.add_data(data = 0., label = 1)
nodeField.add_data(data = 10., label = 2)
nodeField.add_data(data = 20., label = 3)
elementField = FieldOutput(position='element')
elementField.add_data(label = 1, data =10.)
out = ''
out+=mesh.dump2vtk()
out+=nodeField.dump2vtk('nodeField')
out+=elementField.dump2vtk('elementField')
f = open("FieldOutput-dump2vtk.vtk", "w")
f.write(out)
f.close()
예제 #10
0
from abapy.postproc import FieldOutput
from abapy.mesh import Mesh, Nodes
x = [0., 1., 0.]
y = [0., 0., 1.]
z = [0., 0., 0.]
labels = [1, 2, 3]
nodes = Nodes(x=x, y=y, z=z, labels=labels)
mesh = Mesh(nodes=nodes)
mesh.add_element(label=1, connectivity=[1, 2, 3], space=2,
                 name='tri3')  # triangle element
nodeField = FieldOutput()
nodeField.add_data(data=0., label=1)
nodeField.add_data(data=10., label=2)
nodeField.add_data(data=20., label=3)
elementField = FieldOutput(position='element')
elementField.add_data(label=1, data=10.)
out = ''
out += mesh.dump2vtk()
out += nodeField.dump2vtk('nodeField')
out += elementField.dump2vtk('elementField')
f = open("FieldOutput-dump2vtk.vtk", "w")
f.write(out)
f.close()