dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23305
Re: [Question #158032]: Saving tensor to file
Have you tried projecting the function to a function from a full
TensorFunctionSpace?
Johan
On Wednesday May 18 2011 06:26:02 myhill.bob wrote:
> 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
Follow ups
References