← Back to team overview

dolfin team mailing list archive

[Question #158032]: Saving tensor to file

 

New question #158032 on DOLFIN:
https://answers.launchpad.net/dolfin/+question/158032

Is there a way to save a tensor to file? For example, if we have the strain rate tensor sym(grad(u1)), is there a way to output this as a pvd file in one step (such that it is readable by Paraview)? I can output each component separately without problem:

# 2D strain rate tensor
efile_pvd << project(u1[0].dx(0),FunctionSpace(mesh,"CG",2)) # E11
efile_pvd << project(0.5*(u1[1].dx(0)+u1[0].dx(1)),FunctionSpace(mesh,"CG",2)) #E12
efile_pvd << project(u1[1].dx(1),FunctionSpace(mesh,"CG",2)) #E22


# I can also create a strain rate tensor function 
d = mesh.geometry().dim()
symmetry = dict(((i,j),(j,i)) for i in range(d) \
                    for j in range(d) if i > j)
Sij = project(sym(grad(u1)),TensorFunctionSpace(mesh,"CG",1,symmetry=symmetry))

# But attempting to output the values of this function yields malloc() errors
efile_pvd << Sij
 
Thanks,
Bob


-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.


Follow ups