Introduce precursor system
This commit is contained in:
parent
95897777d6
commit
26159d5ffb
|
@ -9,7 +9,6 @@ mod parsing;
|
||||||
use file::*;
|
use file::*;
|
||||||
mod eval;
|
mod eval;
|
||||||
mod system;
|
mod system;
|
||||||
use system::*;
|
|
||||||
|
|
||||||
#[derive(Debug, FromArgs)]
|
#[derive(Debug, FromArgs)]
|
||||||
/// Options for configuring and running the solver
|
/// Options for configuring and running the solver
|
||||||
|
@ -77,35 +76,22 @@ fn main() {
|
||||||
let parsing::RuntimeConfiguration {
|
let parsing::RuntimeConfiguration {
|
||||||
names,
|
names,
|
||||||
grids,
|
grids,
|
||||||
grid_connections,
|
boundary_conditions,
|
||||||
op: operators,
|
op: operators,
|
||||||
integration_time,
|
integration_time,
|
||||||
initial_conditions,
|
initial_conditions,
|
||||||
boundary_conditions: _,
|
|
||||||
} = config.into_runtime();
|
} = config.into_runtime();
|
||||||
|
|
||||||
let mut sys = System::new(grids, grid_connections, operators);
|
let basesystem = system::BaseSystem::new(
|
||||||
match &initial_conditions {
|
names.clone(),
|
||||||
/*
|
grids,
|
||||||
parsing::InitialConditions::File(f) => {
|
0.0,
|
||||||
for grid in &sys.grids {
|
operators,
|
||||||
// Copy initial conditions from file, requires name of field
|
boundary_conditions,
|
||||||
todo!()
|
initial_conditions.clone(),
|
||||||
}
|
);
|
||||||
}
|
let mut sys = basesystem.create();
|
||||||
*/
|
// System::new(grids, grid_connections, operators);
|
||||||
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 dt = sys.max_dt();
|
let dt = sys.max_dt();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub enum InitialConditions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum BoundaryConditions {
|
enum BoundaryConditions {
|
||||||
Vortex(euler::VortexParameters),
|
Vortex(euler::VortexParameters),
|
||||||
Expressions(std::sync::Arc<eval::Evaluator>),
|
Expressions(std::sync::Arc<eval::Evaluator>),
|
||||||
NotNeeded,
|
NotNeeded,
|
||||||
|
@ -36,11 +36,10 @@ pub enum BoundaryConditions {
|
||||||
pub struct RuntimeConfiguration {
|
pub struct RuntimeConfiguration {
|
||||||
pub names: Vec<String>,
|
pub names: Vec<String>,
|
||||||
pub grids: Vec<sbp::grid::Grid>,
|
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 op: Vec<Box<dyn SbpOperator2d>>,
|
||||||
pub integration_time: Float,
|
pub integration_time: Float,
|
||||||
pub initial_conditions: InitialConditions,
|
pub initial_conditions: InitialConditions,
|
||||||
pub boundary_conditions: BoundaryConditions,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl input::Configuration {
|
impl input::Configuration {
|
||||||
|
@ -165,7 +164,7 @@ impl input::Configuration {
|
||||||
Box::new((matcher(eta), matcher(xi))) as Box<dyn SbpOperator2d>
|
Box::new((matcher(eta), matcher(xi))) as Box<dyn SbpOperator2d>
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let grid_connections = self
|
let boundary_conditions = self
|
||||||
.grids
|
.grids
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, g)| {
|
.map(|(name, g)| {
|
||||||
|
@ -226,11 +225,10 @@ impl input::Configuration {
|
||||||
RuntimeConfiguration {
|
RuntimeConfiguration {
|
||||||
names,
|
names,
|
||||||
grids,
|
grids,
|
||||||
grid_connections,
|
boundary_conditions,
|
||||||
op,
|
op,
|
||||||
integration_time: self.integration_time,
|
integration_time: self.integration_time,
|
||||||
initial_conditions,
|
initial_conditions,
|
||||||
boundary_conditions,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::parsing;
|
||||||
use crate::utils::Direction;
|
use crate::utils::Direction;
|
||||||
use crossbeam_channel::{Receiver, Select, Sender};
|
use crossbeam_channel::{Receiver, Select, Sender};
|
||||||
use euler::{
|
use euler::{
|
||||||
|
@ -10,6 +11,60 @@ use sbp::operators::{InterpolationOperator, SbpOperator2d};
|
||||||
use sbp::*;
|
use sbp::*;
|
||||||
use std::sync::{Arc, Barrier};
|
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 struct System {
|
||||||
pub fnow: Vec<euler::Field>,
|
pub fnow: Vec<euler::Field>,
|
||||||
pub fnext: Vec<euler::Field>,
|
pub fnext: Vec<euler::Field>,
|
||||||
|
|
Loading…
Reference in New Issue