assembling weak formulation


400
views
0
13 months ago by
I am having issues assembling this weak formulation

\[ \int_{\Omega}\nabla u \cdot \nabla \phi + \beta\int_{\partial\Omega}\nabla_{\tau}u\cdot\nabla_{\tau}\phi = \int_{\partial\Omega}\lambda u \phi \]

I tried 

from pylab import *
from fenics import *
import dolfin
from mshr import *
import matplotlib.pyplot as plt
import sympy as sp


beta=0
#Define 3D geometry
sphere1 = Sphere(Point(0, 0, 0), 1.0)
sphere2 = Sphere(Point(0, 0, 0), 0.5)
g3d = sphere1 - sphere2


#Define mesh and function space
mesh = generate_mesh(g3d, 32)

File("sphericalshell.pvd")<<mesh
plot(mesh, interactive=True)
#plot(mesh)
#plt.show()

V = FunctionSpace(mesh,"Lagrange", 1)
n = FacetNormal(mesh)

# Define basis and bilinear form
u = TrialFunction(V)
v = TestFunction(V)

a = dot(grad(u), grad(v))*dx
m = -beta*dot(grad(u)-dot(grad(u),n)*n, grad(v)-dot(grad(v),n)*n)*ds + u*v*ds

but I get this error

This integral is missing an integration domain.
Traceback (most recent call last):
    File "sphericalshell.py", line 33, in <module>
        m = -beta*dot(grad(u)-dot(grad(u),n)*n, grad(v)-dot(grad(v),n)*n)*ds + u*v*ds

is this a problem with the domain, the mesh or the assembly of the weak formulation? I feel the problem is with the assembly  but any help is appreciated. 





1 Answer


1
13 months ago by
pf4d 
Your beta = 0, therefore, no integration domain.

Here's a fix for you:

from fenics import *
from mshr   import *

#Define 3D geometry
sphere1 = Sphere(Point(0, 0, 0), 1.0)
sphere2 = Sphere(Point(0, 0, 0), 0.5)
g3d     = sphere1 - sphere2
mesh    = generate_mesh(g3d, 10)

def grad_tangent(u):
  return grad(u) - dot(grad(u),n)*n

V = FunctionSpace(mesh,"Lagrange", 1)
n = FacetNormal(mesh)

u = TrialFunction(V)
v = TestFunction(V)

beta = Constant(0)

a = dot(grad(u), grad(v))*dx  
m = - beta*dot(grad_tangent(u), grad_tangent(v))*ds + u*v*ds​
Please login to add an answer/comment or follow this question.

Similar posts:
Search »