mindflow.geometry.GeometryWithTime

View Source On Gitee
class mindflow.geometry.GeometryWithTime(geometry, timedomain, sampling_config=None)[source]

Definition of geometry with time.

Parameters
Raises

ValueError – If sampling_config is not None but sampling_config.time is None .

Supported Platforms:

Ascend GPU

Examples

>>> from mindflow.geometry 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')[source]

sampling points

Parameters

geom_type (str) –

geometry type: can be 'domain' or 'BC' or 'IC'. Default: 'domain'.

  • 'domain', feasible domain of the problem.

  • 'BC', boundary of the problem.

  • 'IC', initial condition of the problem.

Returns

Numpy.array, if the with_normal property of boundary configuration is true, returns 2D numpy array with

boundary normal vectors. Otherwise, returns 2D numpy array without boundary normal vectors.

Raises
  • ValueError – If config is None.

  • KeyError – If geom_type is 'domain' but config.domain is None.

  • KeyError – If geom_type is 'BC' but config.bc is None.

  • KeyError – If geom_type is 'IC' but config.ic is None.

  • ValueError – If geom_type is not 'BC', 'IC' nor 'domain'.

set_sampling_config(sampling_config: SamplingConfig)[source]

set sampling info

Parameters

sampling_config (SamplingConfig) – sampling configuration.

Raises

TypeError – If sampling_config is not instance of SamplingConfig.