Changeset 18349


Ignore:
Timestamp:
08/08/14 13:33:36 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: added CreateLHS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/solutionsequences/solutionsequence_fct.cpp

    r18348 r18349  
    161161
    162162        /*Create LHS: [ML − theta*detlat *(K+D)^n+1]*/
    163         MatDuplicate(K_petsc,MAT_SHARE_NONZERO_PATTERN,&LHS);
    164         MatGetOwnershipRange(K_petsc,&rstart,&rend);
    165         for(int row=rstart; row<rend; row++){
    166                 MatGetRow(K_petsc,row,&ncols, (const int**)&cols, (const double**)&vals);
    167                 MatGetRow(D_petsc,row,&ncols2,(const int**)&cols2,(const double**)&vals2);
    168                 _assert_(ncols==ncols2);
    169                 for(int j=0; j<ncols; j++) {
    170                         _assert_(cols[j]==cols2[j]);
    171                         d = -theta*deltat*(vals[j] + vals2[j]);
    172                         if(cols[j]==row){
    173                                 VecGetValues(Ml_petsc,1,(const int*)&cols[j],&mi);
    174                                 d += mi;
    175                         }
    176                         if(fabs(d)>dmax) dmax = fabs(d);
    177                         MatSetValues(LHS,1,&row,1,&cols[j],(const double*)&d,INSERT_VALUES);
    178                 }
    179                 MatRestoreRow(K_petsc,row,&ncols, (const int**)&cols, (const double**)&vals);
    180                 MatRestoreRow(D_petsc,row,&ncols2,(const int**)&cols2,(const double**)&vals2);
    181         }
    182 
    183         /*Penalize Dirichlet boundary*/
    184         dmax = dmax * 1.e+3;
    185         for(int i=0;i<femmodel->constraints->Size();i++){
    186                 Constraint* constraint=(Constraint*)femmodel->constraints->GetObjectByOffset(i);
    187                 if(constraint->InAnalysis(analysis_type)){
    188                         constraint->PenaltyDofAndValue(&dof,&d,femmodel->nodes,femmodel->parameters);
    189                         if(dof!=-1){
    190                                 MatSetValues(LHS,1,&dof,1,&dof,(const double*)&dmax,INSERT_VALUES);
    191                         }
    192                 }
    193         }
    194         MatAssemblyBegin(LHS,MAT_FINAL_ASSEMBLY);
    195         MatAssemblyEnd(  LHS,MAT_FINAL_ASSEMBLY);
     163        CreateLHS(&LHS,&dmax,K_petsc,D_petsc,Ml_petsc,theta,deltat,femmodel,configuration_type);
    196164
    197165        /*Create RHS: [ML + (1 − theta) deltaT L^n] u^n */
     
    265233        VecDuplicate(u,&Ri_plus);
    266234        VecDuplicate(u,&Ri_minus);
     235        MatGetOwnershipRange(K_petsc,&rstart,&rend);
    267236        for(int row=rstart; row<rend; row++){
    268237                double Pi_plus  = 0.;
Note: See TracChangeset for help on using the changeset viewer.