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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1639 - (hide annotations)
Mon Jul 14 08:55:25 2008 UTC (11 years, 7 months ago) by gross
File MIME type: text/plain
File size: 2003 byte(s)


1 gross 1639 /* $Id:$ */
2    
3     /*******************************************************
4     *
5     * Copyright 2008 by University of Queensland
6     *
7     * http://esscc.uq.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     #include "Common.h"
15     #include "Functions.h"
16     #include "PasoUtil.h"
17     #include "Solver.h"
18     /*
19     * generate Linear System (mainly for test purposes)
20     *
21     */
22     Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options)
23     {
24     Paso_Function * out=NULL;
25     Paso_Solver_setPreconditioner(A,options);
26     if (! Paso_noError()) return NULL;
27     out=MEMALLOC(1,Paso_Function);
28     if (! Paso_checkPtr(out)) {
29     out->kind=LINEAR_SYSTEM;
30     out->mpi_info=Paso_MPIInfo_getReference(A->mpi_info);
31     out->n=Paso_SystemMatrix_getTotalNumRows(A);
32     out->more=Paso_SystemMatrix_reference(A);
33     out->b=b;
34     out->tmp=MEMALLOC(out->n, double);
35     Paso_checkPtr(out->tmp);
36     }
37     if (Paso_noError()) {
38     return out;
39     } else {
40     Paso_Function_LinearSystem_free(out);
41     return NULL;
42     }
43     }
44     void Paso_Function_LinearSystem_free(Paso_Function * F)
45     {
46     if (F!=NULL) {
47     Paso_MPIInfo_free(F->mpi_info);
48     Paso_SystemMatrix_free((Paso_SystemMatrix*)(F->more));
49     MEMFREE(F->tmp);
50     MEMFREE(F);
51     }
52     }
53     /*
54     * evaluates value=P*(b-Ax)
55     *
56     */
57     err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg)
58     {
59     Paso_SystemMatrix* A=(Paso_SystemMatrix*)(F->more);
60     printf("F B\n");
61     Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
62     printf("F C %d %d %d\n",A,arg,F->tmp);
63     Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(-ONE, A, arg,ONE, F->tmp); /* tmp=(tmp-A*arg) */
64     printf("F D \n");
65     Paso_Solver_solvePreconditioner(A,value,F->tmp); /* value=P*tmp */
66     printf("F E\n");
67     return NO_ERROR;
68     }
69    

  ViewVC Help
Powered by ViewVC 1.1.26