use gmt_dos_clients_fem::{DiscreteStateSpace, StateSpaceError, solvers::ExponentialMatrix};
use gmt_dos_clients_windloads::{CfdLoads, FOH};
use super::Include;
#[derive(Debug, Clone)]
pub enum WindLoaded {
Mount,
M1,
M2,
None,
}
#[derive(Debug, Clone)]
pub struct WindLoads {
mount: WindLoaded,
m1: WindLoaded,
m2: WindLoaded,
pub(crate) cfd_loads: Option<CfdLoads<FOH>>,
}
impl Default for WindLoads {
fn default() -> Self {
Self {
mount: WindLoaded::Mount,
m1: WindLoaded::M1,
m2: WindLoaded::M2,
cfd_loads: None,
}
}
}
impl From<CfdLoads<FOH>> for WindLoads {
fn from(value: CfdLoads<FOH>) -> Self {
Self::new(value)
}
}
impl WindLoads {
pub fn new(cfd_loads: CfdLoads<FOH>) -> Self {
Self {
cfd_loads: Some(cfd_loads),
..Default::default()
}
}
pub fn no_mount(mut self) -> Self {
self.mount = WindLoaded::None;
self
}
pub fn no_m1(mut self) -> Self {
self.m1 = WindLoaded::None;
self
}
pub fn no_m2(mut self) -> Self {
self.m2 = WindLoaded::None;
self
}
}
impl<'a> Include<'a, WindLoads> for DiscreteStateSpace<'a, ExponentialMatrix> {
fn including(self, wind_loads: Option<&'a mut WindLoads>) -> Result<Self, StateSpaceError> {
let Some(wind_loads) = wind_loads else {
return Ok(self);
};
let mut state_space = self;
#[cfg(cfd2021)]
if let WindLoaded::Mount = wind_loads.mount {
state_space = state_space.ins::<gmt_dos_clients_io::gmt_fem::inputs::CFD2021106F>();
}
#[cfg(cfd2025)]
if let WindLoaded::Mount = wind_loads.mount {
state_space = state_space.ins::<gmt_dos_clients_io::gmt_fem::inputs::CFD2025046F>();
}
if let WindLoaded::M1 = wind_loads.m1 {
state_space = state_space.ins::<gmt_dos_clients_io::gmt_fem::inputs::OSSM1Lcl6F>();
}
if let WindLoaded::M2 = wind_loads.m2 {
state_space = state_space.ins::<gmt_dos_clients_io::gmt_fem::inputs::MCM2Lcl6F>();
}
Ok(state_space)
}
}