SummationByParts/multigrid/src/eval.rs

35 lines
863 B
Rust
Raw Normal View History

2021-07-01 16:37:22 +00:00
use ndarray::{ArrayView, ArrayViewMut, Dimension};
use sbp::Float;
use std::convert::{TryFrom, TryInto};
2021-07-01 16:37:22 +00:00
pub mod evalexpr;
#[derive(Clone, Debug)]
pub enum Evaluator {
2021-07-01 16:37:22 +00:00
EvalExpr(evalexpr::Evaluator),
}
2021-07-01 16:37:22 +00:00
impl<D: Dimension> euler::eval::Evaluator<D> for Evaluator {
fn evaluate(
&self,
t: Float,
x: ArrayView<Float, D>,
y: ArrayView<Float, D>,
rho: ArrayViewMut<Float, D>,
rhou: ArrayViewMut<Float, D>,
rhov: ArrayViewMut<Float, D>,
e: ArrayViewMut<Float, D>,
) {
match self {
2021-07-01 16:37:22 +00:00
Self::EvalExpr(c) => c.evaluate(t, x, y, rho, rhou, rhov, e),
}
}
}
impl TryFrom<crate::input::Expressions> for Evaluator {
type Error = ();
fn try_from(expr: crate::input::Expressions) -> Result<Self, Self::Error> {
Ok(Self::EvalExpr(expr.try_into()?))
}
}