/[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 1804 - (show annotations)
Wed Sep 24 07:52:19 2008 UTC (11 years, 4 months ago) by gross
File MIME type: text/plain
File size: 1940 byte(s)
a robister version of the upwinding scheme
1 /* $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=(void*)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, Paso_Performance *pp)
58 {
59 Paso_SystemMatrix* A=(Paso_SystemMatrix*)(F->more);
60 Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
61 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 return NO_ERROR;
64 }

  ViewVC Help
Powered by ViewVC 1.1.26