Skip to content

Meshing and Simulation

Imports

import numpy as np
import meshplot as mp

import wildmeshing as wm
import polyfempy as pf

Load Data

V = np.load("data/V.npy")
L = np.load("data/L.npy")

p=mp.plot(V, np.zeros((0,3)), return_plot=True)
p.add_edges(V, L, shading={});
p.add_points(V, shading={"point_color": "red", "point_size": 10})

Meshing

vs, tris, nodes, F_nodes = wm.triangulate_svg("data/plane_hole.svg", cut_outside=True)
1/1 n sub paths: 5
p = mp.plot(vs, tris, shading={"wireframe": True}, return_plot=True)
p.add_points(V, shading={"point_color": "red", "point_size": 2});
p.add_points(nodes, shading={"point_color": "green", "point_size": 2})

Sidesets for Boundary Conditions

solver = pf.Solver()
solver.set_high_order_mesh(vs, tris, nodes, F_nodes)

sp, sl, s = solver.get_boundary_sidesets()
[2020-05-25 21:25:57.997] [polyfem] [info] Loading mesh...
[2020-05-25 21:25:57.997] [polyfem] [info] mesh bb min [144.3, 163.8], max [244.3, 213.8]
[2020-05-25 21:25:57.997] [polyfem] [info]  took 3.9e-05s
p=mp.plot(sp, np.zeros((0,3)), return_plot=True)

p.add_edges(sp, sl);

e1 = sl[s[:,0] == 1, :]
e2 = sl[s[:,0] == 2, :]
e3 = sl[s[:,0] == 3, :]
e4 = sl[s[:,0] == 4, :]

p.add_points((sp[e1[:, 0], :]+sp[e1[:, 1], :])/2, shading={"point_color": "red", "point_size": 0.1});
p.add_points((sp[e2[:, 0], :]+sp[e2[:, 1], :])/2, shading={"point_color": "green", "point_size": 0.1});
p.add_points((sp[e3[:, 0], :]+sp[e3[:, 1], :])/2, shading={"point_color": "blue", "point_size": 0.1});
p.add_points((sp[e4[:, 0], :]+sp[e4[:, 1], :])/2, shading={"point_color": "black", "point_size": 0.1})

Problem and Settings Setup

settings = pf.Settings()
problem = pf.Problem()

settings.set_pde(pf.PDEs.NonLinearElasticity)

settings.discr_order = 2

settings.set_material_params("E", 210000)
settings.set_material_params("nu", 0.3)

problem.set_x_symmetric(1)
problem.set_y_symmetric(2)
problem.set_force(3, [100, 0])

settings.set_problem(problem)

Solving!

solver.settings(settings)
solver.solve()
[2020-05-25 21:25:58.166] [polyfem] [info] simplex_count:  347
[2020-05-25 21:25:58.166] [polyfem] [info] regular_count:   0
[2020-05-25 21:25:58.166] [polyfem] [info] regular_boundary_count:  0
[2020-05-25 21:25:58.166] [polyfem] [info] simple_singular_count:   0
[2020-05-25 21:25:58.166] [polyfem] [info] multi_singular_count:    0
[2020-05-25 21:25:58.166] [polyfem] [info] boundary_count:  0
[2020-05-25 21:25:58.166] [polyfem] [info] multi_singular_boundary_count:   0
[2020-05-25 21:25:58.166] [polyfem] [info] non_regular_count:   0
[2020-05-25 21:25:58.166] [polyfem] [info] non_regular_boundary_count:  0
[2020-05-25 21:25:58.166] [polyfem] [info] undefined_count:     0
[2020-05-25 21:25:58.166] [polyfem] [info] total count:  347
[2020-05-25 21:25:58.166] [polyfem] [info] Building not isoparametric basis...
[2020-05-25 21:25:58.167] [polyfem] [info] Computing polygonal basis...
[2020-05-25 21:25:58.167] [polyfem] [info]  took 1.5e-05s
[2020-05-25 21:25:58.167] [polyfem] [info] hmin: 3.56264
[2020-05-25 21:25:58.167] [polyfem] [info] hmax: 8.40019
[2020-05-25 21:25:58.167] [polyfem] [info] havg: 5.79831
[2020-05-25 21:25:58.167] [polyfem] [info]  took 0.001096s
[2020-05-25 21:25:58.167] [polyfem] [info] flipped elements 0
[2020-05-25 21:25:58.167] [polyfem] [info] h: 8.40019
[2020-05-25 21:25:58.167] [polyfem] [info] n bases: 750
[2020-05-25 21:25:58.167] [polyfem] [info] n pressure bases: 0
[2020-05-25 21:25:58.167] [polyfem] [info] Assigning rhs...
[2020-05-25 21:25:58.168] [polyfem] [info]  took 0.000143s
[2020-05-25 21:25:58.168] [polyfem] [info] Assembling stiffness mat...
[2020-05-25 21:25:58.168] [polyfem] [info]  took 2e-06s
[2020-05-25 21:25:58.168] [polyfem] [info] sparsity: 0/0
[2020-05-25 21:25:58.168] [polyfem] [info] Solving NeoHookean with
[2020-05-25 21:25:58.168] [polyfem] [info] t: 1 prev: 0 step: 1

Results

sol_pts, sol_tri, disp = solver.get_sampled_solution()
misises, _ = solver.get_sampled_mises_avg()
mp.plot(sol_pts+disp, sol_tri, misises)