Skip to main content

Flow

Enum Flow 

Source
pub enum Flow {
    PrescribedUniform {
        velocity_m_s: [f64; 3],
    },
    Laminar {
        initial_velocity_m_s: [f64; 3],
        viscosity_m2_s: f64,
        acceleration_m_s2: [f64; 3],
    },
    NeutralRans {
        speed_m_s: f64,
        reference_height_m: f64,
        roughness_m: f64,
        direction_deg_from: f64,
        viscosity_m2_s: f64,
        turbulent_schmidt: f64,
    },
}
Expand description

Flow model, selected by kind: prescribed_uniform (a fixed uniform velocity; only the constituents are solved), laminar (incompressible flow with constant viscosity) or neutral_rans (a neutral atmospheric boundary layer with the k-epsilon model). The numeric fields are checked as CFD-E012.

Variants§

§

PrescribedUniform

A fixed uniform velocity with no flow solve. Its normal component must be zero at impermeable boundaries (CFD-E024), and solid boxes are not allowed (CFD-E013).

Fields

§velocity_m_s: [f64; 3]

Velocity [u, v, w] in m/s, finite.

§

Laminar

Incompressible laminar flow with constant kinematic viscosity, started from a uniform velocity.

Fields

§initial_velocity_m_s: [f64; 3]

Uniform initial velocity [u, v, w] in m/s, finite. It also sets the velocity of open inlet faces and decides which open faces are inlets or outlets.

§viscosity_m2_s: f64

Kinematic viscosity in m2/s, finite and positive.

§acceleration_m_s2: [f64; 3]

Uniform body acceleration [x, y, z] in m/s2, for example the pressure-gradient drive of a periodic channel. Default: zero.

§

NeutralRans

Neutral atmospheric boundary layer with the k-epsilon model (C_mu 0.09, C_epsilon1 1.44, C_epsilon2 1.92, kappa 0.4). Inflow and initial fields are the logarithmic equilibrium profiles U = u*/kappa ln((z + z0)/z0), k = u*^2/sqrt(C_mu) and epsilon = u*^3/(kappa (z + z0)), with u* set by speed_m_s at reference_height_m. Requires boundaries.z = ground_open_top (CFD-E011).

Fields

§speed_m_s: f64

Mean wind speed at reference_height_m in m/s, finite and positive. It is also the velocity scale of the normalized checks.

§reference_height_m: f64

Height of speed_m_s above the ground in meters, positive and not above the domain top. It is also the length scale of the normalized checks.

§roughness_m: f64

Aerodynamic roughness length z0 of the ground in meters, positive. Building and other wall faces use min(z0, 0.001 cell width), which ties that wall roughness to the grid (see the flow model card).

§direction_deg_from: f64

Meteorological wind direction in degrees: where the wind blows from, clockwise from north. 270 blows toward +x (east), 180 toward +y (north). Finite; any value is accepted.

§viscosity_m2_s: f64

Molecular kinematic viscosity in m2/s, positive; the eddy viscosity C_mu k^2/epsilon is added to it.

§turbulent_schmidt: f64

Turbulent Schmidt number Sc_t, positive: constituents diffuse with their molecular diffusivity plus nu_t / Sc_t.

Implementations§

Source§

impl Flow

Source

pub fn prescribed(&self) -> bool

True for prescribed_uniform, whose velocity stays fixed: no momentum or pressure equations are solved.

Source

pub fn rans(&self) -> bool

True for neutral_rans, which adds the k and epsilon fields.

Source

pub fn viscosity(&self) -> f64

Molecular kinematic viscosity in m2/s; zero for prescribed flow.

Source

pub fn vector(&self, z: f64) -> [f64; 3]

The case’s reference velocity at height z (meters), in m/s: the prescribed velocity, the laminar initial velocity, or the logarithmic neutral_rans profile in the wind direction (negative heights are evaluated at the ground).

It initializes the face velocities, sets the velocity of open inlet faces and decides whether an open face is an inlet, an outlet or a slip face.

use cfd_craft::case::Flow;

let flow: Flow = serde_json::from_str(
    r#"{"kind": "neutral_rans", "speed_m_s": 3.0, "reference_height_m": 10.0,
        "roughness_m": 0.1, "direction_deg_from": 270.0,
        "viscosity_m2_s": 1.5e-5, "turbulent_schmidt": 0.7}"#,
)
.unwrap();
let [u, v, w] = flow.vector(10.0);
// A wind from the west blows toward +x, at the declared reference speed.
assert!((u - 3.0).abs() < 1e-12 && v.abs() < 1e-12 && w == 0.0);
assert!(flow.vector(1.0)[0] < u);
Source

pub fn reference_speed(&self) -> f64

Velocity scale of the normalized checks and divergence limits, in m/s: speed_m_s for neutral_rans, otherwise the magnitude of vector at z = 1 m, but at least 1 m/s.

Source

pub fn ustar(&self) -> f64

Friction velocity of the neutral_rans inflow profile in m/s, u* = kappa speed / ln((z_ref + z0)/z0) with kappa = 0.4; zero for the other flow models.

Source

pub fn turbulence(&self, z: f64) -> (f64, f64)

Equilibrium (k, epsilon) of the neutral_rans inflow at height z (meters): k = u*^2/sqrt(C_mu) in m2/s2 and epsilon = u*^3/(kappa (z + z0)) in m2/s3. (0, 0) for the other flow models. These values initialize the fields and set the inlet and top values.

Trait Implementations§

Source§

impl Clone for Flow

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Flow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Flow

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for Flow

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for Flow

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Forget for Flow

§

impl Freeze for Flow

§

impl Move for Flow

§

impl RefUnwindSafe for Flow

§

impl Send for Flow

§

impl Sync for Flow

§

impl Unpin for Flow

§

impl UnsafeUnpin for Flow

§

impl UnwindSafe for Flow

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.