Skip to main content

Closed

Struct Closed 

Source
pub struct Closed<T>(pub T);
Expand description

Restrict points to the inside of a shape.

Closed is a newtype that wraps a shape. It prevents bodies and sites from existing outside the shape. Bodies and sites are never wrapped, and there are no ghost sites.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl<B, X> AppendMicrostate<B, OrientedPoint<Cartesian<2>, Angle>, X, Closed<Hypercuboid<2>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, OrientedPoint<Cartesian<2>, Angle>, X, Closed<Hypercuboid<2>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<B, X> AppendMicrostate<B, OrientedPoint<Cartesian<3>, Versor>, X, Closed<Hypercuboid<3>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, OrientedPoint<Cartesian<3>, Versor>, X, Closed<Hypercuboid<3>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<B, X> AppendMicrostate<B, Point<Cartesian<2>>, X, Closed<Hypercuboid<2>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, Point<Cartesian<2>>, X, Closed<Hypercuboid<2>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<B, X> AppendMicrostate<B, Point<Cartesian<3>>, X, Closed<Hypercuboid<3>>> for HoomdGsdFile

Source§

fn append_microstate( &mut self, microstate: &Microstate<B, Point<Cartesian<3>>, X, Closed<Hypercuboid<3>>>, ) -> Result<Frame<'_>, AppendError>

Append the contents of the microstate as a frame in a GSD file. Read more
Source§

impl<T: Clone> Clone for Closed<T>

Source§

fn clone(&self) -> Closed<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Closed<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for Closed<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T, P> Distribution<P> for Closed<T>
where T: Distribution<P>,

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> P

Generate points uniformly distributed in the wrapped shape.

§Example
use hoomd_geometry::{IsPointInside, shape::Sphere};
use hoomd_microstate::boundary::Closed;
use rand::{SeedableRng, distr::Distribution, rngs::StdRng};

let sphere = Closed(Sphere {
    radius: 5.0.try_into()?,
});
let mut rng = StdRng::seed_from_u64(1);

let point = sphere.sample(&mut rng);
assert!(sphere.0.is_point_inside(&point));
Source§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl<S, T> GenerateGhosts<S> for Closed<T>
where S: Default,

Source§

fn maximum_interaction_range(&self) -> f64

The largest interaction distance between sites. Read more
Source§

fn generate_ghosts(&self, _site_properties: &S) -> ArrayVec<S, MAX_GHOSTS>

Place periodic images of sites within the interaction range. Read more
Source§

impl<P, T> MapPoint<P> for Closed<T>
where T: MapPoint<P>,

Source§

fn map_point(&self, point: P, other: &Self) -> Result<P, Error>

Map a point in the wrapped shape to another.

§Errors

hoomd_geometry::Error::PointOutsideShape when point is outside self.shape().

§Example
use hoomd_geometry::{MapPoint, shape::Rectangle};
use hoomd_microstate::boundary::Closed;
use hoomd_vector::Cartesian;

let closed_a = Closed(Rectangle::with_equal_edges(10.0.try_into()?));
let closed_b = Closed(Rectangle::with_equal_edges(20.0.try_into()?));

let mapped_point =
    closed_a.map_point(Cartesian::from([-1.0, 1.0]), &closed_b);

assert_eq!(mapped_point, Ok(Cartesian::from([-2.0, 2.0])));
assert_eq!(
    closed_a.map_point(Cartesian::from([-100.0, 1.0]), &closed_b),
    Err(hoomd_geometry::Error::PointOutsideShape)
);
Source§

impl<T: PartialEq> PartialEq for Closed<T>

Source§

fn eq(&self, other: &Closed<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Scale for Closed<T>
where T: Scale,

Source§

fn scale_length(&self, v: PositiveReal) -> Self

Scale the wrapped shape.

§Example
use hoomd_geometry::{Scale, shape::Sphere};
use hoomd_microstate::boundary::Closed;

let sphere = Closed(Sphere {
    radius: 5.0.try_into()?,
});

let scaled_sphere = sphere.scale_length(0.5.try_into()?);

assert_eq!(scaled_sphere.0.radius.get(), 2.5);
Source§

fn scale_volume(&self, v: PositiveReal) -> Self

Scale the wrapped shape.

§Example
use hoomd_geometry::{Scale, shape::Rectangle};
use hoomd_microstate::boundary::Closed;

let closed = Closed(Rectangle::with_equal_edges(10.0.try_into()?));

let scaled_closed = closed.scale_volume(4.0.try_into()?);

assert_eq!(scaled_closed.0.edge_lengths[0].get(), 20.0);
Source§

impl<T> Serialize for Closed<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Volume for Closed<T>
where T: Volume,

Source§

fn volume(&self) -> f64

Volume of the wrapped shape.

§Examples
use hoomd_geometry::{Volume, shape::Rectangle};
use hoomd_microstate::boundary::Closed;

let closed = Closed(Rectangle::with_equal_edges(10.0.try_into()?));

let volume = closed.volume();

assert_eq!(volume, 100.0);
Source§

impl<BS, T, P> Wrap<BS> for Closed<T>
where BS: Position<Position = P>, T: IsPointInside<P>,

Source§

fn wrap(&self, properties: BS) -> Result<BS, Error>

Transform body/point properties into the boundary. Read more
Source§

impl<T> StructuralPartialEq for Closed<T>

Auto Trait Implementations§

§

impl<T> Freeze for Closed<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Closed<T>
where T: RefUnwindSafe,

§

impl<T> Send for Closed<T>
where T: Send,

§

impl<T> Sync for Closed<T>
where T: Sync,

§

impl<T> Unpin for Closed<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Closed<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Closed<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,