rename CellStateWithM => Fields; parameterize Sample over R

This commit is contained in:
2022-07-29 14:55:12 -07:00
parent 7e452f508f
commit 895c87869b
3 changed files with 21 additions and 24 deletions

View File

@@ -81,19 +81,29 @@ pub type GenericSim<R> = SpirvSim<R, FullyGenericMaterial<R>, CpuBackend>;
/// +------------+------------+
///
#[derive(Clone, Default, Serialize, Deserialize)]
pub struct Sample {
state: CellStateWithM<f32>,
conductivity: Vec3<f32>,
pub struct Sample<R=f32> {
state: Fields<R>,
conductivity: Vec3<R>,
}
#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct CellStateWithM<R> {
pub struct Fields<R> {
e: Vec3<R>,
h: Vec3<R>,
m: Vec3<R>,
}
impl<R: Real> CellStateWithM<R> {
impl<R: Real> Fields<R> {
pub fn new(e: Vec3<R>, h: Vec3<R>, m: Vec3<R>) -> Self {
Self { e, h, m }
}
pub fn cast<R2: Real>(&self) -> Fields<R2> {
Fields {
e: self.e.cast(),
h: self.h.cast(),
m: self.m.cast(),
}
}
pub fn e(&self) -> Vec3<R> {
self.e
}