/[escript]/trunk/paso/src/FCT_Solver.cpp
ViewVC logotype

Diff of /trunk/paso/src/FCT_Solver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4800 by caltinay, Wed Mar 26 01:50:04 2014 UTC revision 4801 by caltinay, Wed Mar 26 03:26:58 2014 UTC
# Line 54  Paso_FCT_Solver* Paso_FCT_Solver_alloc(P Line 54  Paso_FCT_Solver* Paso_FCT_Solver_alloc(P
54           out->du = NULL;           out->du = NULL;
55           out->z=NULL;           out->z=NULL;
56          }          }
57      out->u_coupler = Paso_Coupler_alloc(Paso_TransportProblem_borrowConnector(fctp), blockSize);      out->u_coupler = paso::Coupler_alloc(Paso_TransportProblem_borrowConnector(fctp), blockSize);
58          out->u_old_coupler = Paso_Coupler_alloc(Paso_TransportProblem_borrowConnector(fctp), blockSize);          out->u_old_coupler = paso::Coupler_alloc(Paso_TransportProblem_borrowConnector(fctp), blockSize);
59      out->omega=0;      out->omega=0;
60            
61      if ( options->ode_solver == PASO_LINEAR_CRANK_NICOLSON ) {      if ( options->ode_solver == PASO_LINEAR_CRANK_NICOLSON ) {
# Line 86  void Paso_FCT_Solver_free(Paso_FCT_Solve Line 86  void Paso_FCT_Solver_free(Paso_FCT_Solve
86            Paso_TransportProblem_free(in->transportproblem);            Paso_TransportProblem_free(in->transportproblem);
87        Paso_FCT_FluxLimiter_free(in->flux_limiter);        Paso_FCT_FluxLimiter_free(in->flux_limiter);
88            Esys_MPIInfo_free(in->mpi_info);            Esys_MPIInfo_free(in->mpi_info);
89        Paso_Coupler_free(in->u_old_coupler);            paso::Coupler_free(in->u_old_coupler);
90        Paso_Coupler_free(in->u_coupler);            paso::Coupler_free(in->u_coupler);
91    
92        delete[] in->b;        delete[] in->b;
93        delete[] in->z;        delete[] in->z;
# Line 221  err_t Paso_FCT_Solver_update_LCN(Paso_FC Line 221  err_t Paso_FCT_Solver_update_LCN(Paso_FC
221      err_t errorCode = SOLVER_NO_ERROR;      err_t errorCode = SOLVER_NO_ERROR;
222      double norm_u_tilde;      double norm_u_tilde;
223        
224      Paso_Coupler_startCollect(fct_solver->u_old_coupler,u_old);      paso::Coupler_startCollect(fct_solver->u_old_coupler,u_old);
225      Paso_Coupler_finishCollect(fct_solver->u_old_coupler);      paso::Coupler_finishCollect(fct_solver->u_old_coupler);
226            
227      /* b[i]=m*u_tilde[i] = m u_old[i] + dt/2 sum_{j <> i} l_{ij}*(u_old[j]-u_old[i])        /* b[i]=m*u_tilde[i] = m u_old[i] + dt/2 sum_{j <> i} l_{ij}*(u_old[j]-u_old[i])  
228             = u_tilde[i]   = u_old[i] where constraint m<0.             = u_tilde[i]   = u_old[i] where constraint m<0.
# Line 300  err_t Paso_FCT_Solver_updateNL(Paso_FCT_ Line 300  err_t Paso_FCT_Solver_updateNL(Paso_FCT_
300     bool converged=FALSE, max_m_reached=FALSE,diverged=FALSE;       bool converged=FALSE, max_m_reached=FALSE,diverged=FALSE;  
301     options->num_iter=0;     options->num_iter=0;
302        
303     Paso_Coupler_startCollect(fct_solver->u_old_coupler,u_old);     paso::Coupler_startCollect(fct_solver->u_old_coupler,u_old);
304     Paso_Coupler_finishCollect(fct_solver->u_old_coupler);     paso::Coupler_finishCollect(fct_solver->u_old_coupler);
305      /* prepare u_tilda and flux limiter */      /* prepare u_tilda and flux limiter */
306      if ( fct_solver->method == PASO_BACKWARD_EULER ) {      if ( fct_solver->method == PASO_BACKWARD_EULER ) {
307            /* b[i]=m_i* u_old[i] */            /* b[i]=m_i* u_old[i] */
# Line 333  err_t Paso_FCT_Solver_updateNL(Paso_FCT_ Line 333  err_t Paso_FCT_Solver_updateNL(Paso_FCT_
333      Paso_Copy(n,u,u_old);      Paso_Copy(n,u,u_old);
334            
335      while ( (!converged) && (!diverged) && (! max_m_reached) && Esys_noError()) {      while ( (!converged) && (!diverged) && (! max_m_reached) && Esys_noError()) {
336           Paso_Coupler_startCollect(fct_solver->u_coupler,u);          paso::Coupler_startCollect(fct_solver->u_coupler,u);
337           Paso_Coupler_finishCollect(fct_solver->u_coupler);          paso::Coupler_finishCollect(fct_solver->u_coupler);
338    
339           /*  set antidiffusive_flux_{ij} for u */           /*  set antidiffusive_flux_{ij} for u */
340           if (fct_solver->method == PASO_BACKWARD_EULER) {           if (fct_solver->method == PASO_BACKWARD_EULER) {
# Line 447  err_t Paso_FCT_Solver_updateNL(Paso_FCT_ Line 447  err_t Paso_FCT_Solver_updateNL(Paso_FCT_
447  void Paso_FCT_setAntiDiffusionFlux_CN(Paso_SystemMatrix *flux_matrix,  void Paso_FCT_setAntiDiffusionFlux_CN(Paso_SystemMatrix *flux_matrix,
448                                        const Paso_TransportProblem* fct,                                        const Paso_TransportProblem* fct,
449                        const double dt,                        const double dt,
450                            const Paso_Coupler* u_coupler,                              const paso::Coupler* u_coupler,  
451                        const Paso_Coupler* u_old_coupler)                        const paso::Coupler* u_old_coupler)
452  {  {
453    dim_t i;    dim_t i;
454    index_t iptr_ij;    index_t iptr_ij;
455        
456    const double *u    = Paso_Coupler_borrowLocalData(u_coupler);    const double *u    = paso::Coupler_borrowLocalData(u_coupler);
457    const double *u_old= Paso_Coupler_borrowLocalData(u_old_coupler);    const double *u_old= paso::Coupler_borrowLocalData(u_old_coupler);
458    const double *remote_u=Paso_Coupler_borrowRemoteData(u_coupler);    const double *remote_u=paso::Coupler_borrowRemoteData(u_coupler);
459    const double *remote_u_old=Paso_Coupler_borrowRemoteData(u_old_coupler);    const double *remote_u_old=paso::Coupler_borrowRemoteData(u_old_coupler);
460    const double dt_half= dt/2;    const double dt_half= dt/2;
461    const paso::SystemMatrixPattern *pattern=fct->iteration_matrix->pattern;    const paso::SystemMatrixPattern *pattern=fct->iteration_matrix->pattern;
462    const dim_t n=Paso_SystemMatrix_getTotalNumRows(fct->iteration_matrix);    const dim_t n=Paso_SystemMatrix_getTotalNumRows(fct->iteration_matrix);
# Line 493  void Paso_FCT_setAntiDiffusionFlux_CN(Pa Line 493  void Paso_FCT_setAntiDiffusionFlux_CN(Pa
493  void Paso_FCT_setAntiDiffusionFlux_BE(Paso_SystemMatrix *flux_matrix,  void Paso_FCT_setAntiDiffusionFlux_BE(Paso_SystemMatrix *flux_matrix,
494                                        const Paso_TransportProblem* fct,                                        const Paso_TransportProblem* fct,
495                        const double dt,                        const double dt,
496                            const Paso_Coupler* u_coupler,                              const paso::Coupler* u_coupler,  
497                        const Paso_Coupler* u_old_coupler)                        const paso::Coupler* u_old_coupler)
498  {  {
499    dim_t i;    dim_t i;
500    index_t iptr_ij;    index_t iptr_ij;
501        
502    const double *u=Paso_Coupler_borrowLocalData(u_coupler);    const double *u=paso::Coupler_borrowLocalData(u_coupler);
503    const double *u_old= Paso_Coupler_borrowLocalData(u_old_coupler);    const double *u_old= paso::Coupler_borrowLocalData(u_old_coupler);
504    const double *remote_u=Paso_Coupler_borrowRemoteData(u_coupler);    const double *remote_u=paso::Coupler_borrowRemoteData(u_coupler);
505    const double *remote_u_old=Paso_Coupler_borrowRemoteData(u_old_coupler);    const double *remote_u_old=paso::Coupler_borrowRemoteData(u_old_coupler);
506    const paso::SystemMatrixPattern *pattern=fct->iteration_matrix->pattern;    const paso::SystemMatrixPattern *pattern=fct->iteration_matrix->pattern;
507    const dim_t  n=Paso_SystemMatrix_getTotalNumRows(fct->iteration_matrix);    const dim_t  n=Paso_SystemMatrix_getTotalNumRows(fct->iteration_matrix);
508    
# Line 547  void Paso_FCT_setAntiDiffusionFlux_BE(Pa Line 547  void Paso_FCT_setAntiDiffusionFlux_BE(Pa
547  void Paso_FCT_setAntiDiffusionFlux_linearCN(Paso_SystemMatrix *flux_matrix,  void Paso_FCT_setAntiDiffusionFlux_linearCN(Paso_SystemMatrix *flux_matrix,
548                                              const Paso_TransportProblem* fct,                                              const Paso_TransportProblem* fct,
549                              const double dt,                              const double dt,
550                                  const Paso_Coupler* u_tilde_coupler,                                    const paso::Coupler* u_tilde_coupler,  
551                              const Paso_Coupler* u_old_coupler)                              const paso::Coupler* u_old_coupler)
552  {  {
553    dim_t i;    dim_t i;
554    index_t iptr_ij;    index_t iptr_ij;
555        
556    const double *u_tilde=Paso_Coupler_borrowLocalData(u_tilde_coupler);    const double *u_tilde=paso::Coupler_borrowLocalData(u_tilde_coupler);
557    const double *u_old= Paso_Coupler_borrowLocalData(u_old_coupler);    const double *u_old= paso::Coupler_borrowLocalData(u_old_coupler);
558    const double *remote_u_tilde=Paso_Coupler_borrowRemoteData(u_tilde_coupler);    const double *remote_u_tilde=paso::Coupler_borrowRemoteData(u_tilde_coupler);
559    const double *remote_u_old=Paso_Coupler_borrowRemoteData(u_old_coupler);    const double *remote_u_old=paso::Coupler_borrowRemoteData(u_old_coupler);
560    const paso::SystemMatrixPattern *pattern=fct->iteration_matrix->pattern;    const paso::SystemMatrixPattern *pattern=fct->iteration_matrix->pattern;
561    const dim_t n=Paso_SystemMatrix_getTotalNumRows(fct->iteration_matrix);    const dim_t n=Paso_SystemMatrix_getTotalNumRows(fct->iteration_matrix);
562    
# Line 688  printf("a[%d,%d]=%e\n",j,i,rtmp2); Line 688  printf("a[%d,%d]=%e\n",j,i,rtmp2);
688   */   */
689  void Paso_FCT_Solver_setMuPaLu(double* out,  void Paso_FCT_Solver_setMuPaLu(double* out,
690                                const double* M,                                const double* M,
691                                const Paso_Coupler* u_coupler,                                const paso::Coupler* u_coupler,
692                                const double a,                                const double a,
693                                const Paso_SystemMatrix *L)                                const Paso_SystemMatrix *L)
694  {  {
695    dim_t i;    dim_t i;
696    const paso::SystemMatrixPattern *pattern = L->pattern;    const paso::SystemMatrixPattern *pattern = L->pattern;
697    const double *u=Paso_Coupler_borrowLocalData(u_coupler);    const double *u=paso::Coupler_borrowLocalData(u_coupler);
698    const double *remote_u=Paso_Coupler_borrowRemoteData(u_coupler);    const double *remote_u=paso::Coupler_borrowRemoteData(u_coupler);
699    index_t iptr_ij;    index_t iptr_ij;
700    const dim_t n=Paso_SystemMatrix_getTotalNumRows(L);    const dim_t n=Paso_SystemMatrix_getTotalNumRows(L);
701    

Legend:
Removed from v.4800  
changed lines
  Added in v.4801

  ViewVC Help
Powered by ViewVC 1.1.26