You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
5.6 KiB
C
197 lines
5.6 KiB
C
18 years ago
|
/*
|
||
17 years ago
|
*
|
||
4 years ago
|
* AMG4PSBLAS version 1.0
|
||
|
* Algebraic Multigrid Package
|
||
8 years ago
|
* based on PSBLAS (Parallel Sparse BLAS version 3.5)
|
||
17 years ago
|
*
|
||
4 years ago
|
* (C) Copyright 2020
|
||
8 years ago
|
*
|
||
7 years ago
|
* Salvatore Filippone
|
||
|
* Pasqua D'Ambra
|
||
4 years ago
|
* Fabio Durastante
|
||
17 years ago
|
*
|
||
|
* Redistribution and use in source and binary forms, with or without
|
||
|
* modification, are permitted provided that the following conditions
|
||
|
* are met:
|
||
|
* 1. Redistributions of source code must retain the above copyright
|
||
|
* notice, this list of conditions and the following disclaimer.
|
||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||
|
* notice, this list of conditions, and the following disclaimer in the
|
||
|
* documentation and/or other materials provided with the distribution.
|
||
4 years ago
|
* 3. The name of the AMG4PSBLAS group or the names of its contributors may
|
||
17 years ago
|
* not be used to endorse or promote products derived from this
|
||
|
* software without specific written permission.
|
||
|
*
|
||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||
4 years ago
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AMG4PSBLAS GROUP OR ITS CONTRIBUTORS
|
||
17 years ago
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||
|
*
|
||
18 years ago
|
*
|
||
4 years ago
|
* File: amg_zumf_interface.c
|
||
18 years ago
|
*
|
||
4 years ago
|
* Functions: amg_zumf_fact_, amg_zumf_solve_, amg_zumf_free_.
|
||
18 years ago
|
*
|
||
17 years ago
|
* This file is an interface to the UMFPACK routines for sparse factorization and
|
||
|
* solve. It was obtained by adapting umfpack_zi_demo under the original UMFPACK
|
||
|
* copyright terms reproduced below.
|
||
|
*
|
||
18 years ago
|
*/
|
||
|
|
||
|
/* =====================
|
||
|
UMFPACK Version 4.4 (Jan. 28, 2005), Copyright (c) 2005 by Timothy A.
|
||
|
Davis. All Rights Reserved.
|
||
|
|
||
|
UMFPACK License:
|
||
|
|
||
|
Your use or distribution of UMFPACK or any modified version of
|
||
|
UMFPACK implies that you agree to this License.
|
||
|
|
||
|
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY
|
||
|
EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
||
|
|
||
|
Permission is hereby granted to use or copy this program, provided
|
||
|
that the Copyright, this License, and the Availability of the original
|
||
|
version is retained on all copies. User documentation of any code that
|
||
|
uses UMFPACK or any modified version of UMFPACK code must cite the
|
||
|
Copyright, this License, the Availability note, and "Used by permission."
|
||
|
Permission to modify the code and to distribute modified code is granted,
|
||
|
provided the Copyright, this License, and the Availability note are
|
||
|
retained, and a notice that the code was modified is included. This
|
||
|
software was developed with support from the National Science Foundation,
|
||
|
and is provided to you free of charge.
|
||
|
|
||
|
Availability:
|
||
|
|
||
|
http://www.cise.ufl.edu/research/sparse/umfpack
|
||
|
|
||
|
*/
|
||
|
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#ifdef Have_UMF_
|
||
|
#include "umfpack.h"
|
||
|
#endif
|
||
|
|
||
|
|
||
4 years ago
|
int amg_zumf_fact(int n, int nnz,
|
||
14 years ago
|
double *values, int *rowind, int *colptr,
|
||
|
void **symptr, void **numptr,
|
||
|
long long int *ssize,
|
||
|
long long int *nsize)
|
||
18 years ago
|
|
||
|
{
|
||
|
|
||
|
#ifdef Have_UMF_
|
||
|
double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL];
|
||
|
void *Symbolic, *Numeric ;
|
||
14 years ago
|
int i, info;
|
||
18 years ago
|
|
||
|
|
||
|
umfpack_zi_defaults(Control);
|
||
|
|
||
14 years ago
|
info = umfpack_zi_symbolic (n, n, colptr, rowind, values, NULL, &Symbolic,
|
||
18 years ago
|
Control, Info);
|
||
|
|
||
|
|
||
14 years ago
|
if ( info == UMFPACK_OK ) {
|
||
|
info = 0;
|
||
18 years ago
|
} else {
|
||
14 years ago
|
printf("umfpack_zi_symbolic() error returns INFO= %d\n", info);
|
||
7 years ago
|
umfpack_zi_report_status(Control,info);
|
||
14 years ago
|
*symptr = (void *) NULL;
|
||
|
*numptr = (void *) NULL;
|
||
|
return -11;
|
||
18 years ago
|
}
|
||
|
|
||
14 years ago
|
*symptr = Symbolic;
|
||
|
*ssize = Info[UMFPACK_SYMBOLIC_SIZE];
|
||
|
*ssize *= Info[UMFPACK_SIZE_OF_UNIT];
|
||
|
|
||
|
info = umfpack_zi_numeric (colptr, rowind, values, NULL, Symbolic, &Numeric,
|
||
18 years ago
|
Control, Info) ;
|
||
|
|
||
|
|
||
14 years ago
|
if ( info == UMFPACK_OK ) {
|
||
|
info = 0;
|
||
|
*numptr = Numeric;
|
||
|
*nsize = Info[UMFPACK_NUMERIC_SIZE];
|
||
|
*nsize *= Info[UMFPACK_SIZE_OF_UNIT];
|
||
|
|
||
18 years ago
|
} else {
|
||
14 years ago
|
printf("umfpack_zi_numeric() error returns INFO= %d\n", info);
|
||
7 years ago
|
umfpack_zi_report_status(Control,info);
|
||
14 years ago
|
info = -12;
|
||
|
*numptr = NULL;
|
||
18 years ago
|
}
|
||
14 years ago
|
|
||
|
|
||
|
return info;
|
||
|
|
||
18 years ago
|
#else
|
||
|
fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n");
|
||
14 years ago
|
return -1;
|
||
18 years ago
|
#endif
|
||
|
}
|
||
|
|
||
|
|
||
4 years ago
|
int amg_zumf_solve(int itrans, int n,
|
||
14 years ago
|
double *x, double *b, int ldb,
|
||
|
void *numptr)
|
||
18 years ago
|
|
||
|
{
|
||
|
#ifdef Have_UMF_
|
||
|
double Info [UMFPACK_INFO], Control [UMFPACK_CONTROL];
|
||
|
void *Symbolic, *Numeric ;
|
||
14 years ago
|
int i,trans, info;
|
||
18 years ago
|
|
||
|
|
||
|
umfpack_di_defaults(Control);
|
||
|
Control[UMFPACK_IRSTEP]=0;
|
||
|
|
||
|
|
||
14 years ago
|
if (itrans == 0) {
|
||
18 years ago
|
trans = UMFPACK_A;
|
||
14 years ago
|
} else if (itrans ==1) {
|
||
18 years ago
|
trans = UMFPACK_At;
|
||
|
} else {
|
||
|
trans = UMFPACK_A;
|
||
|
}
|
||
|
|
||
14 years ago
|
info = umfpack_zi_solve(trans,NULL,NULL,NULL,NULL,
|
||
|
x,NULL,b,NULL, numptr,Control,Info);
|
||
|
return info;
|
||
18 years ago
|
#else
|
||
14 years ago
|
fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n");
|
||
|
return -1;
|
||
18 years ago
|
#endif
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
4 years ago
|
int amg_zumf_free(void *symptr, void *numptr)
|
||
18 years ago
|
|
||
|
{
|
||
|
#ifdef Have_UMF_
|
||
|
void *Symbolic, *Numeric ;
|
||
14 years ago
|
Symbolic = symptr;
|
||
|
Numeric = numptr;
|
||
18 years ago
|
|
||
|
umfpack_zi_free_numeric(&Numeric);
|
||
|
umfpack_zi_free_symbolic(&Symbolic);
|
||
14 years ago
|
return 0;
|
||
18 years ago
|
#else
|
||
14 years ago
|
fprintf(stderr," UMF Not Configured, fix make.inc and recompile\n");
|
||
|
return -1;
|
||
18 years ago
|
#endif
|
||
|
}
|
||
|
|
||
|
|