Changeset 119


Ignore:
Timestamp:
04/29/09 08:36:46 (16 years ago)
Author:
Mathieu Morlighem
Message:

change the way viscosity is computed -> same as ICE and CIELO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/solutions/macayeal/diagnostic.m

    r67 r119  
    9595clear X
    9696
    97 %Initialize viscosity
    98 nu_bar=viscosity(index,nel,alpha,beta,{},{},B_bar,glen_coeff);
    99 
    100 
    101  %  Do once and for all the initial computation of matrix-locations:
    102 
     97
     98%Do once and for all the initial computation of matrix-locations:
    10399row_location=zeros(nel*3*3,1);
    104100col_location=zeros(nel*3*3,1);
     
    116112end
    117113
    118 
    119114count=-nel+1;
    120115
     
    126121        end
    127122end
    128 
    129 
    130123
    131124permanent_pieces_of_A=zeros(nel*6,1);
     
    144137                        permanent_pieces_of_D(count:count+nel-1)= z_thick_bar .* aire ...
    145138                                .*(2*beta(:,i).*beta(:,j) + 1/2*alpha(:,i).*alpha(:,j));
    146 
    147139        end
    148140end
     
    159151                        permanent_pieces_of_C(count:count+nel-1)= z_thick_bar .* aire ...
    160152                        .*(beta(:,j).*alpha(:,i) + 1/2*alpha(:,j).*beta(:,i));
    161 
    162 
    163153        end
    164154end
     
    173163Rhs_y=ones(nel*27,1);
    174164row_rhs=zeros(nel*27,1);
    175 
    176165
    177166count=-nel+1;
     
    198187   sparse(row_rhs,ones(nel*27,1),Rhs_y,nods,1)]);
    199188
    200 for k=1:2
    201         for l=1:2
    202                 for j=1:2
     189        for k=1:2
     190                for l=1:2
     191                        for j=1:2
    203192                                Rhs(index_icefront(:,k))=Rhs(index_icefront(:,k)) + ...
    204 (rho_ice*g/2*z_thick(index_icefront(:,l)).*z_thick(index_icefront(:,j)) ...
    205 + rho_water*g/2*(md.gridoniceshelf(index_icefront(:,k))) ...
    206 .*(-min(0,z_bed(index_icefront(:,l))).*min(0,z_bed(index_icefront(:,j))) ...
    207 +min(0,z_thick(index_icefront(:,l))+z_bed(index_icefront(:,l)))...
    208 .*min(0,z_thick(index_icefront(:,j))+z_bed(index_icefront(:,j)))))...
    209 .*normal_icefront(:,1).*length_icefront(:) ...
    210 /(4*(l==k & j==k) + 12*(l~=k | j~=k) );
     193                                        (rho_ice*g/2*z_thick(index_icefront(:,l)).*z_thick(index_icefront(:,j)) ...
     194                                        + rho_water*g/2*(md.gridoniceshelf(index_icefront(:,k))) ...
     195                                        .*(-min(0,z_bed(index_icefront(:,l))).*min(0,z_bed(index_icefront(:,j))) ...
     196                                        +min(0,z_thick(index_icefront(:,l))+z_bed(index_icefront(:,l)))...
     197                                        .*min(0,z_thick(index_icefront(:,j))+z_bed(index_icefront(:,j)))))...
     198                                        .*normal_icefront(:,1).*length_icefront(:) ...
     199                                        /(4*(l==k & j==k) + 12*(l~=k | j~=k) );
    211200
    212201                                Rhs(index_icefront(:,k)+nods)=Rhs(index_icefront(:,k)+nods) + ...
    213 (rho_ice*g/2*z_thick(index_icefront(:,l)).*z_thick(index_icefront(:,j)) ...
    214 + rho_water*g/2*(md.gridoniceshelf(index_icefront(:,k))) ...
    215 .*(-min(0,z_bed(index_icefront(:,l))).*min(0,z_bed(index_icefront(:,j))) ...
    216 +min(0,z_thick(index_icefront(:,l))+z_bed(index_icefront(:,l)))...
    217 .*min(0,z_thick(index_icefront(:,j))+z_bed(index_icefront(:,j)))))...
    218 .*normal_icefront(:,2).*length_icefront(:) ...
    219 /(4*(l==k & j==k) + 12*(l~=k | j~=k) );
    220 
     202                                        (rho_ice*g/2*z_thick(index_icefront(:,l)).*z_thick(index_icefront(:,j)) ...
     203                                        + rho_water*g/2*(md.gridoniceshelf(index_icefront(:,k))) ...
     204                                        .*(-min(0,z_bed(index_icefront(:,l))).*min(0,z_bed(index_icefront(:,j))) ...
     205                                        +min(0,z_thick(index_icefront(:,l))+z_bed(index_icefront(:,l)))...
     206                                        .*min(0,z_thick(index_icefront(:,j))+z_bed(index_icefront(:,j)))))...
     207                                        .*normal_icefront(:,2).*length_icefront(:) ...
     208                                        /(4*(l==k & j==k) + 12*(l~=k | j~=k) );
    221209                end
    222210        end
     
    253241P=sparse(row,col,value,2*nods-num_specified,2*nods);
    254242
    255 
    256243specified_velocity=zeros(2*nods,1);
    257244pos=find(node_on_dirichlet);
     
    278265        loop=loop+1;
    279266
    280         nu_bar_oldvalue=nu_bar;
     267        %Compute viscosity (as in ICE and CIELO)
     268        if convergence_count==1;
     269                %Initialize viscosity
     270                nu_bar=viscosity(index,nel,alpha,beta,{},{},B_bar,glen_coeff);
     271        elseif convergence_count==2,
     272                nu_bar_oldvalue=nu_bar;
     273                nu_bar=viscosity(index,nel,alpha,beta,u,v,B_bar,glen_coeff);
     274                nu_bar=nu_bar + viscosity_overshoot*(nu_bar-nu_bar_oldvalue);
     275                nu_bar(find(nu_bar<=0))=-nu_bar(find(nu_bar<=0));
     276                u_old=u; v_old=v;
     277        else
     278                nu_bar_oldvalue=viscosity(index,nel,alpha,beta,u_old,v_old,B_bar,glen_coeff);
     279                nu_bar=viscosity(index,nel,alpha,beta,u,v,B_bar,glen_coeff);
     280                nu_bar=nu_bar + viscosity_overshoot*(nu_bar-nu_bar_oldvalue);
     281                nu_bar(find(nu_bar<=0))=-nu_bar(find(nu_bar<=0));
     282                u_old=u; v_old=v;
     283        end
    281284
    282285        % Step 4 -- Set up stress-balance matrix  (whos solution is the velocity
     
    299302                                matrix_value_D(count:count+nel-1)=nu_bar .* ...
    300303                                  permanent_pieces_of_D(count:count+nel-1);
    301 
    302 
    303304                end
    304305        end
     
    315316                                matrix_value_C(count:count+nel-1)=nu_bar .* ...
    316317                                  permanent_pieces_of_C(count:count+nel-1);
    317 
    318 
    319                 end
    320         end
    321 
    322 
     318                end
     319        end
    323320
    324321        A=sparse(row_location_AD,col_location_AD,matrix_value_A,nods,nods);
     
    328325        D=sparse(row_location_AD,col_location_AD,matrix_value_D,nods,nods);
    329326        D=D+triu(D,1)';
    330 
    331327
    332328        F=[A C
     
    399395        end
    400396
    401 
    402397        Rhs_parsed=P*(Rhs - F*specified_velocity);
    403398        F=P*F*P';
    404 
    405399
    406400        % Step 5 -- Solve the problem:
     
    414408        % Cholesky decomposition is twice as efficient as LU for symmetric
    415409        % definite positive matrix
    416 
    417                 if strcmpi(md.solver_type,'lu'),
    418                         % Solve by LU decomposition.
    419                         [L,U] = lu(F);
    420                         solution= U\(L\Rhs_parsed);
    421                 elseif strcmpi(md.solver_type,'cholesky'),
    422                         % Solve by Choleski decomposition.
    423                         L = chol(F);
    424                         solution= L\(L'\Rhs_parsed);
    425                 else
    426                         % use matlab's generic solver
    427                         solution = F\Rhs_parsed;
    428                 end
    429            
    430 
     410        if md.debug,
     411                disp(sprintf('%s%g','      condition number of stiffness matrix: ',condest(F)));
     412        end
     413        solution=Solver(F,Rhs_parsed,md.solver_type);
    431414
    432415        %Add spcs to the calculated solution
     
    436419        u=solution(1:nods);
    437420        v=solution(nods+1:2*nods);
    438 
    439         %Compute viscosity
    440         nu_bar=viscosity(index,nel,alpha,beta,u,v,B_bar,glen_coeff);
    441         change=1 - nu_bar_oldvalue./nu_bar;
    442 
    443         %Update viscosity
    444         nu_bar=nu_bar.*(1+viscosity_overshoot*change);
    445         location=find(nu_bar<=0);
    446         nu_bar(location)=-nu_bar(location);
    447421
    448422        %Test for direct shooting convergence
     
    455429                relative_change=ndug/nug;
    456430
    457 
    458431                %Figure out if viscosity converged
    459432                if relative_change<criterion_rel,
    460                         disp(sprintf('%s %g %s %g %s','   Convergence criterion: norm(du)/norm(u)=',relative_change,' < ',criterion_rel,' m/yr'));
     433                        if md.debug, disp(sprintf('%s %g %s %g %s','   Convergence criterion: norm(du)/norm(u)=',relative_change,' < ',criterion_rel,' m/yr'));end
    461434                        converged_yet=1;
    462435                else
    463                         disp(sprintf('%s %g %s %g %s','   Convergence criterion: norm(du)/norm(u)=',relative_change,' > ',criterion_rel,' m/yr'));
     436                        if md.debug, disp(sprintf('%s %g %s %g %s','   Convergence criterion: norm(du)/norm(u)=',relative_change,' > ',criterion_rel,' m/yr'));end
    464437                        converged_yet=0;
    465438                end
     
    468441                        change=max(abs(dug))*yts;
    469442                        if change<criterion_abs
    470                                 disp(sprintf('%s %g %s %g %s','   Convergence criterion: max(du)=',change,' < ',criterion_abs,' m/yr'));
     443                                if md.debug, disp(sprintf('%s %g %s %g %s','   Convergence criterion: max(du)=',change,' < ',criterion_abs,' m/yr'));end
    471444                        else
    472                                 disp(sprintf('%s %g %s %g %s','   Convergence criterion: max(du)=',change,' > ',criterion_abs,' m/yr'));
     445                                if md.debug, disp(sprintf('%s %g %s %g %s','   Convergence criterion: max(du)=',change,' > ',criterion_abs,' m/yr'));end
    473446                                converged_yet=0;
    474447                        end
     
    477450                converged_yet=0;
    478451        end
    479 
    480         u_old=u;
    481         v_old=v;
    482452
    483453        convergence_count=convergence_count+1;
Note: See TracChangeset for help on using the changeset viewer.