from abapy.postproc import FieldOutput, TensorFieldOutput, VectorFieldOutput data11 = [1., 1., 1.] data22 = [2., 4., -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) tensor2 = TensorFieldOutput(data11=fo22) tensor print(tensor) print(tensor[1, 2]) print(tensor * 2. + 1.) print(tensor**2) # Piecewise power vector = VectorFieldOutput(data1=fo11) print(tensor * vector) # Matrix product print(tensor * tensor2) # Contracted tensor product
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
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 vector.get_data(6) # Returns 3 floats vector.norm() # Returns norm vector.sum() # returns the sum of coords vector * vector2 # Itemwise product (like numpy, unlike matlab) vector.dot(vector2) # Dot/Scalar product vector.cross(vector2) # Cross/Vector product vector + 2 # Itemwise addition vector * 2 # Itemwise multiplication vector / 2 # Itemwise division vector / vector2 # Itemwise division between vectors (numpy way) abs(vector) # Absolute value vector ** 2 # Power vector ** vector # Itemwize power
from abapy.postproc import FieldOutput, VectorFieldOutput from abapy.mesh import RegularQuadMesh mesh = RegularQuadMesh() data1 = [2, 2, 5, 10] 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) out = mesh.dump2vtk() + vector.dump2vtk() f = open('vector.vtk', 'w') f.write("out") f.close()
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()
from abapy.postproc import FieldOutput, VectorFieldOutput from abapy.mesh import RegularQuadMesh mesh = RegularQuadMesh() data1 = [2, 2, 5, 10] data2 = [1.0 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) out = mesh.dump2vtk() + vector.dump2vtk() f = open("vector.vtk", "w") f.write("out") f.close()
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()