|
@ -178,6 +178,39 @@ namespace da::sha { |
|
|
return vt; |
|
|
return vt; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Tensor3d Top3d::GetVonStress() { |
|
|
|
|
|
Eigen::VectorXd ele_to_write = |
|
|
|
|
|
Eigen::VectorXd::Zero( |
|
|
|
|
|
sp_mesh_->GetLx() * sp_mesh_->GetLy() * sp_mesh_->GetLz()); |
|
|
|
|
|
Eigen::VectorXi pixel_idx = sp_mesh_->GetGlobalIdxOfEleInUse(); |
|
|
|
|
|
// stress |
|
|
|
|
|
Eigen::MatrixXd mat_stress(sp_mesh_->GetNumEles(), 6); |
|
|
|
|
|
Eigen::MatrixXd B = sp_fea_->computeBe({0, 0, 0}); |
|
|
|
|
|
for (int i = 0; i < sp_mesh_->GetNumEles(); ++i) { |
|
|
|
|
|
Eigen::VectorXi dofs_in_ele_i = sp_mesh_->MapEleId2Dofs(i); |
|
|
|
|
|
Eigen::VectorXd Ue = U_(dofs_in_ele_i); |
|
|
|
|
|
mat_stress.row(i) = rho_(i) * sp_fea_->computeD() * B * Ue; |
|
|
|
|
|
} |
|
|
|
|
|
// fill |
|
|
|
|
|
Tensor3d vt; |
|
|
|
|
|
auto computeVonStress = [&](Eigen::VectorXd stress) -> double { |
|
|
|
|
|
double x = stress(0); |
|
|
|
|
|
double y = stress(1); |
|
|
|
|
|
double z = stress(2); |
|
|
|
|
|
double xy = stress(3); |
|
|
|
|
|
double yz = stress(4); |
|
|
|
|
|
double zx = stress(5); |
|
|
|
|
|
return sqrt(0.5 * (x * x + y * y + z * z) + 3 * (xy * xy + yz * yz + zx * zx)); |
|
|
|
|
|
}; |
|
|
|
|
|
Eigen::VectorXd vonStress = Eigen::VectorXd::Zero(mat_stress.rows()); |
|
|
|
|
|
for (int i = 0; i < sp_mesh_->GetNumEles(); ++i) { |
|
|
|
|
|
vonStress(i) = computeVonStress(mat_stress.row(i)); |
|
|
|
|
|
} |
|
|
|
|
|
ele_to_write(pixel_idx) = vonStress; |
|
|
|
|
|
vt = GetTensorFromCol(ele_to_write); |
|
|
|
|
|
return vt; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Tensor3d Top3d::GetTensorFromCol(const Eigen::VectorXd &proprty_col) { |
|
|
Tensor3d Top3d::GetTensorFromCol(const Eigen::VectorXd &proprty_col) { |
|
|
Tensor3d ten_prop_to_write(sp_mesh_->GetLx() * sp_mesh_->GetLy() * sp_mesh_->GetLz(), 1, |
|
|
Tensor3d ten_prop_to_write(sp_mesh_->GetLx() * sp_mesh_->GetLy() * sp_mesh_->GetLz(), 1, |
|
|
1); |
|
|
1); |
|
|