Re: [firedrake] Mismatching function spaces error
Good spot, this is the split(foo) vs foo.split() "gotcha". split(foo) is supposed to give symbolic UFL objects that can be used in forms: U = FunctionSpace(...); V = FunctionSpace(...) W = U*V urho = TrialFunction(W) u, rho = split(urho) # could have done u, rho = TrialFunctions(W) a = (u*.... + div(u)*.... + rho*...)*dx Whilst foo.split() splits a Function into subfunctions for further use (assignation, output, etc) urho_out = Function(W) solve(a == L, urho_out, bcs=...) u_out, rho_out = urho_out.split() File("temp.pvd").write(rho_out) Furthermore, these somehow work interchangeably *most of the time*, but not *all of the time*. Apologies. On 20 March 2017 at 07:48, Floriane Gidel [RPG] <mmfg@leeds.ac.uk> wrote:
Sorry, Z0.assign(Z1_out) ------------------------------ *De :* Floriane Gidel [RPG] *Envoyé :* lundi 20 mars 2017 07:47:28 *À :* firedrake@imperial.ac.uk *Objet :* RE: Mismatching function spaces error
Hi Anna,
I think you need to write something like
Phi_out, eta_out, mu_out, Z1_out, W1_out, I_out = w.split() Z0.assign(Z0_out)
Best, Floriane ------------------------------ *De :* firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> de la part de Anna Kalogirou <A.Kalogirou@leeds.ac.uk> *Envoyé :* dimanche 19 mars 2017 22:18:38 *À :* firedrake@imperial.ac.uk *Objet :* [firedrake] Mismatching function spaces error
Dear all,
I am defining a mixed system as follows:
V = FunctionSpace(mesh, "CG", 1) V_R = FunctionSpace(mesh, "R", 0) W = V * V * V * V_R * V_R * V_R
and some of the functions defined are:
Z0 = Function(V_R) w = Function(W) phi, eta, mu, Z1, W1, I = split(w)
After defining and solving some solvers etc, I do the following assignment but run into a “Mismatching function spaces” error: Z0.assign(Z1)
Variable Z1 is solved in a mixed system and I want to assign it to Z0, which belongs to space V_R. Shouldn’t the assignment line above work? Why am I getting the error?
Thank you,
Anna.
On 19 Feb 2017, at 23:09, Anna Kalogirou <a.kalogirou@leeds.ac.uk> wrote:
Dear all,
I am trying to solve a set of PDEs and ODEs together as a mixed system. The ODE variables only depend on time, so I define them as functions from the real function space R.
First question: Is this a correct approach?
Second question: I am running into a “Mismatching function spaces” error; can someone please take a look at my code (found here <https://bitbucket.org/annakalog/buoy2d/src/957e88739223e11d84826c76923a9b07d2ee58a0/Mixed%20system/Alternative-approach-with-scalars/?at=master>) and let me know what I’m doing wrong? The error arises when the value of one of the mixed-system variables is assigned to another variable which belongs to the same function space. [I remember having the same issue some time ago, but I thought that it was fixed.]
Thank you.
Best, Anna. _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
participants (1)
- 
                
                Andrew McRae