AbstractMeasurement: remove the serde typetag stuff
This commit is contained in:
@@ -8,7 +8,6 @@ use serde::{Serialize, Deserialize};
|
||||
|
||||
// TODO: remove this Clone and Send requirement? Have Measurements be shared by-reference across
|
||||
// threads? i.e. Sync, and no Clone
|
||||
#[typetag::serde(tag = "type")]
|
||||
pub trait AbstractMeasurement: Send + Sync + DynClone {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String;
|
||||
fn key_value(&self, state: &dyn GenericSim) -> IndexMap<String, String>;
|
||||
@@ -34,7 +33,6 @@ pub fn eval_to_vec(state: &dyn GenericSim, meas: &[&dyn AbstractMeasurement]) ->
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Time;
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Time {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
format!("{:.3e}s (step {})", state.time(), state.step_no())
|
||||
@@ -50,7 +48,6 @@ impl AbstractMeasurement for Time {
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Meta;
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Meta {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
format!("{}x{}x{} feat: {:.1e}m", state.width(), state.height(), state.depth(), state.feature_size())
|
||||
@@ -77,7 +74,6 @@ impl Evaluated {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Evaluated {
|
||||
fn eval(&self, _state: &dyn GenericSim) -> String {
|
||||
self.1.clone()
|
||||
@@ -110,7 +106,6 @@ impl Volume {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Volume {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
format!("Vol({}): {:.2e} um^3",
|
||||
@@ -194,7 +189,6 @@ impl std::iter::Sum for FieldSamples<[FieldSample; 3]> {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Current {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let (mean_current_mag, mean_current_vec) = self.data(state);
|
||||
@@ -242,7 +236,6 @@ impl CurrentLoop {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for CurrentLoop {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let cross_sectional_current = self.data(state);
|
||||
@@ -311,7 +304,6 @@ impl MagneticLoop {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for MagneticLoop {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let (mean_directed_m, mean_directed_b, mean_directed_h) = self.data(state);
|
||||
@@ -357,7 +349,6 @@ impl MagneticFlux {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for MagneticFlux {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let mean_mag = self.data(state);
|
||||
@@ -396,7 +387,6 @@ impl Magnetization {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Magnetization {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let mean_mag = self.data(state);
|
||||
@@ -418,7 +408,6 @@ fn loc(v: Meters) -> String {
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct MagnetizationAt(pub Meters);
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for MagnetizationAt {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let m = state.sample(self.0).m();
|
||||
@@ -436,7 +425,6 @@ impl AbstractMeasurement for MagnetizationAt {
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct MagneticFluxAt(pub Meters);
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for MagneticFluxAt {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let b = state.sample(self.0).b();
|
||||
@@ -454,7 +442,6 @@ impl AbstractMeasurement for MagneticFluxAt {
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct MagneticStrengthAt(pub Meters);
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for MagneticStrengthAt {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let h = state.sample(self.0).h();
|
||||
@@ -471,7 +458,6 @@ impl AbstractMeasurement for MagneticStrengthAt {
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct ElectricField(pub Meters);
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for ElectricField {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let e = state.sample(self.0).e();
|
||||
@@ -518,7 +504,6 @@ impl Energy {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Energy {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let e = self.data(state);
|
||||
@@ -560,7 +545,6 @@ impl Power {
|
||||
}
|
||||
}
|
||||
|
||||
#[typetag::serde]
|
||||
impl AbstractMeasurement for Power {
|
||||
fn eval(&self, state: &dyn GenericSim) -> String {
|
||||
let power = self.data(state);
|
||||
|
Reference in New Issue
Block a user