void mesh_snap_to_cylinder__hollow_section (const struct const_Vector_i*const ve_curved, const struct Matrix_d*const nodes) { // Set geometry data static bool need_input = true; static struct Geom_Data__chs geom_data; if (need_input) { need_input = false; read_data_cylinder__hollow_section(&geom_data); } // Snap vertices to the boundary const int dims_to_check = 2; const ptrdiff_t n_n = nodes->ext_0; for (ptrdiff_t n = 0; n < n_n; ++n) { if (!ve_curved->data[n]) continue; const double r = norm_d(dims_to_check,get_row_Matrix_d(n,nodes),"L2"); double r_ex = 0.0; if (equal_d(r,geom_data.r_i,NODETOL_MESH)) r_ex = geom_data.r_i; else if (equal_d(r,geom_data.r_o,NODETOL_MESH)) r_ex = geom_data.r_o; if (r_ex == 0.0) EXIT_ERROR("Did not find a matching curved surface"); double*const ve_xyz = get_row_Matrix_d(n,nodes); const double t = atan2(ve_xyz[1],ve_xyz[0]); ve_xyz[0] = r_ex*cos(t); ve_xyz[1] = r_ex*sin(t); } }
int termination_criterion(struct sm_params*params, const double*delta){ double a = norm_d(delta); double b = fabs(delta[2]); return (a<params->epsilon_xy) && (b<params->epsilon_theta); }