/[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 1798 - (hide annotations)
Wed Sep 17 06:21:12 2008 UTC (11 years, 1 month ago) by gross
File MIME type: text/plain
File size: 1919 byte(s)
Fixes for the JacobeanFreeNewton scheme. Still needs to be tested under OPENMP but runs under MPI.


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 gross 1798 out->more=(void*)Paso_SystemMatrix_reference(A);
33 gross 1639 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     Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
61 gross 1798 Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(ONE, A, arg,-ONE, F->tmp); /* tmp=(A*arg-tmp) */
62     Paso_Solver_solvePreconditioner(A,value,F->tmp); /* value=P*tmp */
63 gross 1639 return NO_ERROR;
64     }

  ViewVC Help
Powered by ViewVC 1.1.26