Mismatching function spaces error
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.
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<mailto: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<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
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<mailto: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<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
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<mailto: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<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
I do this already, of course. It doesn’t complain when I assign eta0.assign(eta1) which both belong to CG1, but it complains only for Z0.assign(Z1) Might have something to do with the real function space? Is there a way to inspect (by printing something on screen) in which function space each function belongs to? Best, Anna. On 20 Mar 2017, at 07:47, Floriane Gidel [RPG] <mmfg@leeds.ac.uk<mailto:mmfg@leeds.ac.uk>> wrote: 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<mailto:firedrake-bounces@imperial.ac.uk> <firedrake-bounces@imperial.ac.uk<mailto:firedrake-bounces@imperial.ac.uk>> de la part de Anna Kalogirou <A.Kalogirou@leeds.ac.uk<mailto:A.Kalogirou@leeds.ac.uk>> Envoyé : dimanche 19 mars 2017 22:18:38 À : firedrake@imperial.ac.uk<mailto: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<mailto: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<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
split(f) yields values (UFL expressions to be precise) which remember that they are coming from a mixed space. f.split() yields gives Firedrake Functions which aren't aware of being part of a mixed function. Both work inside UFL expressions. Methods specific to Firedrake Functions will not work with split(f). f.split() only works on functions, but not applicable to arguments, while split(f) works for both. On 19/02/17 23:09, Anna Kalogirou 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? I'm not sure. Cannot you just use Constants? Are these constant-in-space values among your solution variables? Are you doing adjoint stuff?
On 20/03/17 08:02, Anna Kalogirou wrote:
Might have something to do with the real function space? Pass. Is there a way to inspect (by printing something on screen) in which function space each function belongs to? Sure, Z0.function_space()
I have checked both functions with Z0.function_space() Z1.function_space() and both results give WithGeometry(FunctionSpace(<firedrake.mesh.ExtrudedMeshTopology object at 0x10a31e510>, <R0 on a TensorProductCell(interval, interval)>, name=None), <Mesh #4>) so I don’t understand why Z0.assign(Z1) doesn’t work. This is the full error: Traceback (most recent call last): File "buoy-swe.py", line 146, in <module> (phi0, eta0, W0, Z0, mu0_5) = solvers_SV(F_solver, phi_solver1, W_solver1, eta0, phi0, Z0, W0, eta1, phi1, Z1, W1); File "/Users/matak/Documents/Simulations/Firedrake/Ship/Modules/Mixed system/solvers.py", line 95, in solvers_SV Z0.assign(Z1) File "<decorator-gen-271>", line 2, in assign File "/Users/matak/firedrake/src/firedrake/firedrake/utils.py", line 62, in wrapper return f(*args, **kwargs) File "/Users/matak/firedrake/src/firedrake/firedrake/function.py", line 356, in assign assemble_expressions.Assign(self, expr), subset) File "<decorator-gen-276>", line 2, in evaluate_expression File "/Users/matak/firedrake/src/firedrake/firedrake/utils.py", line 59, in wrapper return f(*args, **kwargs) File "/Users/matak/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 573, in evaluate_expression for tree in ExpressionSplitter().split(expr): File "/Users/matak/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 290, in split return [expr._ufl_expr_reconstruct_(*ops) for ops in zip(*map(self.visit, (lhs, rhs)))] File "/Users/matak/firedrake/src/ufl/ufl/algorithms/transformer.py", line 108, in visit r = h(o) File "/Users/matak/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 329, in terminal raise ValueError("Mismatching function spaces") ValueError: Mismatching function spaces On 20 Mar 2017, at 10:20, Miklós Homolya <m.homolya14@imperial.ac.uk<mailto:m.homolya14@imperial.ac.uk>> wrote: split(f) yields values (UFL expressions to be precise) which remember that they are coming from a mixed space. f.split() yields gives Firedrake Functions which aren't aware of being part of a mixed function. Both work inside UFL expressions. Methods specific to Firedrake Functions will not work with split(f). f.split() only works on functions, but not applicable to arguments, while split(f) works for both. On 19/02/17 23:09, Anna Kalogirou 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? I'm not sure. Cannot you just use Constants? Are these constant-in-space values among your solution variables? Are you doing adjoint stuff? On 20/03/17 08:02, Anna Kalogirou wrote: Might have something to do with the real function space? Pass. Is there a way to inspect (by printing something on screen) in which function space each function belongs to? Sure, Z0.function_space() _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk<mailto:firedrake@imperial.ac.uk> https://mailman.ic.ac.uk/mailman/listinfo/firedrake
participants (3)
- 
                
                Anna Kalogirou
- 
                
                Floriane Gidel [RPG]
- 
                
                Miklós Homolya