mindflow.geometry.CSGDifference

View Source On Gitee
class mindflow.geometry.CSGDifference(geom1, geom2, sampling_config=None)[source]

CSG class for difference of geometry.

Parameters
  • geom1 (Geometry) – a geometry object.

  • geom2 (Geometry) – a geometry object to be subtracted from geom1.

  • sampling_config (SamplingConfig) – sampling configuration. Default: None.

Supported Platforms:

Ascend GPU

Examples

>>> from mindflow.geometry import generate_sampling_config, Disk, Rectangle, CSGDifference
>>> sampling_config_csg = dict({
...     'domain': dict({
...         'random_sampling': True,
...         'size': 1000,
...         'sampler': 'uniform'
...     }),
...     'BC': dict({
...         'random_sampling': True,
...         'size': 200,
...         'sampler': 'uniform',
...         'with_normal': True,
...     }),
... })
>>> disk = Disk("disk", (1.2, 0.5), 0.8)
>>> rect = Rectangle("rect", (-1.0, 0), (1, 1))
>>> diff = CSGDifference(rect, disk)
>>> diff.set_sampling_config(generate_sampling_config(sampling_config_csg))
>>> domain = diff.sampling(geom_type="domain")
>>> bc, bc_normal = diff.sampling(geom_type="BC")
>>> print(domain.shape)
(1000, 2)