pub struct PhysicalBox { /* private fields */ }
Expand description
A bounding box describes geometry in which an Octree lives.
Implementations§
Source§impl PhysicalBox
impl PhysicalBox
Sourcepub fn new(coords: [f64; 6]) -> Self
pub fn new(coords: [f64; 6]) -> Self
Create a new bounding box.
The coordinates are given by [xmin, ymin, zmin, xmax, ymax, zmax]
.
Sourcepub fn from_points(points: &[Point]) -> PhysicalBox
pub fn from_points(points: &[Point]) -> PhysicalBox
Give a slice of points. Compute an associated bounding box.
The created bounding box is slightly bigger than the actual point set. This is to make sure that no point lies exactly on the boundary of the box.
Examples found in repository?
examples/mpi_global_bounding_box.rs (line 37)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
pub fn main() {
// Initialise MPI
let universe = mpi::initialize().unwrap();
// Get the world communicator
let comm = universe.world();
// Initialise a seeded Rng.
let mut rng = ChaCha8Rng::seed_from_u64(2);
// Create `npoints` per rank.
let npoints = 10;
// Generate random points.
let points = generate_random_points(npoints, &mut rng, &comm);
// Compute the distributed bounding box.
let bounding_box = compute_global_bounding_box(&points, &comm);
// Copy all points to root and compare local bounding box there.
if let Some(points_root) = gather_to_root(&points, &comm) {
// Compute the bounding box on root.
let expected = PhysicalBox::from_points(&points_root);
assert_eq!(expected.coordinates(), bounding_box.coordinates());
}
}
Sourcepub fn coordinates(&self) -> [f64; 6]
pub fn coordinates(&self) -> [f64; 6]
Return coordinates
Examples found in repository?
examples/mpi_global_bounding_box.rs (line 38)
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
pub fn main() {
// Initialise MPI
let universe = mpi::initialize().unwrap();
// Get the world communicator
let comm = universe.world();
// Initialise a seeded Rng.
let mut rng = ChaCha8Rng::seed_from_u64(2);
// Create `npoints` per rank.
let npoints = 10;
// Generate random points.
let points = generate_random_points(npoints, &mut rng, &comm);
// Compute the distributed bounding box.
let bounding_box = compute_global_bounding_box(&points, &comm);
// Copy all points to root and compare local bounding box there.
if let Some(points_root) = gather_to_root(&points, &comm) {
// Compute the bounding box on root.
let expected = PhysicalBox::from_points(&points_root);
assert_eq!(expected.coordinates(), bounding_box.coordinates());
}
}
Sourcepub fn reference_to_physical(&self, point: [f64; 3]) -> [f64; 3]
pub fn reference_to_physical(&self, point: [f64; 3]) -> [f64; 3]
Map a point from the reference box [0, 1]^3 to the bounding box.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PhysicalBox
impl RefUnwindSafe for PhysicalBox
impl Send for PhysicalBox
impl Sync for PhysicalBox
impl Unpin for PhysicalBox
impl UnwindSafe for PhysicalBox
Blanket Implementations§
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<Src> TryFrom<Src> for Src
impl<Src> TryFrom<Src> for Src
§impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
§impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
§fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.