Skip to content

Commit 3b0fd35

Browse files
Merge branch 'develop' into fix_doctest
2 parents 0e6dcba + 7930348 commit 3b0fd35

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

docs/zh/examples/chip_heat.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $$
4848
$$
4949

5050
<figure markdown>
51-
![domain_chip.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/domain_chip.pdf){ loading=lazy style="height:80%;width:80%" align="center" }
51+
![domain_chip.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/chip_domain.PNG){ loading=lazy style="height:80%;width:80%" align="center" }
5252
<figcaption> 内部具有随机热源分布的 2D 芯片模拟区域,边界上可以为任意的边界条件。</figcaption>
5353
</figure>
5454

@@ -94,7 +94,7 @@ PI-DeepONet模型,将 DeepONet 和 PINN 方法相结合,是一种结合了
9494
对于芯片热仿真问题,PI-DeepONet 模型可以表示为如图所示的模型结构:
9595

9696
<figure markdown>
97-
![pi_deeponet.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/pi_deeponet.pdf){ loading=lazy style="height:80%;width:80%" align="center" }
97+
![pi_deeponet.pdf](https://paddle-org.bj.bcebos.com/paddlescience/docs/ChipHeat/pi_deeponet.PNG){ loading=lazy style="height:80%;width:80%" align="center" }
9898
</figure>
9999

100100
如图所示,我们一共使用了 3 个分支网络和一个主干网络,分支网络分别输入边界类型指标、随机热源分布 $S(x, y)$ 和边界函数 $Q(x, y)$,主干网络输入二维坐标点坐标信息。每个分支网和主干网均输出 $q$ 维特征向量,通过 Hadamard(逐元素)乘积组合所有这些输出特征,然后将所得向量相加为预测温度场的标量输出。

ppsci/geometry/mesh.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ def from_pymesh(cls, mesh: "pymesh.Mesh") -> "Mesh":
7272
7373
Returns:
7474
Mesh: Instantiated ppsci.geometry.Mesh object.
75+
76+
Examples:
77+
>>> import ppsci
78+
>>> import pymesh
79+
>>> import numpy as np
80+
>>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
81+
>>> mesh = ppsci.geometry.Mesh.from_pymesh(box)
82+
>>> print(mesh.vertices)
83+
[[0. 0. 0.]
84+
[1. 0. 0.]
85+
[1. 1. 0.]
86+
[0. 1. 0.]
87+
[0. 0. 1.]
88+
[1. 0. 1.]
89+
[1. 1. 1.]
90+
[0. 1. 1.]]
7591
"""
7692
# check if pymesh is installed when using Mesh Class
7793
if not checker.dynamic_import_to_globals(["pymesh"]):
@@ -182,6 +198,40 @@ def translate(self, translation: np.ndarray, relative: bool = True) -> "Mesh":
182198
183199
Returns:
184200
Mesh: Translated Mesh object.
201+
202+
Examples:
203+
>>> import ppsci
204+
>>> import pymesh
205+
>>> import numpy as np
206+
>>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
207+
>>> mesh = ppsci.geometry.Mesh(box)
208+
>>> print(mesh.vertices)
209+
[[0. 0. 0.]
210+
[1. 0. 0.]
211+
[1. 1. 0.]
212+
[0. 1. 0.]
213+
[0. 0. 1.]
214+
[1. 0. 1.]
215+
[1. 1. 1.]
216+
[0. 1. 1.]]
217+
>>> print(mesh.translate((-0.5, 0, 0.5), False).vertices) # the center is moved to the translation vector.
218+
[[-1. -0.5 0. ]
219+
[ 0. -0.5 0. ]
220+
[ 0. 0.5 0. ]
221+
[-1. 0.5 0. ]
222+
[-1. -0.5 1. ]
223+
[ 0. -0.5 1. ]
224+
[ 0. 0.5 1. ]
225+
[-1. 0.5 1. ]]
226+
>>> print(mesh.translate((-0.5, 0, 0.5), True).vertices) # the translation vector is directly added to the geometry coordinates
227+
[[-0.5 0. 0.5]
228+
[ 0.5 0. 0.5]
229+
[ 0.5 1. 0.5]
230+
[-0.5 1. 0.5]
231+
[-0.5 0. 1.5]
232+
[ 0.5 0. 1.5]
233+
[ 0.5 1. 1.5]
234+
[-0.5 1. 1.5]]
185235
"""
186236
vertices = np.array(self.vertices, dtype=paddle.get_default_dtype())
187237
faces = np.array(self.faces)
@@ -221,6 +271,32 @@ def scale(
221271
222272
Returns:
223273
Mesh: Scaled Mesh object.
274+
275+
Examples:
276+
>>> import ppsci
277+
>>> import pymesh
278+
>>> import numpy as np
279+
>>> box = pymesh.generate_box_mesh(np.array([0, 0, 0]), np.array([1, 1, 1]))
280+
>>> mesh = ppsci.geometry.Mesh(box)
281+
>>> print(mesh.vertices)
282+
[[0. 0. 0.]
283+
[1. 0. 0.]
284+
[1. 1. 0.]
285+
[0. 1. 0.]
286+
[0. 0. 1.]
287+
[1. 0. 1.]
288+
[1. 1. 1.]
289+
[0. 1. 1.]]
290+
>>> mesh = mesh.scale(2, (0.25, 0.5, 0.75))
291+
>>> print(mesh.vertices)
292+
[[-0.25 -0.5 -0.75]
293+
[ 1.75 -0.5 -0.75]
294+
[ 1.75 1.5 -0.75]
295+
[-0.25 1.5 -0.75]
296+
[-0.25 -0.5 1.25]
297+
[ 1.75 -0.5 1.25]
298+
[ 1.75 1.5 1.25]
299+
[-0.25 1.5 1.25]]
224300
"""
225301
vertices = np.array(self.vertices, dtype=paddle.get_default_dtype())
226302
faces = np.array(self.faces, dtype=paddle.get_default_dtype())

0 commit comments

Comments
 (0)