Hello,

I am trying to build on the QG SLEPc demo that I put together a while ago to solve for the linear instability of a 1D Shallow Water Jet.  I've done this in the past using spectral methods and have had much success, but I often get spurious modes, which requires very high resolution to remove.   I have been told by a reliable source that the FEM should be less prone to these spurious modes, which would be great.

I have a notebook and a python script at the following links:

https://github.com/francispoulin/firedrakeQG/blob/master/Linear%20Stability%20Analysis%20SW%20Jet%20(Firedrake).ipynb

https://github.com/francispoulin/firedrakeQG/blob/master/LSA_SW_Jet_Firedrake.py

The error comes from the assemble part.  I have done this previously with QG and SW in 2D and managed to get it working.  This is only a 1D problem, so a little bit different, but should be easier.  Unfortunately, when I do try it I get the following error, see below.  I have tried different combinations but am not having any success.

One issue is that there are three variables: u, v, eta (height).  I define the solution space to be V*V*V where V is a CG space. This is the major difference compared to what I tried before.

I am pretty sure that I am getting the syntax wrong here. Can anyone offer any advice?

Cheers, Francis


(firedrake) fpoulin@fpoulin-Gazelle:~/Research/2015-Ben_Storer/Firedrake$ python LSA_SW_Jet_Firedrake.py
('Ro      = ', 0.25)
('Bu      = ', 0.0004)
('profile = ', 'bickley')
Traceback (most recent call last):
  File "LSA_SW_Jet_Firedrake.py", line 103, in <module>
    petsc_a = assemble(a, mat_type='aij', bcs=bc).M.handle
  File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/assemble.py", line 102, in assemble
    allocate_only=allocate_only)
  File "<decorator-gen-279>", line 2, in _assemble
  File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/utils.py", line 62, in wrapper
    return f(*args, **kwargs)
  File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/assemble.py", line 192, in _assemble
    kernels = tsfc_interface.compile_form(f, "form", parameters=form_compiler_parameters, inverse=inverse)
  File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/tsfc_interface.py", line 193, in compile_form
    number_map).kernels
  File "/home/fpoulin/software/firedrake/src/PyOP2/pyop2/caching.py", line 200, in __new__
    obj = make_obj()
  File "/home/fpoulin/software/firedrake/src/PyOP2/pyop2/caching.py", line 190, in make_obj
    obj.__init__(*args, **kwargs)
  File "/home/fpoulin/software/firedrake/src/firedrake/firedrake/tsfc_interface.py", line 112, in __init__
    tree = tsfc_compile_form(form, prefix=name, parameters=parameters)
  File "/home/fpoulin/software/firedrake/src/tsfc/tsfc/driver.py", line 44, in compile_form
    fd = ufl_utils.compute_form_data(form)
  File "/home/fpoulin/software/firedrake/src/tsfc/tsfc/ufl_utils.py", line 56, in compute_form_data
    do_estimate_degrees=do_estimate_degrees,
  File "/home/fpoulin/software/firedrake/src/ufl/ufl/algorithms/compute_form_data.py", line 387, in compute_form_data
    check_form_arity(preprocessed_form, self.original_form.arguments())  # Currently testing how fast this is
  File "/home/fpoulin/software/firedrake/src/ufl/ufl/algorithms/check_arities.py", line 152, in check_form_arity
    check_integrand_arity(itg.integrand(), arguments)
  File "/home/fpoulin/software/firedrake/src/ufl/ufl/algorithms/check_arities.py", line 145, in check_integrand_arity
    args = map_expr_dag(rules, expr, compress=False)
  File "/home/fpoulin/software/firedrake/src/ufl/ufl/corealg/map_dag.py", line 37, in map_expr_dag
    result, = map_expr_dags(function, [expression], compress=compress)
  File "/home/fpoulin/software/firedrake/src/ufl/ufl/corealg/map_dag.py", line 86, in map_expr_dags
    r = handlers[v._ufl_typecode_](v, *[vcache[u] for u in v.ufl_operands])
  File "/home/fpoulin/software/firedrake/src/ufl/ufl/algorithms/check_arities.py", line 42, in sum
    raise ArityMismatch("Adding expressions with non-matching form arguments {0} vs {1}.".format(a, b))
ufl.algorithms.check_arities.ArityMismatch: Adding expressions with non-matching form arguments (Argument(WithGeometry(FunctionSpace(<firedrake.mesh.MeshTopology object at 0x7f2a458c5290>, FiniteElement('Lagrange', interval, 2), name=None), Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 1)), 0, None), Argument(WithGeometry(FunctionSpace(<firedrake.mesh.MeshTopology object at 0x7f2a458c5290>, FiniteElement('Lagrange', interval, 2), name=None), Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 1)), 1, None)) vs (Argument(WithGeometry(FunctionSpace(<firedrake.mesh.MeshTopology object at 0x7f2a458c5290>, FiniteElement('Lagrange', interval, 2), name=None), Mesh(VectorElement(FiniteElement('Lagrange', interval, 1), dim=1), 1)), 0, None),).


------------------
Francis Poulin                    
Associate Professor
Department of Applied Mathematics
University of Waterloo

email:           fpoulin@uwaterloo.ca
Web:            https://uwaterloo.ca/poulin-research-group/
Telephone:  +1 519 888 4567 x32637