00001
00002
00003
00004
00005
00006
00007 #include <cstdio>
00008 #include <iostream>
00009 #include <fstream>
00010
00011 #include "samg.h"
00012
00013
00014 #ifndef SAMG_OLDALPHA
00015 using namespace std;
00016 #endif
00017
00018 #include "solversamg.h"
00019 #include "fem.h"
00020
00021
00022 int SamgSolver(int iversion, int nna, int nnu, int matrix, int nsys,
00023 int npnt, int *ia, int *ja, double *a, double *f, double *u)
00024 {
00025
00026
00027
00028 int ndiu = 1;
00029 int ndip = 1;
00030
00031 int nsolve = 2;
00032 int ifirst = 1;
00033 double eps = 1.0e-8;
00034 int ncyc = 110200;
00035
00036 double a_cmplx = 2.2;
00037 double g_cmplx = 1.7;
00038 double w_avrge = 2.4;
00039 double p_cmplx = 0.0;
00040
00041 double chktol = -1.0;
00042 int idump = 0;
00043 int iout = -2;
00044
00045 int n_default = 20;
00046
00047
00048
00049
00050 int iswtch = 5300+n_default;
00051
00052
00053
00054
00055
00056
00057
00058 int intin;
00059 double dblin;
00060
00061 if (n_default == 0) {
00062 intin=25; SAMG_SET_LEVELX(&intin);
00063 intin=100; SAMG_SET_NPTMN(&intin);
00064 intin=4; SAMG_SET_NCG(&intin);
00065 intin=2; SAMG_SET_NWT(&intin);
00066 intin=1; SAMG_SET_NTR(&intin);
00067 intin=131; SAMG_SET_NRD(&intin);
00068 intin=131; SAMG_SET_NRU(&intin);
00069 intin=0; SAMG_SET_NRC(&intin);
00070 intin=0; SAMG_SET_NP_OPT(&intin);
00071
00072 dblin=21.25; SAMG_SET_ECG(&dblin);
00073 dblin=0.20; SAMG_SET_EWT(&dblin);
00074 dblin=12.20; SAMG_SET_ETR(&dblin);
00075 }
00076 int * iu = new int[1];
00077 int * ip = new int[1];
00078 int * iscale = new int[1];
00079
00080 int ierr,ncyc_done;
00081 double res_out,res_in;
00082
00083 float told,tnew,tamg;
00084 SAMG_CTIME(&told);
00085
00086 SAMG(&nnu,&nna,&nsys,
00087 &ia[0],&ja[0],&a[0],&f[0],&u[0],&iu[0],&ndiu,&ip[0],&ndip,&matrix,&iscale[0],
00088 &res_in,&res_out,&ncyc_done,&ierr,
00089 &nsolve,&ifirst,&eps,&ncyc,&iswtch,
00090 &a_cmplx,&g_cmplx,&p_cmplx,&w_avrge,
00091 &chktol,&idump,&iout);
00092
00093 if (ierr > 0) {
00094 cout << endl << " SAMG terminated with error code "
00095 << ierr << " **** " << endl;
00096 }
00097 else if (ierr < 0) {
00098 cout << endl << " SAMG terminated with warning code "
00099 << ierr << " **** " << endl;
00100 }
00101
00102 SAMG_CTIME(&tnew);
00103 tamg=tnew-told;
00104 cout << endl << " ***** total run time: " << tamg << " ***** " << endl;
00105
00106 delete[] iu;
00107 delete[] ip;
00108 delete[] iscale;
00109
00110 return ierr;
00111 }