Skip to content

Commit a1d75f7

Browse files
committed
grid fin progress
1 parent 20d3f5d commit a1d75f7

File tree

9 files changed

+4607
-251
lines changed

9 files changed

+4607
-251
lines changed

examples/ansys/Readme.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This directory contains an example Tesseract configuration and scripts demonstrating how to use Tesseract-JAX with ANSYS spaceclaim and PyMAPDL.
44

5+
![Mesh over optimization](mesh_optim.gif)
6+
![Rho over optimization](rho_optim_x.gif)
7+
58
## Get Started
69

710
### PL internal instructions:
2.94 MB
Binary file not shown.

examples/ansys/gf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
images = []
44

5-
for i in range(20):
5+
for i in range(40):
66
filename = f"tmp_img/mesh_optim_{i:03d}.png"
77
images.append(imageio.imread(filename))
88
print(f"Added {filename} to gif.")

examples/ansys/mesh_optim.gif

514 KB
Loading

examples/ansys/meshing_tess/tesseract_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import Any
22

33
import jax.numpy as jnp
4+
5+
# import numpy as jnp
46
from jax.scipy.interpolate import RegularGridInterpolator
57
from pydantic import BaseModel, Field
68
from scipy.interpolate import griddata

examples/ansys/optim_bars.ipynb

Lines changed: 3888 additions & 198 deletions
Large diffs are not rendered by default.

examples/ansys/optim_grid.ipynb

Lines changed: 700 additions & 52 deletions
Large diffs are not rendered by default.

examples/ansys/rho_optim_sum_2.gif

862 KB
Loading

examples/ansys/sdf_fd_tess/tesseract_api.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class InputSchema(BaseModel):
3939

4040
mesh_tesseract: TesseractReference = Field(description="Tesseract to call.")
4141

42+
scale_mesh: float = Field(
43+
default=1.0,
44+
description="Scaling factor applied to the generated mesh.",
45+
)
46+
4247
grid_size: list[float] = Field(
4348
description="Size of the bounding box in x, y, z directions."
4449
)
@@ -164,6 +169,7 @@ def apply_fn(
164169
non_differentiable_parameters: np.ndarray,
165170
static_parameters: list[int],
166171
string_parameters: list[str],
172+
scale_mesh: float,
167173
grid_size: np.ndarray,
168174
grid_elements: np.ndarray,
169175
grid_center: np.ndarray,
@@ -176,6 +182,8 @@ def apply_fn(
176182
static_parameters=static_parameters,
177183
string_parameters=string_parameters,
178184
)
185+
# scale the mesh
186+
geo = geo.apply_scale(scale_mesh)
179187

180188
sd_field = compute_sdf(
181189
geo,
@@ -197,6 +205,7 @@ def jac_sdf_wrt_params(
197205
non_differentiable_parameters: np.ndarray,
198206
static_parameters: list[int],
199207
string_parameters: list[str],
208+
scale_mesh: float,
200209
grid_size: np.ndarray,
201210
grid_elements: np.ndarray,
202211
grid_center: np.ndarray,
@@ -222,6 +231,7 @@ def jac_sdf_wrt_params(
222231
non_differentiable_parameters=non_differentiable_parameters,
223232
static_parameters=static_parameters,
224233
string_parameters=string_parameters,
234+
scale_mesh=scale_mesh,
225235
grid_elements=grid_elements,
226236
grid_size=grid_size,
227237
grid_center=grid_center,
@@ -239,6 +249,7 @@ def jac_sdf_wrt_params(
239249
non_differentiable_parameters=non_differentiable_parameters,
240250
static_parameters=static_parameters,
241251
string_parameters=string_parameters,
252+
scale_mesh=scale_mesh,
242253
grid_elements=grid_elements,
243254
grid_size=grid_size,
244255
grid_center=grid_center,
@@ -272,6 +283,7 @@ def apply(inputs: InputSchema) -> OutputSchema:
272283
grid_size=inputs.grid_size,
273284
static_parameters=inputs.static_parameters,
274285
string_parameters=inputs.string_parameters,
286+
scale_mesh=inputs.scale_mesh,
275287
grid_elements=inputs.grid_elements,
276288
grid_center=inputs.grid_center,
277289
)
@@ -319,6 +331,7 @@ def vector_jacobian_product(
319331
non_differentiable_parameters=inputs.non_differentiable_parameters,
320332
static_parameters=inputs.static_parameters,
321333
string_parameters=inputs.string_parameters,
334+
scale_mesh=inputs.scale_mesh,
322335
grid_size=inputs.grid_size,
323336
grid_elements=inputs.grid_elements,
324337
epsilon=inputs.epsilon,

0 commit comments

Comments
 (0)