-
given a 2byn array of vertices coordinates and a 2bym array of elements defining the connectivity between the vertices, an area A, and boundary condition stiffness BCStifnes. Is it possible to build a mesh, basis, and function to perform assembly using asm()? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
No truss assembler in scikit-fem. It should be max. 20 lines of code to implement it from scratch. |
Beta Was this translation helpful? Give feedback.
-
If you really, really, want to do it, this is how it can be done: from skfem import *
from skfem.helpers import *
import numpy as np
m = MeshTri(np.array([[0, 0],
[10, 5],
[10, 0],
[20, 8],
[20, 0],
[30, 9],
[30, 0],
[40, 8],
[40, 0],
[50, 5],
[50, 0],
[60, 0]]).T,
np.array([[7, 8, 9],
[9, 10, 11],
[8, 9, 10],
[1, 3, 4],
[0, 1, 2],
[3, 5, 6],
[5, 6, 7],
[3, 4, 6],
[6, 7, 8],
[1, 2, 4]]).T)
fbasis = FacetBasis(m, ElementVector(ElementTriP1()))
ifbasis = InteriorFacetBasis(m, ElementVector(ElementTriP1()), side=0)
@BilinearForm
def bilinf(u, v, w):
t = np.array([-w.n[1], w.n[0]])
ut = ddot(grad(u), prod(t, t))
vt = ddot(grad(v), prod(t, t))
return ut * vt
A = asm(bilinf, [ifbasis, fbasis])
f = ifbasis.zeros()
f[ifbasis.get_dofs(nodes=(30, 0)).all('u^2')] = -1e-2
D1 = ifbasis.get_dofs(nodes=(0, 0)).all()
D2 = ifbasis.get_dofs(nodes=(60, 0)).all()
D = np.concatenate((D1, D2))
x = solve(*condense(A, f, D=D))
m.translated(x[fbasis.nodal_dofs]).draw(node_numbering=True).show() |
Beta Was this translation helpful? Give feedback.
If you really, really, want to do it, this is how it can be done: