/[escript]/trunk/paso/src/Solver_Function.c
ViewVC logotype

Contents of /trunk/paso/src/Solver_Function.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (show annotations)
Mon Jul 20 06:20:06 2009 UTC (10 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 1963 byte(s)
Updating copyright notices
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
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 #include "Common.h"
16 #include "Functions.h"
17 #include "PasoUtil.h"
18 #include "Solver.h"
19 /*
20 * generate Linear System (mainly for test purposes)
21 *
22 */
23 Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options)
24 {
25 Paso_Function * out=NULL;
26 Paso_Solver_setPreconditioner(A,options);
27 if (! Paso_noError()) return NULL;
28 out=MEMALLOC(1,Paso_Function);
29 if (! Paso_checkPtr(out)) {
30 out->kind=LINEAR_SYSTEM;
31 out->mpi_info=Paso_MPIInfo_getReference(A->mpi_info);
32 out->n=Paso_SystemMatrix_getTotalNumRows(A);
33 out->more=(void*)Paso_SystemMatrix_reference(A);
34 out->b=b;
35 out->tmp=MEMALLOC(out->n, double);
36 Paso_checkPtr(out->tmp);
37 }
38 if (Paso_noError()) {
39 return out;
40 } else {
41 Paso_Function_LinearSystem_free(out);
42 return NULL;
43 }
44 }
45 void Paso_Function_LinearSystem_free(Paso_Function * F)
46 {
47 if (F!=NULL) {
48 Paso_MPIInfo_free(F->mpi_info);
49 Paso_SystemMatrix_free((Paso_SystemMatrix*)(F->more));
50 MEMFREE(F->tmp);
51 MEMFREE(F);
52 }
53 }
54 /*
55 * evaluates value=P*(b-Ax)
56 *
57 */
58 err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp)
59 {
60 Paso_SystemMatrix* A=(Paso_SystemMatrix*)(F->more);
61 Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
62 Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, arg,-PASO_ONE, F->tmp); /* tmp=(A*arg-tmp) */
63 Paso_Solver_solvePreconditioner(A,value,F->tmp); /* value=P*tmp */
64 return NO_ERROR;
65 }

  ViewVC Help
Powered by ViewVC 1.1.26