2021-07-01 16:37:22 +00:00
|
|
|
use ndarray::{ArrayView, ArrayViewMut, Dimension};
|
2021-06-29 15:55:19 +00:00
|
|
|
use sbp::Float;
|
2021-07-01 16:47:56 +00:00
|
|
|
use std::convert::{TryFrom, TryInto};
|
2021-06-29 15:55:19 +00:00
|
|
|
|
2021-07-01 16:37:22 +00:00
|
|
|
pub mod evalexpr;
|
|
|
|
|
2021-06-29 15:55:19 +00:00
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub enum Evaluator {
|
2021-07-01 16:37:22 +00:00
|
|
|
EvalExpr(evalexpr::Evaluator),
|
2021-06-29 15:55:19 +00:00
|
|
|
}
|
|
|
|
|
2021-07-01 16:37:22 +00:00
|
|
|
impl<D: Dimension> euler::eval::Evaluator<D> for Evaluator {
|
2021-06-29 15:55:19 +00:00
|
|
|
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),
|
2021-06-29 15:55:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-01 16:47:56 +00:00
|
|
|
|
|
|
|
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()?))
|
|
|
|
}
|
|
|
|
}
|