{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import meshplot as mp\n", "\n", "import wildmeshing as wm\n", "import polyfempy as pf" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load Data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "V = np.load(\"V.npy\")\n", "L = np.load(\"L.npy\")\n", "\n", "p=mp.plot(V, np.zeros((0,3)), return_plot=True)\n", "p.add_edges(V, L, shading={});\n", "p.add_points(V, shading={\"point_color\": \"red\", \"point_size\": 10})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Meshing" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "vs, tris, nodes, F_nodes = wm.triangulate_svg(\"plane_hole.svg\", cut_outside=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p = mp.plot(vs, tris, shading={\"wireframe\": True}, return_plot=True)\n", "p.add_points(V, shading={\"point_color\": \"red\", \"point_size\": 2});\n", "p.add_points(nodes, shading={\"point_color\": \"green\", \"point_size\": 2})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Sidesets for Boundary Conditions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "solver = pf.Solver()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "solver.set_high_order_mesh(vs, tris, nodes, F_nodes)\n", "\n", "sp, sl, s = solver.get_boundary_sidesets()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "p=mp.plot(sp, np.zeros((0,3)), return_plot=True)\n", "\n", "p.add_edges(sp, sl);\n", "\n", "e1 = sl[s[:,0] == 1, :]\n", "e2 = sl[s[:,0] == 2, :]\n", "e3 = sl[s[:,0] == 3, :]\n", "e4 = sl[s[:,0] == 4, :]\n", "\n", "p.add_points((sp[e1[:, 0], :]+sp[e1[:, 1], :])/2, shading={\"point_color\": \"red\", \"point_size\": 0.1});\n", "p.add_points((sp[e2[:, 0], :]+sp[e2[:, 1], :])/2, shading={\"point_color\": \"green\", \"point_size\": 0.1});\n", "p.add_points((sp[e3[:, 0], :]+sp[e3[:, 1], :])/2, shading={\"point_color\": \"blue\", \"point_size\": 0.1});\n", "p.add_points((sp[e4[:, 0], :]+sp[e4[:, 1], :])/2, shading={\"point_color\": \"black\", \"point_size\": 0.1})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem and Settings Setup" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "settings = pf.Settings()\n", "problem = pf.Problem()\n", "\n", "settings.set_pde(pf.PDEs.NonLinearElasticity)\n", "\n", "settings.discr_order = 2\n", "\n", "settings.set_material_params(\"E\", 210000)\n", "settings.set_material_params(\"nu\", 0.3)\n", "\n", "problem.set_x_symmetric(1)\n", "problem.set_y_symmetric(2)\n", "problem.set_force(3, [100, 0])\n", "\n", "settings.set_problem(problem)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Solving!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "solver.settings(settings)\n", "solver.solve()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Results" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sol_pts, sol_tri, disp = solver.get_sampled_solution()\n", "misises, _ = solver.get_sampled_mises_avg()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mp.plot(sol_pts+disp, sol_tri, misises)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }