.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/Meshes/Mesh13.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_Meshes_Mesh13.py: Mesh13 ====== Mesh a heterogeneous RVE with cracks. .. GENERATED FROM PYTHON SOURCE LINES 11-122 .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Meshes/images/sphx_glr_Mesh13_001.png :alt: Mesh13 :srcset: /examples/Meshes/images/sphx_glr_Mesh13_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/easyfea/checkouts/v1.6.4/docs/examples/Meshes/images/sphx_glr_Mesh13_001.vtksz .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Meshes/images/sphx_glr_Mesh13_002.png :alt: Mesh13 :srcset: /examples/Meshes/images/sphx_glr_Mesh13_002.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/easyfea/checkouts/v1.6.4/docs/examples/Meshes/images/sphx_glr_Mesh13_002.vtksz .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/Meshes/images/sphx_glr_Mesh13_003.png :alt: Mesh13 :srcset: /examples/Meshes/images/sphx_glr_Mesh13_003.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/easyfea/checkouts/v1.6.4/docs/examples/Meshes/images/sphx_glr_Mesh13_003.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/easyfea/envs/v1.6.4/lib/python3.11/site-packages/EasyFEA/utilities/PyVista.py:975: PyVistaDeprecationWarning: ../../../../envs/v1.6.4/lib/python3.11/site-packages/EasyFEA/utilities/PyVista.py:975: Arguments 'pointa', 'pointb', 'center' must be passed as keyword arguments to function 'CircularArc'. From version 0.50, passing these as positional arguments will result in a TypeError. arc1 = pv.CircularArc(geom.pt1.coord, geom.pt3.coord, geom.center.coord) /home/docs/checkouts/readthedocs.org/user_builds/easyfea/envs/v1.6.4/lib/python3.11/site-packages/EasyFEA/utilities/PyVista.py:976: PyVistaDeprecationWarning: ../../../../envs/v1.6.4/lib/python3.11/site-packages/EasyFEA/utilities/PyVista.py:976: Arguments 'pointa', 'pointb', 'center' must be passed as keyword arguments to function 'CircularArc'. From version 0.50, passing these as positional arguments will result in a TypeError. arc2 = pv.CircularArc( | .. code-block:: Python :lineno-start: 12 from EasyFEA import Display, ElemType, PyVista from EasyFEA.Geoms import Point, Line, Domain, Circle if __name__ == "__main__": Display.Clear() # ---------------------------------------------- # Configuration # ---------------------------------------------- # geom L = 1 # mesh elemType = ElemType.TRI3 meshSize = L / 40 # ---------------------------------------------- # Functions # ---------------------------------------------- def Create_Crack( pt1: tuple[float, float], pt2: tuple[float, float], isOpen=True ) -> Line: """Creates a crack. Parameters ---------- pt1 : tuple[float, float] Point 1 (x, y) pt2 : tuple[float, float] Point 2 (x, y) isOpen : bool, optional The crack is open, by default True Returns ------- Line The crack """ assert len(pt1) == 2, "Must give 2 coordinates" assert len(pt2) == 2, "Must give 2 coordinates" pt1 = Point(*pt1) pt2 = Point(*pt2) return Line(pt1, pt2, meshSize, isOpen) def Create_Circle(pt: tuple[float, float], diam: float, isHollow=False) -> Circle: """Creates a circle. Parameters ---------- pt : tuple[float, float] center point (x, y) diam : float diameter isHollow : bool, optional circle is hollow/empty, by default True Returns ------- Circle The circle """ assert len(pt) == 2, "Must give 2 coordinates" center = Point(*pt) return Circle(center, diam, meshSize / 2, isHollow) # ---------------------------------------------- # Mesh # ---------------------------------------------- # contour contour = Domain(Point(), Point(L, L), meshSize) # circles circle1 = Create_Circle((L / 4, L / 4), L / 10) circle2 = Create_Circle((3 * L / 4, L / 4), L / 8) circle3 = Create_Circle((3 * L / 4, 3 * L / 4), L / 6) circle4 = Create_Circle((L / 4, 3 * L / 4), L / 5) circle5 = Create_Circle((L / 2, L / 2), L / 3, isHollow=True) circle6 = Create_Circle((L, L), L / 6, isHollow=True) inclusions = [circle1, circle2, circle3, circle4, circle5] # cracks crack1 = Create_Crack((3 * L / 5, L / 10), (4 * L / 5, L / 10)) crack2 = Create_Crack((L / 10, L / 2), (2 * L / 10, L / 2 - L / 10)) crack3 = Create_Crack( (8 * L / 10, 5 * L / 10), (8 * L / 10 + L / 20, 5 * L / 10 + L / 20) ) cracks = [crack1, crack2, crack3] PyVista.Plot_Geoms([contour, *inclusions, *cracks, circle6]).show() # mesh mesh = contour.Mesh_2D(inclusions, elemType, cracks, additionalSurfaces=[circle6]) # ---------------------------------------------- # Display # ---------------------------------------------- PyVista.Plot_Mesh(mesh).show() PyVista.Plot_Tags(mesh).show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.559 seconds) .. _sphx_glr_download_examples_Meshes_Mesh13.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: Mesh13.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: Mesh13.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: Mesh13.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_