Adding a Neumann Boundary Condition at Certain Boundary

Asked by Liang Jin Lim

I am trying to solve a elasticity problem.

The model is a cube, clamped at the left side as Dirichlet boundary condition.
Then I would like to add a Neumann boundary condition (Traction force) at the right side of the cube.

How can I apply the neumann boundary condition just at the right side of the cube, not at all the surface? I have no problem applying the Dirichlet boundary, but I am not sure how to do apply Neumann boundary at specific domain.

This is the excerpt of my code in C++:
-------------------------------------------------------------

  UnitCube mesh(10, 10, 10);
  Elasticity::FunctionSpace V(mesh);

  dUdN g;

  // Set up boundary condition at left end
  Clamp c_x;
  Left left;
  DirichletBC bc1(V, c_x, left);

  std::vector<const BoundaryCondition*> bcs;
  bcs.push_back(&bc1);

  // Set elasticity parameters
  double E = 10.0;
  double nu = 0.3;
  Constant mu(E / (2*(1 + nu)));
  Constant lambda(E*nu / ((1 + nu)*(1 - 2*nu)));

  // Define variational problem
  Elasticity::BilinearForm a(V, V);
  a.mu = mu; a.lmbda = lambda;
  Elasticity::LinearForm L(V);
  L.g = g;
  Function u(V);
  LinearVariationalProblem problem(a, L, u, bcs);

  // Compute solution
  LinearVariationalSolver solver(problem);
  solver.parameters["symmetric"] = true;
  solver.parameters["linear_solver"] = "direct";
  solver.solve();
-------------------------------------------------------------------------------

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Marie Rognes
Solved:
Last query:
Last reply:
Revision history for this message
Best Marie Rognes (meg-simula) said :
#1

On 08/25/11 11:20, Liang Jin Lim wrote:
> New question #169140 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/169140
>
> I am trying to solve a elasticity problem.
>
> The model is a cube, clamped at the left side as Dirichlet boundary condition.
> Then I would like to add a Neumann boundary condition (Traction force) at the right side of the cube.
>
> How can I apply the neumann boundary condition just at the right side of the cube, not at all the surface? I have no problem applying the Dirichlet boundary, but I am not sure how to do apply Neumann boundary at specific domain.
>

1. Mark your boundaries, see for instance
demo/undocumented/subdomains/cpp/main.cpp,
     using a MeshFunction over facets (let's call it 'markers')

2. Add the Neumann boundary condition to your linear form in your form
file, typically

     L = dot(f, v)*dx + dot(g, v)*ds(1)

here ds(1) refers to integration over the facets on the boundary marked
by 1, change number at will.

3. Associate the markers with the form by doing

     L.ds = markers

in your main.cpp

--
Marie

> This is the excerpt of my code in C++:
> -------------------------------------------------------------
>
> UnitCube mesh(10, 10, 10);
> Elasticity::FunctionSpace V(mesh);
>
> dUdN g;
>
>
> // Set up boundary condition at left end
> Clamp c_x;
> Left left;
> DirichletBC bc1(V, c_x, left);
>
> std::vector<const BoundaryCondition*> bcs;
> bcs.push_back(&bc1);
>
> // Set elasticity parameters
> double E = 10.0;
> double nu = 0.3;
> Constant mu(E / (2*(1 + nu)));
> Constant lambda(E*nu / ((1 + nu)*(1 - 2*nu)));
>
> // Define variational problem
> Elasticity::BilinearForm a(V, V);
> a.mu = mu; a.lmbda = lambda;
> Elasticity::LinearForm L(V);
> L.g = g;
> Function u(V);
> LinearVariationalProblem problem(a, L, u, bcs);
>
> // Compute solution
> LinearVariationalSolver solver(problem);
> solver.parameters["symmetric"] = true;
> solver.parameters["linear_solver"] = "direct";
> solver.solve();
> -------------------------------------------------------------------------------
>

Revision history for this message
Liang Jin Lim (limliangjin) said :
#2

Thanks Marie Rognes, that solved my question.