Skip to content

Commit

Permalink
Merge branch 'main' into docker_support
Browse files Browse the repository at this point in the history
  • Loading branch information
rchopade7 committed Oct 17, 2024
2 parents 5c57ae0 + 0738752 commit 6a23e87
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
16 changes: 16 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Contributors

## Project Lead

* [Ravindra Chopade](https://github.com/rchopade7)

## Individual Contributors

* [Ninad Kamat](https://github.com/ninad-kamat)
* [Martin Walters](https://github.com/waltersma)
* [Hao Lee](https://https://github.com/hlee0122)
* [Alex Fernandez Luces](https://https://github.com/AlejandroFernandezLuces)
* [Roberto Pastor Muela](https://https://github.com/RobPasMue)
* [Kathy Pippert](https://https://github.com/PipKat)
* [Maxime Rey](https://https://github.com/MaxJPRey)
* [Revathy Venugopal](https://https://github.com/Revathyvenugopal162)
1 change: 1 addition & 0 deletions doc/changelog.d/891.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc: Add quarto cheat sheet
1 change: 1 addition & 0 deletions doc/changelog.d/906.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: remove extension from authors file
1 change: 1 addition & 0 deletions doc/changelog.d/909.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update 11_solder_ball.py
4 changes: 4 additions & 0 deletions doc/source/cheatsheet/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!cheat_sheet.qmd
!.gitignore
/.quarto/
187 changes: 187 additions & 0 deletions doc/source/cheatsheet/cheat_sheet.qmd
Original file line number Diff line number Diff line change
@@ -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,
)
```
5 changes: 5 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
"icon": "fa fa-comment fa-fw",
},
],
"cheatsheet": {
"file": "cheatsheet/cheat_sheet.qmd",
"title": "PyPrimeMesh cheat sheet",
"version": __version__,
},
}

# Sphinx extensions
Expand Down
27 changes: 22 additions & 5 deletions examples/gallery/11_solder_ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
~~~~~~~~~~
#. Import libraries necessary to run the script.
#. Launch an Ansys Prime Server instance.
#. Import stackable simplified CAD geometry.
#. Connect the geometry.
#. Import stackable simplified CAD geometry with refaceting.
#. Connect the geometry using scaffolding.
#. Mesh with hex dominant elements using the volume sweeper.
#. Import the target CAD geometry for the solders for match morphing.
#. Locally match morph the simplified mesh to the target spherical solders.
Expand Down Expand Up @@ -85,11 +85,26 @@
# The model has multiple layers either side of several solder balls with pads
# and contains an infill volume around the solder. During import, the part
# creation type is set to BODY so that each body in the CAD is imported as a
# separate part. Labels can be assigned to manage the entities of each volume.
# separate part. Refaceting is specified for more control of the scaffolding
# operation. Consistent faceting for the curved surfaces to be joined can be
# obtained by specifying CadRefacetingMaxEdgeSizeLimit as ABSOLUTE. To avoid
# over refinement of the faceting the max_edge_size is allowed to reach a size
# of 1.0. Labels can be assigned to manage the entities of each volume.

solder_ball = prime.examples.download_solder_ball_fmd()

params = prime.ImportCadParams(model, append=True, part_creation_type=prime.PartCreationType.BODY)
params = prime.ImportCadParams(
model,
append=True,
part_creation_type=prime.PartCreationType.BODY,
refacet=True,
cad_refaceting_params=prime.CadRefacetingParams(
model,
cad_faceter=prime.CadFaceter.PARASOLID,
max_edge_size_limit=prime.CadRefacetingMaxEdgeSizeLimit.ABSOLUTE,
max_edge_size=1.0,
),
)

prime.FileIO(model).import_cad(file_name=solder_ball, params=params)

Expand Down Expand Up @@ -155,6 +170,8 @@
# Create the base face to quad surface mesh and use for sweeping.
# Stack the base face to create the volume mesh.
# Delete topology on mesh part to allow use of surface utilities and feature extraction.
# A large lateral defeature tolerance of 0.1 is used to avoid additional topo nodes
# from scaffolding impacting the final mesh.

model.set_global_sizing_params(prime.GlobalSizingParams(model, min=0.1, max=0.4))

Expand All @@ -169,7 +186,7 @@
direction=[0, 1, 0],
max_offset_size=0.4,
delete_base=True,
lateral_defeature_tolerance=0.01,
lateral_defeature_tolerance=0.1,
stacking_defeature_tolerance=0.01,
size_control_ids=[size_control.id],
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6a23e87

Please sign in to comment.