Ignore:
Timestamp:
05/15/10 19:36:18 (15 years ago)
Author:
Eric.Larour
Message:

Final build that compiles in serial and parallel model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/parallel/objectivefunctionC.cpp

    r3717 r3751  
    55#include "../modules.h"
    66#include "./parallel.h"
     7#include "../EnumDefinitions/EnumDefinitions.h"
    78
    89#ifdef HAVE_CONFIG_H
     
    2526        double* param_g=NULL;
    2627        double* grad_g=NULL;
    27         ParameterInputs* inputs=NULL;
    2828        int numberofdofspernode;
    2929        int n;
     
    3535        double  cm_min;
    3636        double  cm_max;
    37         char*   control_type=NULL;
     37        int   control_type;
    3838        double* param_g_copy=NULL;
    3939        int     analysis_type;
     
    4343        Vec     u_g_full=NULL;
    4444        double* u_g_double=NULL;
     45        double* vx=NULL;
     46        double* vy=NULL;
     47        double* vz=NULL;
    4548        int     numberofnodes;
    4649               
     
    5962        param_g=optargs->param_g;
    6063        grad_g=optargs->grad_g;
    61         inputs=optargs->inputs;
    6264        n=optargs->n;
    6365
    6466        gsize=femmodel->nodesets->GetGSize();
    6567        femmodel->parameters->FindParam(&optscal,NULL,NULL,OptScalEnum);
    66         femmodel->parameters->FindParam(&control_type,ControlTypeEnum);
    6768        femmodel->parameters->FindParam(&fit,NULL,NULL,FitEnum);
    6869        femmodel->parameters->FindParam(&cm_min,CmMinEnum);
     
    8788
    8889        /*Add new parameter to inputs: */
    89         inputs->Add(control_type,param_g_copy,1,numberofnodes);
     90        femmodel->UpdateInputsFromVector(param_g_copy,control_type,VertexEnum);
    9091
    9192        /*Run diagnostic with updated parameters.*/
    9293        if(!control_steady){
    93                 diagnostic_core_nonlinear(&u_g,NULL,NULL,NULL,femmodel,inputs,DiagnosticAnalysisEnum,sub_analysis_type);
    94                 VecToMPISerial(&u_g_double,u_g); VecFree(&u_g);
    95                 inputs->Add("velocity",u_g_double,numberofdofspernode,numberofnodes);
     94                diagnostic_core_nonlinear(&u_g,NULL,NULL,NULL,femmodel,DiagnosticAnalysisEnum,sub_analysis_type);
     95                femmodel->UpdateInputsFromSolution(u_g,DiagnosticAnalysisEnum,sub_analysis_type);
     96                VecFree(&u_g);
    9697        }
    9798        else{
    9899                //We need a 3D velocity!! (vz is required for the next thermal run)
    99100                diagnostic_results=new DataSet(ResultsEnum);
    100                 diagnostic_core(diagnostic_results,model, inputs);
     101                diagnostic_core(diagnostic_results,model);
    101102
    102103                //extract u_g and add it to input (3d velocity needed by thermal_core)
    103104                diagnostic_results->FindResult(&u_g,"u_g");
    104                 inputs->Add("velocity",u_g,3,numberofnodes);
     105               
     106                SplitSolutionVector(u_g,numberofnodes,3,&vx,&vy,&vz);
     107                femmodel->UpdateInputsFromVector(vx,VxEnum,VertexEnum);
     108                femmodel->UpdateInputsFromVector(vy,VxEnum,VertexEnum);
     109                femmodel->UpdateInputsFromVector(vz,VxEnum,VertexEnum);
     110               
    105111                delete diagnostic_results;
    106112        }
    107113
    108114        /*Compute misfit for this velocity field.*/
    109         inputs->Add("fit",fit[n]);
    110         CostFunctionx( &J, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters,inputs,analysis_type,sub_analysis_type);
     115        femmodel->UpdateInputsFromConstant(fit[n],FitEnum);
     116        CostFunctionx( &J, femmodel->elements,femmodel->nodes, femmodel->vertices,femmodel->loads, femmodel->materials, femmodel->parameters,analysis_type,sub_analysis_type);
    111117
    112118        /*Free ressources:*/
    113119        xfree((void**)&fit);
    114120        xfree((void**)&optscal);
    115         xfree((void**)&control_type);
    116121        xfree((void**)&param_g_copy);
    117         xfree((void**)&u_g_double);
    118122        xfree((void**)&dofset);
     123        xfree((void**)&vx);
     124        xfree((void**)&vy);
     125        xfree((void**)&vz);
    119126
    120127        return J;
Note: See TracChangeset for help on using the changeset viewer.