Quoting Patrick Riesen <prie...@student.ethz.ch>: > i suppose the problem lies not in VTKFile.cpp. > > you consider a tensor function to have a rank >= 2, > but for my tensor function the rank returned by e.g. > > e.function_space().element().value_rank() > > is 1. So it is rather a vector with 4 components having rank 1. > possibly value_rank() in the FiniteElement class should return 2 even > for a 2d tensor function, then your code in VTKFile is fine, but i > didn't look into the FiniteElement classes.
The problem is in ffc/fem/createelement.py where a tensor element is treated as a MixedElement which has rank 1. A simple workaround might be to attach len(ufl_element._shape) as the rank of a mixed element and use this value when we generate code for the value_rank() function. What do you think Anders? Kristian > patrick > > > -------- Original Message -------- > Subject: Re: [FEniCS-users] [Fwd: Re: tensor function] > Date: Wed, 30 Sep 2009 11:30:45 +0200 > From: Patrick Riesen <prie...@student.ethz.ch> > CC: fenics <fenics-us...@fenics.org> > References: <4ac31db1.2040...@student.ethz.ch> > <4ac320f4.1000...@student.ethz.ch> <4ac32181.8050...@cam.ac.uk> > > seems that the tensor function for a 2d problem doesn't get to the > output structure for a tensor function but to that for a vector function > because it only has rank = 1. the write out for tensor is only invoked > for a (3x3) tensor with rank = 2. > > Garth N. Wells wrote: > > > > > > Patrick Riesen wrote: > >> Hello, > >> > >> I don't know if this is a problem (dolfin0.9.2): > >> When i was writing the TensorFunction e to a vtk-file after a solve > >> by just using > >> > >> file << e > >> > >> the results i got were absolutely nonsense. I got three components, > >> but none of them made any sense. This is why i was thinking i'm doing > >> something completely wrong in my equations/code, > >> > > > > VTK output of tensor functions is untested. I would be very surprised if > > it did work. Dig around in VTKFile.cpp to see if you can find the problem. > > > > Garth > > > > > > > > >> But if i first separate all components and write them to separate > >> files as > >> Function e11 = e[0]; > >> Function e12 = e[1]; > >> Function e21 = e[2]; > >> Function e22 = e[3]; > >> > >> fileE11 << e11; > >> fileE12 << e12; > >> fileE21 << e21; > >> fileE22 << e22; > >> > >> the solutions look reasonable (uff!..) and e12 and e21 are the same. > >> > >> regards, > >> patrick > >> > >> > >> Patrick Riesen wrote: > >>> sorry, something went wrong, this would be the message: > >>> > >>> -------- Original Message -------- > >>> Subject: Re: [FEniCS-users] tensor function > >>> Date: Wed, 30 Sep 2009 10:52:02 +0200 > >>> From: Patrick Riesen <prie...@student.ethz.ch> > >>> To: Anders Logg <l...@simula.no> > >>> References: <4ac0a8d5.6040...@student.ethz.ch> > >>> <20090928122033.gh2...@olorin> <4ac0ad56.50...@student.ethz.ch> > >>> <20090928140134.ga24...@olorin> <4ac0c346.7020...@student.ethz.ch> > >>> > >>> or maybe not.. > >>> > >>> i can not do > >>> > >>> Function e11 = e[0][0]; > >>> > >>> i get > >>> > >>> error: no match for 'operator[]' in > >>> 'dolfin::Function::operator[](dolfin::uint)(0u)[0]' > >>> > >>> > >>> but i can get components doing > >>> > >>> e11 = e[0]; > >>> e12 = e[1]; > >>> e21 = e[2]; > >>> e22 = e[3]; > >>> > >>> > >>> i suppose for dolfin 0.9.3 it is the case as described below and for > >>> dolfin 0.9.2 the case as above therefore ? > >>> (which is what i am still using currently) > >>> > >>> greetings, > >>> patrick > >>> > >>> Patrick Riesen wrote: > >>>> this helped to sort things out, thanks again. > >>>> patrick > >>>> > >>>> Anders Logg wrote: > >>>>> On Mon, Sep 28, 2009 at 02:34:30PM +0200, Patrick Riesen wrote: > >>>>>> Hi, > >>>>>> > >>>>>> thans for the quick response, > >>>>>> > >>>>>> therefore when V is the function space of the (e, v, p) element and > >>>>>> > >>>>>>> e[0] = (a, b) > >>>>>>> e[1] = (c, d) > >>>>>>> e[0][0] = a > >>>>>>> e[0][1] = b > >>>>>>> e[1][0] = c > >>>>>>> e[1][1] = d > >>>>>> therefore doing > >>>>>> > >>>>>> fs = new SubSpace(V,0,0) > >>>>>> > >>>>>> corresponds to the subspace for the two components (a, b) of the > >>>>>> element and not just for a, which then would be SubSpace(V,0,0,0) ? > >>>>> Yes. > >>>>> > >>>>> -- > >>>>> Anders > >>>> _______________________________________________ > >>>> FEniCS-users mailing list > >>>> fenics-us...@fenics.org > >>>> http://fenics.org/mailman/listinfo/fenics-users > >>> > >>> _______________________________________________ > >>> FEniCS-users mailing list > >>> fenics-us...@fenics.org > >>> http://fenics.org/mailman/listinfo/fenics-users > >> > >> _______________________________________________ > >> FEniCS-users mailing list > >> fenics-us...@fenics.org > >> http://fenics.org/mailman/listinfo/fenics-users > > > > > > _______________________________________________ > FEniCS-users mailing list > fenics-us...@fenics.org > http://fenics.org/mailman/listinfo/fenics-users > _______________________________________________ > DOLFIN-dev mailing list > DOLFIN-dev@fenics.org > http://www.fenics.org/mailman/listinfo/dolfin-dev > _______________________________________________ DOLFIN-dev mailing list DOLFIN-dev@fenics.org http://www.fenics.org/mailman/listinfo/dolfin-dev