mindscience.data.Tetrahedron

class mindscience.data.Tetrahedron(name, vertices, boundary_type='uniform', dtype=numpy.float32, sampling_config=None)[源代码]

四面体对象的定义。

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

  • vertices (numpy.ndarray) - 四面体顶点坐标数组。

  • 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, Tetrahedron
>>> tetrahedron_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]])
>>> tetrahedron = Tetrahedron("tetrahedron", vertices,
...                           sampling_config=generate_sampling_config(tetrahedron_mesh))
>>> domain = tetrahedron.sampling(geom_type="domain")
>>> bc = tetrahedron.sampling(geom_type="bc")
>>> print(domain.shape)
(300, 2)