use crate::gridder::ExtrapolationPolicy;
use crate::model::builder::WellTie;
use crate::model::model::Georef;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
pub enum TieMethod {
#[default]
Replace,
Radius {
radius_m: f64,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Default, Serialize, Deserialize)]
pub struct TieSettings {
pub method: TieMethod,
}
impl TieSettings {
#[must_use]
pub fn replace() -> Self {
Self {
method: TieMethod::Replace,
}
}
#[must_use]
pub fn radius(radius_m: f64) -> Self {
Self {
method: TieMethod::Radius { radius_m },
}
}
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(default)]
pub struct BuildSpec {
pub inputs_ref: Option<String>,
pub georef: Option<Georef>,
pub boundary: Option<Vec<[f64; 2]>>,
pub extrapolation: ExtrapolationPolicy,
pub clamp_base_to_top: bool,
pub min_thickness_m: Option<f64>,
pub collapse_below_m: Option<f64>,
pub sugar_cube: bool,
pub sw_gas: Option<f64>,
pub well_ties: Vec<WellTie>,
pub ties: TieSettings,
}
impl BuildSpec {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub fn with_inputs_ref(mut self, inputs_ref: impl Into<String>) -> Self {
self.inputs_ref = Some(inputs_ref.into());
self
}
#[must_use]
pub fn with_georef(
mut self,
origin_x: f64,
origin_y: f64,
spacing_x: f64,
spacing_y: f64,
) -> Self {
self.georef = Georef::new(origin_x, origin_y, spacing_x, spacing_y);
self
}
#[must_use]
pub fn with_boundary(mut self, ring: Vec<[f64; 2]>) -> Self {
self.boundary = if ring.is_empty() { None } else { Some(ring) };
self
}
#[must_use]
pub fn with_extrapolation(mut self, policy: ExtrapolationPolicy) -> Self {
self.extrapolation = policy;
self
}
#[must_use]
pub fn with_clamp_base_to_top(mut self, clamp: bool) -> Self {
self.clamp_base_to_top = clamp;
self
}
#[must_use]
pub fn with_min_thickness_m(mut self, min_thickness_m: f64) -> Self {
self.min_thickness_m = Some(min_thickness_m);
self
}
#[must_use]
pub fn with_collapse_below_m(mut self, collapse_below_m: f64) -> Self {
self.collapse_below_m = Some(collapse_below_m);
self
}
#[must_use]
pub fn with_sugar_cube(mut self, sugar_cube: bool) -> Self {
self.sugar_cube = sugar_cube;
self
}
#[must_use]
pub fn with_sw_gas(mut self, sw_gas: f64) -> Self {
self.sw_gas = Some(sw_gas);
self
}
#[must_use]
pub fn with_well_ties(mut self, ties: Vec<WellTie>) -> Self {
self.well_ties = ties;
self
}
#[must_use]
pub fn with_tie_settings(mut self, ties: TieSettings) -> Self {
self.ties = ties;
self
}
}