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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years ago) by jfenwick
File MIME type: text/plain
File size: 1981 byte(s)
Merging dudley and scons updates from branches

1
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 (! Esys_noError()) return NULL;
28 out=MEMALLOC(1,Paso_Function);
29 if (! Esys_checkPtr(out)) {
30 out->kind=FCT;
31 out->mpi_info=Esys_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 Esys_checkPtr(out->tmp);
38 }
39 if (Esys_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 Esys_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