obsidian_backup/多体+耦合求解器/数据结构讨论.md

2.9 KiB

问题1 结构体定义是否需要加大量option

水动 576行 !Pasted image 20250110135219.png

多体 1600行 !Pasted image 20250110135444.png

pub struct MorisonMOutput {

    pub memberid: i32,                      // Member ID for requested output [-]

    pub noutloc: i32,                      // The number of requested output locations [-]

    pub nodelocs: Option<Vec<f64>>,         // Normalized locations along user-specified member for the outputs [-]

    pub memberidindx: i32,                 // Index for member in the master list [-]

    pub meshindx1: Option<Vec<i32>>,        // Index of node in Mesh for the start of the member element [-]

    pub meshindx2: Option<Vec<i32>>,        // Index of node in Mesh for the end of the member element [-]

    pub memberindx1: Option<Vec<i32>>,      // Index of Member nodes for the start of the member element [-]

    pub memberindx2: Option<Vec<i32>>,      // Index of Member nodes for the end of the member element [-]

    pub s: Option<Vec<f64>>,                 // Linear interpolation factor between node1 and node2 for the output location [-]

}

问题2 array数组定义

pub struct AD_Init{ 
    pub Ct_final:                   ArrayBase<OwnedRepr<f64>, Dim<[usize; 3]>>,

    pub Cq_final:                   ArrayBase<OwnedRepr<f64>, Dim<[usize; 3]>>,

    pub CP_final:                   ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,

    pub position_g:                 Vec<[ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>; 3]>,

    pub trans_disp:                 Vec<[ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>; 3]>,
}

impl AD_Init {

    pub fn new() -> Self {
            Ct_final: ArrayBase::zeros((0, 0, 0)),

            Cq_final: ArrayBase::zeros((0, 0, 0)),

            CP_final: ArrayBase::zeros(0),

            position_g: Vec::new(),

            trans_disp: Vec::new(),
	    }
	 }
    
pub struct EDParameterType{
	pub r_nodes: Array1<f64>, // 分析节点到轮毂的半径
	pub pitch_axis: Array2<f64>, // 分析节点的变桨轴
	pub twr_fasf: Array3<f64>, // 塔前后形状函数
	pub twr_sssf: Array3<f64>, // 塔侧向形状函数
	(ArrayBase<OwnedRepr<f64>, Dim<[usize; 3]>>)
}
impl EDParameterType {

    pub fn new() -> EDParameterType {

        EDParameterType {
        // 初始化一个任意维度
        r_nodes: Array1::zeros(1),
        pitch_axis: Array2::zeros((1, 1)),
        twr_fasf: Array3::zeros((3, 3, 3)),
        twr_sssf: Array3::zeros((3, 3, 3)),
        }
	 }
}
// 在代码中根据需要创建维度
p.r_nodes = Array1::zeros(p.bld_nodes as usize);
p.pitch_axis = Array2::zeros((p.num_bl as usize, p.bld_nodes as usize));
p.twr_fasf = Array3::zeros((2, p.t_top_node as usize+ 1, 3));