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("V.npy")
L = np.load("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("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()
[2019-08-20 10:27:35.358] [polyfem] [info] Loading mesh...
[2019-08-20 10:27:35.358] [polyfem] [info] mesh bb min [0, 0], max [1, 0.5]
[2019-08-20 10:27:35.358] [polyfem] [info]  took 8.5695e-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()
[2019-08-20 10:27:35.497] [polyfem] [info] simplex_count:   314
[2019-08-20 10:27:35.497] [polyfem] [info] regular_count:   0
[2019-08-20 10:27:35.497] [polyfem] [info] regular_boundary_count:  0
[2019-08-20 10:27:35.497] [polyfem] [info] simple_singular_count:   0
[2019-08-20 10:27:35.497] [polyfem] [info] multi_singular_count:    0
[2019-08-20 10:27:35.497] [polyfem] [info] boundary_count:  0
[2019-08-20 10:27:35.497] [polyfem] [info] multi_singular_boundary_count:   0
[2019-08-20 10:27:35.497] [polyfem] [info] non_regular_count:   0
[2019-08-20 10:27:35.497] [polyfem] [info] non_regular_boundary_count:  0
[2019-08-20 10:27:35.497] [polyfem] [info] undefined_count:     0
[2019-08-20 10:27:35.497] [polyfem] [info] total count:  314
[2019-08-20 10:27:35.497] [polyfem] [info] Building not isoparametric basis...
[2019-08-20 10:27:35.498] [polyfem] [info] Computing polygonal basis...
[2019-08-20 10:27:35.498] [polyfem] [info]  took 1.0115e-05s
[2019-08-20 10:27:35.498] [polyfem] [info] hmin: 0.0341246
[2019-08-20 10:27:35.498] [polyfem] [info] hmax: 0.0904418
[2019-08-20 10:27:35.498] [polyfem] [info] havg: 0.0597291
[2019-08-20 10:27:35.498] [polyfem] [info]  took 0.00114429s
[2019-08-20 10:27:35.498] [polyfem] [info] flipped elements 0
[2019-08-20 10:27:35.498] [polyfem] [info] h: 0.0904418
[2019-08-20 10:27:35.498] [polyfem] [info] n bases: 679
[2019-08-20 10:27:35.498] [polyfem] [info] n pressure bases: 0
[2019-08-20 10:27:35.498] [polyfem] [info] Assigning rhs...
[2019-08-20 10:27:35.498] [polyfem] [info]  took 0.000215814s
[2019-08-20 10:27:35.498] [polyfem] [info] Assembling stiffness mat...
[2019-08-20 10:27:35.498] [polyfem] [info]  took 4.952e-06s
[2019-08-20 10:27:35.498] [polyfem] [info] sparsity: 0/0
[2019-08-20 10:27:35.499] [polyfem] [info] Solving NeoHookean with
[2019-08-20 10:27:35.499] [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)