Introduce precursor system

This commit is contained in:
Magnus Ulimoen 2021-08-05 19:28:14 +00:00
parent 95897777d6
commit 26159d5ffb
3 changed files with 70 additions and 31 deletions

View File

@ -9,7 +9,6 @@ mod parsing;
use file::*;
mod eval;
mod system;
use system::*;
#[derive(Debug, FromArgs)]
/// Options for configuring and running the solver
@ -77,35 +76,22 @@ fn main() {
let parsing::RuntimeConfiguration {
names,
grids,
grid_connections,
boundary_conditions,
op: operators,
integration_time,
initial_conditions,
boundary_conditions: _,
} = config.into_runtime();
let mut sys = System::new(grids, grid_connections, operators);
match &initial_conditions {
/*
parsing::InitialConditions::File(f) => {
for grid in &sys.grids {
// Copy initial conditions from file, requires name of field
todo!()
}
}
*/
parsing::InitialConditions::Vortex(vortexparams) => sys.vortex(0.0, &vortexparams),
parsing::InitialConditions::Expressions(expr) => {
let t = 0.0;
for (grid, field) in sys.grids.iter().zip(sys.fnow.iter_mut()) {
// Evaluate the expressions on all variables
let x = grid.x();
let y = grid.y();
let (rho, rhou, rhov, e) = field.components_mut();
(*expr).evaluate(t, x, y, rho, rhou, rhov, e);
}
}
}
let basesystem = system::BaseSystem::new(
names.clone(),
grids,
0.0,
operators,
boundary_conditions,
initial_conditions.clone(),
);
let mut sys = basesystem.create();
// System::new(grids, grid_connections, operators);
let dt = sys.max_dt();

View File

@ -27,7 +27,7 @@ pub enum InitialConditions {
}
#[derive(Clone, Debug)]
pub enum BoundaryConditions {
enum BoundaryConditions {
Vortex(euler::VortexParameters),
Expressions(std::sync::Arc<eval::Evaluator>),
NotNeeded,
@ -36,11 +36,10 @@ pub enum BoundaryConditions {
pub struct RuntimeConfiguration {
pub names: Vec<String>,
pub grids: Vec<sbp::grid::Grid>,
pub grid_connections: Vec<euler::BoundaryCharacteristics>,
pub boundary_conditions: Vec<euler::BoundaryCharacteristics>,
pub op: Vec<Box<dyn SbpOperator2d>>,
pub integration_time: Float,
pub initial_conditions: InitialConditions,
pub boundary_conditions: BoundaryConditions,
}
impl input::Configuration {
@ -165,7 +164,7 @@ impl input::Configuration {
Box::new((matcher(eta), matcher(xi))) as Box<dyn SbpOperator2d>
})
.collect();
let grid_connections = self
let boundary_conditions = self
.grids
.iter()
.map(|(name, g)| {
@ -226,11 +225,10 @@ impl input::Configuration {
RuntimeConfiguration {
names,
grids,
grid_connections,
boundary_conditions,
op,
integration_time: self.integration_time,
initial_conditions,
boundary_conditions,
}
}
}

View File

@ -1,3 +1,4 @@
use crate::parsing;
use crate::utils::Direction;
use crossbeam_channel::{Receiver, Select, Sender};
use euler::{
@ -10,6 +11,60 @@ use sbp::operators::{InterpolationOperator, SbpOperator2d};
use sbp::*;
use std::sync::{Arc, Barrier};
pub struct BaseSystem {
pub names: Vec<String>,
pub grids: Vec<grid::Grid>,
pub time: Float,
pub boundary_conditions: Vec<euler::BoundaryCharacteristics>,
pub initial_conditions: crate::parsing::InitialConditions,
pub operators: Vec<Box<dyn SbpOperator2d>>,
}
impl BaseSystem {
pub fn new(
names: Vec<String>,
grids: Vec<grid::Grid>,
time: Float,
operators: Vec<Box<dyn SbpOperator2d>>,
boundary_conditions: Vec<euler::BoundaryCharacteristics>,
initial_conditions: crate::parsing::InitialConditions,
) -> Self {
Self {
names,
grids,
time,
boundary_conditions,
initial_conditions,
operators,
}
}
pub fn create(self) -> System {
let mut sys = System::new(self.grids, self.boundary_conditions, self.operators);
match &self.initial_conditions {
/*
parsing::InitialConditions::File(f) => {
for grid in &sys.grids {
// Copy initial conditions from file, requires name of field
todo!()
}
}
*/
parsing::InitialConditions::Vortex(vortexparams) => sys.vortex(0.0, &vortexparams),
parsing::InitialConditions::Expressions(expr) => {
let t = 0.0;
for (grid, field) in sys.grids.iter().zip(sys.fnow.iter_mut()) {
// Evaluate the expressions on all variables
let x = grid.x();
let y = grid.y();
let (rho, rhou, rhov, e) = field.components_mut();
(*expr).evaluate(t, x, y, rho, rhou, rhov, e);
}
}
}
sys
}
}
pub struct System {
pub fnow: Vec<euler::Field>,
pub fnext: Vec<euler::Field>,