| 1125 | } // getNumberOfStructuresNodes |
| 1126 | |
| 1127 | void |
| 1128 | CIBMethod::setRigidBodyVelocity(const unsigned int part, const RigidDOFVector& U, Vec V) |
| 1129 | { |
| 1130 | const int struct_ln = getStructuresLevelNumber(); |
| 1131 | Eigen::Matrix3d rotation_mat = d_quaternion_half[part].toRotationMatrix(); |
| 1132 | if (d_constrained_velocity_fcns_data[part].nodalvelfcn) |
| 1133 | { |
| 1134 | d_constrained_velocity_fcns_data[part].nodalvelfcn( |
| 1135 | V, |
| 1136 | U, |
| 1137 | d_l_data_manager->getLData("X0_unshifted", struct_ln)->getVec(), |
| 1138 | d_center_of_mass_initial[part], |
| 1139 | rotation_mat, |
| 1140 | d_new_time, |
| 1141 | d_constrained_velocity_fcns_data[part].ctx); |
| 1142 | } |
| 1143 | else |
| 1144 | { |
| 1145 | // Wrap the PETSc V into LData |
| 1146 | std::vector<int> nonlocal_indices; |
| 1147 | LData V_data("V", V, nonlocal_indices, false); |
| 1148 | boost::multi_array_ref<double, 2>& V_data_array = *V_data.getLocalFormVecArray(); |
| 1149 | |
| 1150 | // Get the position info. |
| 1151 | const boost::multi_array_ref<double, 2>& X0_array = |
| 1152 | *(d_l_data_manager->getLData("X0_unshifted", struct_ln)->getLocalFormVecArray()); |
| 1153 | Eigen::Vector3d dr = Eigen::Vector3d::Zero(); |
| 1154 | Eigen::Vector3d R_dr = Eigen::Vector3d::Zero(); |
| 1155 | |
| 1156 | // Get mesh nodes. |
| 1157 | const Pointer<LMesh> mesh = d_l_data_manager->getLMesh(struct_ln); |
| 1158 | const std::vector<LNode*>& local_nodes = mesh->getLocalNodes(); |
| 1159 | const std::pair<int, int>& part_idx_range = d_struct_lag_idx_range[part]; |
| 1160 | for (const auto& node_idx : local_nodes) |
| 1161 | { |
| 1162 | const int lag_idx = node_idx->getLagrangianIndex(); |
| 1163 | if (part_idx_range.first <= lag_idx && lag_idx < part_idx_range.second) |
| 1164 | { |
| 1165 | const int local_idx = node_idx->getLocalPETScIndex(); |
| 1166 | double* const V_node = &V_data_array[local_idx][0]; |
| 1167 | const double* const X0 = &X0_array[local_idx][0]; |
| 1168 | |
| 1169 | for (unsigned int d = 0; d < NDIM; ++d) |
| 1170 | { |
| 1171 | dr[d] = X0[d] - d_center_of_mass_initial[part][d]; |
| 1172 | } |
| 1173 | R_dr = rotation_mat * dr; |
| 1174 | |
| 1175 | #if (NDIM == 2) |
| 1176 | V_node[0] = U[0] - U[2] * R_dr[1]; |
| 1177 | V_node[1] = U[1] + U[2] * R_dr[0]; |
| 1178 | #elif (NDIM == 3) |
| 1179 | V_node[0] = U[0] + U[4] * R_dr[2] - U[5] * R_dr[1]; |
| 1180 | V_node[1] = U[1] + U[5] * R_dr[0] - U[3] * R_dr[2]; |
| 1181 | V_node[2] = U[2] + U[3] * R_dr[1] - U[4] * R_dr[0]; |
| 1182 | #endif |
| 1183 | } |
| 1184 | } |
no test coverage detected