← Back to team overview

dolfin team mailing list archive

[Bug 785244] Re: Spatial coordinates in form are scaled by 2/3 in 2D

 

Below is a test program that digs a bit deeper. Looks like an FFC issue.
Only seems to impact zero and first order elements.

from dolfin import *
mesh = UnitSquare(30, 30)
V = FunctionSpace(mesh, "DG", 0)
v = TestFunction(V)

x = triangle.x
vol = Cell(mesh, 0).volume()
L = x[0]*v*dx
b = assemble(L)
fmax = b.max()/Cell(mesh, 0).volume()

# This should be close to 1.0, but it's close to 2.0
print fmax


** Changed in: dolfin
       Status: New => Confirmed

** Changed in: dolfin
   Importance: Undecided => Critical

** Also affects: ffc
   Importance: Undecided
       Status: New

** Changed in: ffc
       Status: New => Confirmed

** Changed in: ffc
   Importance: Undecided => Critical

** Changed in: ffc
     Assignee: (unassigned) => Kristian B. Ølgaard (k.b.oelgaard)

** Changed in: ffc
    Milestone: None => 0.9.11

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

Title:
  Spatial coordinates in form are scaled by 2/3 in 2D

Status in DOLFIN:
  Confirmed
Status in FEniCS Form Compiler:
  Confirmed

Bug description:
  Here's a program that plots y=x, y=2x, y=3x in 1D and 2D, giving
  correct plots in 1D but scaled by 2/3 in 2D:

  
  from dolfin import *

  n = 30
  factor = 1.0

  #cell = interval
  cell = triangle

  d = cell.d
  if d == 1:
      mesh = UnitInterval(n)
  elif d == 2:
      mesh = UnitSquare(n, n)
      #factor = 3.0/2.0 # Enable this to adjust for bug and get correct plots

  # Asserting that x indeed goes from 0 to 1
  assert mesh.coordinates()[:].max() == 1.0
  assert mesh.coordinates()[:].min() == 0.0

  # Hack for bug in ffc, fix proposed for merging into dev branch
  x = cell.x if d == 1 else cell.x[0]

  V = FunctionSpace(mesh, "CG", 1)

  for k in range(1, 4):
      u = factor*k*x
      print str(u)
      uh = project(u, V)
      plot(uh, vmin=-1.0, vmax=1.0)

  interactive()


References