.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/03-advanced/multi_mesh_example.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_03-advanced_multi_mesh_example.py: Very simple example with multiple element type. The key points are: - define two separated mesh that share to the same node list with different elements. - create two separated Assembly that are combined in a single AssemblySum object. - extract/save results separatedly for each elm_type. .. GENERATED FROM PYTHON SOURCE LINES 13-18 Extract and plot results: For now, the DataSet class is only available for a single element type. To plot the results, we need to extract two separated solution and plot two separted meshes. .. GENERATED FROM PYTHON SOURCE LINES 18-58 .. code-block:: Python import fedoo as fd import numpy as np # Generate a mesh with a 'quad4' element mesh1 = fd.mesh.rectangle_mesh(2, 2, elm_type="quad4") # Add a new node not connected to the quad mesh mesh1.add_nodes([0.5, 1.866]) # Generate a new 'tri3' mesh with the same list of nodes (important) mesh2 = fd.Mesh(mesh1.nodes, elements=np.array([[2, 3, 4]]), elm_type="tri3") # Define equations as usual (constitutivelaw + weakform) fd.ModelingSpace("2Dstress") material = fd.constitutivelaw.ElasticIsotrop(2e5, 0.3) wf = fd.weakform.StressEquilibrium(material) # Create a global assembly assembly1 = fd.Assembly.create(wf, mesh1) assembly2 = fd.Assembly.create(wf, mesh2) assembly = assembly1 + assembly2 # Define a new static problem pb = fd.problem.Linear(assembly) # Extract set of nodes for boundary conditions (here an use mesh1 or mesh2 # because they share the same nodes) left = mesh1.find_nodes("X", mesh1.bounding_box.xmin) right = mesh1.find_nodes("X", mesh1.bounding_box.xmax) # displacement on left (ux=-0.1mm) pb.bc.add("Dirichlet", "left", "Disp", 0) # displacement on right (ux=0.1mm) pb.bc.add("Dirichlet", "right", "DispX", 0.5) # Solve problem pb.solve() .. GENERATED FROM PYTHON SOURCE LINES 59-64 Extract and plot results: For now, the DataSet class is only available for a single element type. To plot the results, we need to extract two separated solution and plot two separted meshes. .. GENERATED FROM PYTHON SOURCE LINES 64-72 .. code-block:: Python # extract the results from the two assembly objects results1 = pb.get_results(assembly1, output_list=["Stress", "Disp", "Strain"]) results2 = pb.get_results(assembly2, output_list=["Stress", "Disp", "Strain"]) plotter = results1.plot("Stress", "vm", show=False) results2.plot("Stress", "vm", plotter=plotter) plotter.show() .. image-sg:: /examples/03-advanced/images/sphx_glr_multi_mesh_example_001.png :alt: multi mesh example :srcset: /examples/03-advanced/images/sphx_glr_multi_mesh_example_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.275 seconds) .. _sphx_glr_download_examples_03-advanced_multi_mesh_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: multi_mesh_example.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: multi_mesh_example.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: multi_mesh_example.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_