Changeset 9834


Ignore:
Timestamp:
Apr 28, 2017 5:21:17 PM (3 years ago)
Author:
Christian Andersson
Message:

Removed direct usage of kinsol attributes. Related to ticket:4815

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/RuntimeLibrary/src/jmi/jmi_kinsol_solver.c

    r9819 r9834  
    13071307
    13081308/* Limit the maximum step to be within bounds. Do projection if needed. */
    1309 static void jmi_kinsol_limit_step(struct KINMemRec * kin_mem, N_Vector x, N_Vector b) {
     1309static void jmi_kinsol_limit_step(struct KINMemRec * kin_mem, N_Vector x, N_Vector b, realtype *sJpnorm, realtype *sFdotJp) {
    13101310    jmi_block_solver_t *block = (jmi_block_solver_t *)kin_mem->kin_user_data;
    13111311    jmi_kinsol_solver_t* solver = (jmi_kinsol_solver_t*)block->solver; 
     
    15991599    if(max_step_ratio < 1.0) {
    16001600        /* reduce the norms of Jp. This is only approximate since active bounds are not accounted for.*/
    1601         kin_mem->kin_sFdotJp *= max_step_ratio;
    1602         kin_mem->kin_sJpnorm *= max_step_ratio;
    1603         solver->sJpnorm = kin_mem->kin_sJpnorm;
     1601        *sFdotJp *= max_step_ratio;
     1602        *sJpnorm *= max_step_ratio;
     1603        solver->sJpnorm = *sJpnorm;
    16041604    }
    16051605    /* The maximum newton step leads to the bound 
     
    22992299            jmi_log_reals(block->log, topnode, logInfo, "unbounded_step", xd, block->n);
    23002300        }
    2301         jmi_kinsol_limit_step(kin_mem, x, b);
     2301        jmi_kinsol_limit_step(kin_mem, x, b, sJpnorm, sFdotJp);
    23022302        t = jmi_block_solver_start_clock(block);
    23032303        if(solver->last_num_active_bounds > 0 && (block->options->active_bounds_mode == jmi_use_steepest_descent_active_bounds_mode)) {
     
    23302330                }
    23312331                N_VScale(g_scale, solver->gradient, x);
    2332              /*   sfJp *= g_scale;
    2333                 jmi_kinsol_calc_Mv(solver->J, FALSE, solver->gradient, b);
    2334                 sJpnorm = N_VWL2Norm(b,solver->kin_f_scale); */
    2335                 jmi_kinsol_limit_step(kin_mem, x, b);
     2332                jmi_kinsol_limit_step(kin_mem, x, b, sJpnorm, sFdotJp);
    23362333
    23372334                sfJp = jmi_kinsol_calc_v1twwv2(x, solver->gradient, 0);
     
    23452342            jmi_kinsol_calc_Mv(block->J, FALSE, x, b);
    23462343            *sJpnorm = N_VWL2Norm(b,block->f_scale);
    2347             /* update sJpnorm and sfdotJp for Kinsol */
    2348             /* kin_mem->kin_sJpnorm = sJpnorm; */
    23492344            *sFdotJp = -sfJp; /* Due to opposite sign of solver->gradient minus is present here. */
    23502345            solver->sJpnorm = *sJpnorm;
Note: See TracChangeset for help on using the changeset viewer.