I am attempting to deform a rectangle.
I expect the rectangle to enlarge in y-direction keeping its shape as a rectangle. How can I do it?
from numpy import *
from ngsolve import *
from netgen.occ import *
from ngsolve.webgui import Draw
Rect1 = MoveTo(-0.2, 0).Rectangle(0.15, 0.2).Face()
Rect1.bc('Rect1')
Rect2 = MoveTo(0.0, 0.0).Rectangle(0.15, 0.2).Face()
Rect2.bc('Rect2')
Rect2.maxh = 0.04
shape = Glue([Rect1, Rect2])
mesh = Mesh(OCCGeometry(shape, dim=2).GenerateMesh(maxh=0.05, quad_dominated=False))
fes = VectorH1(mesh, order=1)
gfu_history = GridFunction(fes, multidim=0)
gfu = GridFunction(fes)
dY = 0.4*sin(linspace(0, pi, 10))
for dy in dY:
gfu.Set(CF((0, dy*y)), definedon=mesh.Materials('Rect2'))
mesh.SetDeformation(gfu)
gfu_history.AddMultiDimComponent(gfu.vec)
Draw(
gfu_history,
interpolate_multidim=True,
animate=True,
min=0,
max=0.1,
autoscale=False,
deformation=True,
settings={
"camera": {"transformations": [{"type": "move", "dir": (0, 0, 1), "dist": -2}]}
},
);