question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] Neumann BC for elasticity problem

See original GitHub issue

Hello.

Thanks for your nice library. I’m trying to implement Neumann BC for the linear elasticity problem

where t is the surface force defined on the part of the outer boundary. But i didn’t find an exact way to do it in the documentation. I studied several examples and issues and came to the following solution:

import numpy as np
from skfem import *
from skfem.models.elasticity import *
from skfem.visuals.matplotlib import *

m = MeshTri.init_tensor(np.linspace(0, 10, 20), np.linspace(0, 2, 10))

e1 = ElementTriP1()
mapping = MappingIsoparametric(m, e1)

e = ElementVectorH1(e1)
gb = InteriorBasis(m, e, mapping, 1)

E = 7.3e4
nu = 0.34
Lambda, mu = lame_parameters(E, nu)

K = asm(linear_elasticity(Lambda, mu), gb)

pu = -1.0 # MPa
def load_func(x, y):
    return pu * (2.0 * x - 1.0)

# Neumann boundary condition
@LinearForm
def loadingN(v, w):
    return load_func(*w.x) * v.value[1]

top_facets=m.facets_satisfying(lambda x: x[1] == 2.)
top_basis = FacetBasis(m, e, facets=top_facets)

rpN = asm(loadingN, top_basis)

clamped = gb.get_dofs(lambda x: x[0] == 0.0).all()
free = gb.complement_dofs(clamped)

u = solve(*condense(K, rpN, I=free)) 

m = MeshTri(m.p + u[gb.nodal_dofs], m.t)
draw(m)
print("min/max u1:", min(u[gb.nodal_dofs][0]), max(u[gb.nodal_dofs][0]))
print("min/max u2:", min(u[gb.nodal_dofs][1]), max(u[gb.nodal_dofs][1]))

x=u
C = linear_stress(Lambda, mu)
# post processing
s = {}
e_dg = ElementTriDG(ElementTriP1())

for itr in range(2):
    for jtr in range(2):

        @BilinearForm
        def proj_cauchy(u, v, w):
            return C(sym_grad(u))[itr, jtr] * v

        @BilinearForm
        def mass(u, v, w):
            return u * v

        ib_dg = InteriorBasis(m, e_dg)

        s[itr, jtr] = solve(asm(mass, ib_dg),
                            asm(proj_cauchy, gb, ib_dg) @ x)

s[2, 2] = 0 # General plane stress

vonmises = np.sqrt(.5 * ((s[0, 0] - s[1, 1]) ** 2 +
                          (s[1, 1] - s[2, 2]) ** 2 +
                          (s[2, 2] - s[0, 0]) ** 2 +
                          6. * s[0, 1]**2))

ax = plot(ib_dg, vonmises, shading='gouraud') 
draw(m, ax=ax)
print("min/max vonmises:", min(vonmises), max(vonmises))

Сould you tell me if I’m doing it right? or there is another way described in the documentation.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tianyikilluacommented, Feb 20, 2021

As @gdmcbain mentioned, maybe you can try this to compute stress tensors on Gauss points

u_gp = gb.interpolate(u)
eps_gp = 0.5 * (u_gp.grad + u_gp.grad.transpose(1, 0, 2, 3))
C = linear_stress(Lambda, mu)
sig_gp = C(eps_gp)

I tried yesterday and it works perfectly and gives the same results. I haven’t yet compared the performance yet.

0reactions
gittsoycommented, Feb 20, 2021

Ok, thanks for the help 😃 So I think this issue can be closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Neumann boundary condition in linear elasticity ...
Normally, when you look at what a Neumann BC is, you get that it's a prescribed derivative of the solution in the direction...
Read more >
Elasticity problem pure Neumann boundary condition.
Hi, I am solving Elasticity problem with pure Neumann boundary condition. Problem definition: Square plate subjected to pressure (2 unit) in y- ...
Read more >
Smart way to define Neumann boundary conditions for an ...
I'm a new user of Fenics and I can't find a simple way to define boundary conditions. I have a linear elasticity problem...
Read more >
Neumann Boundary Condition - an overview
Neumann or second kind boundary condition. The Neumann boundary condition specifies the normal derivative at a boundary to be zero or a constant....
Read more >
Module 4 Boundary value problems in linear elasticity
solve aerospace-relevant problems in plane strain and plane stress in cartesian and cylindrical coordinates. 4.1 Summary of field equations. Readings: BC 3 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found