/[escript]/branches/doubleplusgood/paso/src/Solver_Function.cpp
ViewVC logotype

Contents of /branches/doubleplusgood/paso/src/Solver_Function.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4324 - (show annotations)
Wed Mar 20 00:55:44 2013 UTC (6 years, 1 month ago) by jfenwick
File size: 2081 byte(s)
continues
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 #include "Common.h"
18 #include "Functions.h"
19 #include "PasoUtil.h"
20 #include "Solver.h"
21 /*
22 * generate Linear System (mainly for test purposes)
23 *
24 */
25 Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options)
26 {
27 Paso_Function * out=NULL;
28 Paso_SystemMatrix_setPreconditioner(A,options);
29 if (! Esys_noError()) return NULL;
30 out=new Paso_Function;
31 if (! Esys_checkPtr(out)) {
32 out->kind=LINEAR_SYSTEM;
33 out->mpi_info=Esys_MPIInfo_getReference(A->mpi_info);
34 out->n=Paso_SystemMatrix_getTotalNumRows(A);
35 out->more=(void*)Paso_SystemMatrix_getReference(A);
36 out->b=b;
37 out->tmp=new double[out->n];
38 Esys_checkPtr(out->tmp);
39 }
40 if (Esys_noError()) {
41 return out;
42 } else {
43 Paso_Function_LinearSystem_free(out);
44 return NULL;
45 }
46 }
47 void Paso_Function_LinearSystem_free(Paso_Function * F)
48 {
49 if (F!=NULL) {
50 Esys_MPIInfo_free(F->mpi_info);
51 Paso_SystemMatrix_free((Paso_SystemMatrix*)(F->more));
52 delete[] F->tmp;
53 delete F;
54 }
55 }
56 /*
57 * evaluates value=P*(b-Ax)
58 *
59 */
60 err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp)
61 {
62 Paso_SystemMatrix* A=(Paso_SystemMatrix*)(F->more);
63 Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
64 Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, arg,-PASO_ONE, F->tmp); /* tmp=(A*arg-tmp) */
65 Paso_SystemMatrix_solvePreconditioner(A,value,F->tmp); /* value=P*tmp */
66 return NO_ERROR;
67 }

  ViewVC Help
Powered by ViewVC 1.1.26