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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1011 - (show annotations)
Tue Mar 6 04:41:55 2007 UTC (14 years, 3 months ago) by gross
File size: 3966 byte(s)
it seems to compile now but linking is still not working
1 /* $Id$ */
2
3 /*
4 ************************************************************
5 * Copyright 2006 by ACcESS MNRF *
6 * *
7 * http://www.access.edu.au *
8 * Primary Business: Queensland, Australia *
9 * Licensed under the Open Software License version 3.0 *
10 * http://www.opensource.org/licenses/osl-3.0.php *
11 * *
12 ************************************************************
13 */
14
15 /* Interface to Sandia TRILINOS sparse solver */
16
17 /* Author: k.steube@uq.edu.au */
18
19 /* TODO
20 New TrilinosData object
21 Create Map
22 Begin insert global values
23 Insert values
24 End submit entries
25 Fill complete
26 Clean up
27 Solve system given a RHS
28 Get result
29 */
30
31
32
33 extern "C" {
34 #include "TRILINOS.h"
35 }
36
37 #ifdef TRILINOS
38 #include "Epetra_ConfigDefs.h"
39 #ifdef PASO_MPI
40 #include "mpi.h"
41 #include "Epetra_MpiComm.h"
42 #else
43 #include "Epetra_SerialComm.h"
44 #endif
45 #include "Epetra_Map.h"
46 #include "Epetra_SerialDenseVector.h"
47 #include "Epetra_Vector.h"
48 #include "Epetra_CrsMatrix.h"
49 #include "Epetra_IntSerialDenseVector.h"
50 #endif
51
52
53
54 /* This C++ class is accessed from a C program via the extern "C" functions that are included below */
55
56
57
58 /**
59 \brief
60 Defines the class that stores TRILINOS map and epetra matrix
61
62 Description:
63 This file is only necessary because we have to use C++ objects from C
64 */
65
66 class ESCRIPT_DLL_API TrilinosData {
67
68 Epetra_Map *epetra_map;
69 Epetra_CrsMatrix *epetra_crs_matrix;
70
71 public:
72
73 TrilinosData(Paso_SystemMatrixPattern *pattern,dim_t row_block_size,dim_t col_block_size) {
74 #ifdef TRILINOS
75 Paso_Distribution *row_distribution=pattern->output_distribution;
76 Paso_MPIInfo *mpi_info=row_distribution->mpi_info;
77 Epetra_MpiComm Comm(mpi_info->comm);
78 Epetra_Map temp_map(row_distribution->numComponents,row_distribution->myNumComponents, 0,Comm);
79 epetra_map = &temp_map;
80 int *numNz = new int[row_distribution->myNumComponents];
81 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 #else
85 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) {
95 printf("ksteube TrilinosData::SumIntoMyValues num=%d value=%f col=%d\n", num, *value, *col);
96 #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:
104
105 private:
106
107 };
108
109
110 /* Below here are the methods we use to access the class above from a C program */
111
112
113
114 extern "C"
115 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");
117 trilinos_data = new TrilinosData(pattern,row_block_size,col_block_size);
118 printf("ksteube Paso_SystemMatrixPattern len=%d\n", pattern->myLen);
119 }
120
121 extern "C"
122 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);
124 ((TrilinosData *)p)->SumIntoMyValues(row, 1, value, &col);
125 }
126
127
128 extern "C"
129 void Paso_TRILINOS(Paso_SystemMatrix* A,
130 double* out,
131 double* in,
132 Paso_Options* options,
133 Paso_Performance* pp) {
134 #ifdef TRILINOS
135 printf("no solver called.\n");
136 #else
137 Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
138 #endif
139 }
140
141 extern "C"
142 void Paso_TRILINOS_free(void* in) {
143 ((TrilinosData *)in)->~TrilinosData();
144 }

  ViewVC Help
Powered by ViewVC 1.1.26