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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2987 - (hide annotations)
Tue Mar 16 01:32:43 2010 UTC (9 years, 6 months ago) by gross
File MIME type: text/plain
File size: 1981 byte(s)
FCT solver rewritten
1 gross 2987
2     /*******************************************************
3     *
4     * Copyright (c) 2003-2010 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_FCTSolver_Function_alloc(PasoTransportProblem *tp, Paso_Options* options)
24     {
25     Paso_Function * out=NULL;
26     Paso_Solver_setPreconditioner(tp->iteration_matrix,options);
27     if (! Paso_noError()) return NULL;
28     out=MEMALLOC(1,Paso_Function);
29     if (! Paso_checkPtr(out)) {
30     out->kind=FCT;
31     out->mpi_info=Paso_MPIInfo_getReference(A->mpi_info);
32     out->n=Paso_SystemMatrix_getTotalNumRows(fctp->iteration_matrix);
33    
34     out->more=(void*)Paso_SystemMatrix_getReference(A);
35     out->b=NULL;
36     out->tmp=MEMALLOC(out->n, double);
37     Paso_checkPtr(out->tmp);
38     }
39     if (Paso_noError()) {
40     return out;
41     } else {
42     Paso_Function_FCTSolver_free(out);
43     return NULL;
44     }
45     }
46     void Paso_Function_FCTSolver_free(Paso_Function * F)
47     {
48     if (F!=NULL) {
49     Paso_MPIInfo_free(F->mpi_info);
50     Paso_SystemMatrix_free((Paso_SystemMatrix*)(F->more));
51     MEMFREE(F->tmp);
52     MEMFREE(F);
53     }
54     }
55     /*
56     * evaluates value=P*(b-Ax)
57     *
58     */
59     err_t Paso_Function_FCTSolver_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp)
60     {
61     Paso_SystemMatrix* A=(Paso_SystemMatrix*)(F->more);
62     Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
63     Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, arg,-PASO_ONE, F->tmp); /* tmp=(A*arg-tmp) */
64     Paso_Solver_solvePreconditioner(A,value,F->tmp); /* value=P*tmp */
65     return NO_ERROR;
66     }

  ViewVC Help
Powered by ViewVC 1.1.26