Re: [firedrake] Product in an expression
Hi Floriane, It looks rather like you are trying to express the basis function expansion at the Firedrake level. This is something which is likely to be quite hard because you're operating at the wrong abstraction level. Can you post at a weak form (i.e. PDEs and function spaces) level what it is you are trying to achieve? Many thanks, David On Mon, 1 Aug 2016 at 16:29 Floriane Gidel [RPG] <mmfg@leeds.ac.uk> wrote:
Dear all,
I would like to compute the following sum over i : phi(x,y,z,t) = psi_i(x,y,t)varphi_i(z), where :
- each psi_i (x,y,t) is a Firedrake function defined on a horizontal plane,
-varphi_i is defined by a lagrange expansion of order n, that is: varphi_i(z) = product( (z-z_k)/(z_i - z_k) ) for k = 0:n , and k different from i. Each z_k can be computed analytically and denotes the discretised z coordinate. For instance, z_k can be defined as z_k = (n-k)H0/n , for z in [0,H0].
How can I define varphi_i so that I can compute the dot product dot(psi,varphi) on Firedrake ? I tried two options:
- use the symbpy package to compute the expression of varphi_i with the 'product' function. But in that case the expression of varphi_i depends on z as a symbol, and I did not manage to use it correctly on Firedrake afterwards,
- define varphi_i(z) as a Firedrake function in z, but in that case, how can I compute the product ? I would normally use an expression, but is there a 'product expression' that I could interpolate ? Something like : varphi[i].interpolate(Expression( "product((x[2]-z[k]) / (z[i]-z[k]) )", z=z, i=i, for k=0:n))
Thank you for your help,
Floriane
Hi David, Thanks for your fast answer. It is indeed something similar to a basis function that I need to define. The objective is to solve the potential flow equations in 3D, but using Firedrake only in the 2D horizontal plane. I use this trick because in my weak formulations, phi(x,y,z,t) is updated only at the surface (z=H0), and that was a problem when trying to solve the WF for the 3D function. So I use a separation of variable in the form : phi(x,y,z,t) = psi(x,y,t)varphi(z), and I solve the part for psi(x,y,t) with Firedrake, and compute the z-dependent part varphi(z) analytically (as a Lagrange expansion). The Firedrake code works well for psi(x,y,t), but I would like to observe the full solution (in 3D) and for this I need to compute the dot product of the horizontal solution psi(x,y,t) (computed with Firedrake) and vertical analytical solution varphi(z). On Firedrake, I define psi(x,y,t) on the vector function space Vec : Vec = VectorFunctionSpace(hor_mesh,"CG",1,dim=n) where hor_mesh is a rectangle mesh, and n is the order of the Lagrange expansion used for varphi(z) such that there is one function psi_i(x,y,t) associated with each varphi_i (z). Then I solve the weak formulations for psi(x,y,t) , which do not depend on varphi(z), and once I get the solution for psi(x,y,t), I would like to compute the product : dot(psi,varphi) = psi_i(x,y,t)varphi_i(z) (= phi(x,y,z,t) ). This product is really independent from the solvers, it's only for a plotting purpose, to observe the final solution in 3D. The solver for psi(x,y,t) works well, but I do not know how to define varphi(z), which is indeed the same as a basis function in z. Best, Floriane ________________________________ De : firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> de la part de David Ham <David.Ham@imperial.ac.uk> Envoyé : lundi 1 août 2016 09:27:54 À : firedrake Objet : Re: [firedrake] Product in an expression Hi Floriane, It looks rather like you are trying to express the basis function expansion at the Firedrake level. This is something which is likely to be quite hard because you're operating at the wrong abstraction level. Can you post at a weak form (i.e. PDEs and function spaces) level what it is you are trying to achieve? Many thanks, David On Mon, 1 Aug 2016 at 16:29 Floriane Gidel [RPG] <mmfg@leeds.ac.uk<mailto:mmfg@leeds.ac.uk>> wrote: Dear all, I would like to compute the following sum over i : phi(x,y,z,t) = psi_i(x,y,t)varphi_i(z), where : - each psi_i (x,y,t) is a Firedrake function defined on a horizontal plane, -varphi_i is defined by a lagrange expansion of order n, that is: varphi_i(z) = product( (z-z_k)/(z_i - z_k) ) for k = 0:n , and k different from i. Each z_k can be computed analytically and denotes the discretised z coordinate. For instance, z_k can be defined as z_k = (n-k)H0/n , for z in [0,H0]. How can I define varphi_i so that I can compute the dot product dot(psi,varphi) on Firedrake ? I tried two options: - use the symbpy package to compute the expression of varphi_i with the 'product' function. But in that case the expression of varphi_i depends on z as a symbol, and I did not manage to use it correctly on Firedrake afterwards, - define varphi_i(z) as a Firedrake function in z, but in that case, how can I compute the product ? I would normally use an expression, but is there a 'product expression' that I could interpolate ? Something like : varphi[i].interpolate(Expression( "product((x[2]-z[k]) / (z[i]-z[k]) )", z=z, i=i, for k=0:n)) Thank you for your help, Floriane
participants (2)
- 
                
                David Ham
- 
                
                Floriane Gidel [RPG]