In [1]:
from dolfin import *

In [2]:
mesh = UnitSquareMesh(2,2)
V = FunctionSpace?

In [ ]:
V = FunctionSpace

In [3]:
V = FunctionSpace(mesh,"N1curl",1)
Q = FunctionSpace(mesh,"CG",1)


DEBUG:UFL:No integrals left after transformation, returning empty form.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Level 25:FFC:Calling FFC just-in-time (JIT) compiler, this may take some time.
INFO:FFC:Compiling form ffc_form_595366d186cb7f687a3d8b00949e44b1f9938977

INFO:FFC:Compiler stage 1: Analyzing form(s)
INFO:FFC:-----------------------------------
INFO:FFC:  
INFO:FFC:  Name:                   ''
  Geometric dimension:    2
  Rank:                   1
  Arguments:              '[v_0]'
  Argument names:         '[v0]'
  Number of coefficients: 0
  Coefficients:           '[]'
  Coefficient names:      '[]'
  Unique elements:        'N1curl1(?)'
  Unique sub elements:    'N1curl1(?)'
  
INFO:FFC:  Extracting monomial form representation from UFL form
INFO:FFC:  Transforming monomial form to reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Estimated cost of tensor representation: 1
INFO:FFC:  representation:    auto --> tensor
DEBUG:FFC:  Selecting quadrature degree based on total polynomial degree of integrand: 1
INFO:FFC:  quadrature_degree: auto --> 1
INFO:FFC:  quadrature_rule:   auto --> default
INFO:FFC:  
INFO:FFC:Compiler stage 1 finished in 0.0217571 seconds.

INFO:FFC:Compiler stage 2: Computing intermediate representation
INFO:FFC:-------------------------------------------------------
INFO:FFC:  Computing representation of 1 elements
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Computing representation of 1 dofmaps
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Computing representation of integrals
INFO:FFC:  Computing tensor representation
INFO:FFC:  Extracting monomial form representation from UFL form
INFO:FFC:  Transforming monomial form to reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Precomputing integrals on reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  6 entries computed in 0.00144 seconds
DEBUG:FFC:  Shape of reference tensor: (3, 2)
DEBUG:FFC:  Primary multi index:   rank = 1 dims = [3] indices = [[0], [1], [2]]
DEBUG:FFC:  Secondary multi index: rank = 1 dims = [2] indices = [[0], [1]]
DEBUG:FFC:  Internal multi index:  rank = 0 dims = [] indices = [[]]
DEBUG:FFC:  Secondary multi index: rank = 1 dims = [2] indices = [[0], [1]]
DEBUG:FFC:  External multi index:  rank = 0 dims = [] indices = [[]]
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Computing representation of forms
INFO:FFC:  
INFO:FFC:Compiler stage 2 finished in 0.0332582 seconds.

INFO:FFC:Compiler stage 3: Optimizing intermediate representation
INFO:FFC:--------------------------------------------------------
INFO:FFC:  Skipping optimizations, add -O to optimize
INFO:FFC:  
INFO:FFC:Compiler stage 3 finished in 0.00315499 seconds.

INFO:FFC:Compiler stage 4: Generating code
INFO:FFC:---------------------------------
INFO:FFC:  Generating code for 1 element(s)
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
INFO:FFC:  Generating code for 1 dofmap(s)
INFO:FFC:  Generating code for integrals
INFO:FFC:  Generating code for forms
INFO:FFC:  
INFO:FFC:Compiler stage 4 finished in 0.111201 seconds.

INFO:FFC:Compiler stage 4.1 finished in 2.86102e-06 seconds.

INFO:FFC:Compiler stage 5: Formatting code
INFO:FFC:---------------------------------
INFO:FFC:  Output written to ./ffc_form_595366d186cb7f687a3d8b00949e44b1f9938977.h.
INFO:FFC:  
INFO:FFC:Compiler stage 5 finished in 0.011843 seconds.

INFO:FFC:FFC finished in 0.185476 seconds.
DEBUG:FFC:Compiling and linking Python extension module, this may take some time.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.

In [4]:
u = TestFunction(V)
v = TrialFunction(V)

In [5]:
def Pih(u0, mesh):
    r = 1
    V = FunctionSpace(mesh, 'N1curl', r)
    u = TrialFunction(V)
    if r == 1:
        W = FunctionSpace(mesh, 'N1curl', 1)
        v0 = TestFunction(W)
    else:
        V0 = FunctionSpace(mesh, 'N1curl', r, restriction='facet')
        V1 = VectorFunctionSpace(mesh, 'DG', r-2)
        W = MixedFunctionSpace([V0, V1])    
        v0, v1 = TestFunctions(W)
    # Define the tangent to element facets (edges)
    n = FacetNormal(mesh)
    t = as_vector((-n[1], n[0]))
    # Define the bilinear form
    #
    #  A(u, (v0, v1)) = int_Gamma u.t v0.t ds + int u.v1 dx
    #
    # where the first integral is over all the edges of the mesh, and the second
    # over the domain.  v0 is in the N2curl space with all non-edge DOFs set to zero
    # so v0 -> v0.t is an isomorphism onto DG_{r-1} on the edges.  v1 is a vector DG
    A = (inner(u, t) * inner(v0, t))('+') * dS  +  inner(u, t) * inner(v0, t) * ds
    # Define the right hand side, L(v0, v1) = A(u0, (v0, v1))
    L = (inner(u0, t) * inner(v0, t))('+') * dS  +  inner(u0, t) * inner(v0, t) * ds
    if r > 1:
        A = A + inner(u, v1) * dx
        L = L + inner(u0, v1) * dx
    # Solve the resulting linear system for u = Pih(u0)
    u = Function(V)
    solve(A == L, u)
    return u

In [7]:
u0 = Function(V)
Pih(u0,mesh)


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-7-beb50c5642d2> in <module>()
      1 u0 = Function(V)
----> 2 Pih(u0,mesh)

<ipython-input-5-edaad88a255c> in Pih(u0, mesh)
      1 def Pih(u0, mesh):
----> 2     V = FunctionSpace(mesh, 'N1curl', r)
      3     u = TrialFunction(V)
      4     if r == 1:
      5         W = FunctionSpace(mesh, 'N1curl', 1)

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dolfin/functions/functionspace.py in __init__(self, mesh, family, degree, form_degree, constrained_domain, restriction)
    454             cpp.dolfin_error("functionspace.py",
    455                              "create function space",
--> 456                              "Illegal argument for degree, not an integer: " + str(degree))
    457 
    458         # Get Mesh or Restriction from Domain or Domain from Mesh or

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dolfin/cpp/common.py in dolfin_error(*args)
   2357 
   2358     """
-> 2359   return _common.dolfin_error(*args)
   2360 
   2361 def deprecation(*args):

RuntimeError: 

*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
***     fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error:   Unable to create function space.
*** Reason:  Illegal argument for degree, not an integer: i_6.
*** Where:   This error was encountered inside functionspace.py.
*** Process: unknown
*** 
*** DOLFIN version: 1.4.0
*** Git changeset:  
*** -------------------------------------------------------------------------

In [ ]: