mindscience.data.GeometryWithTime

class mindscience.data.GeometryWithTime(geometry, timedomain, sampling_config=None)[源代码]

带时间维度的几何对象定义。

参数:
  • geometry (Geometry) - 空间几何对象。

  • timedomain (TimeDomain) - 时间域对象。

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

异常:
  • ValueError - 当 sampling_config 不为 Nonesampling_config.timeNone 时抛出。

样例:

>>> from mindscience.data import generate_sampling_config, Rectangle, TimeDomain, GeometryWithTime
>>> rect_with_time_config = dict({
...     'domain': dict({
...         'random_sampling': True,
...         'size': 200,
...     }),
...     'BC': dict({
...         'random_sampling': False,
...         'size': 100,
...         'with_normal': True,
...     }),
...     'IC': dict({
...         'random_sampling': False,
...         'size': [10, 10],
...     }),
...     'time': dict({
...         'random_sampling': True,
...         'size': 10,
...     })
... })
>>> rect = Rectangle("rect", [-1.0, -0.5], [1.0, 0.5])
>>> time = TimeDomain("time", 0.0, 1.0)
>>> rect_with_time = GeometryWithTime(rect, time)
>>> sampling_config = generate_sampling_config(rect_with_time_config)
>>> rect_with_time.set_sampling_config(sampling_config)
>>> bc, bc_normal = rect_with_time.sampling(geom_type="BC")
>>> domain = rect_with_time.sampling(geom_type="domain")
>>> ic = rect_with_time.sampling(geom_type="IC")
>>> print(domain.shape)
(200, 3)
>>> print(bc.shape)
(90, 3)
>>> print(ic.shape)
(100, 3)
sampling(geom_type='domain')[源代码]

采样点。

参数:
  • geom_type (str) - 几何类型:支持 'domain''BC''IC',默认 'domain'

    • 'domain':问题的可行域(feasible domain of the problem)。

    • 'BC':问题的边界(boundary of the problem)。

    • 'IC':问题的初始条件(initial condition of the problem)。

返回:

Numpy.array。若边界配置 with_normal 为 True,则返回 两项 (采样点二维数组与对应法线二维数组);否则返回 一项 (采样点二维数组)。

异常:
  • KeyError - 当 geom_type'domain'self.sampling_config.domainNone 时抛出。

  • KeyError - 当 geom_type'BC'self.sampling_config.bcNone 时抛出。

  • KeyError - 当 geom_type'IC'self.sampling_config.icNone 时抛出。

set_sampling_config(sampling_config)[源代码]

设置采样信息。

参数:
  • sampling_config (SamplingConfig) - 采样配置。

异常:
  • TypeError - 当 sampling_config 不是 SamplingConfig 的实例时抛出。