mindscience.data.Disk
- class mindscience.data.Disk(name, center, radius, dtype=numpy.float32, sampling_config=None)[source]
Definition of Disk object.
- Parameters
name (str) – Name of the disk.
center (Union[tuple, list, numpy.ndarray]) – Center coordinates of the disk. If the parameter type is tuple or list, each element should be of type int or float, and its length must be
2.dtype (numpy.dtype) – Data type of sampled point data type. Default:
numpy.float32.sampling_config (SamplingConfig) – Sampling configuration. Default:
None.
- Raises
ValueError – If center is neither list nor tuple of length 2.
ValueError – If radius is negative.
Examples
>>> from mindscience.data import generate_sampling_config, Disk >>> disk_mesh = dict({'domain': dict({'random_sampling': False, 'size' : [100, 180]}), ... 'BC': dict({'random_sampling': False, 'size': 200, 'with_normal' : True,})}) >>> disk = Disk("disk", (-1.0, 0), 2.0, sampling_config=generate_sampling_config(disk_mesh)) >>> domain = disk.sampling(geom_type="domain") >>> bc, bc_normal = disk.sampling(geom_type="BC") >>> print(bc.shape) (200, 2)
- sampling(geom_type='domain')[source]
Sampling domain and boundary 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
KeyError – If geom_type is
'domain'butself.sampling_config.domainisNone.KeyError – If geom_type is
'BC'butself.sampling_config.bcisNone.ValueError – If geom_type is neither
'BC'nor'domain'.