Minor modifications and comment changes for solving systems.
This commit is contained in:
parent
78b17e9d1b
commit
8ebbd0a915
@ -228,6 +228,15 @@ hypre_AMGSetup( void *amg_vdata,
|
||||
#endif
|
||||
|
||||
P_array[level] = hypre_BCSRMatrixToCSRMatrix(PB);
|
||||
|
||||
#if 0 /* for debugging */
|
||||
{
|
||||
char new_file[80];
|
||||
sprintf(new_file,"%s.level.%d","P.out" ,level);
|
||||
hypre_CSRMatrixPrint(P_array[level], new_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(P_trunc_factor > 0 || P_max_elmts > 0) {
|
||||
hypre_AMGTruncation(P_array[level], P_trunc_factor, P_max_elmts);
|
||||
}
|
||||
@ -240,6 +249,29 @@ hypre_AMGSetup( void *amg_vdata,
|
||||
|
||||
hypre_AMGBuildCoarseOperator(P_array[level], A_array[level],
|
||||
P_array[level], &A_array[level + 1]);
|
||||
|
||||
|
||||
#if 0 /* for debugging - to compare with parallel */
|
||||
{
|
||||
hypre_CSRMatrix *A_no_zeros = NULL;
|
||||
char new_file[80];
|
||||
sprintf(new_file,"%s.level.%d","RAP.out" ,level+1);
|
||||
A_no_zeros = hypre_CSRMatrixDeleteZeros(A_array[level+1], 1e-14);
|
||||
if (A_no_zeros)
|
||||
{
|
||||
hypre_CSRMatrixPrint(A_no_zeros, new_file);
|
||||
hypre_CSRMatrixDestroy(A_no_zeros);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
hypre_CSRMatrixPrint(A_array[level+1], new_file);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
if(A_trunc_factor > 0 || A_max_elmts > 0) {
|
||||
hypre_AMGOpTruncation(A_array[level + 1],
|
||||
A_trunc_factor, A_max_elmts);
|
||||
|
||||
@ -159,9 +159,9 @@ hypre_BCSRMatrixDenseBlockDiag(hypre_BCSRMatrixDenseBlock* A) {
|
||||
int
|
||||
hypre_BCSRMatrixDenseBlockMulInv(hypre_BCSRMatrixDenseBlock* A,
|
||||
hypre_BCSRMatrixDenseBlock* B) {
|
||||
/* returns AB^{-1} in A */
|
||||
|
||||
/* AHB 9/05: this is actually returning B{^-1}A in A*/
|
||||
/* AHB 9/05: this is actually returning B{^-1}A in A*. If B cannot be
|
||||
inverted, returns A = A */
|
||||
|
||||
int i, j, k;
|
||||
int num_rows = A->num_rows, num_cols = A->num_cols;
|
||||
@ -255,10 +255,12 @@ hypre_BCSRMatrixDenseBlockMultiplyInverse2(hypre_BCSRMatrixDenseBlock* A,
|
||||
hypre_BCSRMatrixDenseBlock* B)
|
||||
{
|
||||
|
||||
/* AHB: here we return BA^{-1} in A*/
|
||||
/* AHB: here we return BA^{-1} in A. If A cannot be inverted, returns
|
||||
A = B*/
|
||||
|
||||
hypre_BCSRMatrixBlock *A_t, *B_t;
|
||||
double *out_data;
|
||||
int ierr = 0;
|
||||
|
||||
|
||||
/* this is the lazy way - for testing */
|
||||
@ -268,24 +270,23 @@ hypre_BCSRMatrixDenseBlockMultiplyInverse2(hypre_BCSRMatrixDenseBlock* A,
|
||||
B_t = hypre_BCSRMatrixBlockCopy(B);
|
||||
hypre_BCSRMatrixBlockTranspose(B_t);
|
||||
|
||||
/* A = B^(-1)A */
|
||||
hypre_BCSRMatrixDenseBlockMulInv(B_t, A_t);
|
||||
/* now B_t = inv(A_t)*B_t */
|
||||
ierr = hypre_BCSRMatrixDenseBlockMulInv(B_t, A_t);
|
||||
|
||||
/*result in B_t -copy to A and then take transpose */
|
||||
out_data = hypre_CTAlloc(double, A->num_rows*A->num_cols);
|
||||
|
||||
hypre_BCSRMatrixDenseBlockGetData(B_t, out_data);
|
||||
hypre_BCSRMatrixDenseBlockFillData(A, out_data);
|
||||
|
||||
hypre_BCSRMatrixDenseBlockTranspose(A);
|
||||
|
||||
|
||||
hypre_BCSRMatrixDenseBlockDestroy(A_t);
|
||||
hypre_BCSRMatrixDenseBlockDestroy(B_t);
|
||||
|
||||
hypre_TFree(out_data);
|
||||
|
||||
|
||||
return 0;
|
||||
return ierr;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1199,9 +1199,13 @@ BuildLaplacian( int argc,
|
||||
mtrx[2] = 1;
|
||||
mtrx[3] = 2;
|
||||
|
||||
/* mtrx[2] = 10;
|
||||
mtrx[3] = 100; */
|
||||
|
||||
#if 0
|
||||
mtrx[0] = .01;
|
||||
mtrx[1] = 200;
|
||||
mtrx[2] = 200;
|
||||
mtrx[3] = .01;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
else if (num_fun == 3)
|
||||
@ -1216,9 +1220,17 @@ BuildLaplacian( int argc,
|
||||
mtrx[7] = 1;
|
||||
mtrx[8] = 1.01;
|
||||
|
||||
/* mtrx[6] = 2000; */
|
||||
|
||||
|
||||
#if 0
|
||||
mtrx[0] = 3.0;
|
||||
mtrx[1] = 1;
|
||||
mtrx[2] = 0.0;
|
||||
mtrx[3] = 1;
|
||||
mtrx[4] = 4;
|
||||
mtrx[5] = 2;
|
||||
mtrx[6] = 0.0;
|
||||
mtrx[7] = 2;
|
||||
mtrx[8] = .25;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -1237,149 +1249,54 @@ BuildLaplacian( int argc,
|
||||
if (num_fun == 2)
|
||||
{
|
||||
|
||||
#if 1
|
||||
mtrx[0] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 0.01, 1.0, 0, mtrx_values);
|
||||
|
||||
mtrx[1] = 200;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.01, 1.0, 1.0, 1, mtrx_values);
|
||||
|
||||
mtrx[2] = 200;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.01, 1.0, 1.0, 2, mtrx_values);
|
||||
|
||||
mtrx[3] = .03;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 2.0, 0.02, 1.0, 3, mtrx_values);
|
||||
#endif
|
||||
#if 0
|
||||
mtrx[0] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0,.01, 1.0, 0, mtrx_values);
|
||||
|
||||
mtrx[1] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, .01, 1.0, 1.0, 1, mtrx_values);
|
||||
|
||||
mtrx[2] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, .01, 1.0, 1.0, 2, mtrx_values);
|
||||
|
||||
mtrx[3] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 2.0, .02, 1.0, 3, mtrx_values);
|
||||
|
||||
#endif
|
||||
#if 0
|
||||
|
||||
mtrx[0] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0,1.0, 1.0, 0, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 0, mtrx_values);
|
||||
|
||||
mtrx[1] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 1, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 2.0, 1.0, 1, mtrx_values);
|
||||
|
||||
mtrx[2] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 2, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 2.0, 1.0, 0.0, 2, mtrx_values);
|
||||
|
||||
mtrx[3] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 3, mtrx_values);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 3.0, 1.0, 3, mtrx_values);
|
||||
|
||||
|
||||
}
|
||||
else if (num_fun == 3)
|
||||
{
|
||||
|
||||
#if 1
|
||||
mtrx[0] = 1.01;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 0, mtrx_values);
|
||||
mtrx[0] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, .01, 1, 0, mtrx_values);
|
||||
|
||||
mtrx[1] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 1, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, 1, 1, 1, mtrx_values);
|
||||
|
||||
mtrx[2] = 0.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 2, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, 1, 1, 2, mtrx_values);
|
||||
|
||||
mtrx[3] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 3, mtrx_values);
|
||||
|
||||
mtrx[4] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 4, mtrx_values);
|
||||
|
||||
mtrx[5] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 5, mtrx_values);
|
||||
|
||||
mtrx[6] = 0.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 6, mtrx_values);
|
||||
|
||||
mtrx[7] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 7, mtrx_values);
|
||||
|
||||
mtrx[8] = 1.01;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 8, mtrx_values);
|
||||
#endif
|
||||
#if 0
|
||||
mtrx[0] = 3;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 0, mtrx_values);
|
||||
|
||||
mtrx[1] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 1, mtrx_values);
|
||||
|
||||
mtrx[2] = 0.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 2, mtrx_values);
|
||||
|
||||
mtrx[3] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 3, mtrx_values);
|
||||
|
||||
mtrx[4] = 4;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 4, mtrx_values);
|
||||
|
||||
mtrx[5] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 5, mtrx_values);
|
||||
|
||||
mtrx[6] = 0.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 6, mtrx_values);
|
||||
|
||||
mtrx[7] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 7, mtrx_values);
|
||||
|
||||
mtrx[8] = 0.25;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, cx, cy, cz, 8, mtrx_values);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
mtrx[0] = 1.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, .01, 1.0, 0, mtrx_values);
|
||||
|
||||
mtrx[1] = 1.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz,1.0, 1.0, 1.0, 1, mtrx_values);
|
||||
|
||||
mtrx[2] = 0.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 2, mtrx_values);
|
||||
|
||||
mtrx[3] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 3, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, 1, 1, 3, mtrx_values);
|
||||
|
||||
mtrx[4] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 2.0, .02, 1.0, 4, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 2, .02, 1, 4, mtrx_values);
|
||||
|
||||
mtrx[5] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0,1.0, 1.0, 5, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, 1, 1, 5, mtrx_values);
|
||||
|
||||
mtrx[6] = 0.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 6, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, 1, 1, 6, mtrx_values);
|
||||
|
||||
mtrx[7] = 2;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.0, 1.0, 1.0, 7, mtrx_values);
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1, 1, 1, 7, mtrx_values);
|
||||
|
||||
mtrx[8] = 1.0;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.5, .04, 1.0, 8, mtrx_values);
|
||||
#endif
|
||||
mtrx[8] = 1;
|
||||
SetSysVcoefValues(num_fun, nx, ny, nz, 1.5, .04, 1, 8, mtrx_values);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
A = hypre_GenerateSysLaplacianVCoef(nx, ny, nz, P, Q, R, num_fun, mtrx, mtrx_values);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user