# 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:
- 2013-04-30

- Last reply:
- 2013-05-09

## This question was reopened

- 2013-04-30 by Niraj Kumar Jha

Jan Blechta (blechta) said : | #1 |

On Tue, 30 Apr 2013 12:21:15 -0000

Niraj Kumar Jha <email address hidden> wrote:

> New question #227859 on DOLFIN:

> https:/

>

> 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)

L = - inner(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)

>

>

>

>

Niraj Kumar Jha (niraj-jha) said : | #2 |

thnks Jan Blechta..

Niraj Kumar Jha (niraj-jha) said : | #3 |

Thanks Jan Blechta, that solved my question.

Niraj Kumar Jha (niraj-jha) said : | #4 |

Hi..

I am just curious to know about the load application ata particular node..can zou please guide ??

Anders Logg (logg) said : | #5 |

FEniCS no longer uses Launchapd for Questions & Answers. Please

consult the documentation on the FEniCS web page for where and

how to (re)post your question: http://

Anders Logg (logg) said : | #6 |

FEniCS no longer uses Launchapd for Questions & Answers. Please

consult the documentation on the FEniCS web page for where and

how to (re)post your question: http://

Chaitanya (chaitanyaraj108) said : | #7 |

Whoever would like to follow further discussion on this problem....pls. check this link:

http://

## Can you help with this problem?

Provide an answer of your own, or ask Niraj Kumar Jha for more information if necessary.