sim: fold most accessors behind the meta method

This commit is contained in:
2022-07-28 16:25:39 -07:00
parent 0465e3d7f5
commit a49d9cd7a4
3 changed files with 29 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
use crate::geom::{Coord, Cube, Index, InvertedRegion, Meters, Region};
use crate::cross::mat::Vacuum;
use crate::cross::real::Real;
use crate::cross::step::SimMeta;
use crate::cross::vec::{Vec3, Vec3u};
use crate::stim::{AbstractStimulus, NoopStimulus};
use rayon::prelude::*;
@@ -292,9 +293,18 @@ impl<'a> dyn SampleableSim + 'a {
// TODO: the Send/Sync bounds here could be removed with some refactoring
pub trait SampleableSim: Send + Sync {
fn sample(&self, pos: Meters) -> Sample;
fn meta(&self) -> SimMeta<f32>;
fn step_no(&self) -> u64;
fn size(&self) -> Index;
fn feature_size(&self) -> f32;
/// Take a "snapshot" of the simulation, dropping all material-specific information.
fn to_static(&self) -> StaticSim;
fn size(&self) -> Index {
Index(self.meta().dim)
}
fn feature_size(&self) -> f32 {
self.meta().feature_size
}
fn feature_volume(&self) -> f32 {
let f = self.feature_size();
f*f*f
@@ -303,9 +313,9 @@ pub trait SampleableSim: Send + Sync {
let s = self.size().to_meters(self.feature_size());
s.x() * s.y() * s.z()
}
fn timestep(&self) -> f32;
fn step_no(&self) -> u64;
fn timestep(&self) -> f32 {
self.meta().time_step
}
fn width(&self) -> u32 {
self.size().x()
@@ -319,7 +329,4 @@ pub trait SampleableSim: Send + Sync {
fn time(&self) -> f32 {
self.timestep() * self.step_no() as f32
}
/// Take a "snapshot" of the simulation, dropping all material-specific information.
fn to_static(&self) -> StaticSim;
}