Hi Dokken,
Sorry for the delayed response. I roughly understand your point, but I’m not sure how to apply it to my situation
I want to solve the following equation, but I’m not sure how to implement it using the method you suggested.
\text { find } w_h \in V_h \text { such that } \forall v_h \in V_h \text { : }
-J_h^{\prime}\left(u_h\right)\left(v_h\right)=\left\{\begin{array}{l}
\left(D_{D G}\left(w_h ; 0\right), D_{D G}\left(v_h ; 0\right)\right)_{\Omega} \\
+\left\langle\eta h^{-1} [[ w_h\right],\left[[v_h ]]\right\rangle_{\Gamma^o}+\left\langle\eta h^{-1} w_h, v_h\right\rangle_{\Gamma^D},
\end{array}\right.
where
\begin{aligned}
\forall \boldsymbol{\zeta}_h \in \Sigma_h, & \left(D_{D G}(v ; g), \boldsymbol{\zeta}_h\right)_{\Omega} \\
= & -\left(v, \nabla_h \cdot \boldsymbol{\zeta}_h\right)_{\Omega}+\left\langle\{\{v\}\}+\boldsymbol{C}_{12} \cdot [[ v ]], [[\boldsymbol{\zeta}_h ]]\right\rangle_{\Gamma^{\circ}}+\left\langle g, \boldsymbol{\zeta}_h \cdot \boldsymbol{n}\right\rangle_{\Gamma^D} .
\end{aligned}
from dolfin import *
from petsc4py import PETSc
import numpy as np
import matplotlib.pyplot as plt
import math
x, y = sp.symbols('x[0] x[1]')
p = 2.0
test = 2
pdeg = 1
size = 2
P1 = VectorElement("DG", triangle, pdeg)
P2 = VectorElement("DG", triangle, pdeg)
P3 = FiniteElement("DG", triangle, pdeg)
P1P2P3 = MixedElement([P1, P2, P3])
W = FunctionSpace(mesh, P1P2P3)
V1 = FunctionSpace(mesh, P1)
V2 = FunctionSpace(mesh, P2)
V3 = FunctionSpace(mesh, P3)
(q,sigma,u) = TrialFunctions(W)
(zeta,tau,v) = TestFunctions(W)
n = FacetNormal(mesh)
h = CellDiameter(mesh)
h_avg = (h('+') + h('-'))/2
def Discrete_weak_gradient(v,g):
(q,sigma,uu) = TrialFunctions(W)
(zeta,tau,vv) = TestFunctions(W)
# v = interpolate(v,V3)
g = project(g,V3)
C12 = Constant((1.0,0))
dot_product = inner(C12,n('+'))
sign = conditional(dot_product > 0, 1.0, -1.0)
# sign = conditional(dot_product > 0, 1.0,conditional(dot_product < 0, -1.0, 0.0) )
# bc = DirichletBC(W.sub(2), g, "on_boundary")
L = inner(q,zeta)*dx
R = -v*div(zeta)*dx + avg(v)*inner(jump(zeta),n('+'))*dS\
+ inner(0.5*sign,jump(v))*inner(jump(zeta),n('+'))*dS + g*inner(zeta,n)*ds
F = L - R
L = lhs(F)
R = rhs(F)
w = Function(W)
solve(L==R,w)
(q,sigma,u) = w.split()
return q