How to update an UserExpression for the next time step?

Thanks @Dokken for the link.

I´m aware of how to update a parameter, which I initialized via __init__, inside the main time stepping for-loop.
But I would like to update f_prev to the current value[0] of the UserExpression. In my revised MWCE I solved this by

# Update previous solution
u_prev.assign(u)
f_prev = MySourceConcentration(t, u_prev)

Now, I´m unsure, if Fenics will use this f_prev for the next time step or the f_prev, I initially created for t=0 (line 116)?

Thanks,

Cou

Revised MWCE
from fenics import *
import numpy as np

# Define source term f
class MySourceConcentration(UserExpression):
    def __init__(self, t, u, **kwargs):
        super().__init__(**kwargs)
        self.t = t
        self.u = u

    def eval(self, values, x):
        
        # Calculate the source term f for t>0
        if self.t >0:
            if x[0]>0 and x[0]<=0.5:
                # Calculate average of u for the domain x>=0 and x<=0.5
                u_avg = assemble(self.u*dx(1)) / assemble(Constant(1.0)*dx(1))
            
                # Calculate the surface area of a particle (equation is made up for demonstrationen purposes without physical correctness) 
                area = area_t0 - dt * (1 - u_avg)
                
                # Calculate source term f
                values[0] = Constant1 * area * (Constant2 - u_avg)
                self.msc = values[0]
                
            # for the rest of the domain: source term f=0     
            else:
                values[0] = 0  
                
        # Set the source term f for t=0
        else:
            if x[0]>0 and x[0]<=0.5:
                values[0] = f_0
            else:
                values[0] = 0

    def value_shape(self):
        return ()      
    
# Define Constants
Constant1 = 1
Constant2 = 10
D = Constant(0.6)  # diffusion coefficient
f_0 = 4            # Source term value for t=0
beta = 1.2
area_t0 = 5

T = 2.0            # final time
num_steps = 10     # number of time steps
dt = T / num_steps # time step size

# Create mesh and define function space
nx = ny = 16
mesh = UnitSquareMesh(nx, ny)
space_dim = mesh.geometry().dim()
V = FunctionSpace(mesh, 'CG', 1)

# Create classes for defining parts of the boundaries and the interior
# of the domain
class Left(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[0], 0.0)

class Right(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[0], 1.0)

class Bottom(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[1], 0.0)

class Top(SubDomain):
    def inside(self, x, on_boundary):
        return near(x[1], 1.0)

class Obstacle_left(SubDomain):
    def inside(self, x, on_boundary):
        return (between(x[0], (0.0, 0.5)))
    
class Obstacle_right(SubDomain):
    def inside(self, x, on_boundary):
        return (between(x[0], (0.5, 1.0)))
    
# Initialize sub-domain instances
left = Left()
top = Top()
right = Right()
bottom = Bottom()
obstacle_left = Obstacle_left()
obstacle_right = Obstacle_right()

# Initialize mesh function for interior domains
domains = MeshFunction("size_t", mesh, space_dim-1)
obstacle_left.mark(domains, 1)
obstacle_right.mark(domains, 3)

# Initialize mesh function for boundary domains
boundaries = MeshFunction("size_t", mesh, space_dim-1)
boundaries.set_all(0)
left.mark(boundaries, 1)
top.mark(boundaries, 2)
right.mark(boundaries, 3)
bottom.mark(boundaries, 4)

# Define new measures associated with the interior domains and
# exterior boundaries
dx = Measure('dx', domain=mesh, subdomain_data=domains)
ds = Measure('ds', domain=mesh, subdomain_data=boundaries)
    
vtkfile = File("20201028_UE_update_umsetzen.pvd")

################### Initial values (t=0) ######################################
t=0
u_0 = Constant(1)
u_prev = interpolate(u_0, V)
f_prev = MySourceConcentration(t, u_prev, degree=1)
    
############ Robin boundary condition j_m * n_m = h*(u-c_oo) ##################
h = 1.0
c_oo = 1.0

#################### Define variational problem ###############################
u = TrialFunction(V)
v = TestFunction(V)
f = MySourceConcentration(t, u_prev, degree=1)

F = (u - u_prev)*v*dx + 0.5*h*beta*dt*(u+u_prev-2*c_oo)*v*ds + 0.5*beta*dt*D*(inner((grad(u)+grad(u_prev)),grad(v)))*dx - 0.5*dt*(f_prev+f)*v*dx(1) - 0.5*dt*(f_prev+f)*v*dx(3)
a, L = lhs(F), rhs(F)

# Time-stepping
u = Function(V)

for n in range(num_steps):

    # Update current time
    t += dt
    
    # Compute solution
    solve(a == L, u)
    vtkfile << (u, t)
    
    # Update previous solution
    u_prev.assign(u)
    f_prev = MySourceConcentration(t, u_prev)