///|
/// Return the number of stored cells in a vector field.
pub fn VectorField2D::size(self : VectorField2D) -> Int {
self.size.width.max(0) * self.size.height.max(0)
}
///|
/// Return the width of a vector field.
pub fn VectorField2D::width(self : VectorField2D) -> Int {
self.size.width
}
///|
/// Return the height of a vector field.
pub fn VectorField2D::height(self : VectorField2D) -> Int {
self.size.height
}
///|
/// Copy the x component of a vector field.
pub fn VectorField2D::ux_field(self : VectorField2D) -> Array[Double] {
self.ux.copy()
}
///|
/// Copy the y component of a vector field.
pub fn VectorField2D::uy_field(self : VectorField2D) -> Array[Double] {
self.uy.copy()
}
///|
/// Return the legacy lattice dimensions.
pub fn Lattice::dimensions(self : Lattice) -> Size {
self.size
}
///|
/// Count legacy solid cells.
pub fn Lattice::solid_count(self : Lattice) -> Int {
let mut count = 0
for solid in self.solid {
if solid {
count += 1
}
}
count
}
///|
/// Count legacy fluid cells.
pub fn Lattice::fluid_count(self : Lattice) -> Int {
self.size.width.max(0) * self.size.height.max(0) - self.solid_count()
}
///|
/// Compute legacy kinetic energy.
pub fn Lattice::kinetic_energy(self : Lattice) -> Double {
let mut total = 0.0
for y in 0.. VectorField2D {
let result = VectorField2D::new(size=self.size)
for y in 0.. Field2D {
let result = Field2D::new(size=self.size)
for y in 0.. DomainMask {
let result = DomainMask::new(size=self.size)
for y in 0.. Double {
abs_double(self.mass() - reference)
}
///|
/// Return the location of the largest legacy speed.
pub fn Lattice::maximum_speed_location(self : Lattice) -> GridPoint {
let best = GridPoint::{ x: 0, y: 0 }
let mut maximum = -1.0
let mut result = best
for y in 0.. maximum {
maximum = speed
result = GridPoint::{ x, y }
}
}
}
result
}
///|
/// Return the total vorticity magnitude.
pub fn Lattice::vorticity_l1(self : Lattice) -> Double {
let mut total = 0.0
for value in self.vorticity_field() {
total += abs_double(value)
}
total
}
///|
/// Return a scalar field of legacy speed magnitudes.
pub fn Lattice::speed_scalar_field(self : Lattice) -> Field2D {
let result = Field2D::new(size=self.size)
for y in 0.. Unit {
for y in 0.. Unit {
for y in 0.. FieldStatistics {
self
.speed_scalar_field()
.statistics_masked(mask=self.domain_mask(), include_solid=false)
}