use crate::CfdScalar;
use crate::solvers::dec::BoundaryZone;
use crate::types::flow::{
CompressibleMarchRun, DuctMarchRun, MarchPipeline, PhysicsStage, QttMarchRun, Report,
};
use crate::types::flow_config::{CompressibleMarchConfig, DuctConfig, MarchConfig, QttMarchConfig};
use deep_causality_algebra::ConjugateScalar;
use deep_causality_physics::PhysicsError;
pub trait MarchDispatch<R: CfdScalar> {
type Pipeline<'c>
where
Self: 'c;
fn pipeline(&self) -> Self::Pipeline<'_>;
}
impl<const D: usize, R, Z, C> MarchDispatch<R> for MarchConfig<D, R, Z, C>
where
R: CfdScalar,
Z: BoundaryZone<D, R>,
C: PhysicsStage<D, R>,
{
type Pipeline<'c>
= MarchPipeline<'c, D, R, Z, C>
where
Self: 'c;
fn pipeline(&self) -> Self::Pipeline<'_> {
MarchPipeline::new(self)
}
}
impl<R: CfdScalar> MarchDispatch<R> for DuctConfig<R> {
type Pipeline<'c>
= DuctMarchRun<'c, R>
where
Self: 'c;
fn pipeline(&self) -> Self::Pipeline<'_> {
DuctMarchRun::new(self)
}
}
impl<R> MarchDispatch<R> for QttMarchConfig<R>
where
R: CfdScalar + ConjugateScalar<Real = R>,
{
type Pipeline<'c>
= QttMarchRun<'c, R>
where
Self: 'c;
fn pipeline(&self) -> Self::Pipeline<'_> {
QttMarchRun::new(self)
}
}
impl<R> MarchDispatch<R> for CompressibleMarchConfig<R>
where
R: CfdScalar + ConjugateScalar<Real = R>,
{
type Pipeline<'c>
= CompressibleMarchRun<'c, R>
where
Self: 'c;
fn pipeline(&self) -> Self::Pipeline<'_> {
CompressibleMarchRun::new(self)
}
}
#[cfg(feature = "std")]
impl<R> MarchDispatch<R> for crate::types::flow_config::UncertainMarchConfig<R>
where
R: CfdScalar + deep_causality_uncertain::ProbabilisticType,
{
type Pipeline<'c>
= crate::types::flow::UncertainMarchPipeline<'c, R>
where
Self: 'c;
fn pipeline(&self) -> Self::Pipeline<'_> {
crate::types::flow::UncertainMarchPipeline::new(self)
}
}
pub trait Marchable<R: CfdScalar> {
fn march(&self) -> Result<Report<R>, PhysicsError>;
}
impl<R: CfdScalar> Marchable<R> for DuctConfig<R> {
fn march(&self) -> Result<Report<R>, PhysicsError> {
DuctMarchRun::new(self).run()
}
}
impl<const D: usize, R, Z, C> Marchable<R> for MarchConfig<D, R, Z, C>
where
R: CfdScalar,
Z: BoundaryZone<D, R> + Clone,
C: PhysicsStage<D, R>,
{
fn march(&self) -> Result<Report<R>, PhysicsError> {
MarchPipeline::new(self).run_owned()
}
}
impl<R> Marchable<R> for QttMarchConfig<R>
where
R: CfdScalar + ConjugateScalar<Real = R>,
{
fn march(&self) -> Result<Report<R>, PhysicsError> {
QttMarchRun::new(self).run()
}
}