mindelec.geometry.HyperCube

class mindelec.geometry.HyperCube(name, dim, coord_min, coord_max, dtype=np.float32, sampling_config=None)[source]

Definition of HyperCube object.

Parameters
  • name (str) – name of the hyper cube.

  • dim (int) – number of dimensions.

  • coord_min (Union[int, float, tuple, list, numpy.ndarray]) – minimal coordinate of the hyper cube. if the parameter type is tuple or list, the element support tuple[int, int], tuple[float, float], list[int, int], list[float, float].

  • coord_max (Union[int, float, tuple, list, numpy.ndarray]) – maximal coordinate of the hyper cube. if the parameter type is tuple or list, the element support tuple[int, int], tuple[float, float], list[int, int], list[float, float].

  • dtype (numpy.dtype) – Data type of sampled point data type. Default: numpy.float32.

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

Raises

TypeError – sampling_config is not instance of class SamplingConfig.

Supported Platforms:

Ascend

Examples

>>> from easydict import EasyDict as edict
>>> from mindelec.geometry import create_config_from_edict, HyperCube
>>> hypercube_random = edict({
...      'domain': edict({
...          'random_sampling': True,
...          'size': 1000,
...          'sampler': 'uniform'
...         }),
...      'BC': edict({
...          'random_sampling': True,
...          'size': 200,
...          'sampler': 'uniform',
...          'with_normal': False,
...      }),
...  })
>>> sampling_config = create_config_from_edict(hypercube_random)
>>> hypercube = HyperCube("HyperCube", 3, [-1, 2, 1], [0, 3, 2], sampling_config=sampling_config)
>>> domain = hypercube.sampling(geom_type="domain")
>>> bc = hypercube.sampling(geom_type="BC")
>>> print(domain.shape)
(1000, 3)
sampling(geom_type='domain')[source]

sampling points

Parameters

geom_type (str) –

geometry type: can be ‘domain’ or ‘BC’. Default: ‘domain’.

  • ’domain’, feasible domain of the problem.

  • ’BC’, boundary 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.

  • ValueError – If geom_type is neither BC nor domain.