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, list[int, float], tuple[int, float], numpy.ndarray]) – minimal coordinate of the hyper cube.
coord_max (Union[int, float, list[int, float], tuple[int, float], numpy.ndarray]) – maximal coordinate of the hyper cube.
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
- Returns
Numpy.array, 2D numpy array with or 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.