← Back to team overview

dolfin team mailing list archive

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

 

Public bug reported:

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()

** Affects: dolfin
     Importance: Undecided
         Status: New

-- 
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:
  New

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()


Follow ups

References