/[escript]/trunk/paso/src/SolverFCT.c
ViewVC logotype

Diff of /trunk/paso/src/SolverFCT.c

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

revision 1370 by gross, Wed Jan 2 09:21:43 2008 UTC revision 1415 by ksteube, Thu Feb 21 04:57:17 2008 UTC
# Line 36  void Paso_FCTransportProblem_free(Paso_F Line 36  void Paso_FCTransportProblem_free(Paso_F
36          if (in->reference_counter<=0) {          if (in->reference_counter<=0) {
37    
38             Paso_SystemMatrix_free(in->transport_matrix);             Paso_SystemMatrix_free(in->transport_matrix);
39             Paso_SystemMatrix_free(in->flux_matrix);             Paso_SystemMatrix_free(in->mass_matrix);
40               Paso_SystemMatrix_free(in->iteration_matrix);
41             Paso_MPIInfo_free(in->mpi_info);             Paso_MPIInfo_free(in->mpi_info);
   
42             MEMFREE(in->u);             MEMFREE(in->u);
            MEMFREE(in->lumped_mass_matrix);  
            MEMFREE(in->row_sum_flux_matrix);  
            MEMFREE(in->transport_matrix_diagonal);  
            MEMFREE(in->colorOf);  
43             MEMFREE(in->main_iptr);             MEMFREE(in->main_iptr);
44               MEMFREE(in->lumped_mass_matrix);
45               MEMFREE(in->main_diagonal_low_order_transport_matrix);
46             MEMFREE(in);             MEMFREE(in);
47          }          }
48      }      }
# Line 60  Paso_FCTransportProblem* Paso_FCTranspor Line 58  Paso_FCTransportProblem* Paso_FCTranspor
58  Paso_SystemMatrix* Paso_FCTransportProblem_borrowTransportMatrix(Paso_FCTransportProblem* in) {  Paso_SystemMatrix* Paso_FCTransportProblem_borrowTransportMatrix(Paso_FCTransportProblem* in) {
59     return in->transport_matrix;     return in->transport_matrix;
60  }  }
61    Paso_SystemMatrix* Paso_FCTransportProblem_borrowMassMatrix(Paso_FCTransportProblem* in) {
62  Paso_SystemMatrix* Paso_FCTransportProblem_borrowFluxMatrix(Paso_FCTransportProblem* in) {     return in->mass_matrix;
     return in->flux_matrix;  
63  }  }
64    
65  double* Paso_FCTransportProblem_borrowLumpedMassMatrix(Paso_FCTransportProblem* in) {  double* Paso_FCTransportProblem_borrowLumpedMassMatrix(Paso_FCTransportProblem* in) {
# Line 73  dim_t Paso_FCTransportProblem_getTotalNu Line 70  dim_t Paso_FCTransportProblem_getTotalNu
70      return Paso_SystemMatrix_getTotalNumRows(in->transport_matrix);      return Paso_SystemMatrix_getTotalNumRows(in->transport_matrix);
71  }  }
72    
73  Paso_FCTransportProblem* Paso_FCTransportProblem_alloc(double theta, double dt_max, Paso_SystemMatrixPattern *pattern, int block_size  Paso_FCTransportProblem* Paso_FCTransportProblem_alloc(double theta, Paso_SystemMatrixPattern *pattern, int block_size
74    
75    
76  ) {  ) {
# Line 90  Paso_FCTransportProblem* Paso_FCTranspor Line 87  Paso_FCTransportProblem* Paso_FCTranspor
87       out=MEMALLOC(1,Paso_FCTransportProblem);       out=MEMALLOC(1,Paso_FCTransportProblem);
88       if (Paso_checkPtr(out)) return NULL;       if (Paso_checkPtr(out)) return NULL;
89    
90    
91       out->theta=theta;       out->theta=theta;
92       out->dt_max=dt_max;       out->dt_max=LARGE_POSITIVE_FLOAT;
93       out->valid_matrices=FALSE;       out->valid_matrices=FALSE;
94       out->transport_matrix=Paso_SystemMatrix_alloc(matrix_type,pattern,block_size,block_size);       out->transport_matrix=Paso_SystemMatrix_alloc(matrix_type,pattern,block_size,block_size);
95       Paso_SystemMatrix_allocBuffer(out->transport_matrix);       Paso_SystemMatrix_allocBuffer(out->transport_matrix);
96       out->flux_matrix=Paso_SystemMatrix_alloc(matrix_type,pattern,block_size,block_size);       out->mass_matrix=Paso_SystemMatrix_alloc(matrix_type,pattern,block_size,block_size);
97       out->mpi_info=Paso_MPIInfo_getReference(pattern->mpi_info);       out->iteration_matrix=NULL;
98    
99       out->colorOf=NULL;       out->mpi_info=Paso_MPIInfo_getReference(pattern->mpi_info);
100         out->u=NULL;
101         out->u_min=0.;
102       out->main_iptr=NULL;       out->main_iptr=NULL;
103       out->lumped_mass_matrix=NULL;       out->lumped_mass_matrix=NULL;
104       out->row_sum_flux_matrix=NULL;       out->main_diagonal_low_order_transport_matrix=NULL;
      out->transport_matrix_diagonal=NULL;  
105    
106       if (Paso_noError()) {       if (Paso_noError()) {
107           n=Paso_SystemMatrix_getTotalNumRows(out->transport_matrix);           n=Paso_SystemMatrix_getTotalNumRows(out->transport_matrix);
108    
109           out->colorOf=MEMALLOC(n,index_t);           out->u=MEMALLOC(n,double);
110           out->main_iptr=MEMALLOC(n,index_t);           out->main_iptr=MEMALLOC(n,index_t);
111           out->lumped_mass_matrix=MEMALLOC(n,double);           out->lumped_mass_matrix=MEMALLOC(n,double);
112           out->row_sum_flux_matrix=MEMALLOC(n,double);           out->main_diagonal_low_order_transport_matrix=MEMALLOC(n,double);
          out->transport_matrix_diagonal=MEMALLOC(n,double);  
          out->u=MEMALLOC(n,double);  
   
          if ( ! (Paso_checkPtr(out->colorOf) || Paso_checkPtr(out->main_iptr) ||  
                  Paso_checkPtr(out->lumped_mass_matrix) || Paso_checkPtr(out->transport_matrix_diagonal) || Paso_checkPtr(out->row_sum_flux_matrix) || Paso_checkPtr(out->u)) ) {  
               
              printf("Paso_SolverFCT_getFCTransportProblem: Revise coloring!!\n");  
              Paso_Pattern_color(pattern->mainPattern,&(out->num_colors),out->colorOf);  
113    
114             if ( ! (Paso_checkPtr(out->u) || Paso_checkPtr(out->main_iptr) ||
115                     Paso_checkPtr(out->lumped_mass_matrix) || Paso_checkPtr(out->main_diagonal_low_order_transport_matrix))  ) {
116                            
117               #pragma omp parallel for schedule(static) private(i)               #pragma omp parallel for schedule(static) private(i)
118               for (i = 0; i < n; ++i) {               for (i = 0; i < n; ++i) {
119                  out->lumped_mass_matrix[i]=0.;                  out->lumped_mass_matrix[i]=0.;
120                  out->row_sum_flux_matrix[i]=0.;                  out->main_diagonal_low_order_transport_matrix[i]=0.;
121                  out->u[i]=0.;                  out->u[i]=0.;
122               }               }
123               /* identify the main diagonals */               /* identify the main diagonals */
# Line 155  Paso_FCTransportProblem* Paso_FCTranspor Line 148  Paso_FCTransportProblem* Paso_FCTranspor
148    
149  void Paso_FCTransportProblem_checkinSolution(Paso_FCTransportProblem* in, double* u) {  void Paso_FCTransportProblem_checkinSolution(Paso_FCTransportProblem* in, double* u) {
150      dim_t i, n;      dim_t i, n;
151        double local_u_min,u_min;
152        
153      n=Paso_FCTransportProblem_getTotalNumRows(in);      n=Paso_FCTransportProblem_getTotalNumRows(in);
154        u_min=LARGE_POSITIVE_FLOAT;
155        #pragma omp parallel private(local_u_min)
156        {
157             local_u_min=0.;
158             #pragma omp for schedule(static) private(i)
159             for (i=0;i<n;++i) local_u_min=MIN(local_u_min,u[i]);
160             #pragma omp critical
161             {
162                u_min=MIN(u_min,local_u_min);
163             }
164        }
165        #ifdef PASO_MPI
166             local_u_min=u_min;
167             MPI_Allreduce(&local_u_min,&u_min, 1, MPI_DOUBLE, MPI_MIN, in->mpi_info->comm);
168        #endif
169        in->u_min=u_min;
170      #pragma omp parallel for schedule(static) private(i)      #pragma omp parallel for schedule(static) private(i)
171      for (i = 0; i < n; ++i) {      for (i=0;i<n;++i) {
172           in->u[i]=u[i];          in->u[i]=u[i]-u_min;
173      }      }
174  }  }

Legend:
Removed from v.1370  
changed lines
  Added in v.1415

  ViewVC Help
Powered by ViewVC 1.1.26