UserExpression throws warning

I am assuming that you are creating a subclass of UserExpression in your code.

When doing so, you must declare the shape of the expression (for it to be able to select appropriate ufl element, i.e. FiniteElement, VectorElement, TensorElement and so on, see this) like this example. By default it expects a scalar expression

import dolfin as dol
class Delta_Function(dol.UserExpression):
    '''Some user defined expression'''
    def __init__(self, *args):
        
        dol.UserExpression.__init__(self)
    def eval(self, *args):

        values[0] = # code to define user expression
    def value_shape(self):
        return ()

This should take care of your first warning. For the second warning, you can manually set the quadrature_degree for e.g. (Edit: you should set the degree only after knowing what’s best for your problem since this will affect the fidelity of your FE solution)

parameters["form_compiler"]["quadrature_degree"] = 5 # 
6 Likes