diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index e418f3012d..84f12a1eb4 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -102,9 +102,10 @@ jobs: uses: pyvista/setup-headless-display-action@v2 - name: "Run Ansys documentation building action" - uses: ansys/actions/doc-build@v7 + uses: ansys/actions/doc-build@v8 with: check-links: false + needs-quarto: true sphinxopts: "-j auto --keep-going" env: PYPRIMEMESH_LAUNCH_CONTAINER: 1 diff --git a/doc/changelog.d/891.documentation.md b/doc/changelog.d/891.documentation.md new file mode 100644 index 0000000000..1a6e3cc17b --- /dev/null +++ b/doc/changelog.d/891.documentation.md @@ -0,0 +1 @@ +doc: Add quarto cheat sheet \ No newline at end of file diff --git a/doc/source/cheatsheet/.gitignore b/doc/source/cheatsheet/.gitignore new file mode 100644 index 0000000000..4f7dc5def0 --- /dev/null +++ b/doc/source/cheatsheet/.gitignore @@ -0,0 +1,4 @@ +* +!cheat_sheet.qmd +!.gitignore +/.quarto/ \ No newline at end of file diff --git a/doc/source/cheatsheet/cheat_sheet.qmd b/doc/source/cheatsheet/cheat_sheet.qmd new file mode 100644 index 0000000000..d2e2ba8aa5 --- /dev/null +++ b/doc/source/cheatsheet/cheat_sheet.qmd @@ -0,0 +1,187 @@ +--- +title: PyPrimeMesh cheat sheet +format: cheat_sheet-pdf +params: + version: main +footer: PyPrimeMesh +footerlinks: + - urls: 'https://prime.docs.pyansys.com/version/stable/' + text: Documentation + - urls: 'https://prime.docs.pyansys.com/version/stable/getting_started/index.html' + text: Getting started + - urls: 'https://prime.docs.pyansys.com/version/stable/examples/index.html' + text: Examples + - urls: 'https://prime.docs.pyansys.com/version/stable/api/index.html' + text: API reference + +execute: + output: false + eval: false + +latex-clean: true +jupyter: + jupytext: + text_representation: + extension: .qmd + format_name: quarto + format_version: '1.0' + jupytext_version: 1.16.1 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 +--- + +## Launch PyPrimeMesh client +Launch and exit PyPrimeMesh server from Python in gRPC +mode: +```{python} +# Launch PyPrimeMesh server +from ansys.meshing import prime + +with prime.launch_prime(timeout=20) as prime_client: + model = prime_client.model + # Define script here + prime_client.exit() + +``` + +Launch an instance of PyPrimeMesh at IP address 127.0.0.1 +and port 50055 with the number of processes set to 4: +```{python} +with prime.launch_prime( + ip="127.0.0.1", port=50055, n_procs=4 + ) as prime_client: + model = prime_client.model +``` + +## Read and write files +Read or write files of different formats based on file +extensions: + +```{python} +from ansys.meshing.prime import lucid + +# Define \texttt{mesher} object +mesher = lucid.Mesh(model) +# Read mesh (*.msh) file +mesh_file_name = r"sample1_mesh.msh" +mesher.read(mesh_file_name, append=False) +# Write mesh (*.cdb) file +cdb_file_name = r"sample3_case.cdb" +mesher.write(cdb_file_name) +``` + +## Part summary +Query for the part summary: + +```{python} +part = model.get_part_by_name("sample_part") +summary = part.get_summary(prime.PartSummaryParams( + model)) +print("Total number of cells: ", summary.n_cells) +``` + +## Define size controls +Set global sizing parameters: + +```{python} +model.set_global_sizing_params( + prime.GlobalSizingParams(min=0.5, max=16.0, + growth_rate=1.2) +) +``` + +Define the curvature size control: +```{python} +curvature_control = model.control_data.create_size_control( + prime.SizingType.CURVATURE +) +control_name = "Curvature_Size_Control" +curvature_control.set_suggested_name(control_name) +eval_type = prime.ScopeEvaluationType.LABELS +scope = prime.ScopeDefinition( + model, + evaluation_type=eval_type, + label_expression="*", +) +curvature_control.set_scope(scope) +curvature_control.set_curvature_sizing_params( + prime.CurvatureSizingParams(model, normal_angle=18) +) +``` + +## Generate wrapper surface mesh +Generate the wrapper surface mesh: +```{python} +mesher.wrap( + min_size=0.5, + max_size=16, + input_parts="flange,pipe", + use_existing_features=True, +) +``` + +## Generate surface mesh +Generate the surface mesh based on specified minimum and +maximum sizes: + +```{python} +mesher.surface_mesh( + min_size=0.5, + max_size=16, + generate_quads=True, +) +``` + +Generate the surface mesh based on size controls: +```{python} +control_name = "Curvature_Size_Control" +mesher.surface_mesh_with_size_controls( + control_name, +) +``` +## Analyze surface mesh +Generate surface mesh diagnostics: + +```{python} +surface_scope = prime.ScopeDefinition(model, part_expression="*") +diag = prime.SurfaceSearch(model) +diag_prms = prime.SurfaceDiagnosticSummaryParams( + model, + scope=surface_scope, + compute_free_edges=True, +) +diag_res = diag.get_surface_diagnostic_summary( + diag_prms +) +print("Number of free edges : ", diag_res.n_free_edges) +``` +Generate surface mesh quality metrics: + +```{python} +face_quality_measures = prime.FaceQualityMeasure.SKEWNESS +quality = prime.SurfaceSearch(model) +quality_params = prime.SurfaceQualitySummaryParams( + model=model, + scope=surface_scope, + face_quality_measures=[face_quality_measures], + quality_limit=[0.9], +) +qual_summary_res = quality.get_surface_quality_summary( + quality_params +) +print( + "Maximum surface skewness : ", + qual_summary_res.quality_results[0].max_quality +) +``` + +## Generate volume mesh +Generate a volume mesh: +```{python} +volume_fill_type = prime.VolumeFillType.HEXCOREPOLY +mesher.volume_mesh( + volume_fill_type=volume_fill_type, +) +``` \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 47729e0025..c0f876e9c9 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -58,6 +58,11 @@ "icon": "fa fa-comment fa-fw", }, ], + "cheatsheet": { + "file": "cheatsheet/cheat_sheet.qmd", + "title": "PyPrimeMesh cheat sheet", + "version": __version__, + }, } # Sphinx extensions diff --git a/pyproject.toml b/pyproject.toml index af378ed794..be7afdbe00 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ tests = [ "pyvista[trame]==0.44.1" ] doc = [ - "ansys-sphinx-theme==1.0.11", + "ansys-sphinx-theme[autoapi]==1.1.2", "ansys-tools-visualization-interface==0.4.4", "jupyter-sphinx==0.5.3", "numpydoc==1.8.0",