This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Linear dependent basis function on FEniCS formulations?

+1 vote

I would like to combine trial functions related to distinct meshes (hierarchically related) to assembler a rectangular 5x8 global matrix. I tried the script below.

from dolfin import *

set_log_level(DEBUG)

mesh1 = UnitIntervalMesh(4)
mesh2 = UnitIntervalMesh(2)

V1 = FunctionSpace(mesh1, "CG", 1)
V2 = FunctionSpace(mesh2, "CG", 1)

V = V1 * V2

(u1, u2) = TrialFunctions(V)
v1 = TestFunctions(V1)

a =  (inner(grad(u1), grad(v1)) * dx) + (inner(grad(u2), grad(v1)) * dx) 
A = assemble(a)

print(A.array())

I can't interpret the error messages below

Traceback (most recent call last):
  File "/home/andremachado/Desktop/basis_function_dictionary_example.py", line 23, in <module>
    a =  (inner(grad(u1), grad(v1)) * dx) + (inner(grad(u2), grad(v1)) * dx) 
  File "/usr/lib/python2.7/dist-packages/ufl/operators.py", line 319, in grad
    f = as_ufl(f)
  File "/usr/lib/python2.7/dist-packages/ufl/constantvalue.py", line 394, in as_ufl
    "The representation of the object is:\n%r") % (type(expression), expression))
  File "/usr/lib/python2.7/dist-packages/ufl/log.py", line 154, in error
    raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Invalid type conversion: <type 'tuple'> can not be converted to any UFL type.

The representation of the object is:

(Argument(FiniteElement('Lagrange', Domain(Cell('interval', 1), 'interval_multiverse', 1, 1), 1, None), -2),)
asked Sep 14, 2013 by Andre Machado FEniCS User (1,040 points)
edited Sep 16, 2013 by Garth N. Wells

1 Answer

+3 votes
 
Best answer

Use:

v1 = TestFunction(V1)

instead of TestFunctions. The error message follows since v1 in your code is a tuple and not a UFL type.

answered Sep 15, 2013 by mikael-mortensen FEniCS Expert (29,340 points)
selected Sep 18, 2013 by johanhake

Thanks a lot!

Best regards
Andre

Just out of curiosity: how is the second term of a assembled internally? Is there a point search for one of the meshes involved?

...