{ "cells": [ { "cell_type": "markdown", "id": "64b3392e", "metadata": { "papermill": { "duration": 0.002767, "end_time": "2026-05-27T19:58:53.033266+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.030499+00:00", "status": "completed" }, "tags": [] }, "source": [ "# Coaxial cable mesh" ] }, { "cell_type": "code", "execution_count": 1, "id": "6e0056ab", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.040193Z", "iopub.status.busy": "2026-05-27T19:58:53.040022Z", "iopub.status.idle": "2026-05-27T19:58:53.438863Z", "shell.execute_reply": "2026-05-27T19:58:53.438261Z" }, "papermill": { "duration": 0.402233, "end_time": "2026-05-27T19:58:53.439571+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.037338+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "from palacetoolkit.viz import view_mesh\n", "from palacetoolkit.geometry import extract_tag, xmin, xmax, ymin, ymax, zmin, zmax\n", "import math\n", "import gmsh\n", "\n" ] }, { "cell_type": "markdown", "id": "f1e8f011", "metadata": { "papermill": { "duration": 0.00393, "end_time": "2026-05-27T19:58:53.446094+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.442164+00:00", "status": "completed" }, "tags": [] }, "source": [ "Parameters:\n", "\n", "- filename - the filename to use for the generated mesh.\n", "- refinement - measure of how many elements to include, 0 is least\n", "- order - the polynomial order of the approximation, minimum 1\n", "- inner_diameter_mm - the inner diameter of the cable, in millimeters\n", "- outer_diameter_mm - the outer diameter of the cable, in millimeters\n", "- length_mm - the length of the cable, in millimeters\n", "- verbose - flag to dictate the level of print to REPL, passed to Gmsh\n", "- gui - whether to launch the Gmsh GUI on mesh generation" ] }, { "cell_type": "code", "execution_count": 2, "id": "88f3a33d", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.451072Z", "iopub.status.busy": "2026-05-27T19:58:53.450807Z", "iopub.status.idle": "2026-05-27T19:58:53.453838Z", "shell.execute_reply": "2026-05-27T19:58:53.453275Z" }, "papermill": { "duration": 0.006085, "end_time": "2026-05-27T19:58:53.454210+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.448125+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "filename : str = \"coax.msh\" \n", "refinement : int = 2 \n", "order : int = 2 \n", "inner_diameter_mm : float = 1.6383 \n", "outer_diameter_mm : float = 5.461 \n", "length_mm : float = 40.0\n", "verbose : int = 5\n", "gui : bool = True " ] }, { "cell_type": "markdown", "id": "74ea6cc0", "metadata": { "papermill": { "duration": 0.002115, "end_time": "2026-05-27T19:58:53.458378+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.456263+00:00", "status": "completed" }, "tags": [] }, "source": [ "Check that the geometry makes sense." ] }, { "cell_type": "code", "execution_count": 3, "id": "f1f466d5", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.463780Z", "iopub.status.busy": "2026-05-27T19:58:53.463602Z", "iopub.status.idle": "2026-05-27T19:58:53.466160Z", "shell.execute_reply": "2026-05-27T19:58:53.465675Z" }, "papermill": { "duration": 0.006401, "end_time": "2026-05-27T19:58:53.466661+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.460260+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "assert outer_diameter_mm > inner_diameter_mm > 0\n", "assert length_mm > 0\n", "assert refinement >= 0\n", "assert order > 0 " ] }, { "cell_type": "markdown", "id": "406b0c2f", "metadata": { "papermill": { "duration": 0.00187, "end_time": "2026-05-27T19:58:53.470881+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.469011+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Initialization of the model." ] }, { "cell_type": "code", "execution_count": 4, "id": "3bf5f9fe", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.475741Z", "iopub.status.busy": "2026-05-27T19:58:53.475530Z", "iopub.status.idle": "2026-05-27T19:58:53.479029Z", "shell.execute_reply": "2026-05-27T19:58:53.478572Z" }, "papermill": { "duration": 0.006985, "end_time": "2026-05-27T19:58:53.479727+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.472742+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Creates a reference to the geometry module based on OpenCASCADE (OCC).\n", "kernel = gmsh.model.occ\n", "\n", "# Initialize gmsh.\n", "gmsh.initialize()\n", "\n", "# Set the verbosity of the output.\n", "gmsh.option.setNumber(\"General.Verbosity\", verbose)" ] }, { "cell_type": "markdown", "id": "f5c72ae7", "metadata": { "papermill": { "duration": 0.00222, "end_time": "2026-05-27T19:58:53.484608+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.482388+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Geometry definitions." ] }, { "cell_type": "code", "execution_count": 5, "id": "11022e99", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.489348Z", "iopub.status.busy": "2026-05-27T19:58:53.489156Z", "iopub.status.idle": "2026-05-27T19:58:53.491978Z", "shell.execute_reply": "2026-05-27T19:58:53.491586Z" }, "papermill": { "duration": 0.006033, "end_time": "2026-05-27T19:58:53.492532+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.486499+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Geometry (en mm)\n", "inner_radio = inner_diameter_mm / 2\n", "outer_radio = outer_diameter_mm / 2\n", "\n", "# Mesh parameters\n", "n_circum = 4 * 2**refinement \n", "n_length = 4 * 2**refinement\n", " \n", "# Geometry\n", "p0 = kernel.addPoint(inner_radio, 0, 0)\n", "p1 = kernel.addPoint(outer_radio, 0, 0)\n", "\n", "l0 = kernel.addLine(p0, p1)" ] }, { "cell_type": "markdown", "id": "3363ea1d", "metadata": { "papermill": { "duration": 0.001936, "end_time": "2026-05-27T19:58:53.496623+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.494687+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Revolve operation - base face generation.\n", "\n", "Rotate the line (l_0) around the z-axis.\n", "\n", "- First revolve (base_face_0) is made with a 180° degree and n_circum//2 divisions.\n", "- Seconde revolve (base_face_1) with a -180° degree and n_circum//2 divisions." ] }, { "cell_type": "code", "execution_count": 6, "id": "8f7c9081", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.502291Z", "iopub.status.busy": "2026-05-27T19:58:53.502073Z", "iopub.status.idle": "2026-05-27T19:58:53.505185Z", "shell.execute_reply": "2026-05-27T19:58:53.504796Z" }, "papermill": { "duration": 0.007223, "end_time": "2026-05-27T19:58:53.505775+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.498552+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "base_face_0 = kernel.revolve(\n", " [(1, l0)], # list of entities to rotate (dim=1 → curve, tag=l0)\n", " 0.0, 0.0, 0.0, # origin point of rotation\n", " 0.0, 0.0, 1.0, # rotation axis (here, the z-axis)\n", " math.pi, # rotation angle (180°)\n", " [n_circum // 2], # number of divisions in the angular direction\n", " [1.0], # scale factor for the mesh size (1.0 means no scaling)\n", " recombine=True # recombinar las caras resultantes\n", " )\n", " \n", "base_face_1 = kernel.revolve(\n", " [(1, l0)], \n", " 0.0, 0.0, 0.0, \n", " 0.0, 0.0, 1.0, \n", " -math.pi, \n", " [n_circum//2], \n", " [1.0], \n", " recombine=True \n", ")" ] }, { "cell_type": "markdown", "id": "79879482", "metadata": { "papermill": { "duration": 0.002189, "end_time": "2026-05-27T19:58:53.510266+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.508077+00:00", "status": "completed" }, "tags": [] }, "source": [ "kernel.revolve returns a list of entities created by the revolution, each one represented as a tuple (dim, tag).\n", "- dim is the dimension of the entity (0 for points, 1 for lines, 2 for surfaces, 3 for volumes).\n", "- A tag is a unique identifier assigned by Gmsh to each entity created.\n", "\n", "We will filter these lists to keep only the surfaces (dim=2) that represent the cylinder faces, \n", "discarding any other entities that may have been created during the revolution.\n", "\n", "In this case the revolution returns [(1, 4), (2, 1), (1, 2), (1, 3)]. We are only interested in\n", "(2, 1), which is the surface created by the revolution, and we discard the lines (1, 4), (1, 2), (1, 3)." ] }, { "cell_type": "code", "execution_count": 7, "id": "d57df280", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.515133Z", "iopub.status.busy": "2026-05-27T19:58:53.514966Z", "iopub.status.idle": "2026-05-27T19:58:53.517424Z", "shell.execute_reply": "2026-05-27T19:58:53.517021Z" }, "papermill": { "duration": 0.005711, "end_time": "2026-05-27T19:58:53.517908+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.512197+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "base_face_0 = [x for x in base_face_0 if x[0] == 2]\n", "base_face_1 = [x for x in base_face_1 if x[0] == 2]\n", "\n", "# Check that there was generated only one face.\n", "assert len(base_face_0) == 1 and len(base_face_1) == 1" ] }, { "cell_type": "markdown", "id": "587441fd", "metadata": { "papermill": { "duration": 0.002035, "end_time": "2026-05-27T19:58:53.522042+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.520007+00:00", "status": "completed" }, "tags": [] }, "source": [ "Now, we extrude the base faces to get the cylinder." ] }, { "cell_type": "code", "execution_count": 8, "id": "d4d8c594", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.527148Z", "iopub.status.busy": "2026-05-27T19:58:53.526926Z", "iopub.status.idle": "2026-05-27T19:58:53.530137Z", "shell.execute_reply": "2026-05-27T19:58:53.529596Z" }, "papermill": { "duration": 0.006492, "end_time": "2026-05-27T19:58:53.530632+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.524140+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Extrude the faces along the z-axis. \n", "cylinder_0 = kernel.extrude(\n", " base_face_0, # List of entities (dim=2, tag)\n", " 0.0, 0.0, length_mm, # How much extrusion in (x, y, z)\n", " [n_length], # Divisions in the direction of the extrusion\n", " [1.0], # Scale\n", " recombine=True # recombine faces\n", ")\n", "\n", "cylinder_1 = kernel.extrude(\n", " base_face_1,\n", " 0.0, 0.0, length_mm,\n", " [n_length],\n", " [1.0],\n", " recombine=True\n", ")" ] }, { "cell_type": "markdown", "id": "a85abbbc", "metadata": { "papermill": { "duration": 0.001954, "end_time": "2026-05-27T19:58:53.534867+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.532913+00:00", "status": "completed" }, "tags": [] }, "source": [ "\n", "We keep only the tags of the faces and volumes created by the extrusion, filtering by dimension.\n", "Remember that cylinder_0 and cylinder_1 are lists of tuples (dim, tag) representing all \n", "entities created by the extrusion, including lines, surfaces, and volumes. We are interested \n", "only in the faces (dim=2) that form the cylinder end caps, and in the volumes (dim=3) \n", "that represent the cylinder body.\n" ] }, { "cell_type": "code", "execution_count": 9, "id": "5d6eb730", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.539782Z", "iopub.status.busy": "2026-05-27T19:58:53.539555Z", "iopub.status.idle": "2026-05-27T19:58:53.542275Z", "shell.execute_reply": "2026-05-27T19:58:53.541900Z" }, "papermill": { "duration": 0.006035, "end_time": "2026-05-27T19:58:53.542815+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.536780+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "base_face_0 = base_face_0[0][1] # Tag of the first surface.\n", "base_face_1 = base_face_1[0][1] \n", "\n", "far_face_0 = cylinder_0[0][1] \n", "cylinder_0 = cylinder_0[1][1] \n", "\n", "far_face_1 = cylinder_1[0][1]\n", "cylinder_1 = cylinder_1[1][1]" ] }, { "cell_type": "markdown", "id": "91caa4c5", "metadata": { "papermill": { "duration": 0.00219, "end_time": "2026-05-27T19:58:53.547122+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.544932+00:00", "status": "completed" }, "tags": [] }, "source": [ "Fragment the geometry to create a valid mesh. This is necessary because we have extruded two faces that share an edge, and we need to ensure that the resulting geometry is properly connected. " ] }, { "cell_type": "code", "execution_count": 10, "id": "3e9cf066", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.552005Z", "iopub.status.busy": "2026-05-27T19:58:53.551832Z", "iopub.status.idle": "2026-05-27T19:58:53.567094Z", "shell.execute_reply": "2026-05-27T19:58:53.566661Z" }, "papermill": { "duration": 0.018576, "end_time": "2026-05-27T19:58:53.567766+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.549190+00:00", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Info : Rebinding OpenCASCADE point 3 \n", "Info : Rebinding OpenCASCADE point 4\n", "Info : Cannot bind existing OpenCASCADE point 3 to second tag 5\n", "Info : Could not preserve tag of 0D object 5 (->3)\n", "Info : Cannot bind existing OpenCASCADE point 4 to second tag 6\n", "Info : Could not preserve tag of 0D object 6 (->4)\n", "Info : Rebinding OpenCASCADE point 7\n", "Info : Rebinding OpenCASCADE point 8\n", "Info : Rebinding OpenCASCADE point 9\n", "Info : Rebinding OpenCASCADE point 10\n", "Info : Cannot bind existing OpenCASCADE point 7 to second tag 11\n", "Info : Could not preserve tag of 0D object 11 (->7)\n", "Info : Cannot bind existing OpenCASCADE point 8 to second tag 12\n", "Info : Could not preserve tag of 0D object 12 (->8)\n", "Info : Cannot bind existing OpenCASCADE point 9 to second tag 13\n", "Info : Could not preserve tag of 0D object 13 (->9)\n", "Info : Cannot bind existing OpenCASCADE point 10 to second tag 14\n", "Info : Could not preserve tag of 0D object 14 (->10)\n", "Info : Rebinding OpenCASCADE curve 2\n", "Info : Rebinding OpenCASCADE curve 3\n", "Info : Rebinding OpenCASCADE curve 4\n", "Info : Rebinding OpenCASCADE curve 5\n", "Info : Rebinding OpenCASCADE curve 6\n", "Info : Cannot bind existing OpenCASCADE curve 4 to second tag 7\n", "Info : Could not preserve tag of 1D object 7 (->4)\n", "Info : Rebinding OpenCASCADE curve 8\n", "Info : Rebinding OpenCASCADE curve 9\n", "Info : Rebinding OpenCASCADE curve 10\n", "Info : Rebinding OpenCASCADE curve 11\n", "Info : Rebinding OpenCASCADE curve 12\n", "Info : Rebinding OpenCASCADE curve 13\n", "Info : Rebinding OpenCASCADE curve 14\n", "Info : Rebinding OpenCASCADE curve 15\n", "Info : Cannot bind existing OpenCASCADE curve 8 to second tag 16\n", "Info : Could not preserve tag of 1D object 16 (->8)\n", "Info : Cannot bind existing OpenCASCADE curve 9 to second tag 17\n", "Info : Could not preserve tag of 1D object 17 (->9)\n", "Info : Rebinding OpenCASCADE curve 18\n", "Info : Cannot bind existing OpenCASCADE curve 11 to second tag 19\n", "Info : Could not preserve tag of 1D object 19 (->11)\n", "Info : Cannot bind existing OpenCASCADE curve 12 to second tag 20\n", "Info : Could not preserve tag of 1D object 20 (->12)\n", "Info : Rebinding OpenCASCADE curve 21\n", "Info : Cannot bind existing OpenCASCADE curve 14 to second tag 22\n", "Info : Could not preserve tag of 1D object 22 (->14)\n", "Info : Cannot bind existing OpenCASCADE curve 15 to second tag 23\n", "Info : Could not preserve tag of 1D object 23 (->15)\n", "Info : Rebinding OpenCASCADE surface 1\n", "Info : Rebinding OpenCASCADE surface 2\n", "Info : Rebinding OpenCASCADE surface 3\n", "Info : Rebinding OpenCASCADE surface 4\n", "Info : Rebinding OpenCASCADE surface 5\n", "Info : Rebinding OpenCASCADE surface 6\n", "Info : Rebinding OpenCASCADE surface 7\n", "Info : Rebinding OpenCASCADE surface 8\n", "Info : Rebinding OpenCASCADE surface 9\n", "Info : Cannot bind existing OpenCASCADE surface 5 to second tag 10\n", "Info : Could not preserve tag of 2D object 10 (->5)\n", "Info : Cannot bind existing OpenCASCADE surface 6 to second tag 11\n", "Info : Could not preserve tag of 2D object 11 (->6)\n", "Info : Rebinding OpenCASCADE surface 12\n" ] } ], "source": [ "# Remove duplicates (if there is any) and preserve the original geometry.\n", "kernel.fragment(kernel.getEntities(), [])\n", "kernel.synchronize()" ] }, { "cell_type": "code", "execution_count": 11, "id": "9ee877eb", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.574146Z", "iopub.status.busy": "2026-05-27T19:58:53.573875Z", "iopub.status.idle": "2026-05-27T19:58:53.577912Z", "shell.execute_reply": "2026-05-27T19:58:53.577450Z" }, "papermill": { "duration": 0.008214, "end_time": "2026-05-27T19:58:53.578434+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.570220+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "# Get the boundaries deleting non necessary surfaces\n", "boundaries = []\n", "for cylinder in [cylinder_0, cylinder_1]:\n", " _, local_boundaries = gmsh.model.getAdjacencies(3, cylinder)\n", " local_delete = []\n", " for boundary in local_boundaries:\n", " if boundary not in boundaries:\n", " boundaries.append(boundary)\n", " else:\n", " local_delete.append(boundaries.index(boundary))\n", " # eliminar duplicados\n", " for idx in sorted(local_delete, reverse=True):\n", " del boundaries[idx]\n", "\n", "# Delete faces\n", "for face in [base_face_0, base_face_1, far_face_0, far_face_1]:\n", " if face in boundaries:\n", " boundaries.remove(face)" ] }, { "cell_type": "markdown", "id": "84119459", "metadata": { "papermill": { "duration": 0.002067, "end_time": "2026-05-27T19:58:53.582909+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.580842+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Defining the Physical groups." ] }, { "cell_type": "code", "execution_count": 12, "id": "073577ca", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.588404Z", "iopub.status.busy": "2026-05-27T19:58:53.588225Z", "iopub.status.idle": "2026-05-27T19:58:53.591221Z", "shell.execute_reply": "2026-05-27T19:58:53.590854Z" }, "papermill": { "duration": 0.006361, "end_time": "2026-05-27T19:58:53.591767+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.585406+00:00", "status": "completed" }, "tags": [] }, "outputs": [], "source": [ "cylinder_group = gmsh.model.addPhysicalGroup(3, [cylinder_0, cylinder_1], -1, \"cylinder\") \n", "boundary_group = gmsh.model.addPhysicalGroup(2, boundaries, -1, \"boundaries\") \n", "port1_group = gmsh.model.addPhysicalGroup(2, [base_face_0, base_face_1], -1, \"port1\") \n", "port2_group = gmsh.model.addPhysicalGroup(2, [far_face_0, far_face_1], -1, \"port2\")" ] }, { "cell_type": "markdown", "id": "7e4cc80d", "metadata": { "papermill": { "duration": 0.001979, "end_time": "2026-05-27T19:58:53.596051+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.594072+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Mesh settings and generation." ] }, { "cell_type": "code", "execution_count": 13, "id": "40ca8722", "metadata": { "execution": { "iopub.execute_input": "2026-05-27T19:58:53.601576Z", "iopub.status.busy": "2026-05-27T19:58:53.601390Z", "iopub.status.idle": "2026-05-27T19:58:54.235019Z", "shell.execute_reply": "2026-05-27T19:58:54.233786Z" }, "papermill": { "duration": 0.647944, "end_time": "2026-05-27T19:58:54.246545+00:00", "exception": false, "start_time": "2026-05-27T19:58:53.598601+00:00", "status": "completed" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Info : Meshing 1D...\n", "Info : [ 0%] Meshing curve 1 (Line)\n", "Info : [ 10%] Meshing curve 2 (Extruded)\n", "Info : [ 20%] Meshing curve 3 (Extruded)\n", "Info : [ 20%] Meshing curve 4 (Extruded)\n", "Info : [ 30%] Meshing curve 5 (Extruded)\n", "Info : [ 40%] Meshing curve 6 (Extruded)\n", "Info : [ 40%] Meshing curve 8 (Extruded)\n", "Info : [ 50%] Meshing curve 9 (Extruded)\n", "Info : [ 60%] Meshing curve 10 (Extruded)\n", "Info : [ 60%] Meshing curve 11 (Extruded)\n", "Info : [ 70%] Meshing curve 12 (Extruded)\n", "Info : [ 70%] Meshing curve 13 (Extruded)\n", "Info : [ 80%] Meshing curve 14 (Extruded)\n", "Info : [ 90%] Meshing curve 15 (Extruded)\n", "Info : [ 90%] Meshing curve 18 (Extruded)\n", "Info : [100%] Meshing curve 21 (Extruded)\n", "Info : Done meshing 1D (Wall 0.000124882s, CPU 0.000294s)\n", "Info : Meshing 2D...\n", "Info : [ 0%] Meshing surface 1 (Extruded)\n", "Info : [ 20%] Meshing surface 2 (Extruded)\n", "Info : [ 30%] Meshing surface 3 (Extruded)\n", "Info : [ 40%] Meshing surface 4 (Extruded)\n", "Info : [ 50%] Meshing surface 5 (Extruded)\n", "Info : [ 60%] Meshing surface 6 (Extruded)\n", "Info : [ 70%] Meshing surface 7 (Extruded)\n", "Info : [ 80%] Meshing surface 8 (Extruded)\n", "Info : [ 90%] Meshing surface 9 (Extruded)\n", "Info : [100%] Meshing surface 12 (Extruded)\n", "Info : Done meshing 2D (Wall 0.00464383s, CPU 0.00181s)\n", "Info : Meshing 3D...\n", "Info : Meshing volume 1 (Extruded)\n", "Info : Meshing volume 2 (Extruded)\n", "Info : Done meshing 3D (Wall 0.000631244s, CPU 0.000508s)\n", "Info : Optimizing mesh...\n", "Info : Done optimizing mesh (Wall 6.853e-06s, CPU 0s)\n", "Info : 544 nodes 972 elements\n", "Info : Meshing order 2 (curvilinear on)...\n", "Info : [ 0%] Meshing curve 1 order 2\n", "Info : [ 10%] Meshing curve 2 order 2\n", "Info : [ 10%] Meshing curve 3 order 2\n", "Info : [ 20%] Meshing curve 4 order 2\n", "Info : [ 20%] Meshing curve 5 order 2\n", "Info : [ 20%] Meshing curve 6 order 2\n", "Info : [ 30%] Meshing curve 8 order 2\n", "Info : [ 30%] Meshing curve 9 order 2\n", "Info : [ 30%] Meshing curve 10 order 2\n", "Info : [ 40%] Meshing curve 11 order 2\n", "Info : [ 40%] Meshing curve 12 order 2\n", "Info : [ 40%] Meshing curve 13 order 2\n", "Info : [ 50%] Meshing curve 14 order 2\n", "Info : [ 50%] Meshing curve 15 order 2\n", "Info : [ 60%] Meshing curve 18 order 2\n", "Info : [ 60%] Meshing curve 21 order 2\n", "Info : [ 60%] Meshing surface 1 order 2\n", "Info : [ 70%] Meshing surface 2 order 2\n", "Info : [ 70%] Meshing surface 3 order 2\n", "Info : [ 70%] Meshing surface 4 order 2\n", "Info : [ 80%] Meshing surface 5 order 2\n", "Info : [ 80%] Meshing surface 6 order 2\n", "Info : [ 80%] Meshing surface 7 order 2\n", "Info : [ 90%] Meshing surface 8 order 2\n", "Info : [ 90%] Meshing surface 9 order 2\n", "Info : [ 90%] Meshing surface 12 order 2\n", "Info : [100%] Meshing volume 1 order 2\n", "Info : [100%] Meshing volume 2 order 2\n", "Info : Done meshing order 2 (Wall 0.00397241s, CPU 0.003217s)\n", "Info : Writing 'coax.msh'...\n", "\n", "Finished generating mesh. Physical group tags:\n", "Cylinder: 1\n", "Boundaries: 2\n", "Port 1: 3\n", "Port 2: 4\n", "\n", "Info : Done writing 'coax.msh'\n", "Loading mesh file: coax.msh\n", "Groups to render transparent: ['air_none', 'air_plastic_enclosure']\n", "\n", "Mesh loaded successfully with 2 cell blocks\n", "Found 1088 triangles total\n", "Physical group tags in mesh: {2: 'boundaries', 3: 'port1', 4: 'port2'}\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "def _generate_coax_mesh():\n", " # Mesh options\n", " gmsh.option.setNumber(\"Mesh.MinimumCurveNodes\", 2)\n", " gmsh.option.setNumber(\"Mesh.MinimumCircleNodes\", 0)\n", " gmsh.option.setNumber(\"Mesh.MeshSizeFromPoints\", 0)\n", " gmsh.option.setNumber(\"Mesh.MeshSizeFromCurvature\", 0)\n", " gmsh.option.setNumber(\"Mesh.MeshSizeExtendFromBoundary\", 0)\n", "\n", " # Set mesh algorithms\n", " gmsh.option.setNumber(\"Mesh.Algorithm\", 6) # frontal (2D)\n", " gmsh.option.setNumber(\"Mesh.Algorithm3D\", 1) # Delaunay (3D)\n", "\n", " # Generate 3D mesh\n", " gmsh.model.mesh.generate(3)\n", "\n", " # Order of the mesh elements (1 = linear, 2 = quadratic)\n", " gmsh.model.mesh.setOrder(order)\n", "\n", " # Save mesh\n", " gmsh.option.setNumber(\"Mesh.MshFileVersion\", 2.2)\n", " gmsh.option.setNumber(\"Mesh.Binary\", 1)\n", " gmsh.write(filename)\n", "\n", " if verbose > 0:\n", " print(\"\\nFinished generating mesh. Physical group tags:\")\n", " print(\"Cylinder:\", cylinder_group)\n", " print(\"Boundaries:\", boundary_group)\n", " print(\"Port 1:\", port1_group)\n", " print(\"Port 2:\", port2_group)\n", " print()\n", "\n", "_generate_coax_mesh()\n", "\n", "gmsh.finalize()\n", "view_mesh(filename)" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" }, "papermill": { "default_parameters": {}, "duration": 2.437599, "end_time": "2026-05-27T19:58:54.777132+00:00", "environment_variables": {}, "exception": null, "input_path": "docs/examples/coax.ipynb", "output_path": "docs/examples/coax.ipynb", "parameters": {}, "start_time": "2026-05-27T19:58:52.339533+00:00", "version": "2.7.0" } }, "nbformat": 4, "nbformat_minor": 5 }