/[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 1014 - (show annotations)
Wed Mar 7 09:55:41 2007 UTC (12 years, 5 months ago) by gross
File size: 4024 byte(s)
compiles with mpi now and runs on one processor.
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 #ifdef TRILINOS
69 Epetra_Map *epetra_map;
70 Epetra_CrsMatrix *epetra_crs_matrix;
71 #endif
72
73 public:
74
75 TrilinosData(Paso_SystemMatrixPattern *pattern,dim_t row_block_size,dim_t col_block_size) {
76 #ifdef TRILINOS
77 Paso_Distribution *row_distribution=pattern->output_distribution;
78 Paso_MPIInfo *mpi_info=row_distribution->mpi_info;
79 Epetra_MpiComm Comm(mpi_info->comm);
80 Epetra_Map temp_map(row_distribution->numComponents,row_distribution->myNumComponents, 0,Comm);
81 epetra_map = &temp_map;
82 int *numNz = new int[row_distribution->myNumComponents];
83 for (int i=0; i<row_distribution->myNumComponents; i++) numNz[i] = pattern->ptr[i+1] - pattern->ptr[i];
84 Epetra_CrsMatrix temp(Copy, *epetra_map, numNz, true);
85 epetra_crs_matrix = &temp;
86 #else
87 Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
88 #endif
89 }
90
91 ~TrilinosData() {
92 #ifdef TRILINOS
93 delete &epetra_map;
94 delete &epetra_crs_matrix;
95 #endif
96 }
97
98 void SumIntoMyValues(int row, int num, double *value, int *col) {
99 printf("ksteube TrilinosData::SumIntoMyValues num=%d value=%f col=%d\n", num, *value, *col);
100 #ifdef TRILINOS
101 epetra_crs_matrix->SumIntoMyValues(row, num, value, col);
102 #else
103 Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
104 #endif
105 }
106
107 protected:
108
109 private:
110
111 };
112
113
114 /* Below here are the methods we use to access the class above from a C program */
115
116
117
118 extern "C"
119 void Paso_TRILINOS_alloc(void* trilinos_data, Paso_SystemMatrixPattern *pattern,dim_t row_block_size,dim_t col_block_size) {
120 printf("ksteube in Initialize_TrilinosData\n");
121 trilinos_data = new TrilinosData(pattern,row_block_size,col_block_size);
122 printf("ksteube Paso_SystemMatrixPattern len=%d\n", pattern->myLen);
123 }
124
125 extern "C"
126 void Trilinos_SumIntoMyValues(void *p, int row, int col, double *value) {
127 printf("ksteube in Trilinos_SumIntoMyValues row=%d col=%d value=%lf\n", row, col, value);
128 ((TrilinosData *)p)->SumIntoMyValues(row, 1, value, &col);
129 }
130
131
132 extern "C"
133 void Paso_TRILINOS(Paso_SystemMatrix* A,
134 double* out,
135 double* in,
136 Paso_Options* options,
137 Paso_Performance* pp) {
138 #ifdef TRILINOS
139 printf("no solver called.\n");
140 #else
141 Paso_setError(SYSTEM_ERROR,"Paso_TRILINOS: TRILINOS is not available.");
142 #endif
143 }
144
145 extern "C"
146 void Paso_TRILINOS_free(void* in) {
147 ((TrilinosData *)in)->~TrilinosData();
148 }

  ViewVC Help
Powered by ViewVC 1.1.26