So I have a slightly awkward set of boundaries in a Cahn-Hilliard type problem which makes getting a good initial guess reasonably difficult. I would like to solve Laplace's equation to get an initial condition, which I have done, obtaining a function mu0.
def macro_solver(mesh, boundaries, mu0):
# Create mesh and build function space
P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 2)
ME = FunctionSpace(mesh, P1*P1)
# Class representing the initial conditions
class InitialConditions(Expression):
def eval(self, values, x):
values[0] = -np.tanh(5*(x[0]-1-0.05*cos(6.28*x[1])))
values[1] = mu0
def value_shape(self):
return (2,)
This is essentially what I want to do, now a cursory look suggests using the FunctionAssigner class, but mu0 is on a different function space so needs projection and there is no obvious demo or useful documentation as to how this might be accomplished.
Many thanks in advance for any advice