Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Polygon sdf #406

Merged
merged 13 commits into from
Jun 27, 2023
Merged

add Polygon sdf #406

merged 13 commits into from
Jun 27, 2023

Conversation

mrcangye
Copy link
Contributor

@mrcangye mrcangye commented Jun 24, 2023

PR types

New features

PR changes

APIs

Describe

#376
测试代码

import ppsci
from ppsci.utils import logger
from ppsci import visualize

logger.init_logger()

geo = ppsci.geometry.Polygon(((0, 0), (1, 0), (2, 1), (2, 2), (0, 2)))
points_dict = geo.sample_interior(n=100000) # 可视化100000个点
visualize.vtu.save_vtu_from_dict("./visualize_sdf.vtu", points_dict, geo.dim_keys, ("sdf", ))

Screenshot - 2023-06-25 00 42 30

@paddle-bot
Copy link

paddle-bot bot commented Jun 24, 2023

Thanks for your contribution!

@HydrogenSulfate
Copy link
Collaborator

看了下范围,感觉不太对?
左边是用Poly生成的边长为 $\sqrt 2$ 的矩形的sdf
右边是用Rectangle生成的同边长的矩形的sdf,可以看到Rectangle的结果是对的,Poly的结果范围并不正确
image

@mrcangye
Copy link
Contributor Author

看了下范围,感觉不太对? 左边是用Poly生成的边长为 2 的矩形的sdf 右边是用Rectangle生成的同边长的矩形的sdf,可以看到Rectangle的结果是对的,Poly的结果范围并不正确 image

我修改了下代码,得出的结果如下:
Screenshot - 2023-06-26 09 55 58
使用的测试代码如下:

import ppsci
from ppsci.utils import logger
from ppsci import visualize

logger.init_logger()

geo = ppsci.geometry.Polygon(((0, 1), (1, 0), (0, -1), (-1, 0)))
points_dict = geo.sample_interior(n=500000) # 可视化500000个点
visualize.vtu.save_vtu_from_dict("./visualize_sdf.vtu", points_dict, geo.dim_keys, ("sdf", ))

这样的范围是正确的嘛

ppsci/geometry/geometry_2d.py Outdated Show resolved Hide resolved
@HydrogenSulfate
Copy link
Collaborator

看了下范围,感觉不太对? 左边是用Poly生成的边长为 2 的矩形的sdf 右边是用Rectangle生成的同边长的矩形的sdf,可以看到Rectangle的结果是对的,Poly的结果范围并不正确 image

我修改了下代码,得出的结果如下: Screenshot - 2023-06-26 09 55 58 使用的测试代码如下:

import ppsci
from ppsci.utils import logger
from ppsci import visualize

logger.init_logger()

geo = ppsci.geometry.Polygon(((0, 1), (1, 0), (0, -1), (-1, 0)))
points_dict = geo.sample_interior(n=500000) # 可视化500000个点
visualize.vtu.save_vtu_from_dict("./visualize_sdf.vtu", points_dict, geo.dim_keys, ("sdf", ))

这样的范围是正确的嘛

用五角星看了下结果基本是对了,但返回值还需要加一个负号
image

ppsci/geometry/geometry_2d.py Outdated Show resolved Hide resolved
ppsci/geometry/geometry_2d.py Outdated Show resolved Hide resolved
ppsci/geometry/geometry_2d.py Outdated Show resolved Hide resolved
@HydrogenSulfate
Copy link
Collaborator

code-style-check CI 挂了,commit之前请先安装pre-commit

pip install pre-commit
pre-commit install

@mrcangye
Copy link
Contributor Author

code-style-check CI 挂了,commit之前请先安装pre-commit

pip install pre-commit
pre-commit install

已经修改,谢谢你!

Copy link
Collaborator

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HydrogenSulfate HydrogenSulfate merged commit abf9559 into PaddlePaddle:develop Jun 27, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jun 27, 2023
huohuohuohuohuo123 pushed a commit to huohuohuohuohuo123/PaddleScience that referenced this pull request Aug 12, 2024
* add Polygon sdf

* add Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf and add some annotations

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf

* rewrite Polygon sdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants