Changeset 1671


Ignore:
Timestamp:
08/13/09 15:49:12 (15 years ago)
Author:
Mathieu Morlighem
Message:

Moved ControlPrepareStokes to ControlInitialization to avoid ifstokes everywhere

Location:
issm/trunk/src/c
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Makefile.am

    r1669 r1671  
    587587                                        ./parallel/control.cpp\
    588588                                        ./parallel/control_core.cpp\
    589                                         ./parallel/ControlPrepareStokes.cpp\
     589                                        ./parallel/ControlInitialization.cpp\
    590590                                        ./parallel/ControlTemporaryResults.cpp\
    591591                                        ./parallel/objectivefunctionC.cpp\
  • issm/trunk/src/c/parallel/control_core.cpp

    r1619 r1671  
    1313        extern int my_rank;
    1414
    15         /*fem models: */
    16         FemModel* fem_dh=NULL;
    17         FemModel* fem_dv=NULL;
    18         FemModel* fem_dhu=NULL;
    19         FemModel* fem_ds=NULL;
    20         FemModel* fem_sl=NULL;
     15        /*fem model: */
     16        FemModel* fem_model=NULL;
    2117
    2218        /*output: */
     
    4743
    4844        /*flags: */
    49         int   analysis_type;
    50         int   sub_analysis_type;
     45        int analysis_type;
     46        int sub_analysis_type;
    5147        int debug=0;
    52         int dim=-1;
    53         int ishutter=0;
    54         int ismacayealpattyn=0;
    55         int isstokes=0;
    56         int numberofdofspernode_sl;
    57         int numberofdofspernode_dh;
    58         int numberofdofspernode_ds;
    5948        int numberofnodes;
    6049
    61         /*recover fem models: */
    62         fem_dh=fems+0;
    63         fem_dv=fems+1;
    64         fem_ds=fems+2;
    65         fem_dhu=fems+3;
    66         fem_sl=fems+4;
    67 
    68         //first recover parameters common to all solutions
    69         fem_dh->parameters->FindParam((void*)&debug,"debug");
    70         fem_dh->parameters->FindParam((void*)&dim,"dim");
    71         fem_dh->parameters->FindParam((void*)&ishutter,"ishutter");
    72         fem_dh->parameters->FindParam((void*)&ismacayealpattyn,"ismacayealpattyn");
    73         fem_dh->parameters->FindParam((void*)&numberofnodes,"numberofnodes");
    74         fem_dh->parameters->FindParam((void*)&isstokes,"isstokes");
     50        /*Process models*/
     51        ControlInitialization(&fem_model,fems,inputs);
    7552
    7653        /*Recover parameters used throughout the solution:*/
    77         fem_dh->parameters->FindParam((void*)&nsteps,"nsteps");
    78         fem_dh->parameters->FindParam((void*)&control_type,"control_type");
    79         fem_dh->parameters->FindParam((void*)&fit,"fit");
    80         fem_dh->parameters->FindParam((void*)&optscal,"optscal");
    81         fem_dh->parameters->FindParam((void*)&maxiter,"maxiter");
    82         fem_dh->parameters->FindParam((void*)&tolx,"tolx");
    83         fem_dh->parameters->FindParam((void*)&mincontrolconstraint,"mincontrolconstraint");
    84         fem_dh->parameters->FindParam((void*)&maxcontrolconstraint,"maxcontrolconstraint");
    85         fem_dh->parameters->FindParam((void*)&param_g,"param_g");
    86         fem_dh->parameters->FindParam((void*)&analysis_type,"analysis_type");
    87         fem_dh->parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type");
    88         fem_dh->parameters->FindParam((void*)&numberofnodes,"numberofnodes");
    89         gsize=fem_dh->nodes->NumberOfDofs();
     54        fem_model->parameters->FindParam((void*)&nsteps,"nsteps");
     55        fem_model->parameters->FindParam((void*)&control_type,"control_type");
     56        fem_model->parameters->FindParam((void*)&fit,"fit");
     57        fem_model->parameters->FindParam((void*)&optscal,"optscal");
     58        fem_model->parameters->FindParam((void*)&maxiter,"maxiter");
     59        fem_model->parameters->FindParam((void*)&tolx,"tolx");
     60        fem_model->parameters->FindParam((void*)&mincontrolconstraint,"mincontrolconstraint");
     61        fem_model->parameters->FindParam((void*)&maxcontrolconstraint,"maxcontrolconstraint");
     62        fem_model->parameters->FindParam((void*)&param_g,"param_g");
     63        fem_model->parameters->FindParam((void*)&analysis_type,"analysis_type");
     64        fem_model->parameters->FindParam((void*)&sub_analysis_type,"sub_analysis_type");
     65        fem_model->parameters->FindParam((void*)&numberofnodes,"numberofnodes");
     66        gsize=fem_model->nodes->NumberOfDofs();
    9067
    9168        /*Initialize misfit: */
     
    9370
    9471        /*erase useless parameters: */
    95         param=(Param*)fem_dh->parameters->FindParamObject("param_g");
    96         fem_dh->parameters->DeleteObject((Object*)param);
     72        param=(Param*)fem_model->parameters->FindParamObject("param_g");
     73        fem_model->parameters->DeleteObject((Object*)param);
    9774
    98         param=(Param*)fem_dh->parameters->FindParamObject("u_g");
    99         fem_dh->parameters->DeleteObject((Object*)param);
    100 
    101         /*take care of Stokes: compute slope and get spc once for all*/
    102         if (isstokes) ControlPrepareStokes(fems,inputs);
     75        param=(Param*)fem_model->parameters->FindParamObject("u_g");
     76        fem_model->parameters->DeleteObject((Object*)param);
    10377
    10478        /*Start looping: */
     
    11084
    11185                /*Update parameters: */
    112                 if (isstokes) UpdateFromInputsx(fem_ds->elements,fem_ds->nodes,fem_ds->loads, fem_ds->materials,inputs);
    113                 else UpdateFromInputsx(fem_dh->elements,fem_dh->nodes,fem_dh->loads, fem_dh->materials,inputs);
     86                UpdateFromInputsx(fem_model->elements,fem_model->nodes,fem_model->loads, fem_model->materials,inputs);
    11487
    11588                _printf_("%s\n","      computing gradJ...");
    116                 if (isstokes) grad_g=GradJCompute(inputs,fem_ds);
    117                 else grad_g=GradJCompute(inputs,fem_dh);
     89                grad_g=GradJCompute(inputs,fem_model);
    11890                _printf_("%s\n","      done.");
    11991
     
    12698
    12799                _printf_("%s\n","      optimizing along gradient direction...");
    128                 if (isstokes) optargs.femmodel=fem_ds;
    129                 else optargs.femmodel=fem_dh;
     100                optargs.femmodel=fem_model;
    130101                optargs.param_g=param_g; optargs.grad_g=grad_g_double; optargs.inputs=inputs;optargs.n=n;
    131102                optpars.xmin=0; optpars.xmax=1; optpars.tolerance=tolx; optpars.maxiter=(int)maxiter[n];
  • issm/trunk/src/c/parallel/parallel.h

    r1669 r1671  
    4141void WriteLockFile(char* filename);
    4242
    43 void ControlPrepareStokes(FemModel* fems, ParameterInputs* inputs);
     43void ControlInitialization(FemModel** pmodel, FemModel* fems, ParameterInputs* inputs);
    4444void ControlTemporaryResults(FemModel* fems,double* param_g,double* J,int n,ParameterInputs* inputs);
    4545
Note: See TracChangeset for help on using the changeset viewer.