Question #153591 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/153591

Johan Hake posted a new comment:
Sorry for late reply:

Try with:

 class cellcoords(Expression):
        def __init__(self, mesh):
                self.mesh = mesh
        def eval_cell(self, out, x, ufc_cell):
                dolfin_cell = Cell(self.mesh, ufc_cell.index)
                p = dolfin_cell.midpoint()
                out[0] = x[0]-p.x
                out[1] = x[1]-p.y
                out[2] = x[2]-p.z
        def value_shape(self):
                return (3,)


Johan

On Wednesday April 20 2011 06:24:29 B. Emek Abali wrote:
> New question #153591 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/153591
> 
> I need the coordinates relative to the middle of the cell in my form, so I
> came to the idea of
> 
> class cellcoords(Expression):
>       def eval(self, out, x):
>               out[0] = x[0]-self.??().midpoint()
>               out[1] = x[1]-self.??().midpoint()
>               out[2] = x[2]-self.??().midpoint()
>       def value_shape(self):
>               return (3,)
> 
> x = cellcoords()
> 
> where my lack of programming knowledge restricts me to the question marks !
> I dig in the Mesh...h but could not find out..
> 
> How can I reach to a method (midpoint() )  in MeshEntity class from the
> Expression (I think self. directs me to the MeshData class) ?
> 
> any other method is also welcome.
> 
> Thanks a lot,

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

_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~dolfin
More help   : https://help.launchpad.net/ListHelp

Reply via email to