problem with the bc
I am facing problem while defining the bcs..
problem desp- I have a square domain which is fixed at the left side..
case I - I want to apply the external load *Neumann bc * at the node (1,1)
case- II - I want to apply the external load at the whole top boundary..
..
I have written a code after goin through manuals..but it does not work..please gv your suggestions
from dolfin import *
# Create classes for defining parts of the boundaries and the interior
# of the domain
class Left(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], 0.0)
class Right(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], 1.0)
class Bottom(SubDomain):
def inside(self, x, on_boundary):
return near(x[1], 0.0)
class Top(SubDomain):
def inside(self, x, on_boundary):
return near(x[1], 1.0)
class Obstacle(
def inside(self, x, on_boundary):
return ((x[1], (1.0)) and (x[0], (1.0)))
# Initialize sub-domain instances
left = Left()
top = Top()
right = Right()
bottom = Bottom()
obstacle = Obstacle()
# Create mesh and define function space
mesh = dolfin.
# Initialize mesh function for interior domains
domains = CellFunction(
domains.set_all(0)
obstacle.
# Initialize mesh function for boundary domains
boundaries = FacetFunction(
boundaries.
left.mark(
top.mark(
right.mark(
bottom.
# Define function space and basis functions
V = VectorFunctionS
U = TrialFunction(V)
v = TestFunction(V)
# Define boundary conditions
bc = DirichletBC(V, 0.0, boundaries,1)
# Define new measures associated with the interior domains and exterior boundaries
dx = Measure(
ds = Measure(
# Define functions
v = TestFunction(V) # Test function
U = TrialFunction(V)
# Elasticity parameters
E, nu ,g_T= 10.0, 0.3, Constant("1.0")
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
def epsilon(v):return 0.5*(grad(
def sigma(v):return 2*mu*epsilon(
# Define variational problem
a = inner(grad(
L = - g_T*v*ds(2)
# Solve problem
U = Function(V)
solve(a == L, U, bc)
# Plot solution and mesh
# Hold plot
plot(U, interactive=True)
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
This question was reopened
Can you help with this problem?
Provide an answer of your own, or ask Niraj Kumar Jha for more information if necessary.