{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Shape Function Generation" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import numpy as np" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "from polymesh.cells import H8\n", "\n", "pcoords = H8.lcoords()\n", "shpf = H8.shape_function_values\n", "shpmf = H8.shape_function_matrix\n", "dshpf = H8.shape_function_derivatives" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((8, 8), (2, 8))" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "shpf(pcoords).shape, shpf(pcoords[:2]).shape" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((8, 3, 24), (2, 3, 24))" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "shpmf(pcoords).shape, shpmf(pcoords[:2]).shape" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((8, 8, 3), (2, 8, 3))" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dshpf(pcoords).shape, dshpf(pcoords[:2]).shape" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "pcoords = H8.lcoords()\n", "*_, shpfH8, shpmfH8, dshpfH8 = H8.generate_class_functions()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.all(np.isclose(shpfH8(pcoords), shpf(pcoords)))" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.all(np.isclose(dshpfH8(pcoords), dshpf(pcoords)))" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.all(np.isclose(shpmfH8(pcoords), shpmf(pcoords)))" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [], "source": [ "from polymesh.cells import TET10\n", "\n", "pcoords = TET10.lcoords()\n", "shp, dshp, shpf, shpmf, dshpf = TET10.generate_class_functions()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((10, 10), (2, 10))" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "shpf(pcoords).shape, shpf(pcoords[:2]).shape" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((10, 3, 30), (2, 3, 30))" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "shpmf(pcoords).shape, shpmf(pcoords[:2]).shape" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "((10, 10, 3), (2, 10, 3))" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dshpf(pcoords).shape, dshpf(pcoords[:2]).shape" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(10, 10)" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "shpf(pcoords).shape" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.8.10 ('.sigeps': venv)", "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.8.10" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "5facf25dadae24d0f6f3d9b821e9851478f51388ee31821a60476e833f1169c6" } } }, "nbformat": 4, "nbformat_minor": 2 }