add a to_generic method to the AbstractSim trait

This commit is contained in:
2022-07-29 13:11:16 -07:00
parent 02920f9bd3
commit 95ffb73fe3
3 changed files with 27 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
use crate::geom::{Coord, Cube, Index, InvertedRegion, Meters, Region};
use crate::cross::mat::Vacuum;
use crate::cross::mat::{FullyGenericMaterial, Vacuum};
use crate::cross::real::Real;
use crate::cross::step::SimMeta;
use crate::cross::vec::{Vec3, Vec3u};
@@ -15,6 +15,7 @@ pub mod units;
use spirv::{CpuBackend, SpirvSim};
pub type StaticSim = SpirvSim<f32, Vacuum, CpuBackend>;
pub type GenericSim<R> = SpirvSim<R, FullyGenericMaterial<R>, CpuBackend>;
/// Conceptually, one cell looks like this (in 2d):
@@ -109,6 +110,7 @@ impl<R: Real> CellStateWithM<R> {
// TODO: the Sync bound here could be removed with some refactoring
pub trait AbstractSim: Sync {
type Real;
type Material;
fn meta(&self) -> SimMeta<f32>;
fn step_no(&self) -> u64;
@@ -117,6 +119,8 @@ pub trait AbstractSim: Sync {
/// Take a "snapshot" of the simulation, dropping all material-specific information.
fn to_static(&self) -> StaticSim;
fn to_generic(&self) -> GenericSim<Self::Real>;
fn put_material<C: Coord, M: Into<Self::Material>>(&mut self, pos: C, mat: M);
fn get_material<C: Coord>(&self, pos: C) -> &Self::Material;