This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to redefine jump operator for a space-time problem?

0 votes

Hi everyone! I'm new to FEniCS and would like to solve a PDE of the form $\partial_{tt} u - \Delta^2 u = 0$ using a space-time Galerkin method, i.e., I would like to treat the time like a space dimension.

I see in FEniCS that there is C0 interior penalty method to implement $\Delta^2 u = 0$. However in my case, I have to redefine the normal components used in the jump operator. I have written the following code for a 1D+1D (space+time) problem:

def myjump(v, n): "UFL operator: Take the jump of *v* across a facet." v = as_ufl(v) r = len(v.ufl_shape) if r == 0: warning("not defined: myjump") else: return v('+')[0]*n('+')[0] + v('-')[0]*n('-')[0]

My question is how can I scale the following expression?

v('+')[0]*n('+')[0] + v('-')[0]*n('-')[0]

I cannot simply divide by n[0] as it might divide the expression by zero, and I'm not also sure if division operation is defined with such data structure.

asked Jan 26, 2017 by hajian FEniCS Novice (130 points)
edited Jan 27, 2017 by hajian

1 Answer

+1 vote

Hi, how about conditional

from dolfin import *

mesh = UnitSquareMesh(10, 10)
V = VectorFunctionSpace(mesh, 'CG', 1)
v = interpolate(Expression(('x[0]', '2*x[1]'), degree=1), V)
n = FacetNormal(mesh)

def myjump(v, n, tol=1E-12):
    j = v('+')[0]*n('+')[0] + v('-')[0]*n('-')[0]
    return conditional(abs(n('-')[0]) > tol, j/n('-')[0], j)

print assemble(myjump(v, n)*dS) 
answered Jan 27, 2017 by MiroK FEniCS Expert (80,920 points)

Thanks! Do you know perhaps why it crashes with optimization flags?
I used the following two:

parameters["form_compiler"]["cpp_optimize"] = True

and

parameters["form_compiler"]["optimize"] = True

Hi, looking at the error.log I see something like

/tmp/tmpk6qs8B/ffc_form_e9a89afcd2a6fe79628a1f5625f7eab29646345e.cpp:170:32: error: ‘n_00’ was not declared in this scope
           C[0] = ((std::abs( - n_00) > 1e-12)) ? (F0*n_00 - F1*n_00)/( - n_00) : (F0*n_00 - F1*n_00);

so wrong code was generated. This could be a bug in FFC.

...