mindscience.data.Cylinder

class mindscience.data.Cylinder(name, centre, radius, h_min, h_max, h_axis, boundary_type='uniform', dtype=numpy.float32, sampling_config=None)[源代码]

圆柱体对象的定义。

参数:
  • name (str) - 圆柱体对象的名称。

  • centre (numpy.ndarray) - 圆柱体底面的圆心坐标。

  • radius (float) - 圆柱体截面半径。

  • h_min (float) - 圆柱体底面的高度坐标。

  • h_max (float) - 圆柱体顶面的高度坐标。

  • h_axis (int) - 圆柱体底面法向量所对应的坐标轴索引。

  • boundary_type (str) - 边界采样策略,默认 'uniform'

    • 'uniform':按照各边界的“面积/长度”占比分配采样点。

    • 'unweighted':对所有边/面平均分配采样点数量。

  • dtype (numpy.dtype) - 采样点的数据类型,默认 numpy.float32

  • sampling_config (SamplingConfig) - 采样配置,默认 None

样例:

>>> import numpy as np
>>> from mindscience.data import generate_sampling_config, Cylinder
>>> cylinder_mesh = dict({'domain': dict({'random_sampling': True, 'size': 300}),
...                       'BC': dict({'random_sampling': True, 'size': 300, 'with_normal': False,}),})
>>> vertices = np.array([[0., .1, 0.], [.9, .2, .1], [.5, .6, 0.1], [.6, .5, .8]])
>>> centre = np.array([0., 0.5])
>>> radius = 1.5
>>> h_min = -7.
>>> h_max = 7.
>>> h_axis = 2
>>> cylinder = Cylinder("cylinder", centre, radius, h_min, h_max, h_axis,
...                     sampling_config=generate_sampling_config(cylinder_mesh))
>>> domain = cylinder.sampling(geom_type="domain")
>>> bc = cylinder.sampling(geom_type="bc")
>>> print(domain.shape)
(300, 2)