Changeset 22633


Ignore:
Timestamp:
03/26/18 15:10:15 (7 years ago)
Author:
erobo
Message:

FIX: allow for ad/m1qn3 to work in parallel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/cores/controladm1qn3_core.cpp

    r22612 r22633  
    123123        CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
    124124        solutioncore(femmodel);
    125 
    126125
    127126        /*Reset the time to zero for next optimization*/
     
    276275        _assert_(JlistN==num_responses+1);
    277276
    278         /*Compute objective function*/
     277        /*Compute objective function and broadcast it to other cpus*/
    279278        *pf = reCast<double>(J);
     279        ISSM_MPI_Bcast(pf,1,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
    280280        _printf0_("f(x) = "<<setw(12)<<setprecision(7)<<*pf<<"  |  ");
    281281
     
    410410        /*Initialize Gradient and cost function of M1QN3*/
    411411        indic = 4; /*gradient required*/
    412         printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    413412        simul_ad(&indic,&n,X,&f,G,izs,rzs,(void*)&mystruct);
    414         printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    415413        /*Estimation of the expected decrease in f during the first iteration*/
    416414        double df1=f;
    417415
    418 printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    419416        /*Call M1QN3 solver*/
    420417        m1qn3_(simul_ptr,prosca,&ctonbe_,&ctcabe_,
     
    422419                                &gttol,normtype,&impres,&io,imode,&omode,&niter,&nsim,iz,dz,&ndz,
    423420                                &reverse,&indic,izs,rzs,(void*)&mystruct);
    424         printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    425421        switch(int(omode)){
    426422                case 0:  _printf0_("   Stop requested (indic = 0)\n"); break;
     
    434430                default: _printf0_("   Unknown end condition\n");
    435431        }
     432
    436433        /*Constrain solution vector*/
    437434        double  *XL = NULL;
    438         printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    439435        double  *XU = NULL;
    440436        GetPassiveVectorFromControlInputsx(&XL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"lowerbound");
    441         printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    442437        GetPassiveVectorFromControlInputsx(&XU,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,"upperbound");
    443438
    444         printf("-------------- file: controladm1qn3_core.cpp line: %i\n",__LINE__);
    445439        for(int i=0;i<numberofvertices;i++){
    446440                for(int c=0;c<num_controls;c++){
     
    465459
    466460        /*Add last cost function to results*/
     461
     462        if (solution_type == TransientSolutionEnum){
     463                int step = 1;
     464                femmodel->parameters->SetParam(step,StepEnum);
     465                femmodel->OutputControlsx(&femmodel->results);
     466                femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,mystruct.Jlist,(*mystruct.i),mystruct.N,1,0));
     467        }
     468        else{
     469                femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,mystruct.Jlist,(*mystruct.i),mystruct.N,0,0));
     470
    467471        femmodel->OutputControlsx(&femmodel->results);
    468         femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,mystruct.Jlist,(*mystruct.i),mystruct.N,0,0));
    469 
     472        }
    470473        /*Finalize*/
    471474        if(VerboseControl()) _printf0_("   preparing final solution\n");
     
    474477        CorePointerFromSolutionEnum(&solutioncore,femmodel->parameters,solution_type);
    475478        solutioncore(femmodel);
    476 
    477479
    478480        /*Clean-up and return*/
Note: See TracChangeset for help on using the changeset viewer.