← Back to team overview

dolfin team mailing list archive

Re: [Bug 785192] [NEW] Taking the gradient of an expression with a Constant crashes

 

I think adding mesh or cell as an optional argument would be good.

To remedy the recompilation bug, which is now fixed, I added an extra
cell argument to Constant in my local code  But maybe mesh is a better
option.

Johan

On May 19, 2011, at 7:05, Martin Sandve Alnæs
<785192@xxxxxxxxxxxxxxxxxx> wrote:

> Public bug reported:
> 
> Since a Constant does not have any way to provide a cell, PyDOLFIN
> forces me to use python floats instead as coefficients in some forms,
> thereby significantly increasing the amount of recompilation I have to
> do. PyDOLFIN therefore does not support the full range of expressions
> possible to express in UFL. This can be remedied by adding an optional
> cell or mesh argument to Constant.__init__ in PyDOLFIN. Mesh is probably
> more convenient/consistent in a PyDOLFIN setting.
> 
> # This currently crashes:
>    from dolfin import Constant, grad
>    grad(Constant(1e-1))
> 
> # This syntax would make it possible to express fully ufl compliant constant coefficients in PyDOLFIN
>    from dolfin import Constant, grad, UnitSquare
>    mesh = UnitSquare(3,3)
>    grad(Constant(1e-1, mesh))
> 
> ** Affects: dolfin
>     Importance: Undecided
>         Status: New
> 
> -- 
> You received this bug notification because you are a member of DOLFIN
> Core Team, which is subscribed to DOLFIN.
> https://bugs.launchpad.net/bugs/785192
> 
> Title:
>  Taking the gradient of an expression with a Constant crashes
> 
> Status in DOLFIN:
>  New
> 
> Bug description:
>  Since a Constant does not have any way to provide a cell, PyDOLFIN
>  forces me to use python floats instead as coefficients in some forms,
>  thereby significantly increasing the amount of recompilation I have to
>  do. PyDOLFIN therefore does not support the full range of expressions
>  possible to express in UFL. This can be remedied by adding an optional
>  cell or mesh argument to Constant.__init__ in PyDOLFIN. Mesh is
>  probably more convenient/consistent in a PyDOLFIN setting.
> 
>  # This currently crashes:
>      from dolfin import Constant, grad
>      grad(Constant(1e-1))
> 
>  # This syntax would make it possible to express fully ufl compliant constant coefficients in PyDOLFIN
>      from dolfin import Constant, grad, UnitSquare
>      mesh = UnitSquare(3,3)
>      grad(Constant(1e-1, mesh))

-- 
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/785192

Title:
  Taking the gradient of an expression with a Constant crashes

Status in DOLFIN:
  New

Bug description:
  Since a Constant does not have any way to provide a cell, PyDOLFIN
  forces me to use python floats instead as coefficients in some forms,
  thereby significantly increasing the amount of recompilation I have to
  do. PyDOLFIN therefore does not support the full range of expressions
  possible to express in UFL. This can be remedied by adding an optional
  cell or mesh argument to Constant.__init__ in PyDOLFIN. Mesh is
  probably more convenient/consistent in a PyDOLFIN setting.

  # This currently crashes:
      from dolfin import Constant, grad
      grad(Constant(1e-1))

  # This syntax would make it possible to express fully ufl compliant constant coefficients in PyDOLFIN
      from dolfin import Constant, grad, UnitSquare
      mesh = UnitSquare(3,3)
      grad(Constant(1e-1, mesh))


References