Changeset 365


Ignore:
Timestamp:
05/12/09 16:14:22 (16 years ago)
Author:
Eric.Larour
Message:

diagnostic_core_nonlinear in parallel/ is now identical to serial matlab version. New get routine for input parameters

Location:
issm/trunk/src/c
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Input.cpp

    r301 r365  
    220220        throw ErrorException(__FUNCT__,"not supported yet!");
    221221}
     222
     223#undef __FUNCT__
     224#define __FUNCT__ "Input::Get"
     225Vec   Input::Get(int* in_dofs, int in_numdofs){
     226
     227        int i,j;
     228        int index;
     229        double value;
     230        extern int my_rank;
     231        int count=0;
     232        int i0,i1;
     233
     234        /*output: */
     235        Vec outvector=NULL;
     236        int totaldofs=0;
     237
     238        if (type!=DOUBLEVEC)throw ErrorException(__FUNCT__," trying to recover Petsc vector on non DOUBLEVEC entity!");
     239
     240        /*figure out how many dofs are requested: */
     241        totaldofs=0;
     242        for(i=0;i<in_numdofs;i++)totaldofs+=in_dofs[i];
     243       
     244        /*Allocate outvector: */
     245        outvector=NewVec(totaldofs*numberofnodes);
     246
     247        i0=MPI_Lowerrow(numberofnodes);
     248        i1=MPI_Upperrow(numberofnodes);
     249
     250        for(i=i0;i<i1;i++){
     251                count=0;
     252                for(j=0;j<in_numdofs;j++){
     253                        if (in_dofs[j]){
     254                                index=i*totaldofs+count;
     255                                value=vector[i*ndof+j];
     256                                VecSetValues(outvector,1,&index,&value,INSERT_VALUES);
     257                                count++;
     258                        }
     259                }
     260        }
     261
     262        /*Assmeble: */
     263        VecAssemblyBegin(outvector);
     264        VecAssemblyEnd(outvector);
     265
     266
     267        return outvector;
     268}
  • issm/trunk/src/c/objects/Input.h

    r246 r365  
    5757                void  Recover(double* pdouble);
    5858
     59                /*get into workspace: */
     60                Vec   Get(int* dofs, int numdofs);
     61
    5962};
    6063
  • issm/trunk/src/c/objects/ParameterInputs.cpp

    r246 r365  
    240240        return 1;
    241241}
     242               
     243#undef __FUNCT__
     244#define __FUNCT__ "ParameterInputs::Get"
     245Vec ParameterInputs::Get(char* name,int* dofs, int numdofs){
     246       
     247        int i;
     248        Input* input=NULL;
     249        int found=0;
     250       
     251        /*output: */
     252        Vec ug=NULL;
     253
     254        /*Go through dataset, and figure out if an Input
     255         * has the name "name": */
     256        for(i=0;i<dataset->Size();i++){
     257                input=(Input*)dataset->GetObjectByOffset(i);
     258
     259                if (input->IsSameName(name)){
     260                        found=1;
     261                        break;
     262                }
     263        }
     264
     265        if(found==0)return NULL;
     266       
     267        /*call submethod: */
     268        ug=input->Get(dofs,numdofs);
     269
     270        return ug;
     271}
  • issm/trunk/src/c/objects/ParameterInputs.h

    r246 r365  
    3333                int  Recover(char* name,double* values, int ndof, int* dofs,int numnodes,void** nodes); //void** because otherwise we get a circular dependency with Node
    3434
     35                Vec  Get(char* field_name,int* dofs, int numdofs);
     36
    3537                /*declaration found in io: */
    3638                void Init( void* data_handle);
  • issm/trunk/src/c/parallel/diagnostic_core_nonlinear.cpp

    r256 r365  
    4242        int debug=0;
    4343        double eps_rel,eps_abs,yts;
     44        int dofs[3]={1,1,0}; //recover vx,vy by default. vz may be.
    4445
    4546        /*Recover parameters: */
     
    5859        /*Copy loads for backup: */
    5960        loads=fem->loads->Copy();
     61       
     62        /*recover input velocities if present: */
     63        if (numberofdofspernode>=3)dofs[2]=1;//only keep vz if running with more than 3 dofs per node
     64        ug=inputs->Get("velocity",&dofs[0],3);
     65
     66        VecDuplicate(ug,&old_ug);
     67        VecCopy(ug,old_ug);
    6068
    6169        count=1;
  • issm/trunk/src/c/toolkits/mpi/patches/MPI_Lowerrow.cpp

    r1 r365  
    2727       
    2828}
    29 
    30 
    31 
    32 
    33 
Note: See TracChangeset for help on using the changeset viewer.