← Back to team overview

ffc team mailing list archive

Re: [Branch ~ffc-core/ffc/main] Rev 1498: Added support for CellVolume from UFL.

 

On Thu, 2010-07-08 at 08:50 +0100, Garth N. Wells wrote:
> 
> On 08/07/10 08:33, Mehdi Nikbakht wrote:
> > On Thu, 2010-07-08 at 08:22 +0100, Garth N. Wells wrote:
> >> On Jul 8 2010, Anders Logg wrote:
> >>
> >>> On Wed, Jul 07, 2010 at 10:34:39PM +0100, Kristian Oelgaard wrote:
> >>>> On 7 July 2010 20:22, Garth N. Wells<gnw20@xxxxxxxxx>  wrote:
> >>>>>
> >>>>>
> >>>>> On 07/07/10 20:14, Anders Logg wrote:
> >>>>>>
> >>>>>> On Wed, Jul 07, 2010 at 06:26:20PM +0100, Kristian Oelgaard wrote:
> >>>>>>>
> >>>>>>> Supporting CellVolume makes it possible to do:
> >>>>>>>
> >>>>>>> CG = FiniteElement("Lagrange", triangle, 2)
> >>>>>>> DG = FiniteElement("DG", triangle, 0)
> >>>>>>> v = TestFunction(DG)
> >>>>>>> f = Coefficient(CG)
> >>>>>>> vol = triangle.v
> >>>>>>
> >>>>>> Would it be better to call it vol or volume instead of v? Or does it
> >>>>>> have to be a one-letter word?
> >>>>>>
> >>>>>
> >>>>> . . . or call it 'volume'.
> >>>>
> >>>> It can be whatever we want, I just followed what was already there.
> >>>> Should we then rename 'd', 'n' and 'x' to 'geometric_dimension',
> >>>> 'facet_normal', and 'spatial_coordinate' while we're at it?
> >>>
> >>> I think d, n, x are fine, but v does not necessarily look like a
> >>> volume to me (it looks like a test function).
> >>>
> >>
> >> I agree - d, n and x are all commonly used, but v for volume isn't.
> >>
> >> Garth
> >
> > I have another request related to geometric computation inside UFL. Is
> > it possible to add a class called SurfaceNormal to geometry.py?
> >
> 
> I don't see how this is possible - it  can't be computed from the cell 
> geometry. Shouldn't it be a Constant/Coefficient computed by the user?

Yes, it can. However, we need to define an extra finite element space
for it. Now we have,

  elem = VectorElement("DG", "triangle", 0)
  n = Coefficient(elem)                       # Surface normal

I would expect to have just one line for this,

  n = SurfaceNormal("triangle")

SurfaceNormal is just a coefficient defined on DG space with zero order.
The same can be done for surface tangent.

Mehdi 



> 
> Garth
> 
> > Mehdi
> >
> >>
> >>> --
> >>> Anders
> >>>
> >>>
> >>>> Kristian
> >>>>
> >>>>> Garth
> >>>>>
> >>>>>>
> >>>>>>
> >>>>>>> L = 1.0/vol*v*f*dx
> >>>>>>>
> >>>>>>> instead of using a Coefficient for 'vol' and then defining an
> >>>>>>> Expression in DOLFIN.
> >>>>>>>
> >>>>>>> Currently, it will use the absolute value of the determinant of the
> >>>>>>> Jacobian in tabulate_tensor ( std::abs(detJ) ).
> >>>>>>>
> >>>>>>> Kristian
> >>>>>>>
> >>>>>>> On 7 July 2010 18:19,<noreply@xxxxxxxxxxxxx>   wrote:
> >>>>>>>>
> >>>>>>>> ------------------------------------------------------------
> >>>>>>>> revno: 1498
> >>>>>>>> committer: Kristian B. Ølgaard<k.b.oelgaard@xxxxxxxxx>
> >>>>>>>> branch nick: ffc
> >>>>>>>> timestamp: Wed 2010-07-07 18:17:07 +0100
> >>>>>>>> message:
> >>>>>>>>   Added support for CellVolume from UFL.
> >>>>>>>> modified:
> >>>>>>>>   ChangeLog
> >>>>>>>>   ffc/quadrature/optimisedquadraturetransformer.py
> >>>>>>>>   ffc/quadrature/quadraturetransformer.py
> >>>>>>>>   ffc/quadrature/quadraturetransformerbase.py
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Your team FFC Core Team is subscribed to branch lp:ffc.
> >>>>>>>> To unsubscribe from this branch go to
> >>>>>>>> https://code.launchpad.net/~ffc-core/ffc/main/+edit-subscription
> >>>>>>>>
> >>>>>>>> === modified file 'ChangeLog' --- ChangeLog   2010-07-01 17:43:36
> >>>>>>>> +0000 +++ ChangeLog   2010-07-07 17:17:07 +0000 @@ -1,3 +1,4 @@ + -
> >>>>>>>> Added support for new geometric quantity CellVolume in UFL.  0.9.3
> >>>>>>>> [2010-07-01]  - Make global_dimension for Real return an int
> >>>>>>>> instead of double, bug # 592088  - Add support for facet normal in
> >>>>>>>> 1D.
> >>>>>>>>
> >>>>>>>> === modified file 'ffc/quadrature/optimisedquadraturetransformer.py'
> >>>>>>>> --- ffc/quadrature/optimisedquadraturetransformer.py    2010-07-01
> >>>>>>>> 17:41:40 +0000
> >>>>>>>> +++ ffc/quadrature/optimisedquadraturetransformer.py    2010-07-07
> >>>>>>>> 17:17:07 +0000
> >>>>>>>> @@ -187,7 +187,7 @@
> >>>>>>>>          return {():new_val}
> >>>>>>>>
> >>>>>>>>      #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>> -    # FacetNormal (geometry.py). +    # FacetNormal, CellVolume
> >>>>>>>> (geometry.py).     #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>>      def facet_normal(self, o,  *operands):         #print("Visiting
> >>>>>>>> FacetNormal:") @@ -216,6 +216,17 @@
> >>>>>>>>
> >>>>>>>>          return {(): create_symbol(normal_component, GEO)}
> >>>>>>>>
> >>>>>>>> +    def cell_volume(self, o,  *operands): +        # Safety
> >>>>>>>> check. +        ffc_assert(not operands, "Didn't expect any
> >>>>>>>> operands for FacetNormal: " + repr(operands)) + +        # FIXME:
> >>>>>>>> KBO: This has to change for higher order elements +        detJ =
> >>>>>>>> format["det(J)"](self.restriction) +        volume =
> >>>>>>>> format["absolute value"](detJ) +        self.trans_set.add(detJ) +
> >>>>>>>> +        return {():create_symbol(volume, GEO)} +     def
> >>>>>>>> create_argument(self, ufl_argument, derivatives, component,
> >>>>>>>> local_comp,                   local_offset, ffc_element,
> >>>>>>>> transformation, multiindices):         "Create code for basis
> >>>>>>>> functions, and update relevant tables of used basis."
> >>>>>>>>
> >>>>>>>> === modified file 'ffc/quadrature/quadraturetransformer.py'
> >>>>>>>> --- ffc/quadrature/quadraturetransformer.py     2010-06-30 09:59:49
> >>>>>>>> +0000
> >>>>>>>> +++ ffc/quadrature/quadraturetransformer.py     2010-07-07 17:17:07
> >>>>>>>> +0000
> >>>>>>>> @@ -262,7 +262,7 @@
> >>>>>>>>          return {():f_abs(operands[0][()])}
> >>>>>>>>
> >>>>>>>>      #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>> -    # FacetNormal (geometry.py). +    # FacetNormal, CellVolume
> >>>>>>>> (geometry.py).     #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>>      def facet_normal(self, o,  *operands):         #print("Visiting
> >>>>>>>> FacetNormal:") @@ -291,6 +291,18 @@
> >>>>>>>>
> >>>>>>>>          return {():normal_component}
> >>>>>>>>
> >>>>>>>> +    def cell_volume(self, o,  *operands): +        # Safety
> >>>>>>>> check. +        ffc_assert(not operands, "Didn't expect any
> >>>>>>>> operands for CellVolume: " + repr(operands)) + +        # FIXME:
> >>>>>>>> KBO: This has to change for higher order elements +        detJ =
> >>>>>>>> format["det(J)"](self.restriction) +        volume =
> >>>>>>>> format["absolute value"](detJ) +        self.trans_set.add(detJ) +
> >>>>>>>> +        return {():volume} + +     def create_argument(self,
> >>>>>>>> ufl_argument, derivatives, component, local_comp,
> >>>>>>>> local_offset, ffc_element, transformation, multiindices):
> >>>>>>>> "Create code for basis functions, and update relevant tables of
> >>>>>>>> used basis."
> >>>>>>>>
> >>>>>>>> === modified file 'ffc/quadrature/quadraturetransformerbase.py'
> >>>>>>>> --- ffc/quadrature/quadraturetransformerbase.py 2010-07-01 17:41:40
> >>>>>>>> +0000 +++ ffc/quadrature/quadraturetransformerbase.py 2010-07-07
> >>>>>>>> 17:17:07 +0000 @@ -250,12 +250,16 @@         error("This object
> >>>>>>>> should be implemented by the child class.")
> >>>>>>>>
> >>>>>>>>      #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>> -    # FacetNormal (geometry.py). +    # FacetNormal, CellVolume
> >>>>>>>> (geometry.py).     #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>>      def facet_normal(self, o,  *operands):         print
> >>>>>>>> "\n\nVisiting FacetNormal: ", repr(o)         error("This object
> >>>>>>>> should be implemented by the child class.")
> >>>>>>>>
> >>>>>>>> +    def cell_volume(self, o,  *operands): +        print
> >>>>>>>> "\n\nVisiting CellVolume: ", repr(o) +        error("This object
> >>>>>>>> should be implemented by the child class.") +     #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>>      # Things that can be handled by the base class.     #
> >>>>>>>> -------------------------------------------------------------------------
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> Mailing list: https://launchpad.net/~ffc
> >>>>>>> Post to     : ffc@xxxxxxxxxxxxxxxxxxx
> >>>>>>> Unsubscribe : https://launchpad.net/~ffc
> >>>>>>> More help   : https://help.launchpad.net/ListHelp
> >>>>>>>
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> Mailing list: https://launchpad.net/~ffc
> >>>>>>> Post to     : ffc@xxxxxxxxxxxxxxxxxxx
> >>>>>>> Unsubscribe : https://launchpad.net/~ffc
> >>>>>>> More help   : https://help.launchpad.net/ListHelp
> >>>>>
> >>>
> >>
> >> _______________________________________________
> >> Mailing list: https://launchpad.net/~ffc
> >> Post to     : ffc@xxxxxxxxxxxxxxxxxxx
> >> Unsubscribe : https://launchpad.net/~ffc
> >> More help   : https://help.launchpad.net/ListHelp
> >




Follow ups

References