Commit e8f1b87b authored by Olivier Lantsoght's avatar Olivier Lantsoght 🏁

Merge branch 'error_in_equil_modal' into 'dev'

Error in equil modal

See merge request !239
parents 96861225 5b1e7b22
Pipeline #4888 passed with stages
in 13 minutes and 3 seconds
......@@ -441,8 +441,8 @@ tutorial_modal_monolithic:
- mkdir ExampleProjects/TutorialProjects/analysisModules/modal_CI/workR/build
- cd ExampleProjects/TutorialProjects/analysisModules/modal_CI/workR/build
- cmake ..
# - make
# - ./exe_modal_CI
- make
- ./exe_modal_CI
tutorial_Solvekin_monolithic:
# No reference solution
......@@ -489,8 +489,8 @@ tutorial_modal_separate:
- mkdir ExampleProjects/TutorialProjects/analysisModules/modal_CI/workR/build
- cd ExampleProjects/TutorialProjects/analysisModules/modal_CI/workR/build
- cmake -DFLAG_SEPARATE_BUILD=ON ..
# - make
# - ./exe_modal_CI
- make
- ./exe_modal_CI
tutorial_Solvekin_separate:
# No reference solution
......
......@@ -134,6 +134,7 @@ int main(int argc, char const *argv[])
save_dmat_0(mbs_ss->A, mbs_ss->nx, mbs_ss->nx, PROJECT_SOURCE_DIR"/../resultsR/ss_A.res");
save_dmat_0(mbs_ss->B, mbs_ss->nx, mbs_ss->nu, PROJECT_SOURCE_DIR"/../resultsR/ss_B.res");
save_dmat_0(mbs_ss->C, mbs_ss->ny, mbs_ss->nx, PROJECT_SOURCE_DIR"/../resultsR/ss_C.res");
mbs_delete_statespace(mbs_ss);
mbs_delete_modal(mbs_modal, mbs_data);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
......
......@@ -98,18 +98,19 @@ int main(int argc, char const *argv[])
mbs_modal->options->verbose = 1;
mbs_run_modal(mbs_modal, mbs_data);
// reuse mo->Mr,mo->Gr,mo->Kr
MbsSS *mbs_ss = mbs_new_statespace(mbs_data->nqu, mbs_data->nqu * 2, 2, 1);
MbsSS *mbs_ss = mbs_new_statespace(mbs_data->nqu, mbs_data->nqu * 2, 2, 1,0,0);
mbs_ss->iu[1] = T1_cart_id;
mbs_ss->iu[2] = R2_crank_id;
mbs_ss->iy[1] = 4;
mbs_compute_linearMatrices(mbs_modal->ss, mbs_data, mbs_modal->lpk, mbs_modal->aux);
mbs_compute_statespace(mbs_ss, mbs_data, mbs_modal->aux->Bvuc);
copy_dmat_0(mbs_modal->ss->Mr, mbs_ss->Mr, mbs_data->nqu, mbs_data->nqu);
mbs_compute_linearMatrices(mbs_ss, mbs_data, mbs_modal->lpk, mbs_modal->aux);
mbs_compute_statespace(mbs_ss, mbs_data, mbs_modal->Bvuc);
save_dmat_0(mbs_ss->A, mbs_ss->nx, mbs_ss->nx, PROJECT_SOURCE_DIR"/../resultsR/ss_A.res");
save_dmat_0(mbs_ss->B, mbs_ss->nx, mbs_ss->nu, PROJECT_SOURCE_DIR"/../resultsR/ss_B.res");
save_dmat_0(mbs_ss->C, mbs_ss->ny, mbs_ss->nx, PROJECT_SOURCE_DIR"/../resultsR/ss_C.res");
mbs_modal_finish(mbs_modal, mbs_data);
mbs_delete_statespace(mbs_ss);
mbs_delete_modal(mbs_modal, mbs_data);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/* DIRECT DYNANMICS *
......
......@@ -19,9 +19,10 @@
int mbs_Mred(MbsAux *mbs_aux,MbsData *s)
{
int i, j, k;
int iter = 0;
int nL, nC, nk;
int err = 0;
double term;
int has_a_line_of_zeros;
......@@ -33,11 +34,11 @@ int mbs_Mred(MbsAux *mbs_aux,MbsData *s)
if (s->Ncons > 0)
{
// Geometric resolution
iter = mbs_close_geo(s, mbs_aux);
if (iter >= mbs_aux->MAX_NR_ITER)
err = mbs_close_geo(s, mbs_aux);
if (err<0) // Error management
{
return -1;
mbs_msg("\t \t in >MRED> \n");
return err;
}
// Kinematic resolution
......@@ -140,11 +141,13 @@ int mbs_Mred(MbsAux *mbs_aux,MbsData *s)
}
if (has_a_line_of_zeros)
{
mbs_msg("The line %d of the reduced mass matrix, associated to q(%d), is full of zeros\n", i, mbs_aux->iquc[i]);
mbs_msg("\t >DIRDYNARED> The line %d of the reduced mass matrix, associated to q(%d), is full of zeros\n", i, mbs_aux->iquc[i]);
for (k = 1; k <= nC; k++)
mbs_msg("mbs_aux->Mr[%d][%d] = %e;\n", i, k, mbs_aux->Mr[i][k]);
mbs_error_msg("The reduced mass matrix has a line of zeros\n");
{
mbs_msg("\t >DIRDYNARED> mbs_aux->Mr[%d][%d] = %e;\n", i, k, mbs_aux->Mr[i][k]);
}
return -90;
}
}
return iter;
return err;
}
......@@ -36,11 +36,11 @@ int mbs_Rred(MbsAux *mbs_aux,MbsData *s)
if (s->Ncons > 0)
{
// Geometric resolution
iter = mbs_close_geo(s, mbs_aux);
if (iter >= mbs_aux->MAX_NR_ITER)
err = mbs_close_geo(s, mbs_aux);
if (err<0) // Error management
{
return -1;
mbs_msg("\t \t in >RRED> \n");
return err;
}
// Kinematic resolution (computation of the Bvuc term)
......@@ -117,6 +117,15 @@ int mbs_Rred(MbsAux *mbs_aux,MbsData *s)
mbs_aux->Rred[i] = mbs_aux->Rruc[i];
}
for (i = 1; i <= s->nqu; i++)
{
if (isnan(mbs_aux->Rred[i]))
{
mbs_msg("\t >RRED> Rred[%d] is Not a number (Nan) \n", s->qu[i]);
return -87;
}
}
// lambda computation
if (s->nqv > 0)
......@@ -138,6 +147,11 @@ int mbs_Rred(MbsAux *mbs_aux,MbsData *s)
}
// compute lambda
ludcmp(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, &d);
if (err < 0) // Error management
{
mbs_msg("\t >RRED> Error in Rred during LU decomposition of Jv matrix for lambda computation\n");
return (-80 + err);
}
lubksb(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, s->lambda);
}
......
......@@ -53,10 +53,10 @@ int mbs_close_geo(MbsData *s, MbsAux *mbs_aux)
// Decomposition LU de la matrice -Jv
err = ludcmp(mbs_aux->mJv,s->nqv,mbs_aux->ind_mJv,&d);
if (err < 0)
if (err < 0) // Error management
{
mbs_msg("\t >CLOSE GEO> Error in mbs_close_geo during LU decomposition of Jv matrix \n");
return err;
mbs_msg("\t \t >CLOSE GEO> Error in mbs_close_geo during LU decomposition of Jv matrix \n");
return -50+err;
}
if(mbs_aux->norm_h > mbs_aux->NRerr)
......@@ -78,6 +78,14 @@ int mbs_close_geo(MbsData *s, MbsAux *mbs_aux)
}
}
}
if (iter >= mbs_aux->MAX_NR_ITER) // Error management
{
mbs_msg("\t \t >CLOSE GEO> Impossible to close the geometry after %d iterations \n", iter);
return -50;
}
return iter;
}
......
......@@ -574,7 +574,7 @@ void mbs_dirdyn_finish(MbsDirdyn* dd, MbsData* mbs_data){
{
mbs_msg(">>DIRDYN>> ***** mbs_dirdyn_write_buffers : impossible to save the files *****\n");
mbs_msg(">>DIRDYN>>\n");
mbs_error_msg("[%d] in mbs_dirdyn_finish !! \n", -500 + err);
mbs_error_msg("[%d] in mbs_dirdyn_finish !! \n", -400 + err);
}
......@@ -632,6 +632,7 @@ int mbs_dirdyn_write_buffers(MbsDirdyn* dd){
void mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdyn *dd)
{
int err = 0;
int i;
s->tsim = tsim;
......@@ -649,51 +650,44 @@ void mbs_fct_dirdyn(double tsim, double y[], double dydt[], MbsData *s, MbsDirdy
if (dd->options->accelred) // Full symbolic computation of qdd (including solving constraint, inv(M), ...)
{
i = mbs_accelred(s, tsim);
err = mbs_accelred(s, tsim);
}
else // Numerical solving of constraints and inv(M)
{
i = dirdynared(dd->mbs_aux,s);
err = dirdynared(dd->mbs_aux,s);
}
if (i < 0) // Error management
if (err < 0) // Error management
{
mbs_msg(">>DIRDYN>>\n");
mbs_msg(">>DIRDYN>> Error during direct dynamics at time %g s !\n", tsim);
save_realtime_update(dd, s);
mbs_dirdyn_finish(dd, s);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -400 + i);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -400 + err);
}
// User Derivatives
if(s->Nux>0) user_Derivative(s);
// Update state vector
for(i=1;i<=s->nqu;i++)
for (i = 1; i <= s->nqu; i++)
{
dydt[i-1] = s->qd [s->qu[i]];
dydt[i+s->nqu-1] = s->qdd[s->qu[i]];
dydt[i - 1] = s->qd[s->qu[i]];
dydt[i + s->nqu - 1] = s->qdd[s->qu[i]];
// Check content of state vector
if (isnan(s->qd[s->qu[i]])) {
mbs_msg(">>DIRDYN>> qd[%d] is Nan at time %g s ! \n", s->qu[i], tsim );
save_realtime_update(dd, s);
mbs_dirdyn_finish(dd, s);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -470 + i);
}
}
// User Derivatives
if(s->Nux>0) user_Derivative(s);
for(i=1;i<=s->Nux;i++)
{
dydt[i+2*s->nqu-1] = s->uxd[i];
// Check content of state vector
if (isnan(s->uxd[i])){
mbs_msg(">>DIRDYN>> User derivative uxd[%d] is Nan\n",i);
if (isnan(s->uxd[i])) // Error management
{
mbs_msg(">>DIRDYN>> User derivative uxd[%d] is Nan\n", i);
mbs_msg(">>DIRDYN>> Error in state vector at time %g s ! \n", tsim);
save_realtime_update(dd, s);
mbs_dirdyn_finish(dd, s);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -407);
mbs_error_msg("[%d] in mbs_fct_dirdyn !! \n", -447);
}
dydt[i+2*s->nqu-1] = s->uxd[i];
}
}
......
......@@ -26,10 +26,9 @@
int dirdynared(MbsAux *mbs_aux,MbsData *s)
{
int i, j, k;
int iter = 0;
int nL, nC, nk;
int err;
int err = 0;
double term;
......@@ -42,19 +41,13 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
if (s->Ncons > 0)
{
// Geometric resolution
iter = mbs_close_geo(s, mbs_aux);
if (iter >= mbs_aux->MAX_NR_ITER)
{
mbs_msg("\t >DIRDYNARED> Impossible to close the geometry after %d iterations \n", iter);
return -50;
}
else if (iter <0) // error during LU decomposition
err = mbs_close_geo(s, mbs_aux);
if (err<0) // Error management
{
mbs_msg("\t >DIRDYNARED> Error during LU decomposition \n");
return -22;
mbs_msg("\t \t in >DIRDYNARED> \n");
return err;
}
// Kinematic resolution
mbs_close_kin(s, mbs_aux);
......@@ -63,12 +56,9 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
}//if(s->Ncons > 0)
// compute forces on the system
mbs_calc_force(s);
// calcul de la matrice de masse et du vecteur des forces non lineaires
mbs_dirdyna(mbs_aux->M, mbs_aux->c, s, s->tsim);
......@@ -260,14 +250,14 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
if (mbs_aux->Mr[i][j] > 1e-16)
has_a_line_of_zeros = 0;
}
if (has_a_line_of_zeros)
if (has_a_line_of_zeros) // Error management
{
mbs_msg("\t >DIRDYNARED> The line %d of the reduced mass matrix, associated to q(%d), is full of zeros\n", i, mbs_aux->iquc[i]);
for (k = 1; k <= nC; k++)
{
mbs_msg("\t >DIRDYNARED> mbs_aux->Mr[%d][%d] = %e;\n", i, k, mbs_aux->Mr[i][k]);
}
return -55;
return -70;
}
term = 0.0;
......@@ -280,19 +270,27 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
// calcul des accelerations reduites : 'resolution' du systeme ODE = Mr*udd = Fr;
err = choldc(mbs_aux->Mr, s->nqu, mbs_aux->p_Mr);
if (err < 0) {
if (err < 0) // Error management
{
mbs_msg("\t >DIRDYNARED> Matrix Mr is not positive definite \n");
return (err-30);
return (-70+err);
}
cholsl(mbs_aux->Mr, s->nqu, mbs_aux->p_Mr, mbs_aux->Fr, s->udd);
nL = s->nqu;
for (i = 1; i <= nL; i++)
{
s->qdd[s->qu[i]] = s->udd[i];
if (isnan(s->qdd[s->qu[i]])) // Error management
{
mbs_msg("\t >DIRDYNARED> qddu[%d] is Nan \n", i);
return -77;
}
}
if (s->nqv > 0)
{
double d;
......@@ -341,23 +339,14 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
// compute lambda
err = ludcmp(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, &d);
if (err < 0)
if (err < 0) // Error management
{
mbs_msg("\t >DIRDYNARED> Error in dirdynared during LU decomposition of Jv matrix \n");
return (err);
mbs_msg("\t >DIRDYNARED> Error in dirdynared during LU decomposition of Jv matrix for lambda computation\n");
return (-70+err);
}
lubksb(mbs_aux->Jvt, s->nqv, mbs_aux->ind_Jvt, s->lambda);
}
for (i = 1; i <= s->nqu; i++)
{
if (isnan(s->qdd[s->qu[i]])) {
mbs_msg("\t >DIRDYNARED> qdd[%d] is Not a number (Nan) \n", s->qu[i]);
return -7;
}
}
// Qc = Mruc_cu * udd + Mruc_cc * qddc + Fruc_c
if (s->nqc > 0)
{
......@@ -385,6 +374,6 @@ int dirdynared(MbsAux *mbs_aux,MbsData *s)
}
}
return iter;
return err;
}
#endif
This diff is collapsed.
......@@ -19,7 +19,7 @@ int mbs_linearipk(double **GK, MbsLpk *lpk, MbsAux *aux, MbsData *s, int EqChoi
int i, j, k; // fctlin,qoqp_equi,fctlin_equi,posvit,epsmod,delta_ua,delta_ur,linpa
int rep, compt, test, li;
int lin_fail = 0;
int err = 0;
double max_GK_k, max_GK_prem_div_k;
double increment;
......@@ -45,7 +45,8 @@ int mbs_linearipk(double **GK, MbsLpk *lpk, MbsAux *aux, MbsData *s, int EqChoi
copy_dvec_0(lpk->qdd_saved, &(s->qdd[1]), s->njoint);
copy_dvec_0(lpk->Qq_saved, &(s->Qq[1]), s->njoint);
copy_dvec_0(lpk->ux_saved, &(s->ux[1]), s->Nux);
lin_fail = mbs_lineari_fct(lpk->x_star,lpk->F_star,lpk, aux, s, EqChoice);
err = mbs_lineari_fct(lpk->x_star,lpk->F_star,lpk, aux, s, EqChoice);
if (err < 0) return err; // Error management (no message because the msg from lineari_fct is already clear enough)
// loop on the matrix column ! (the linearized matrix is build column by column...)
for (k = 0; k < lpk->nx; k++)//
......@@ -88,7 +89,8 @@ int mbs_linearipk(double **GK, MbsLpk *lpk, MbsAux *aux, MbsData *s, int EqChoi
copy_dvec_0(lpk->qdd_saved, &(s->qdd[1]), s->njoint);
copy_dvec_0(lpk->Qq_saved, &(s->Qq[1]), s->njoint);
copy_dvec_0(lpk->ux_saved, &(s->ux[1]), s->Nux);
lin_fail = mbs_lineari_fct(lpk->x_ext, lpk->F_ext, lpk, aux, s, EqChoice);
err = mbs_lineari_fct(lpk->x_ext, lpk->F_ext, lpk, aux, s, EqChoice);
if (err < 0) return err; // Error management
while (rep)
{
......@@ -101,7 +103,8 @@ int mbs_linearipk(double **GK, MbsLpk *lpk, MbsAux *aux, MbsData *s, int EqChoi
copy_dvec_0(lpk->qdd_saved, &(s->qdd[1]), s->njoint);
copy_dvec_0(lpk->Qq_saved, &(s->Qq[1]), s->njoint);
copy_dvec_0(lpk->ux_saved, &(s->ux[1]), s->Nux);
lin_fail = mbs_lineari_fct(lpk->x_mid,lpk->F_mid,lpk, aux, s, EqChoice);
err = mbs_lineari_fct(lpk->x_mid,lpk->F_mid,lpk, aux, s, EqChoice);
if (err < 0) return err; // Error management
for (i = 0; i < lpk->nF; i++)
{
......@@ -224,27 +227,26 @@ int mbs_linearipk(double **GK, MbsLpk *lpk, MbsAux *aux, MbsData *s, int EqChoi
}
if (lpk->verbose)
{
mbs_msg(">>LINEARIPK>> Column %d/%d has converged \n", k + 1, lpk->nx);
mbs_msg(">>LINPK>> Column %d/%d has converged \n", k + 1, lpk->nx);
}
}
// waiting column k is still not acepted
else
else // Error management
{
mbs_msg(">>LINEARIPK>> Column %d/%d no convergence after %d iterations\n", k + 1, lpk->nx, lpk->itermax);
mbs_msg(">>LINEARIPK>> Restart with other parameters !\n");
lin_fail = 1;
return lin_fail;
mbs_msg(">>LINPK>> Column %d/%d no convergence after %d iterations\n", k + 1, lpk->nx, lpk->itermax);
mbs_msg(">>LINPK>> Restart with other parameters !\n");
err = -10;
return err;
}
}
}
lin_fail = 0;
return lin_fail;
return err;
}
int mbs_lineari_fct(double *x,double *Fx, MbsLpk *lpk, MbsAux *aux, MbsData *s,int EqChoice)
{
int fail = 0;
int err = 0;
int i;
for (i = 0; i < lpk->nx; i++)
......@@ -255,7 +257,13 @@ int mbs_lineari_fct(double *x,double *Fx, MbsLpk *lpk, MbsAux *aux, MbsData *s,i
if (EqChoice == 1)
{
//Compute Rred
fail = mbs_Rred(aux, s);
err = mbs_Rred(aux, s);
if (err < 0) // Error management
{
mbs_msg(">>LINPK>>\n");
mbs_msg(">>LINPK>> Error during Rred evaluation !\n");
return err;
}
for (i = 0; i < s->nqu; i++)
{
Fx[i] = aux->Rred[i + 1]; // from Rob to Num convention
......@@ -267,15 +275,29 @@ int mbs_lineari_fct(double *x,double *Fx, MbsLpk *lpk, MbsAux *aux, MbsData *s,i
for (i = 0; i < s->Nux; i++)
{
if (isnan(s->uxd[i+1])) // Error management
{
mbs_msg(">>LINPK>> User derivative uxd[%d] is Nan\n", i+1);
return -47;
}
Fx[i] = s->uxd[i + 1];
}
}
else if (EqChoice == 3) // equilibrium equations (fxe)
{
user_equil_fxe(s, &(Fx[-1])); // dangerous play but it should be ok...
user_equil_fxe(s, &(Fx[-1])); // dangerous play but it should be ok (another way would be to allocate and free a Fxe1 vector)
for (i = 0; i < lpk->nF; i++)
{
if (isnan(Fx[i])) // Error management
{
mbs_msg(">>LINPK>> User equil Fxe[%d] is Nan\n", i+1);
return -17; // equil specific code
}
}
}
return fail;
return err;
}
MbsLpk* mbs_new_lpk(MbsData *s,int nx,int nF)
......
......@@ -102,9 +102,6 @@ void mbs_modal_init(MbsModal *mo, MbsData *s)
mo->lpk->verbose = 1;
}
// 1.1 test if a Modal analysis is needed AND if, a equilibrium has been performed beforehand
if (s->DoneEquil == 0)
{
......@@ -141,6 +138,12 @@ void mbs_modal_init(MbsModal *mo, MbsData *s)
mo->nx =2*s->nqu;
}
if (mo->nx == 0) // Error management
{
mbs_msg(">>MODAL>> There are no modal variables: nqu=%d , Nux=%d - irrelevant process\n", s->nqu, s->Nux);
mbs_error_msg(">>MODAL>> [%d] in mbs_modal_init \n", -300);
}
mo->eval_a = get_dvec_0(mo->nx);
mo->eval_b = get_dvec_0(mo->nx);
mo->evec_a = get_dmat_0(mo->nx, mo->nx);
......@@ -165,7 +168,6 @@ void mbs_modal_init(MbsModal *mo, MbsData *s)
mo->modeList[i]->evec_r = get_dvec_0(mo->nx);
mo->modeList[i]->evec_phi = get_dvec_0(mo->nx);
mo->modeList[i]->q_a = get_dvec_1(s->njoint);
mo->modeList[i]->q_b = get_dvec_1(s->njoint);
mo->modeList[i]->q_r = get_dvec_1(s->njoint);
......@@ -192,6 +194,8 @@ void mbs_modal_loop(MbsModal *mo, MbsData *s)
{
int i, j, k;
int err = 0;
int iMode; // for post-process
int next_type, ind_cur;
......@@ -213,7 +217,7 @@ void mbs_modal_loop(MbsModal *mo, MbsData *s)
copy_dvec_0(&(s->qd[1]), mo->qd_saved, s->njoint);
copy_dvec_0(&(s->qdd[1]), mo->qdd_saved, s->njoint);
copy_dvec_0(&(s->Qq[1]), mo->Qq_saved, s->njoint);
mbs_Mred(mo->aux, s);
err = mbs_Mred(mo->aux, s);
copy_dvec_0(mo->q_saved, &(s->q[1]), s->njoint);
copy_dvec_0(mo->qd_saved, &(s->qd[1]), s->njoint);
copy_dvec_0(mo->qdd_saved, &(s->qdd[1]), s->njoint);// might be unnecessary
......@@ -237,14 +241,27 @@ void mbs_modal_loop(MbsModal *mo, MbsData *s)
}
//---------- Computation of linearized matrices (into ss structure)
mbs_compute_linearMatrices(mo->ss, s, mo->lpk, mo->aux);
err = mbs_compute_linearMatrices(mo->ss, s, mo->lpk, mo->aux);
if (err < 0) // Error management
{
mbs_msg(">>MODAL>>\n");
mbs_msg(">>MODAL>> Error during Linearization \n");
mbs_error_msg("[%d] in mbs_modal_loop !! \n", -300 + err);
}
//---------- Computation of matrix A----------// (see Robotran Basics)
if (mo->options->verbose)
{
mbs_msg(">>MODAL(SS) >> Computation of the 1st order matrix A\n");
}
mbs_compute_statespace(mo->ss, s, mo->aux->Bvuc);
err = mbs_compute_statespace(mo->ss, s, mo->aux->Bvuc);
if (err < 0) // Error management
{
mbs_msg(">>MODAL>>\n");
mbs_msg(">>MODAL>> Error during A,B,C computation \n");
mbs_error_msg("[%d] in mbs_modal_loop !! \n", -300 + err);
}
// 3.---------- Modal analysis ----------//
......@@ -252,7 +269,14 @@ void mbs_modal_loop(MbsModal *mo, MbsData *s)
{
mbs_msg(">>MODAL(LAP)>> Eigenvalue Problem Solving\n");
}
mbs_eig_0(mo->ss->A, mo->nx, mo->eval_a, mo->eval_b, mo->evec_a, mo->evec_b);
err = mbs_eig_0(mo->ss->A, mo->nx, mo->eval_a, mo->eval_b, mo->evec_a, mo->evec_b);
if (err < 0) // Error management
{
mbs_msg(">>MODAL>>\n");
mbs_msg(">>MODAL>> Error during EigenProblem solving (Lapack) \n");
mbs_error_msg("[%d] in mbs_modal_loop !! \n", -300 + err);
}
// 4.---------- Post processing ----------//
......@@ -422,6 +446,7 @@ void mbs_modal_loop(MbsModal *mo, MbsData *s)
}
void mbs_modal_finish(MbsModal *mo, MbsData *s)
{
int err = 0;
char *filename;
if (mo->options->save2file)
......@@ -512,7 +537,13 @@ void mbs_modal_finish(MbsModal *mo, MbsData *s)
if (mo->options->save_result)
{
sprintf(filename, "%s/%s_%s.res", respath, resfilename, "result");
mbs_modal_save_result(mo, s, filename);
err = mbs_modal_save_result(mo, s, filename);
if (err < 0)
{
mbs_msg(">>MODAL>>\n");
mbs_error_msg("[%d] in mbs_modal_finish !! \n", -300 + err);
}
if (mo->options->verbose)
{
......@@ -524,7 +555,13 @@ void mbs_modal_finish(MbsModal *mo, MbsData *s)
if (mo->options->save_anim)
{
sprintf(filename, "%s/", animpath);
mbs_modal_save_anim(mo, s, filename); // actually filepath ...
err = mbs_modal_save_anim(mo, s, filename); // actually filepath ...
if (err < 0)
{
mbs_msg(">>MODAL>>\n");
mbs_error_msg("[%d] in mbs_modal_finish !! \n", -300 + err);
}
if (mo->options->verbose)
{
......@@ -633,10 +670,11 @@ int mbs_modal_norm_evec(double** mat_r, double** mat_phi, int nqu, int ind, doub
int mbs_modal_save_result(MbsModal* mo, MbsData* s, char* filename)
{
int err = 0;
int i, j;
char *q_type_char = "x";
const char *modetype_string[6];
modetype_string[0] = "unoscillating stable ";
modetype_string[1] = "rigid ";
......@@ -656,8 +694,8 @@ int mbs_modal_save_result(MbsModal* mo, MbsData* s, char* filename)
// Fill the file
if (fidR == NULL)
{
mbs_msg("error: cannot open file '%s'\n", filename);
return EXIT_FAILURE;
mbs_msg(">>MODAL>> In mbs_modal_save_result : cannot open file '%s'\n", filename);
return -9;
}
// 1. Result file Heading
......@@ -756,6 +794,8 @@ int mbs_modal_save_anim(MbsModal* mo, MbsData* s, char* filepath)
{
int i, j, k;
int err = 0;
char *filename; // caution
FILE *fidR;
double *q_print, *q_mode_r, *q_mode_phi;
......@@ -793,8 +833,8 @@ int mbs_modal_save_anim(MbsModal* mo, MbsData* s, char* filepath)
// Fill the file
if (fidR == NULL)
{
mbs_msg("error: cannot open file '%s'\n", filename);
return EXIT_FAILURE;
mbs_msg(">>MODAL>> In mbs_modal_save_anim : cannot open file '%s'\n", filename);
return -9;
}
......@@ -877,5 +917,5 @@ int mbs_modal_save_anim(MbsModal* mo, MbsData* s, char* filepath)
free_dvec_0(q_print);
free(filename);
return 0; // signature should be changed if no return is needed
return err; // signature should be changed if no return is needed
}
......@@ -556,8 +556,9 @@ int mbs_solvekin_write_buffers(MbsSolvekin* sk){
int mbs_fct_solvekin(MbsData *s, MbsSolvekin *sk)
{
int err = 0;
int err1=0, err2=0, err3=0;