/[escript]/trunk-mpi-branch/paso/src/TRILINOS.cpp
ViewVC logotype

Diff of /trunk-mpi-branch/paso/src/TRILINOS.cpp

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

revision 1008 by ksteube, Mon Mar 5 01:44:30 2007 UTC revision 1011 by gross, Tue Mar 6 04:41:55 2007 UTC
# Line 29  Line 29 
29  */  */
30    
31    
 #ifdef TRILINOS  
32    
33  #include "Paso.h"  extern "C" {
34  #include "performance.h"  #include "TRILINOS.h"
35  #include "escript/system_dep.h"  }
36    
37    #ifdef TRILINOS
38  #include "Epetra_ConfigDefs.h"  #include "Epetra_ConfigDefs.h"
39  #ifdef PASO_MPI  #ifdef PASO_MPI
40  #include "mpi.h"  #include "mpi.h"
# Line 47  Line 47 
47  #include "Epetra_Vector.h"  #include "Epetra_Vector.h"
48  #include "Epetra_CrsMatrix.h"  #include "Epetra_CrsMatrix.h"
49  #include "Epetra_IntSerialDenseVector.h"  #include "Epetra_IntSerialDenseVector.h"
50    #endif
51    
52    
53    
# Line 64  Line 65 
65    
66  class ESCRIPT_DLL_API TrilinosData {  class ESCRIPT_DLL_API TrilinosData {
67    
     Paso_MPIInfo *MPIInfo;  
68      Epetra_Map *epetra_map;      Epetra_Map *epetra_map;
69      Epetra_CrsMatrix *epetra_crs_matrix;      Epetra_CrsMatrix *epetra_crs_matrix;
70    
71    public:    public:
72    
73    TrilinosData(Paso_MPIInfo *info, Paso_SystemMatrixPattern *pattern) {    TrilinosData(Paso_SystemMatrixPattern *pattern,dim_t row_block_size,dim_t col_block_size) {
74      MPIInfo = info;      #ifdef TRILINOS
75      Epetra_MpiComm Comm(MPI_COMM_WORLD);         Paso_Distribution *row_distribution=pattern->output_distribution;
76      Epetra_Map temp_map(row_distribution->numDOF * row_blocksize, row_distribution->numLocal * row_blocksize, 0, Comm);         Paso_MPIInfo *mpi_info=row_distribution->mpi_info;
77      epetra_map = &temp_map;         Epetra_MpiComm Comm(mpi_info->comm);
78      int *numNz = new int[row_distribution->numDOF]; // probably need numLocal         Epetra_Map temp_map(row_distribution->numComponents,row_distribution->myNumComponents, 0,Comm);
79      for (i=0; i<row_distribution->numLocal; i++) {         epetra_map = &temp_map;
80        for (ii=0; i<row_blocksize; i++) {         int *numNz = new int[row_distribution->myNumComponents];
81      numNz[ii+row_blocksize*i] = (pattern->ptr[i+1] - pattern->ptr[i]) * col_blocksize         for (int i=0; i<row_distribution->myNumComponents; i++) numNz[i] = pattern->ptr[i+1] - pattern->ptr[i];
82        }         Epetra_CrsMatrix temp(Copy, *epetra_map, numNz, true);
83      }         epetra_crs_matrix = &temp;
84      Epetra_CrsMatrix temp(Copy, *epetra_map, numNz);      #else
85      epetra_crs_matrix = &temp;         Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
86        #endif
87      }
88    
89      ~TrilinosData() {
90          delete &epetra_map;
91          delete &epetra_crs_matrix;
92    }    }
93    
94    void SumIntoMyValues(int row, int num, double *value, int *col) {    void SumIntoMyValues(int row, int num, double *value, int *col) {
95      printf("ksteube TrilinosData::SumIntoMyValues num=%d value=%f col=%d\n", num, *value, *col);      printf("ksteube TrilinosData::SumIntoMyValues num=%d value=%f col=%d\n", num, *value, *col);
96      epetra_crs_matrix->SumIntoMyValues(row, num, value, col);      #ifdef TRILINOS
97           epetra_crs_matrix->SumIntoMyValues(row, num, value, col);
98        #else
99           Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
100        #endif
101    }    }
102    
103    protected:    protected:
# Line 97  class ESCRIPT_DLL_API TrilinosData { Line 107  class ESCRIPT_DLL_API TrilinosData {
107  };  };
108    
109    
   
110  /* Below here are the methods we use to access the class above from a C program */  /* Below here are the methods we use to access the class above from a C program */
111    
112    
113    
114  extern "C"  extern "C"
115  void Initialize_TrilinosData(TrilinosData *p, Paso_SystemMatrixPattern *pattern) {  void Paso_TRILINOS_alloc(void* trilinos_data, Paso_SystemMatrixPattern *pattern,dim_t row_block_size,dim_t col_block_size) {
116      printf("ksteube in Initialize_TrilinosData\n");      printf("ksteube in Initialize_TrilinosData\n");
117      p = new TrilinosData(pattern->MPIInfo, pattern);      trilinos_data = new TrilinosData(pattern,row_block_size,col_block_size);
118      printf("ksteube Paso_SystemMatrixPattern len=%d\n", pattern->len);      printf("ksteube Paso_SystemMatrixPattern len=%d\n", pattern->myLen);
119  }  }
120    
121  extern "C"  extern "C"
122  void Trilinos_SumIntoMyValues(TrilinosData *p, int row, int col, double *value) {  void Trilinos_SumIntoMyValues(void *p, int row, int col, double *value) {
123      printf("ksteube in Trilinos_SumIntoMyValues row=%d col=%d value=%lf\n", row, col, value);      printf("ksteube in Trilinos_SumIntoMyValues row=%d col=%d value=%lf\n", row, col, value);
124      p->SumIntoMyValues(row, 1, &value, &col);      ((TrilinosData *)p)->SumIntoMyValues(row, 1, value, &col);
125  }  }
126    
127    
128  extern "C"  extern "C"
129  void Paso_TRILINOS(Paso_SystemMatrix* A,  void Paso_TRILINOS(Paso_SystemMatrix* A,
130                            double* out,                     double* out,
131                            double* in,                     double* in,
132                            Paso_Options* options,                     Paso_Options* options,
133                            Paso_Performance* pp) {                     Paso_Performance* pp) {
134  #ifdef TRILINOS  #ifdef TRILINOS
135    printf("no solver called.\n");
136  #else  #else
137      Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");      Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
138  #endif  #endif
139  }  }
140    
141  extern "C"  extern "C"
142  void Paso_TRILINOS_free(double* in) {  void Paso_TRILINOS_free(void* in) {
143  #ifdef TRILINOS     ((TrilinosData *)in)->~TrilinosData();
 #endif  
144  }  }
   
 #endif /* ifdef TRILINOS */  
   

Legend:
Removed from v.1008  
changed lines
  Added in v.1011

  ViewVC Help
Powered by ViewVC 1.1.26