Dolfin randomly crashes when using interpolated boundary data

Hey,

I think the problem lies here:

I could not test your problem as it loads a file and I currently dont have pandas installed. However I had a similar problem before: I think the DCBoundray calls the function eval(value, x) and not eval_cell(value, x, ufc_cell). Therefore chanigng your UserExpression to

class Velocity_from_PIV(UserExpression):
    # Fenics object to evaluate/interpolate PIV velocity data anywhere
    def __init__(self, data, **kwargs):
        super().__init__(kwargs)
        self.x=data['x'].drop_duplicates().values #vector of x coords (ascending)
        self.y=data['y'].drop_duplicates().values #vector of y coords (ascending)
        self.dx=data['dx'].values.reshape(self.x.size,self.y.size) #matrix of values
        self.dy=data['dy'].values.reshape(self.x.size,self.y.size)
        #Splines (default: cubic, no smoothing)
        self.splx = interp.RectBivariateSpline(self.x,self.y,self.dx)
        self.sply = interp.RectBivariateSpline(self.x,self.y,self.dy)
    def eval(self, value, x):        
        value[0] = self.splx.ev(x[0],x[1])
        value[1] = self.sply.ev(x[0],x[1])
    def value_shape(self):
        return (2,)

could solve your problem :slight_smile:

Vage explanation: Internally (if not overloaded) the function eval_cell(value, x, ufc_cell) calls eval(value, x). However not the other way around, therefore eval(value, x) does not call eval_cell(value, x, ufc_cell) and I also have not found a way to do that (You also linked the topic). In your case in your userExpression you don’t need the ufc_cell variable in your eval_cell function, therefore I’d just leave it out. If you want to evaluate a MeshFunction in your eval_cell function (then you need the ufc_cell argument), then (I think) you first have to interpolate your MeshFunction, therefore creating a function, which then can be called with a coordintate. See: Error: Problem with Expression inside an Expression: Missing eval() function (must be overloaded) - #2 by Emanuel_Gebauer

Best Regards

Emanuel