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

Contents of /trunk/paso/src/TRILINOS.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 969 - (show annotations)
Tue Feb 13 23:02:23 2007 UTC (12 years, 6 months ago) by ksteube
File size: 3586 byte(s)
Parallelization using MPI for solution of implicit problems.

Parallelization for explicit problems has already been accomplished in
the main SVN branch.

This is incomplete and is not ready for use.


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 #ifdef TRILINOS
33
34 #include "Paso.h"
35 #include "performance.h"
36 #include "escript/system_dep.h"
37
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
51
52
53 /* This C++ class is accessed from a C program via the extern "C" functions that are included below */
54
55
56
57 /**
58 \brief
59 Defines the class that stores TRILINOS map and epetra matrix
60
61 Description:
62 This file is only necessary because we have to use C++ objects from C
63 */
64
65 class ESCRIPT_DLL_API TrilinosData {
66
67 Paso_MPIInfo *MPIInfo;
68 Epetra_Map *epetra_map;
69 Epetra_CrsMatrix *epetra_crs_matrix;
70
71 public:
72
73 TrilinosData(Paso_MPIInfo *info, Paso_SystemMatrixPattern *pattern) {
74 MPIInfo = info;
75 Epetra_MpiComm Comm(MPI_COMM_WORLD);
76 Epetra_Map temp_map(row_distribution->numDOF * row_blocksize, row_distribution->numLocal * row_blocksize, 0, Comm);
77 epetra_map = &temp_map;
78 int *numNz = new int[row_distribution->numDOF]; // probably need numLocal
79 for (i=0; i<row_distribution->numLocal; i++) {
80 for (ii=0; i<row_blocksize; i++) {
81 numNz[ii+row_blocksize*i] = (pattern->ptr[i+1] - pattern->ptr[i]) * col_blocksize
82 }
83 }
84 Epetra_CrsMatrix temp(Copy, *epetra_map, numNz);
85 epetra_crs_matrix = &temp;
86 }
87
88 void SumIntoMyValues(int row, int num, double *value, int *col) {
89 printf("ksteube TrilinosData::SumIntoMyValues num=%d value=%f col=%d\n", num, *value, *col);
90 epetra_crs_matrix->SumIntoMyValues(row, num, value, col);
91 }
92
93 protected:
94
95 private:
96
97 };
98
99
100
101 /* Below here are the methods we use to access the class above from a C program */
102
103
104
105 extern "C"
106 void Initialize_TrilinosData(TrilinosData *p, Paso_SystemMatrixPattern *pattern) {
107 printf("ksteube in Initialize_TrilinosData\n");
108 p = new TrilinosData(pattern->MPIInfo, pattern);
109 printf("ksteube Paso_SystemMatrixPattern len=%d\n", pattern->len);
110 }
111
112 extern "C"
113 void Trilinos_SumIntoMyValues(TrilinosData *p, int row, int col, double *value) {
114 printf("ksteube in Trilinos_SumIntoMyValues row=%d col=%d value=%lf\n", row, col, value);
115 p->SumIntoMyValues(row, 1, &value, &col);
116 }
117
118 extern "C"
119 void Paso_TRILINOS(Paso_SystemMatrix* A,
120 double* out,
121 double* in,
122 Paso_Options* options,
123 Paso_Performance* pp) {
124 #ifdef TRILINOS
125 #else
126 Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
127 #endif
128 }
129
130 extern "C"
131 void Paso_TRILINOS_free(double* in) {
132 #ifdef TRILINOS
133 #endif
134 }
135
136 #endif /* ifdef TRILINOS */
137

  ViewVC Help
Powered by ViewVC 1.1.26