# Define Truss Mesh in JuAFEM

**URL:** <https://discourse.julialang.org/t/define-truss-mesh-in-juafem/36191>\
**Category:** Modelling & Simulations\
**Created:** [March 19, 2020, 3:27pm UTC](https://discourse.julialang.org/t/define-truss-mesh-in-juafem/36191 "2020-03-19T15:27:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrootLoops](https://avatars.discourse-cdn.com/v4/letter/f/c4cdca/32.png) [@FrootLoops](https://discourse.julialang.org/u/FrootLoops)\
**Post date:** [March 19, 2020, 3:27pm UTC](https://discourse.julialang.org/t/define-truss-mesh-in-juafem/36191/1 "2020-03-19T15:27:49Z")

</div>

Hello everybody 🙂

I am new to Julia and JuAFEM. Now I am trying to understand the linear Elasticity demo in juAFEM [see](https://kristofferc.github.io/JuAFEM.jl/dev/examples/incompressible_elasticity/). I understood a lot but I have big problems to adjust the code for my own purpose.

I want to define a simple truss problem like:

![ad77f25543945fc49ea841b49096b8dabfda8174](https://global.discourse-cdn.com/julialang/original/3X/a/d/ad77f25543945fc49ea841b49096b8dabfda8174.png)

1 Element with 2 Nodes and 2 DoF in each node i.e. I am searching for the solution (u1\_x, u2\_x, u3\_x, u4\_x).

My first try lead to:

```julia
using JuAFEM
using BlockArrays, SparseArrays, LinearAlgebra
using Pandas
n = 1, l=2
function create__grid(l, n)

    # Ecken zuerst mit Koordinaten
    corners = [Vec{2}((0.0)),
               Vec{2}((l.0))]

    grid = generate_grid(Lagrange, n, corners);

    # facesets for boundary conditions
    addfaceset!(grid, "clamped", x -> norm(x[0]) ≈ 0.0);
    addfaceset!(grid, "traction", x -> norm(x[1]) ≈ 2.0);
    return grid
end

```

Is this the correct way?

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 19, 2020, 3:42pm UTC](https://discourse.julialang.org/t/define-truss-mesh-in-juafem/36191/2 "2020-03-19T15:42:42Z")

</div>

That structure is unstable.

---

<div class="post-metadata">

**Author:** ![FrootLoops](https://avatars.discourse-cdn.com/v4/letter/f/c4cdca/32.png) [@FrootLoops](https://discourse.julialang.org/u/FrootLoops)\
**Post date:** [March 19, 2020, 3:53pm UTC](https://discourse.julialang.org/t/define-truss-mesh-in-juafem/36191/3 "2020-03-19T15:53:14Z")

</div>

What do you mean with unstable? So how is the correct way to define a truss structure? For example something like:

![bef301629066728b8b81f24ec2d29b8af51c1366](https://global.discourse-cdn.com/julialang/original/3X/b/e/bef301629066728b8b81f24ec2d29b8af51c1366.png)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [March 19, 2020, 4:01pm UTC](https://discourse.julialang.org/t/define-truss-mesh-in-juafem/36191/4 "2020-03-19T16:01:58Z")

</div>

This would work. However I’m not qualified to advise you on the construction of the grid.  
I believe you will have to do it manually, the function you used above may be for one-dimensional grids only.
