rename Stimulus -> RegionGated

This commit is contained in:
2022-08-18 15:22:28 -07:00
parent eb406ea46f
commit 60e44d6d4d
2 changed files with 8 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ use coremem::{mat, Driver};
use coremem::geom::{Coord as _, Cube, Index}; use coremem::geom::{Coord as _, Cube, Index};
use coremem::units::Seconds; use coremem::units::Seconds;
use coremem::sim::spirv::{self, SpirvSim}; use coremem::sim::spirv::{self, SpirvSim};
use coremem::stim::{Stimulus, TimeVarying as _, UniformStimulus}; use coremem::stim::{RegionGated, TimeVarying as _, UniformStimulus};
use coremem::cross::vec::Vec3; use coremem::cross::vec::Vec3;
type Mat = mat::FullyGenericMaterial<f32>; type Mat = mat::FullyGenericMaterial<f32>;
@@ -46,7 +46,7 @@ fn main() {
Index::new(201, height*3/4, 1).to_meters(feature_size), Index::new(201, height*3/4, 1).to_meters(feature_size),
); );
// emit a constant E/H delta over this region for 100 femtoseconds // emit a constant E/H delta over this region for 100 femtoseconds
let stim = Stimulus::new( let stim = RegionGated::new(
center_region, center_region,
UniformStimulus::new( UniformStimulus::new(
Vec3::new(2e19, 0.0, 0.0), // E field (per second) Vec3::new(2e19, 0.0, 0.0), // E field (per second)

View File

@@ -224,23 +224,23 @@ impl AbstractStimulus for RngStimulus {
/// Apply a time-varying stimulus uniformly across some region /// Apply a time-varying stimulus uniformly across some region
#[derive(Clone)] #[derive(Clone)]
pub struct Stimulus<R, T> { pub struct RegionGated<R, S> {
region: R, region: R,
stim: T, stim: S,
} }
impl<R, T> Stimulus<R, T> { impl<R, S> RegionGated<R, S> {
pub fn new(region: R, stim: T) -> Self { pub fn new(region: R, stim: S) -> Self {
Self { Self {
region, stim region, stim
} }
} }
} }
impl<R: Region + Sync, T: TimeVarying3 + Sync> AbstractStimulus for Stimulus<R, T> { impl<R: Region + Sync, S: AbstractStimulus + Sync> AbstractStimulus for RegionGated<R, S> {
fn at(&self, t_sec: f32, pos: Meters) -> Fields { fn at(&self, t_sec: f32, pos: Meters) -> Fields {
if self.region.contains(pos) { if self.region.contains(pos) {
self.stim.at(t_sec) self.stim.at(t_sec, pos)
} else { } else {
Fields::default() Fields::default()
} }