<div dir="ltr"><div class="gmail_default" style="font-size:small">Hello,<br><br></div><div class="gmail_default" style="font-size:small">I am modelling a hypersonic computational fluid dynamic problem, where the matrix A is quite sparse and stiff. The solution is x=[rho_1, rho_2, .., rho_11, u, v, w, T], where rho_s is the density for each of the species, some of which can reach 1.E-5, while some others can be below 1.E-20. <br></div><div class="gmail_default" style="font-size:small">As I ran my case, I found the number of iterations oscillated after being steady for a long time. For instance, the number of iterations was like 10 for 2000 steps, then it goes up to 50 for no reason. Then the code blows up. My code has being debugged for months. It should be fine. I was wondering if there is some other method that can be more stable than FGMRES or some method similar in terms of stability that I can try. Some code pieces are attached for checking.  <br><br></div><div class="gmail_default" style="font-size:small">Many thanks,<br>Paul<br></div><div class="gmail_default" style="font-size:small"><br>void petsc_init(void) {<br><br>        vector<Cell>::iterator cit;<br>        vector<int>::iterator it;<br><br>        //Create nonlinear solver context<br>        KSPCreate(PETSC_COMM_WORLD,&ksp);<br><br>        VecCreateMPI(PETSC_COMM_WORLD,grid[gid].cellCount*nVars,grid[gid].globalCellCount*nVars,&rhs);<br>        VecSetFromOptions(rhs);<br>        VecDuplicate(rhs,&deltaU);<br>        if (ps_step_max>1) {<br>                VecDuplicate(rhs,&soln_n);<br>                VecDuplicate(rhs,&pseudo_delta);<br>                VecDuplicate(rhs,&pseudo_right);<br>        }<br>        VecSet(rhs,0.);<br>        VecSet(deltaU,0.);<br><br>        vector<int> diagonal_nonzeros, off_diagonal_nonzeros;<br>        int nextCellCount;<br><br>        // Calculate space necessary for matrix memory allocation<br>        for (cit=grid[gid].cell.begin();cit!=grid[gid].cell.end();cit++) {<br>                nextCellCount=0;<br>                for (it=(*cit).faces.begin();it!=(*cit).faces.end();it++) {<br>                        if (grid[gid].face[*it].bc==INTERNAL_FACE) {<br>                                nextCellCount++;<br>                        }<br>                }<br>                for (int i=0;i<nVars;++i) {<br>                        diagonal_nonzeros.push_back( (nextCellCount+1)*nVars);<br>                        off_diagonal_nonzeros.push_back( ((*cit).ghosts.size())*nVars);<br>                }<br>        }<br><br>        MatCreateMPIAIJ(<br>                        PETSC_COMM_WORLD,<br>                        grid[gid].cellCount*nVars,<br>                        grid[gid].cellCount*nVars,<br>                        grid[gid].globalCellCount*nVars,<br>                        grid[gid].globalCellCount*nVars,<br>                        0,&diagonal_nonzeros[0],<br>                        0,&off_diagonal_nonzeros[0],<br>                        &impOP);<br><br>                                                                                                                                                                                                                         <br>        KSPSetOperators(ksp,impOP,impOP,SAME_NONZERO_PATTERN);<br>        KSPSetTolerances(ksp,rtol,abstol,1.e15,maxits);<br>        KSPSetInitialGuessKnoll(ksp,PETSC_TRUE);<br>        //KSPSetType(ksp,KSPGMRES);<br>        KSPSetType(ksp,KSPFGMRES);<br>        //KSPGMRESSetOrthogonalization(ksp,KSPGMRESModifiedGramSchmidtOrthogonalization);<br>        KSPGMRESSetRestart(ksp,30);<br>        KSPSetFromOptions(ksp);<br><br>        return;<br><br><br><br clear="all"></div><font size="1"><a href="http://gsil.engineering.uky.edu" target="_blank"><span style="color:rgb(0,0,153)"></span></a></font><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,153)"></span></span><div style="color:rgb(255,102,102)"><font size="1"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="text-indent:0px;letter-spacing:normal;font-variant:normal;font-style:normal;font-weight:normal;line-height:normal;border-collapse:separate;text-transform:none;white-space:normal;font-family:Helvetica;word-spacing:0px"><span style="font-family:Tahoma"><span style="font-family:Verdana"><font face="Helvetica"><span></span></font></span></span></span></span></span></span></span></font></div>
</div>