mindflow.geometry
init
- class mindflow.geometry.CSGDifference(geom1, geom2, sampling_config=None)[source]
CSG class for difference of geometry.
- Parameters
geom1 (Geometry) – a geometry object.
geom2 (Geometry) – a geometry object to be subtracted from geom1.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Disk, Rectangle, CSGDifference >>> sampling_config_csg = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1000, ... 'sampler': 'uniform' ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'sampler': 'uniform', ... 'with_normal': True, ... }), ... }) >>> disk = Disk("disk", (1.2, 0.5), 0.8) >>> rect = Rectangle("rect", (-1.0, 0), (1, 1)) >>> diff = CSGDifference(rect, disk) >>> diff.set_sampling_config(generate_sampling_config(sampling_config_csg)) >>> domain = diff.sampling(geom_type="domain") >>> bc, bc_normal = diff.sampling(geom_type="BC") >>> print(domain.shape) (1000, 2)
- class mindflow.geometry.CSGIntersection(geom1, geom2, sampling_config=None)[source]
CSG class for intersection of geometries.
- Parameters
geom1 (Geometry) – a geometry object.
geom2 (Geometry) – a geometry object to be subtracted from geom1.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Disk, Rectangle, CSGIntersection >>> sampling_config_csg = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1000, ... 'sampler': 'uniform' ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'sampler': 'uniform', ... 'with_normal': True, ... }), ... }) >>> disk = Disk("disk", (1.2, 0.5), 0.8) >>> rect = Rectangle("rect", (-1.0, 0), (1, 1)) >>> inter = CSGIntersection(rect, disk) >>> inter.set_sampling_config(generate_sampling_config(sampling_config_csg)) >>> domain = inter.sampling(geom_type="domain") >>> bc, bc_normal = inter.sampling(geom_type="BC") >>> print(domain.shape) (1000, 2)
- class mindflow.geometry.CSGUnion(geom1, geom2, sampling_config=None)[source]
CSG class for union of geometries.
- Parameters
geom1 (Geometry) – a geometry object.
geom2 (Geometry) – a geometry object to be subtracted from geom1.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Disk, Rectangle, CSGUnion >>> sampling_config_csg = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1000, ... 'sampler': 'uniform' ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'sampler': 'uniform', ... 'with_normal': True, ... }), ... }) >>> disk = Disk("disk", (1.2, 0.5), 0.8) >>> rect = Rectangle("rect", (-1.0, 0), (1, 1)) >>> union = CSGUnion(rect, disk) >>> union.set_sampling_config(generate_sampling_config(sampling_config_csg)) >>> domain = union.sampling(geom_type="domain") >>> bc, bc_normal = union.sampling(geom_type="BC") >>> print(domain.shape) (1000, 2)
- class mindflow.geometry.CSGXOR(geom1, geom2, sampling_config=None)[source]
CSG class for xor of geometries.
- Parameters
geom1 (Geometry) – a geometry object.
geom2 (Geometry) – a geometry object to be subtracted from geom1.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Disk, Rectangle, CSGXOR >>> sampling_config_csg = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1000, ... 'sampler': 'uniform' ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'sampler': 'uniform', ... 'with_normal': True, ... }), ... }) >>> disk = Disk("disk", (1.2, 0.5), 0.8) >>> rect = Rectangle("rect", (-1.0, 0), (1, 1)) >>> xor = CSGXOR(rect, disk) >>> xor.set_sampling_config(generate_sampling_config(sampling_config_csg)) >>> domain = xor.sampling(geom_type="domain") >>> bc, bc_normal = xor.sampling(geom_type="BC") >>> print(domain.shape) (1000, 2)
- class mindflow.geometry.Cone(name, centre, radius, h_min, h_max, h_axis, boundary_type='uniform', dtype=numpy.float32, sampling_config=None)[source]
Definition of cone object.
- Parameters
name (str) – name of the cone.
centre (numpy.ndarray) – origin of the bottom disk.
radius (float) – Radius of the bottom disk.
h_min (float) – Height coordinate of the bottom disk.
h_max (float) – Maximum Height coordinate of the cone.
h_axis (int) – Axis of the normal vector of the bottom disk.
boundary_type (str) –
this can be ‘uniform’ or ‘unweighted’. Default: ‘uniform’.
’uniform’, the expected number of samples in each boundary is proportional to the area (length) of the boundary.
’unweighted’, the expected number of samples in each boundary is the same.
dtype (numpy.dtype) – data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: none.
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> from mindflow.geometry import generate_sampling_config, Cone >>> cone_mesh = dict({'domain': dict({'random_sampling': True, 'size': 300}), ... 'BC': dict({'random_sampling': True, 'size': 300, 'with_normal': False,}),}) >>> vertices = np.array([[0., .1, 0.], [.9, .2, .1], [.5, .6, 0.1], [.6, .5, .8]]) >>> centre = np.array([0., 0.5]) >>> radius = 1.5 >>> h_min = -7. >>> h_max = 7. >>> h_axis = 2 >>> cone = Cone("cone", centre, radius, h_min, h_max, h_axis, ... sampling_config=generate_sampling_config(cone_mesh)) >>> domain = cone.sampling(geom_type="domain") >>> bc = cone.sampling(geom_type="bc") >>> print(domain.shape) (300, 2)
- class mindflow.geometry.Cuboid(name, coord_min, coord_max, dtype=numpy.float32, sampling_config=None)[source]
Definition of Cuboid object.
- Parameters
name (str) – name of the cuboid.
coord_min (Union[tuple[int, int], tuple[float, float], list[int, int], list[float, float], numpy.ndarray]) – coordinates of the bottom left back corner of cuboid.
coord_max (Union[tuple[int, int], tuple[float, float], list[int, int], list[float, float], numpy.ndarray]) – coordinates of the top right front corner of cuboid.
dtype (numpy.dtype) – data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Cuboid >>> cuboid_mesh = dict({'domain': dict({'random_sampling': False, 'size': [50, 50, 25]}), ... 'BC': dict({'random_sampling': False, 'size': 1000, 'with_normal': True,}),}) >>> cuboid = Cuboid("cuboid", (-3.0, 1, 0), (1, 2, 1), sampling_config=generate_sampling_config(cuboid_mesh)) >>> domain = cuboid.sampling(geom_type="domain") >>> bc, bc_normal = cuboid.sampling(geom_type="BC") >>> print(domain.shape) (62500, 3)
- class mindflow.geometry.Cylinder(name, centre, radius, h_min, h_max, h_axis, boundary_type='uniform', dtype=numpy.float32, sampling_config=None)[source]
Definition of cylinder object.
- Parameters
name (str) – name of the cylinder.
centre (numpy.ndarray) – origin of the bottom disk.
radius (float) – Radius of the cylinder.
h_min (float) – Height coordinate of the bottom disk.
h_max (float) – Height coordinate of the top disk.
h_axis (int) – Axis of the normal vector of the bottom disk.
boundary_type (str) –
this can be ‘uniform’ or ‘unweighted’. Default: ‘uniform’.
’uniform’, the expected number of samples in each boundary is proportional to the area (length) of the boundary.
’unweighted’, the expected number of samples in each boundary is the same.
dtype (numpy.dtype) – data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: none.
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> from mindflow.geometry import generate_sampling_config, Cylinder >>> cylinder_mesh = dict({'domain': dict({'random_sampling': True, 'size': 300}), ... 'BC': dict({'random_sampling': True, 'size': 300, 'with_normal': False,}),}) >>> vertices = np.array([[0., .1, 0.], [.9, .2, .1], [.5, .6, 0.1], [.6, .5, .8]]) >>> centre = np.array([0., 0.5]) >>> radius = 1.5 >>> h_min = -7. >>> h_max = 7. >>> h_axis = 2 >>> cylinder = Cylinder("cylinder", centre, radius, h_min, h_max, h_axis, ... sampling_config=generate_sampling_config(cylinder_mesh)) >>> domain = cylinder.sampling(geom_type="domain") >>> bc = cylinder.sampling(geom_type="bc") >>> print(domain.shape) (300, 2)
- class mindflow.geometry.Disk(name, center, radius, dtype=np.float32, sampling_config=None)[source]
Definition of Disk object.
- Parameters
name (str) – name of the disk.
center (Union[tuple[int, int], tuple[float, float], list[int, int], list[float, float], numpy.ndarray]) – center coordinates of the disk.
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.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry 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
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.
- class mindflow.geometry.FixedPoint(name, coord, dtype=np.float32, sampling_config=None)[source]
Definition of HyperCube object.
- Parameters
name (str) – name of the fixed point.
coord (Union[int, float, tuple, list, numpy.ndarray]) – coordinate of the fixed point. 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.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, FixedPoint >>> hypercube_random = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1, ... 'sampler': 'uniform' ... }) ... }) >>> sampling_config = generate_sampling_config(hypercube_random) >>> point = FixedPoint("FixedPoint", [-1, 2, 1], sampling_config=sampling_config) >>> domain = point.sampling(geom_type="domain") >>> print(domain.shape) (1, 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.
- class mindflow.geometry.Geometry(name, dim, coord_min, coord_max, dtype=np.float32, sampling_config=None)[source]
Definition of Geometry object.
- Parameters
name (str) – name of the geometry.
dim (int) – number of dimensions.
coord_min (Union[int, float, list[int, float], tuple[int, float], numpy.ndarray]) – minimal coordinate of the geometry.
coord_max (Union[int, float, list[int, float], tuple[int, float], numpy.ndarray]) – maximal coordinate of the geometry.
dtype (numpy.dtype) – Data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: None
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Geometry >>> geometry_config = dict({'domain' : dict({'random_sampling' : True, 'size' : 100}), ... 'BC' : dict({'random_sampling' : True, 'size' : 100, 'sampler' : 'uniform',}), ... 'random_merge' : True,}) >>> sampling_config = generate_sampling_config(geometry_config) >>> geom = Geometry("geom", 1, 0.0, 1.0, sampling_config=sampling_config) >>> geom.set_name("geom_name")
- set_name(name)[source]
set geometry instance name
Examples
>>> from mindflow.geometry import generate_sampling_config, Geometry >>> geom = Geometry("geom", 1, 0.0, 1.0) >>> geom.set_name("geom_name")
- 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.
Examples
>>> from sciai.geometry import generate_sampling_config, Geometry >>> geometry_config = dict({'domain': dict({'random_sampling': True, 'size': 100}), ... 'BC': dict({'random_sampling': True, 'size': 100, 'sampler': 'uniform',}), ... 'random_merge': True,}) >>> sampling_config = generate_sampling_config(geometry_config) >>> geom = Geometry("geom", 1, 0.0, 1.0) >>> geom.set_sampling_config(sampling_config)
- class mindflow.geometry.GeometryWithTime(geometry, timedomain, sampling_config=None)[source]
Definition of geometry with time.
- Parameters
geometry (Geometry) – geometry
timedomain (TimeDomain) – time domain
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- 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.
- class mindflow.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
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, HyperCube >>> hypercube_random = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 1000, ... 'sampler': 'uniform' ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'sampler': 'uniform', ... 'with_normal': False, ... }), ... }) >>> sampling_config = generate_sampling_config(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.
- class mindflow.geometry.Interval(name, coord_min, coord_max, dtype=np.float32, sampling_config=None)[source]
Definition of Interval object.
- Parameters
name (str) – name of the interval.
dtype (numpy.dtype) – Data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Raises
ValueError – If coord_min or coord_max is neither int nor float .
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Interval >>> line_config = dict({'domain': dict({'random_sampling': True, 'size': 100, 'sampler': 'uniform'}), ... 'BC': dict({'random_sampling': True, 'size': 10, 'sampler': 'uniform',}),}) >>> line = Interval("line", -1.0, 1.0, sampling_config=generate_sampling_config(line_config)) >>> domain = line.sampling(geom_type="domain") >>> bc = line.sampling(geom_type="BC") >>> print(bc.shape) (10, 1)
- class mindflow.geometry.PartSamplingConfig(size, random_sampling=True, sampler='uniform', random_merge=True, with_normal=False, with_sdf=False)[source]
Definition of partial sampling configuration.
- Parameters
size (Union[int, tuple[int], list[int]) – number of sampling points.
random_sampling (bool) – Whether randomly sampling points. Default: True.
sampler (str) – method for random sampling. Default: uniform.
random_merge (bool) – Specifies whether randomly merge coordinates of different dimensions. Default: True.
with_normal (bool) – Specifies whether generating the normal vectors of the boundary. Default: False.
with_sdf (bool) – Specifies whether return the sign-distance-function result of the inner domain points. Default: False.
- Raises
TypeError – size is not int number when random sampling.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import PartSamplingConfig >>> partsampling = PartSamplingConfig(100, True, "uniform", True, True)
- class mindflow.geometry.Pentagon(name, vertices, boundary_type='uniform', dtype=np.float32, sampling_config=None)[source]
Definition of pentagon object.
- Parameters
name (str) – name of the pentagon.
vertices (numpy.ndarray) – vertices of the pentagon in an anti-clockwise order.
boundary_type (str) –
this can be ‘uniform’ or ‘unweighted’. Default: ‘uniform’.
’uniform’, the expected number of samples in each boundary is proportional to the area (length) of the boundary.
’unweighted’, the expected number of samples in each boundary is the same.
dtype (numpy.dtype) – data type of sampled point data type. Default: np.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: none.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Pentagon >>> pentagon_mesh = dict({'domain': dict({'random_sampling': True, 'size': 300}), ... 'BC': dict({'random_sampling': True, 'size': 300, 'with_normal': False,}),}) >>> vertices = np.array([[0., .1], [.5, .1], [.9, .2], [.7, .6], [.2, .5]]) >>> pentagon = Pentagon("pentagon", vertices, ... sampling_config=generate_sampling_config(pentagon_mesh)) >>> domain = pentagon.sampling(geom_type="domain") >>> bc = pentagon.sampling(geom_type="bc") >>> print(domain.shape) (300, 2)
- class mindflow.geometry.Rectangle(name, coord_min, coord_max, dtype=np.float32, sampling_config=None)[source]
Definition of Rectangle object.
- Parameters
name (str) – name of the rectangle.
coord_min (Union[tuple[int, int], tuple[float, float], list[int, int], list[float, float], numpy.ndarray]) – coordinates of the bottom left corner of rectangle.
coord_max (Union[tuple[int, int], tuple[float, float], list[int, int], list[float, float], numpy.ndarray]) – coordinates of the top right corner of rectangle.
dtype (numpy.dtype) – data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Rectangle >>> rectangle_mesh = dict({'domain': dict({'random_sampling': False, 'size': [50, 25]}), ... 'BC': dict({'random_sampling': False, 'size': 300, 'with_normal': True,}),}) >>> rectangle = Rectangle("rectangle", (-3.0, 1), (1, 2), ... sampling_config=generate_sampling_config(rectangle_mesh)) >>> domain = rectangle.sampling(geom_type="domain") >>> bc, bc_normal = rectangle.sampling(geom_type="BC") >>> print(domain.shape) (1250, 2)
- class mindflow.geometry.SamplingConfig(part_sampling_dict)[source]
Definition of global sampling configuration.
- Parameters
part_sampling_dict (dict) – sampling configuration.
- Raises
ValueError – If coord_min or coord_max is neither int nor float .
TypeError – If part_sampling_dict is not dict.
KeyError – If geom_type not “domain”, “BC”, “IC” or “time”.
TypeError – If ‘config’ is not PartSamplingConfig object.
ValueError – If self.domain.size is neither list nor tuple.
ValueError – If self.ic.size is neither list nor tuple.
ValueError – If self.time.size is neither list nor tuple.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import SamplingConfig, PartSamplingConfig >>> part_sampling_config_dict = {"domain" : PartSamplingConfig([100, 100], False, True), ... "BC" : PartSamplingConfig(100, True, "uniform", True, True)} >>> sampling_config = SamplingConfig(part_sampling_config_dict)
- class mindflow.geometry.Tetrahedron(name, vertices, boundary_type='uniform', dtype=numpy.float32, sampling_config=None)[source]
Definition of tetrahedron object.
- Parameters
name (str) – name of the tetrahedron.
vertices (numpy.ndarray) – vertices of the tetrahedron.
boundary_type (str) –
this can be ‘uniform’ or ‘unweighted’. Default: ‘uniform’.
’uniform’, the expected number of samples in each boundary is proportional to the area (length) of the boundary.
’unweighted’, the expected number of samples in each boundary is the same.
dtype (numpy.dtype) – data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: none.
- Supported Platforms:
Ascend
GPU
Examples
>>> import numpy as np >>> from mindflow.geometry import generate_sampling_config, Tetrahedron >>> tetrahedron_mesh = dict({'domain': dict({'random_sampling': True, 'size': 300}), ... 'BC': dict({'random_sampling': True, 'size': 300, 'with_normal': False,}),}) >>> vertices = np.array([[0., .1, 0.], [.9, .2, .1], [.5, .6, 0.1], [.6, .5, .8]]) >>> tetrahedron = Tetrahedron("tetrahedron", vertices, ... sampling_config=generate_sampling_config(tetrahedron_mesh)) >>> domain = tetrahedron.sampling(geom_type="domain") >>> bc = tetrahedron.sampling(geom_type="bc") >>> print(domain.shape) (300, 2)
- class mindflow.geometry.TimeDomain(name, start=0.0, end=1.0, dtype=np.float32, sampling_config=None)[source]
Definition of Time Domain.
- Parameters
name (str) – name of the time domain.
start (Union[int, float]) – start of the time domain. Default: 0.0.
end (Union[int, float]) – end of the time domain. Default: 1.0.
dtype (numpy.dtype) – Data type of sampled point data type. Default: numpy.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: None.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, TimeDomain >>> time_config = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 100, ... 'sampler': 'lhs' ... }) ... }) >>> time_domain = TimeDomain("time", 0.0, 1.0, sampling_config=generate_sampling_config(time_config)) >>> domain = time_domain.sampling(geom_type="domain") >>> print(domain.shape) (100, 1)
- class mindflow.geometry.Triangle(name, vertices, boundary_type='uniform', dtype=np.float32, sampling_config=None)[source]
Definition of triangle object.
- Parameters
name (str) – name of the triangle.
vertices (numpy.ndarray) – vertices of the triangle.
boundary_type (str) –
this can be ‘uniform’ or ‘unweighted’. Default: ‘uniform’.
’uniform’, the expected number of samples in each boundary is proportional to the area (length) of the boundary.
’unweighted’, the expected number of samples in each boundary is the same.
dtype (numpy.dtype) – data type of sampled point data type. Default: np.float32.
sampling_config (SamplingConfig) – sampling configuration. Default: none.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config, Triangle >>> triangle_mesh = dict({'domain': dict({'random_sampling': True, 'size': 300}), ... 'BC': dict({'random_sampling': True, 'size': 300, 'with_normal': False,}),}) >>> vertices = np.array([[0., .1], [.9, .2], [.5, .6]]) >>> triangle = Triangle("triangle", vertices, ... sampling_config=generate_sampling_config(triangle_mesh)) >>> domain = triangle.sampling(geom_type="domain") >>> bc = triangle.sampling(geom_type="bc") >>> print(domain.shape) (300, 2)
- mindflow.geometry.generate_sampling_config(dict_config)[source]
Convert from dict to SamplingConfig.
- Parameters
dict_config (dict) – dict containing configuration info.
- Returns
geometry_base.SamplingConfig, sampling configuration.
- Raises
ValueError – If part_dict_config can not be generated from input dict.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindflow.geometry import generate_sampling_config >>> rect_config = dict({ ... 'domain': dict({ ... 'random_sampling': True, ... 'size': 200, ... 'with_sdf': False, ... }), ... 'BC': dict({ ... 'random_sampling': True, ... 'size': 50, ... 'with_normal': True, ... }) ... }) >>> sampling_config = generate_sampling_config(rect_config)