.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/basic/cantilever_beam_3d.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_basic_cantilever_beam_3d.py: Cantilever beam using 3D hexahedral elements ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Linear elastic cantilever beam meshed with ``hex8`` elements: the left face is clamped and a transverse displacement is imposed on the right face. .. GENERATED FROM PYTHON SOURCE LINES 8-11 .. code-block:: Python import fedoo as fd .. GENERATED FROM PYTHON SOURCE LINES 12-14 Pre-treatment: mesh and problem definition ------------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 14-51 .. code-block:: Python # Units: N, mm, MPa mesh = fd.mesh.box_mesh( nx=51, ny=7, nz=7, x_min=0, x_max=1000, y_min=0, y_max=100, z_min=0, z_max=100, elm_type="hex8", name="Domain", ) fd.ModelingSpace("3D") # Material definition fd.constitutivelaw.ElasticIsotrop(200e3, 0.3, name="ElasticLaw") wf = fd.weakform.StressEquilibrium("ElasticLaw") # Assembly assembly = fd.Assembly.create(wf, mesh, "hex8") # Type of problem pb = fd.problem.Linear(assembly) # Boundary conditions nodes_left = mesh.node_sets["left"] nodes_right = mesh.node_sets["right"] nodes_top = mesh.node_sets["top"] nodes_bottom = mesh.node_sets["bottom"] pb.bc.add("Dirichlet", nodes_left, "Disp", 0) pb.bc.add("Dirichlet", nodes_right, "DispY", -50) .. rst-class:: sphx-glr-script-out .. code-block:: none Dirichlet boundary condition: var = 'DispY' n_nodes = 49 value = -50 .. GENERATED FROM PYTHON SOURCE LINES 52-56 Solve the problem ----------------- The default direct solver is used. ``pb.set_solver("cg")`` before ``pb.solve()`` would use the conjugate gradient iterative solver instead. .. GENERATED FROM PYTHON SOURCE LINES 56-59 .. code-block:: Python pb.solve() .. GENERATED FROM PYTHON SOURCE LINES 60-62 Post-treatment: get and plot results ------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 62-73 .. code-block:: Python # Get the displacement vector U = pb.get_disp() # Get the stress and strain tensor at nodes res = pb.get_results(assembly, ["Stress", "Strain", "Disp"], "Node") stress = res["Stress"] strain = res["Strain"] # plot the stress (xx component) res.plot("Stress", "XX") .. image-sg:: /examples/basic/images/sphx_glr_cantilever_beam_3d_001.png :alt: cantilever beam 3d :srcset: /examples/basic/images/sphx_glr_cantilever_beam_3d_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.725 seconds) .. _sphx_glr_download_examples_basic_cantilever_beam_3d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cantilever_beam_3d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cantilever_beam_3d.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cantilever_beam_3d.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_