Shape not matching itself...?


283
views
0
8 months ago by
I have been asked to update some old FEniCS code to work with the latest versions of FEniCS and messing around with the old mixed spaces and the new setup with mixed elements instead, I have run into a problem with non-matching shapes of some sort. I get the following error at the moment:

Shapes do not match: <Argument id=140597342911632> and <Indexed id=140597380113584>.
*** UFLException: Shapes do not match: <Argument id=140597342911632> and <Indexed id=140597380113584>.

Of course, this is not super helpful, so I made a small piece of code reproducing the problem.
Running the follow code snippet produces a number of functions. Somehow in my mind (and this might be where things go wrong) the functions v1 and w[0] and v2 and w[1] should be quite similar, seeing as they were generated from similar elements and on the same mesh? However, w does not even appear to relate very well to itself. The last commented line is an attempt at interpolating w[1] to the subspace corresponding to the Raviart-Thomas element, which produces the above error on my machine. Similarly attempting inner products between w[1] and v2 is likewise futile.

Can someone explain to me, my misconception here, and how one would go about making these things compatible?
I have attempted interpolations and projections to different spaces, but the shape error comes up every time.

mesh = UnitSquareMesh(10,10)

E1 = FiniteElement('P', mesh.ufl_cell(), 1)
E2 = FiniteElement('RT', mesh.ufl_cell(), 2)

V1 = FunctionSpace(mesh, E1)
V2 = FunctionSpace(mesh, E2)

W = FunctionSpace(mesh, E1*E2)

v1 = Function(V1)
v2 = Function(V2)

w = Function(W)​

#interpolate(w[1], W.sub(1).collapse())
Community: FEniCS Project

1 Answer


3
8 months ago by
what about
interpolate(w.sub(1), W.sub(1).collapse())​
Yes, that works for my example. Thank you. It, however, doesn't work for my original more complicated problem. But at least I now know that the two problems were not caused by the same.
Do my underlying problem is an ambiguity in integration domain, which I thought was related to the above problem, as I was getting that one when trying to get rid of any ambiguity.
But I feel stuck now... There is only one mesh, everything in my bilinear form is defined on this mesh, but it still claims an ambiguity. Is it possible to forcibly select a domain? I tried to do this by defining a measure and fixing the domain of that one. Alas, that is apparently not how things work.
written 8 months ago by Bjørn Jensen  
I find it difficult to comprehend the problem, can you build a MWE for this?
You can define a measure like this..
dx = Measure("dx",domain = mesh)​
written 8 months ago by Lukas O.  
1
I can understand why. I figured out part of the problem though (the part I complained about before). Thanks for being helpful.
written 8 months ago by Bjørn Jensen  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »