LinearForm and SymbolicLFI


I’m trying to solve the problem of linear elasticity (similar to this), and then there is one question.
If I apply force to a line, is it considered distributed or concentrated? Do I need to divide the force components by the length of the line?

def _stress(u, mu, lam, grid_mesh):

    return 2 * mu * _epsilon(u) + lam * Trace(_epsilon(u)) *  Id(grid_mesh.dim)

def _epsilon(u):

    return 0.5 * (u.Deriv().trans + u.Deriv())

# length 'bottom' = 0.5
length = 0.5

force_1 = CoefficientFunction((0 / length, 100 / length))

coef_mu = [1 / 2 * (E[mat] / (1 + nu[mat])) for mat in grid_mesh.GetMaterials()]

coef_lam = [E[mat] * nu[mat] / ((1 + nu[mat]) * (1 - 2 * nu[mat])) for mat in grid_mesh.GetMaterials()]

solve_func = H1(grid_mesh, order=3, dirichlet='top', dim=grid_mesh.dim)

u, v = solve_func.TrialFunction(), solve_func.TestFunction()

mu = CoefficientFunction(coef_mu)
lam = CoefficientFunction(coef_lam)

bform = BilinearForm(solve_func)
bform += SymbolicBFI(2 * mu * InnerProduct(_epsilon(u), _epsilon(v)) + lam * Trace(u.Deriv()) * Trace(v.Deriv()))

lform = LinearForm(solve_func)
lform += SymbolicLFI(force_1 * v, definedon=grid_mesh.Boundaries('bottom'))


grid = GridFunction(solve_func, name='grid_1') = bform.mat.Inverse(solve_func.FreeDofs()) * lform.vec

displacement = grid
deformation = _epsilon(grid)
stress = _stress(grid, mu, lam, grid_mesh)


I am also interested in a unit of measurement of displacements, mm or m?
I hope you will help me, thank you!

Hi LilBeng,


SymbolicLFI(force * v, definedon=grid_mesh.Boundaries('bottom'))

you apply a force with the density “force”.

If you want to have a point load

SymbolicLFI(force * v, definedon=grid_mesh.BBoundaries('some_point'))

you could use an approximation of the Dirac Delta distribution

SymbolicLFI(approx_delta_eps * v, definedon=grid_mesh.Boundaries('bottom'), bonus_intorder=8)

For a gravity force you would write

SymbolicLFI(9.81 * v)

without dividing through the area.

NGSolve does not use units internally. If you define a rectangle with L=2, W=1 then the resulting displacement has the same “unit” as L.
I would recommend using SI units ( L=2m), non-dimensionalize the equation or compute the resulting units on paper before.

I hope this answers your questions.


Thank you Michael!