read config from json

This commit is contained in:
Magnus Ulimoen
2020-04-02 21:36:56 +02:00
parent c1895a6c33
commit d80a9bfa6d
5 changed files with 126 additions and 83 deletions

View File

@@ -577,17 +577,17 @@ pub struct BoundaryTerms<'a> {
#[derive(Clone, Debug)]
pub enum BoundaryCharacteristic {
This,
// Grid(usize),
Grid(usize),
Vortex(VortexParameters),
// Vortices(Vec<VortexParameters>),
}
#[derive(Clone, Debug)]
pub struct BoundaryCharacteristics {
north: BoundaryCharacteristic,
south: BoundaryCharacteristic,
east: BoundaryCharacteristic,
west: BoundaryCharacteristic,
pub north: BoundaryCharacteristic,
pub south: BoundaryCharacteristic,
pub east: BoundaryCharacteristic,
pub west: BoundaryCharacteristic,
}
fn boundary_extractor<'a, SBP: SbpOperator>(
@@ -599,18 +599,22 @@ fn boundary_extractor<'a, SBP: SbpOperator>(
north: match bc.north {
BoundaryCharacteristic::This => field.south(),
BoundaryCharacteristic::Vortex(_params) => todo!(),
BoundaryCharacteristic::Grid(_) => panic!("Only working on self grid"),
},
south: match bc.south {
BoundaryCharacteristic::This => field.north(),
BoundaryCharacteristic::Vortex(_params) => todo!(),
BoundaryCharacteristic::Grid(_) => panic!("Only working on self grid"),
},
west: match bc.west {
BoundaryCharacteristic::This => field.east(),
BoundaryCharacteristic::Vortex(_params) => todo!(),
BoundaryCharacteristic::Grid(_) => panic!("Only working on self grid"),
},
east: match bc.east {
BoundaryCharacteristic::This => field.west(),
BoundaryCharacteristic::Vortex(_params) => todo!(),
BoundaryCharacteristic::Grid(_) => panic!("Only working on self grid"),
},
}
}

View File

@@ -27,7 +27,7 @@ pub struct SimpleGrid {
/// Optional parameters:
/// * name (for relating boundaries)
/// * dir{e,w,n,s} (for boundary terms)
pub fn json_to_grids(json: &str) -> Result<Vec<SimpleGrid>, String> {
pub fn json_to_grids(json: json::JsonValue) -> Result<Vec<SimpleGrid>, String> {
use json::JsonValue;
fn json_to_grid(mut grid: JsonValue) -> Result<SimpleGrid, String> {
#[derive(Debug)]
@@ -184,9 +184,7 @@ pub fn json_to_grids(json: &str) -> Result<Vec<SimpleGrid>, String> {
})
}
let js = json::parse(&json).map_err(|e| format!("{}", e))?;
match js {
match json {
JsonValue::Array(a) => a
.into_iter()
.map(|g| json_to_grid(g))