Closed hawkspar closed 2 years ago
The issue here is that you need to use inner
whenever you multiply by a test function, i.e.
# Navier Stokes variational form
def NS_form(m):
u,p=split(q)
test_u,test_m=split(test)
#mass (variational formulation)
M = inner(div(u,m),test_m)*dx
#set_trace()
#momentum (different test functions and IBP)
M += inner(grad(u,m)*u, test_u) *dx # Convection
M += 1/Re*inner(grad(u,m), grad(test_u,m))*dx # Diffusion
M -= inner(p, div(test_u,m))*dx # Pressure
return M
pert_form=compute_form_data(NS_form(m),complex_mode=True)
Hello UFL users and developers,
This post is taken from the fenics forum with an adapted minimal working example.
I'm trying to use a fenics code to reproduce the results of this paper as part of a validation process.
This is a fluid mechanics paper that involves a specific decomposition : q(x,r,theta,t)=q_0(x,r)+epsilon q_1(x,r)e^(imtheta+(sigma+i omega)t) Going from the Navier-Stokes equations Nd_tq+M(q)=0 and obtaining a base flow q_0 from M(q_0)=0, this allows for computation of the perturbations as a generalised eigenvalue problem dM/dq(q_0)q_1=(sigma+i omega)Nq_1
The nonlinear operator M is well--known in the case of the Navier Stokes equations but in this decomposition it is complex (q_1 is complex as well). The core of the problem is computing dM/dq.
I've read here that the UFL can handle complex values. The code below is an attempt to leverage automatic differentiation to obtain dM/dq(q_0)
With my installation, UFL bundled into
dolfin 2019.1.0
installed usingdocker
I obtain the resulting traceback :I would be grateful on any insight as to why this error arises, how to go around it, or more generally how to handle complex values in UFL (I've found few examples) and how to solve my problem.