.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/MeshGeneration/demo_mixed-top.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_MeshGeneration_demo_mixed-top.py: Mixed-Topology TPMS =================== Mixed-topology surfaces :cite:p:`Josephson2024b` combine multiple implicit functions by taking weighted sums of the functions. By controlling the weights, the resulting surface can be varied continuously between the set of surfaces. Depending on the set of surfaces, this can constitute a low-parameter, topology-varying design space that can be used for design optimization (as in :cite:`Josephson2024b`). Triply periodic minimal surfaces (TPMS) are particularly interesting subjects for a mixed-topology approach because the resultant surface will remain triply periodic (though not minimal) as long as the periodicities are compatible. Such surfaces can be easily generated in MyMesh with the :mod:`~mymesh.implicit` module. Several TPMSs are available as built-in functions in :mod:`~mymesh.implicit` including :func:`~mymesh.implicit.gyroid`, :func:`~mymesh.implicit.primitive` (Schwarz P), and :func:`~mymesh.implicit.diamond` (Schwarz D) [#f1]_. .. GENERATED FROM PYTHON SOURCE LINES 25-51 .. code-block:: Python from mymesh import implicit import numpy as np functions = [implicit.primitive, implicit.gyroid] bounds = [0,1,0,1,0,1] h = 0.04 # element size weights1 = [0.25, 1] mixed_topology1 = lambda x,y,z : np.sum([w*f(x,y,z) for w,f in zip(weights1, functions)], axis=0) M1 = implicit.TetMesh(implicit.thickenf(mixed_topology1,1), bounds, h) M1.plot(bgcolor='white') weights2 = [0.5, 0.8] mixed_topology2 = lambda x,y,z : np.sum([w*f(x,y,z) for w,f in zip(weights2, functions)], axis=0) M2 = implicit.TetMesh(implicit.thickenf(mixed_topology2,1), bounds, h) M2.plot(bgcolor='white') weights3 = [0.8, 0.5] mixed_topology3 = lambda x,y,z : np.sum([w*f(x,y,z) for w,f in zip(weights3, functions)], axis=0) M3 = implicit.TetMesh(implicit.thickenf(mixed_topology3,1), bounds, h) M3.plot(bgcolor='white') weights4 = [1, 0.25] mixed_topology4 = lambda x,y,z : np.sum([w*f(x,y,z) for w,f in zip(weights4, functions)], axis=0) M4 = implicit.TetMesh(implicit.thickenf(mixed_topology4,1), bounds, h) M4.plot(bgcolor='white') .. rst-class:: sphx-glr-horizontal * .. image-sg:: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_001.png :alt: demo mixed top :srcset: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_001.png :class: sphx-glr-multi-img * .. image-sg:: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_002.png :alt: demo mixed top :srcset: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_002.png :class: sphx-glr-multi-img * .. image-sg:: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_003.png :alt: demo mixed top :srcset: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_003.png :class: sphx-glr-multi-img * .. image-sg:: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_004.png :alt: demo mixed top :srcset: /examples/MeshGeneration/images/sphx_glr_demo_mixed-top_004.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none RFBOutputContext() RFBOutputContext() RFBOutputContext() RFBOutputContext() .. GENERATED FROM PYTHON SOURCE LINES 52-59 .. [#f1] To be specific, the implicit function TPMS representations are Fourier series approximations (also known as periodic nodal surfaces :cite:p:`VonSchnering1991`) and are not *truly* minimal surfaces (though they are truly triply periodic). This can be seen by measuring the surface curvature (:mod:`~mymesh.curvature`) and observing that the mean curvature is not zero at all points. Nevertheless, these are reasonably accurate and commonly used approximations. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 5.688 seconds) .. _sphx_glr_download_examples_MeshGeneration_demo_mixed-top.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_mixed-top.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_mixed-top.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demo_mixed-top.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_