Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use geo::{Polygon, LineString, Point, point, Closest};
use geo::algorithm::closest_point::ClosestPoint;

///Trait for a Geometry object - all forms of geometry must implement these traits to be used
pub trait Geometry: GeometryInput {
pub trait Geometry {

type InputFileFormat: InputFile + Clone;

Expand Down Expand Up @@ -45,15 +45,11 @@ pub struct Mesh0D {
pub energy_barrier_thickness: f64,
}

impl GeometryInput for Mesh0D {
type GeometryInput = Mesh0DInput;
}

impl Geometry for Mesh0D {

type InputFileFormat = Input0D;

fn new(input: &<Self as GeometryInput>::GeometryInput) -> Mesh0D {
fn new(input: &<<Self as Geometry>::InputFileFormat as GeometryInput>::GeometryInput) -> Mesh0D {

let length_unit: f64 = match input.length_unit.as_str() {
"MICRON" => MICRON,
Expand Down Expand Up @@ -139,10 +135,6 @@ pub struct Mesh1D {
pub bottom_energy_barrier_thickness: f64,
}

impl GeometryInput for Mesh1D {
type GeometryInput = Mesh1DInput;
}

impl Geometry for Mesh1D {

type InputFileFormat = input::Input1D;
Expand Down Expand Up @@ -326,16 +318,12 @@ impl Mesh2D {
}
}

impl GeometryInput for Mesh2D {
type GeometryInput = Mesh2DInput;
}

impl Geometry for Mesh2D {

type InputFileFormat = Input2D;

/// Constructor for Mesh2D object from geometry_input.
fn new(geometry_input: &<Self as GeometryInput>::GeometryInput) -> Mesh2D {
fn new(geometry_input: &<<Self as Geometry>::InputFileFormat as GeometryInput>::GeometryInput) -> Mesh2D {

let triangles = geometry_input.triangles.clone();
let material_boundary_points = geometry_input.material_boundary_points.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub struct Options {
}

pub fn input<T: Geometry>(input_file: String) -> (Vec<particle::ParticleInput>, material::Material<T>, Options, OutputUnits)
where <T as Geometry>::InputFileFormat: Deserialize<'static> + 'static, <T as GeometryInput>::GeometryInput: Clone {
where <T as Geometry>::InputFileFormat: Deserialize<'static> + 'static {

//Read input file, convert to string, and open with toml
let mut input_toml = String::new();
Expand Down
2 changes: 1 addition & 1 deletion src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Material<T: Geometry> {
pub surface_binding_model: SurfaceBindingModel,
pub bulk_binding_model: BulkBindingModel
}
impl <T: Geometry + GeometryInput> Material<T> {
impl <T: Geometry> Material<T> {

pub fn new(material_parameters: &MaterialParameters, geometry_input: &<<T as Geometry>::InputFileFormat as GeometryInput>::GeometryInput) -> Material<T> {

Expand Down
16 changes: 4 additions & 12 deletions src/parry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ pub struct InputParryBall {
pub geometry_input: ParryBallInput,
}

impl GeometryInput for InputParryBall {
type GeometryInput = ParryBallInput;
}

impl InputFile for InputParryBall {

fn new(string: &str) -> InputParryBall {
Expand Down Expand Up @@ -54,15 +50,15 @@ pub struct ParryBall {
pub ball: Ball,
}

impl GeometryInput for ParryBall {
impl GeometryInput for InputParryBall {
type GeometryInput = ParryBallInput;
}

impl Geometry for ParryBall {

type InputFileFormat = InputParryBall;

fn new(input: &<Self as GeometryInput>::GeometryInput) -> ParryBall {
fn new(input: &<<Self as Geometry>::InputFileFormat as GeometryInput>::GeometryInput) -> ParryBall {

let length_unit: f64 = match input.length_unit.as_str() {
"MICRON" => MICRON,
Expand Down Expand Up @@ -144,10 +140,6 @@ pub struct InputParryTriMesh {
pub geometry_input: ParryTriMeshInput,
}

impl GeometryInput for InputParryTriMesh {
type GeometryInput = ParryTriMeshInput;
}

impl InputFile for InputParryTriMesh {

fn new(string: &str) -> InputParryTriMesh {
Expand Down Expand Up @@ -187,15 +179,15 @@ pub struct ParryTriMesh {
pub boundary: AABB,
}

impl GeometryInput for ParryTriMesh {
impl GeometryInput for InputParryTriMesh {
type GeometryInput = ParryTriMeshInput;
}

impl Geometry for ParryTriMesh {

type InputFileFormat = InputParryTriMesh;

fn new(input: &<Self as GeometryInput>::GeometryInput) -> ParryTriMesh {
fn new(input: &<<Self as Geometry>::InputFileFormat as GeometryInput>::GeometryInput) -> ParryTriMesh {

let length_unit: f64 = match input.length_unit.as_str() {
"MICRON" => MICRON,
Expand Down
8 changes: 2 additions & 6 deletions src/sphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ pub struct InputSphere {
pub geometry_input: sphere::SphereInput,
}

impl GeometryInput for InputSphere {
type GeometryInput = sphere::SphereInput;
}

impl InputFile for InputSphere {

fn new(string: &str) -> InputSphere {
Expand Down Expand Up @@ -49,15 +45,15 @@ pub struct Sphere {
pub energy_barrier_thickness: f64,
}

impl GeometryInput for Sphere {
impl GeometryInput for InputSphere {
type GeometryInput = SphereInput;
}

impl Geometry for Sphere {

type InputFileFormat = InputSphere;

fn new(input: &<Self as GeometryInput>::GeometryInput) -> Sphere {
fn new(input: &<<Self as Geometry>::InputFileFormat as GeometryInput>::GeometryInput) -> Sphere {

let length_unit: f64 = match input.length_unit.as_str() {
"MICRON" => MICRON,
Expand Down