1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! # csx
//!
//! Pure Rust continuous-structure geometry and material modeling, compatible
//! with CSXCAD and openEMS.
//!
//! A [`ContinuousStructure`] holds named [`Property`]s (materials, metals,
//! excitations, probes, ...). Each property owns [`Primitive`]s describing
//! where it applies; overlapping primitives are resolved by priority. The
//! structure also carries a [`RectilinearGrid`] (the FDTD mesh), a
//! [`ParameterSet`] for parametric models and the background material.
//!
//! ```
//! use csx::primitives::{BoxShape, Cylinder};
//! use csx::properties::Material;
//! use csx::{ContinuousStructure, CoordSystem, Primitive, Property, TypeMask, Vec3};
//!
//! let mut model = ContinuousStructure::new();
//! model.parameters.set("h", 1.6);
//!
//! // FR4 substrate, its thickness given by the parameter `h`.
//! let fr4 = model.add_property(Property::material("FR4", Material::new(4.3, 0.0)));
//! model.add_primitive(fr4, Primitive::new(BoxShape {
//! start: [-10.0, -10.0, 0.0].into(),
//! stop: csx::ScalarPoint(["10".into(), "10".into(), "h".into()]),
//! }))?;
//!
//! // A metal via with higher priority.
//! let pec = model.add_property(Property::metal("via"));
//! model.add_primitive(pec, Primitive::new(Cylinder::new([0.0, 0.0, 0.0], [0.0, 0.0, 1.6], 0.3))
//! .with_priority(10))?;
//!
//! model.update()?; // evaluate parametric values
//!
//! let hit = model.property_at(Vec3::new(5.0, 0.0, 0.8), CoordSystem::Cartesian, TypeMask::ANY);
//! assert_eq!(hit.unwrap().property.name, "FR4");
//! let hit = model.property_at(Vec3::new(0.1, 0.0, 0.8), CoordSystem::Cartesian, TypeMask::ANY);
//! assert_eq!(hit.unwrap().property.name, "via");
//! # Ok::<(), csx::Error>(())
//! ```
//!
//! ## Module overview
//!
//! * [`structure`], [`properties`], [`primitives`]: the model.
//! * [`param`], [`expr`]: parametric values and expressions.
//! * [`grid`], [`mesh`]: mesh lines and automatic mesh generation.
//! * [`discretize`]: sampling the model onto the FDTD grid.
//! * [`tessellate`], [`io`]: triangle meshes, file import/export and (with
//! the `xml` feature) CSXCAD / openEMS XML.
//! * [`fdtd`]: openEMS simulation settings.
//! * [`prelude`]: glob-importable common types.
//!
//! ## Conventions
//!
//! * Axis indices are `usize`: `0` = x (ρ), `1` = y (α), `2` = z.
//! * Lengths are in drawing units (see
//! [`RectilinearGrid::delta_unit`]); material parameters are SI.
//! * Angles are radians.
//! * Point queries always take the [`CoordSystem`] of the point.
//! * Parametric values are re-evaluated by [`ContinuousStructure::update`].
//! * NaN marks unset values ([`Scalar::is_unset`]) and is false in
//! expressions.
//!
//! Details: [`coords`](coords#crate-wide-conventions) and [`expr`].
//!
//! ## Stability
//!
//! Enums and option/result structs that are expected to grow (errors, shape
//! and property kinds, type ids, `*Options`, ...) are `#[non_exhaustive]`:
//! match them with a wildcard arm and build options from `Default` plus
//! their `with_*` builders.
//!
//! This is a clean-room implementation written from public documentation and
//! the observable file format only.
pub use CoordSystem;
pub use ;
pub use RectilinearGrid;
pub use OpenEmsDocument;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// The most commonly used types, for glob import:
///
/// ```
/// use csx::prelude::*;
///
/// let mut s = ContinuousStructure::new();
/// let id = s.add_property(Property::metal("pec"));
/// s.add_primitive(id, BoxShape::new([0.0, 0.0, 0.0], [1.0, 1.0, 1.0]))?;
/// assert!(s.property_at(Vec3::new(0.5, 0.5, 0.5), CoordSystem::Cartesian, TypeMask::ANY).is_some());
/// # Ok::<(), csx::Error>(())
/// ```