Challenging variational formulation

Does anyone have a clue as to how to implement the following variational form in FEniCS?

\dots + \dfrac{\partial}{\partial x} \left[ |\nabla \phi|^2 A(\mathbf{n}) \dfrac{\partial A(\mathbf{n})}{\partial \left( \dfrac{\partial \phi}{\partial x}\right)} \right] + \dfrac{\partial}{\partial y} \left[ |\nabla \phi|^2 A(\mathbf{n}) \dfrac{\partial A(\mathbf{n})}{\partial \left( \dfrac{\partial \phi}{\partial y}\right)} \right]

where \phi(\mathbf{x},t) is a scalar field and A(\mathbf{n}) is a nonlinear function of the approximate normal:

\mathbf{n} \approx \dfrac{\nabla \phi}{|\nabla \phi|}

In particular, I am not sure how to deal with the absolute value operator and the differentiation with respect to the directional derivatives of \phi.

Thanks!

So, first, I’m guessing that these are terms from the strong form of a conservation law

\cdots + \nabla\cdot\mathbf{F}(\nabla\phi)\text{ ,}

where the flux \mathbf{F} is

\mathbf{F}(\nabla\phi) = \vert\nabla\phi\vert^2 A(\mathbf{n})\frac{\partial A(\mathbf{n})}{\partial\nabla\phi}\text{ ,}

so a typical corresponding term from the weak form would be

\cdots - \int_\Omega\mathbf{F}(\nabla\phi)\cdot\nabla\psi\,d\mathbf{x}\text{ ,}

where \psi is a test function. Partial UFL code for \mathbf{F} might look something like

gp = variable(grad(phi)) # (needed for diff to work)
gp2 = dot(gp,gp)
def safeSqrt(x):
    # Regularized sqrt; more robust for use with derivative(), in 
    # case sqrt(x) ends up in the denominator)
    return sqrt(x + DOLFIN_EPS)
n = gp/safeSqrt(gp2)
A = # (something depending on n)
dA_dgp = diff(A,gp)
F = gp2*A*dA_dgp
1 Like