.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/samples_and_meshes/tetrahedral_local.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_gallery_samples_and_meshes_tetrahedral_local.py: Refine a tetrahedral mesh near layers and contacts ================================================== Create a layered sample, refine the epidermis, and add finer elements near a source and detector on the surface. Plot the resulting unstructured mesh. .. GENERATED FROM PYTHON SOURCE LINES 8-20 .. code-block:: Python # Limit displayed edges to keep the local size transition visible. import MomentRT from MomentRT import ( Material, StructuredMedium, SurfaceDetector, SurfaceSource, TetrahedralMesh, ureg, ) .. GENERATED FROM PYTHON SOURCE LINES 22-24 Configure a layered optical sample ---------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 24-52 .. code-block:: Python epidermis_material = Material( absorption=0.1 / ureg.millimeter, reduced_scattering=1.5 / ureg.millimeter, refractive_index=1.4, anisotropy=0.85, phase_function=MomentRT.HenyeyGreenstein(), ) dermis_material = Material( absorption=0.03 / ureg.millimeter, reduced_scattering=1.0 / ureg.millimeter, refractive_index=1.4, anisotropy=0.8, phase_function=MomentRT.HenyeyGreenstein(), ) sample = StructuredMedium( origin=(0, 0, 0) * ureg.millimeter, size=(2, 2, 1) * ureg.millimeter, ) sample.add_background(material=dermis_material) sample.add_layer( name="Epidermis", material=epidermis_material, thickness=0.2 * ureg.millimeter, ) .. GENERATED FROM PYTHON SOURCE LINES 53-55 Place surface contacts and generate a base mesh ----------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 55-79 .. code-block:: Python source = SurfaceSource.on_face( sample=sample, face="z_min", coordinates=(0.7, 1.0) * ureg.millimeter, radius=0.15 * ureg.millimeter, wavelength=850 * ureg.nanometer, optical_power=1 * ureg.milliwatt, ) detector = SurfaceDetector.on_face( sample=sample, face="z_min", coordinates=(1.3, 1.0) * ureg.millimeter, radius=0.15 * ureg.millimeter, orientation="outward_normal", acceptance_angle=30 * ureg.degree, ) mesh = TetrahedralMesh.from_sample( sample=sample, resolution=0.5 * ureg.millimeter, ) .. GENERATED FROM PYTHON SOURCE LINES 80-82 Add layer and contact refinement -------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 82-102 .. code-block:: Python mesh.refine_region( name="Epidermis", resolution=0.1 * ureg.millimeter, ) mesh.refine_near( objects=[source, detector], resolution=0.08 * ureg.millimeter, distance=0.2 * ureg.millimeter, ) figure = mesh.plot( length_unit="mm", max_edges=4000, show=False, ) print(f"Locally refined mesh nodes: {len(mesh.points)}") print(f"Locally refined tetrahedra: {len(mesh.tetrahedra)}") .. raw:: html .. rst-class:: sphx-glr-script-out .. code-block:: none Locally refined mesh nodes: 1804 Locally refined tetrahedra: 7807 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.428 seconds) .. _sphx_glr_download_gallery_samples_and_meshes_tetrahedral_local.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: tetrahedral_local.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: tetrahedral_local.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: tetrahedral_local.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_