diff --git a/docs/zh/examples/chip_heat.md b/docs/zh/examples/chip_heat.md index 97a1f5f3c0..b4af9eaa58 100644 --- a/docs/zh/examples/chip_heat.md +++ b/docs/zh/examples/chip_heat.md @@ -48,7 +48,7 @@ $$ $$
- ![domain_chip.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/domain_chip.pdf){ loading=lazy style="height:80%;width:80%" align="center" } + ![domain_chip.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/domain_chip.PNG){ loading=lazy style="height:80%;width:80%" align="center" }
内部具有随机热源分布的 2D 芯片模拟区域,边界上可以为任意的边界条件。
@@ -94,7 +94,7 @@ PI-DeepONet模型,将 DeepONet 和 PINN 方法相结合,是一种结合了 对于芯片热仿真问题,PI-DeepONet 模型可以表示为如图所示的模型结构:
- ![pi_deeponet.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/pi_deeponet.pdf){ loading=lazy style="height:80%;width:80%" align="center" } + ![pi_deeponet.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/pi_deeponet.PNG){ loading=lazy style="height:80%;width:80%" align="center" }
如图所示,我们一共使用了 3 个分支网络和一个主干网络,分支网络分别输入边界类型指标、随机热源分布 $S(x, y)$ 和边界函数 $Q(x, y)$,主干网络输入二维坐标点坐标信息。每个分支网和主干网均输出 $q$ 维特征向量,通过 Hadamard(逐元素)乘积组合所有这些输出特征,然后将所得向量相加为预测温度场的标量输出。 diff --git a/ppsci/geometry/mesh.py b/ppsci/geometry/mesh.py index 82869b6f07..7563496cc6 100644 --- a/ppsci/geometry/mesh.py +++ b/ppsci/geometry/mesh.py @@ -72,6 +72,22 @@ def from_pymesh(cls, mesh: "pymesh.Mesh") -> "Mesh": Returns: Mesh: Instantiated ppsci.geometry.Mesh object. + + Examples: + >>> import ppsci + >>> import pymesh + >>> import numpy as np + >>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) + >>> mesh = ppsci.geometry.Mesh.from_pymesh(box) + >>> print(mesh.vertices) + [[0. 0. 0.] + [1. 0. 0.] + [1. 1. 0.] + [0. 1. 0.] + [0. 0. 1.] + [1. 0. 1.] + [1. 1. 1.] + [0. 1. 1.]] """ # check if pymesh is installed when using Mesh Class if not checker.dynamic_import_to_globals(["pymesh"]): @@ -182,6 +198,40 @@ def translate(self, translation: np.ndarray, relative: bool = True) -> "Mesh": Returns: Mesh: Translated Mesh object. + + Examples: + >>> import ppsci + >>> import pymesh + >>> import numpy as np + >>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) + >>> mesh = ppsci.geometry.Mesh(box) + >>> print(mesh.vertices) + [[0. 0. 0.] + [1. 0. 0.] + [1. 1. 0.] + [0. 1. 0.] + [0. 0. 1.] + [1. 0. 1.] + [1. 1. 1.] + [0. 1. 1.]] + >>> print(mesh.translate((-0.5, 0, 0.5), False).vertices) # the center is moved to the translation vector. + [[-1. -0.5 0. ] + [ 0. -0.5 0. ] + [ 0. 0.5 0. ] + [-1. 0.5 0. ] + [-1. -0.5 1. ] + [ 0. -0.5 1. ] + [ 0. 0.5 1. ] + [-1. 0.5 1. ]] + >>> print(mesh.translate((-0.5, 0, 0.5), True).vertices) # the translation vector is directly added to the geometry coordinates + [[-0.5 0. 0.5] + [ 0.5 0. 0.5] + [ 0.5 1. 0.5] + [-0.5 1. 0.5] + [-0.5 0. 1.5] + [ 0.5 0. 1.5] + [ 0.5 1. 1.5] + [-0.5 1. 1.5]] """ vertices = np.array(self.vertices, dtype=paddle.get_default_dtype()) faces = np.array(self.faces) @@ -221,6 +271,32 @@ def scale( Returns: Mesh: Scaled Mesh object. + + Examples: + >>> import ppsci + >>> import pymesh + >>> import numpy as np + >>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1])) + >>> mesh = ppsci.geometry.Mesh(box) + >>> print(mesh.vertices) + [[0. 0. 0.] + [1. 0. 0.] + [1. 1. 0.] + [0. 1. 0.] + [0. 0. 1.] + [1. 0. 1.] + [1. 1. 1.] + [0. 1. 1.]] + >>> mesh = mesh.scale(2, (0.25, 0.5, 0.75)) + >>> print(mesh.vertices) + [[-0.25 -0.5 -0.75] + [ 1.75 -0.5 -0.75] + [ 1.75 1.5 -0.75] + [-0.25 1.5 -0.75] + [-0.25 -0.5 1.25] + [ 1.75 -0.5 1.25] + [ 1.75 1.5 1.25] + [-0.25 1.5 1.25]] """ vertices = np.array(self.vertices, dtype=paddle.get_default_dtype()) faces = np.array(self.faces, dtype=paddle.get_default_dtype())