| 69 | }; |
| 70 | |
| 71 | void |
| 72 | reset_solid_level_set_callback_fcn(double current_time, double new_time, int /*cycle_num*/, void* ctx) |
| 73 | { |
| 74 | SolidLevelSetResetter* resetter = static_cast<SolidLevelSetResetter*>(ctx); |
| 75 | const FoilInterface& foil = *(resetter->ptr_foil); |
| 76 | |
| 77 | // Get the new centroid of the body |
| 78 | const double dt = new_time - current_time; |
| 79 | const Eigen::Vector3d XCOM_current = resetter->bp_rbd->getCurrentCOMPosn(); |
| 80 | const Eigen::Vector3d XCOM_new = XCOM_current + dt * (resetter->bp_rbd->getNewCOMTransVelocity()); |
| 81 | |
| 82 | // b) Rotational matrix. |
| 83 | const double theta = foil.theta_0 * std::sin(2 * M_PI * foil.freq * new_time); |
| 84 | |
| 85 | const Eigen::Vector3d rot_axis(0.0, 0.0, 1.0); |
| 86 | Eigen::Quaterniond q(Eigen::AngleAxisd(theta, rot_axis)); |
| 87 | q.normalize(); |
| 88 | |
| 89 | const Eigen::Matrix3d R_mat = q.toRotationMatrix(); |
| 90 | |
| 91 | const double& R = foil.R; |
| 92 | const Eigen::Vector3d& X0 = foil.X0; |
| 93 | const Eigen::Vector3d& X1 = foil.X1; |
| 94 | const Eigen::Vector3d& X2 = foil.X2; |
| 95 | const Eigen::Vector3d& X3 = foil.X3; |
| 96 | Eigen::Vector3d check1, check2, check3, check4, check5, check6; |
| 97 | |
| 98 | // Rotate and translate the top, bottom and circular surface to get new coordiantes. |
| 99 | const Eigen::Vector3d X1_new = R_mat * (X1 - X0) + XCOM_new; |
| 100 | const Eigen::Vector3d X2_new = R_mat * (X2 - X0) + XCOM_new; |
| 101 | const Eigen::Vector3d X3_new = R_mat * (X3 - X0) + XCOM_new; |
| 102 | |
| 103 | const Eigen::Vector3d X_T_new = (X1_new + X2_new + X3_new) / 3.0; |
| 104 | |
| 105 | const double slope1 = (X3_new[1] - X1_new[1]) / (X3_new[0] - X1_new[0]); |
| 106 | const double slope2 = (X3_new[1] - X2_new[1]) / (X3_new[0] - X2_new[0]); |
| 107 | const double slope3 = (X2_new[0] - X1_new[0]) / (X2_new[1] - X1_new[1]); |
| 108 | |
| 109 | const double y_intercept1 = X1_new[1] - slope1 * X1_new[0]; |
| 110 | const double y_intercept2 = X2_new[1] - slope2 * X2_new[0]; |
| 111 | const double x_intercept3 = X1_new[0] - slope3 * X1_new[1]; |
| 112 | |
| 113 | double distance1[2], distance2[3]; // Foil has three surfaces and 1 surface for circle. |
| 114 | |
| 115 | // Set a large value away from the solid body. |
| 116 | Pointer<PatchHierarchy<NDIM>> patch_hier = resetter->adv_diff_integrator->getPatchHierarchy(); |
| 117 | const int hier_finest_ln = patch_hier->getFinestLevelNumber(); |
| 118 | |
| 119 | VariableDatabase<NDIM>* var_db = VariableDatabase<NDIM>::getDatabase(); |
| 120 | const int ls_solid_idx = |
| 121 | var_db->mapVariableAndContextToIndex(resetter->ls_solid_var, resetter->adv_diff_integrator->getNewContext()); |
| 122 | |
| 123 | for (int ln = 0; ln <= hier_finest_ln; ++ln) |
| 124 | { |
| 125 | Pointer<PatchLevel<NDIM>> patch_level = patch_hier->getPatchLevel(ln); |
| 126 | for (PatchLevel<NDIM>::Iterator p(patch_level); p; p++) |
| 127 | { |
| 128 | Pointer<Patch<NDIM>> patch = patch_level->getPatch(p()); |
nothing calls this directly
no test coverage detected