Commit d55b1e90 authored by Igor Konshin's avatar Igor Konshin

new linear solver k3biilu2 is added

parent 9a92cf91
......@@ -15,22 +15,24 @@ int main(int argc, char ** argv)
int rank,procs;
if( argc < 3 )
{
std::cout << "Usage: " << argv[0] << " method_number<0:INNER_ILU2,1:INNER_MLILUC,2:PETSc,3:Trilinos_Aztec,4:Trilinos_Belos,5:Trilinos_Ifpack,6:Trilinos_ML,7:ANI> matrix.mtx [right_hand_side.rhs] [solver_options.txt]" << std::endl;
std::cout << "Usage: " << argv[0] << " method_number<0:INNER_ILU2,1:INNER_DDPQILUC,2:INNER_MPTILUC,3:INNER_MPTILU2,4:Trilinos_Aztec,5:Trilinos_Belos,6:Trilinos_ML,7:Trilinos_Ifpack,8:PETSc,9:ANI,10:FCBIILU2,11:K3BIILU2> matrix.mtx [right_hand_side.rhs] [solver_options.txt]" << std::endl;
return -1;
}
Solver::Type type;
switch(atoi(argv[1]))
{
case 0: type = Solver::INNER_ILU2; break;
case 1: type = Solver::INNER_DDPQILUC; break;
case 2: type = Solver::PETSc; break;
case 3: type = Solver::Trilinos_Aztec; break;
case 4: type = Solver::Trilinos_Belos; break;
case 5: type = Solver::Trilinos_Ifpack; break;
case 6: type = Solver::Trilinos_ML; break;
case 7: type = Solver::ANI; break;
case 8: type = Solver::INNER_MPTILUC; break;
case 9: type = Solver::INNER_MPTILU2; break;
case 0: type = Solver::INNER_ILU2; break;
case 1: type = Solver::INNER_DDPQILUC; break;
case 2: type = Solver::INNER_MPTILUC; break;
case 3: type = Solver::INNER_MPTILU2; break;
case 4: type = Solver::Trilinos_Aztec; break;
case 5: type = Solver::Trilinos_Belos; break;
case 6: type = Solver::Trilinos_ML; break;
case 7: type = Solver::Trilinos_Ifpack; break;
case 8: type = Solver::PETSc; break;
case 9: type = Solver::ANI; break;
case 10: type = Solver::FCBIILU2; break;
case 11: type = Solver::K3BIILU2; break;
}
Solver::Initialize(&argc,&argv,argc > 4 ? argv[4] : NULL); // Initialize the linear solver in accordance with args
{
......
......@@ -51,8 +51,8 @@ namespace INMOST
Trilinos_Ifpack,///< external Solver AztecOO with Ifpack preconditioner.
PETSc, ///< external Solver PETSc, @see http://www.mcs.anl.gov/petsc/
ANI, ///< external Solver from ANI3D based on ILU2 (sequential Fortran version), @see http://ani3d.sourceforge.net/
FCBIILU2, // external FCBIILU2 Solver (BIILU2 parallel F2C version).
K3BIILU2 // inner K3BIILU2 Solver (BIILU2 parallel version).
FCBIILU2, ///< external FCBIILU2 Solver (BIILU2 parallel F2C version).
K3BIILU2 ///< inner K3BIILU2 Solver (BIILU2 parallel version).
};
static INMOST_MPI_Type & GetRowEntryType() {return RowEntryType;}
......
This diff is collapsed.
This diff is collapsed.
......@@ -1929,14 +1929,7 @@ namespace INMOST
void Solver::SetMatrix(Matrix & A, bool OldPreconditioner)
{
(void) OldPreconditioner;
std::cout<<"##### SetMatrix: bef.: the very-very beginning... _pack="<<_pack<<std::endl;//db!
bool ok = false;
#if defined(HAVE_SOLVER_FCBIILU2)
std::cout<<"##### SetMatrix: HAVE_SOLVER_FCBIILU2 is set, OK!!!!!!!!!!!!! _pack="<<_pack<<std::endl;//db!
#endif
#if defined(HAVE_SOLVER_K3BIILU2)
std::cout<<"##### SetMatrix: HAVE_SOLVER_K3BIILU2 is set, OK!!!!!!!!!!!!! _pack="<<_pack<<std::endl;//db!
#endif
#if defined(USE_SOLVER_PETSC)
if( _pack == PETSc )
{
......@@ -2094,7 +2087,6 @@ namespace INMOST
#if defined(HAVE_SOLVER_FCBIILU2)
if( _pack == FCBIILU2 )
{
std::cout<<"##### bef. FCBIILU2: bool modified_pattern = ... "<<std::endl;//db!
bool modified_pattern = false;
for(Matrix::iterator it = A.Begin(); it != A.End() && !modified_pattern; ++it)
modified_pattern |= it->modified_pattern;
......@@ -2104,7 +2096,6 @@ namespace INMOST
MatrixInitDataFcbiilu2(&matrix_data,A.GetCommunicator(),A.GetName().c_str());
modified_pattern = true;
}
std::cout<<"##### bef. if( modified_pattern )... "<<modified_pattern<<std::endl;//db!
if( modified_pattern )
{
global_size = local_size = A.Size();
......@@ -2133,7 +2124,6 @@ namespace INMOST
ibl[1] = n;
#endif
int * ia = (int *)malloc(sizeof(int)*(n+1));
std::cout<<"##### bef. for(...) myid="<<myid<<" A.Size()="<<A.Size()<<" n="<<n<<" nproc="<<nproc<<" ibl: "<<ibl[0]<<" "<<ibl[1]<<" ... "<<ibl[nproc]<<std::endl;//db!
for(Matrix::iterator it = A.Begin(); it != A.End(); it++) nnz += it->Size();
int * ja = (int *)malloc(sizeof(int)*nnz);
double * values = (double *) malloc(sizeof(double)*nnz);
......@@ -2150,7 +2140,6 @@ namespace INMOST
shift += it->Size();
ia[q++] = shift;
}
std::cout<<"##### bef. MatrixFillFcbiilu2 myid="<<myid<<" n="<<n<<" nnz="<<nnz<<" shift="<<shift<<" ia: "<<ia[0]<<" "<<ia[1]<<" "<<ia[2]<<" ... "<<ia[n]<<" ja: "<<ja[0]<<" "<<ja[1]<<" "<<ja[2]<<" ... "<<ja[nnz-1]<<" a: "<<values[0]<<" "<<values[1]<<" "<<values[2]<<" ... "<<values[nnz-1]<<std::endl;//db!
MatrixFillFcbiilu2(matrix_data,n,nproc,ibl,ia,ja,values);
}
else
......@@ -2166,14 +2155,12 @@ namespace INMOST
}
MatrixFinalizeFcbiilu2(matrix_data);
SolverSetMatrixFcbiilu2(solver_data,matrix_data,modified_pattern,OldPreconditioner);
std::cout<<"##### bef. ok=true"<<std::endl;//db!
ok = true;
}
#endif
#if defined(HAVE_SOLVER_K3BIILU2)
if( _pack == K3BIILU2 )
{
std::cout<<"##### bef. K3BIILU2: bool modified_pattern = ... "<<std::endl;//db!
bool modified_pattern = false;
for(Matrix::iterator it = A.Begin(); it != A.End() && !modified_pattern; ++it)
modified_pattern |= it->modified_pattern;
......@@ -2183,14 +2170,13 @@ namespace INMOST
MatrixInitDataK3biilu2(&matrix_data,A.GetCommunicator(),A.GetName().c_str());
modified_pattern = true;
}
std::cout<<"##### bef. if( modified_pattern )... "<<modified_pattern<<std::endl;//db!
if( modified_pattern )
{
global_size = local_size = A.Size();
MatrixDestroyDataK3biilu2(&matrix_data);
MatrixInitDataK3biilu2(&matrix_data,A.GetCommunicator(),A.GetName().c_str());
INMOST_DATA_ENUM_TYPE nnz = 0, k = 0, q = 1, shift = 1;
INMOST_DATA_ENUM_TYPE nnz = 0, k = 0, q = 1, shift = 0;
int nproc, myid;
#if defined(USE_MPI)
MPI_Comm_size(A.GetCommunicator(),&nproc);
......@@ -2212,7 +2198,6 @@ namespace INMOST
ibl[1] = n;
#endif
int * ia = (int *)malloc(sizeof(int)*(n+1));
std::cout<<"##### bef. for(...) myid="<<myid<<" A.Size()="<<A.Size()<<" n="<<n<<" nproc="<<nproc<<" ibl: "<<ibl[0]<<" "<<ibl[1]<<" ... "<<ibl[nproc]<<std::endl;//db!
for(Matrix::iterator it = A.Begin(); it != A.End(); it++) nnz += it->Size();
int * ja = (int *)malloc(sizeof(int)*nnz);
double * values = (double *) malloc(sizeof(double)*nnz);
......@@ -2221,7 +2206,7 @@ namespace INMOST
{
for(Row::iterator jt = it->Begin(); jt != it->End(); jt++)
{
ja[k] = jt->first + 1;
ja[k] = jt->first + 0;
values[k] = jt->second;
//std::cout<<"# q="<<q<<" k="<<k<<" ja="<<ja[k]<<" a="<<values[k]<<std::endl;//db!
k++;
......@@ -2229,7 +2214,6 @@ namespace INMOST
shift += it->Size();
ia[q++] = shift;
}
std::cout<<"##### bef. MatrixFillK3biilu2 myid="<<myid<<" n="<<n<<" nnz="<<nnz<<" shift="<<shift<<" ia: "<<ia[0]<<" "<<ia[1]<<" "<<ia[2]<<" ... "<<ia[n]<<" ja: "<<ja[0]<<" "<<ja[1]<<" "<<ja[2]<<" ... "<<ja[nnz-1]<<" a: "<<values[0]<<" "<<values[1]<<" "<<values[2]<<" ... "<<values[nnz-1]<<std::endl;//db!
MatrixFillK3biilu2(matrix_data,n,nproc,ibl,ia,ja,values);
}
else
......@@ -2245,7 +2229,6 @@ namespace INMOST
}
MatrixFinalizeK3biilu2(matrix_data);
SolverSetMatrixK3biilu2(solver_data,matrix_data,modified_pattern,OldPreconditioner);
std::cout<<"##### bef. ok=true"<<std::endl;//db!
ok = true;
}
#endif
......@@ -2377,7 +2360,6 @@ namespace INMOST
}
for(Matrix::iterator it = A.Begin(); it != A.End(); it++) it->modified_pattern = false;
std::cout<<"##### SetMatrix: bef.: the very-very end... "<<std::endl;//db!
if(!ok) throw NotImplemented;
}
......
This diff is collapsed.
#ifndef SOLVER_K3BIILU2_H_INCLUDED
#define SOLVER_K3BIILU2_H_INCLUDED
#include "inmost_solver.h"
//#define USE_SOLVER_K3BIILU2 //just for test; see flag HAVE_SOLVER_K3BIILU2
//#if defined(USE_SOLVER_K3BIILU2)
void MatrixCopyDataK3biilu2(void ** ppA, void * pB);
void MatrixAssignDataK3biilu2(void * pA, void * pB);
void MatrixInitDataK3biilu2(void ** ppA, INMOST_MPI_Comm comm, const char * name);
void MatrixDestroyDataK3biilu2(void ** pA);
void MatrixFillK3biilu2(void * pA, int size, int nproc, int * ibl, int * ia, int * ja, double * values);
void MatrixFillValuesK3biilu2(void * pA, double * values);
void MatrixFinalizeK3biilu2(void * data);
void VectorInitDataK3biilu2(void ** ppA, INMOST_MPI_Comm comm, const char * name);
void VectorCopyDataK3biilu2(void ** ppA, void * pB);
void VectorAssignDataK3biilu2(void * pA, void * pB);
void VectorPreallocateK3biilu2(void * pA, int size);
void VectorFillK3biilu2(void * pA, double * values);
void VectorLoadK3biilu2(void * pA, double * values);
void VectorFinalizeK3biilu2(void * data);
void VectorDestroyDataK3biilu2(void ** ppA);
void SolverInitializeK3biilu2(int * argc,char *** argv, const char * file_options);
bool SolverIsFinalizedK3biilu2();
void SolverFinalizeK3biilu2();
void SolverDestroyDataK3biilu2(void ** data);
void SolverInitDataK3biilu2(void ** data, INMOST_MPI_Comm comm, const char * name);
void SolverCopyDataK3biilu2(void ** data, void * other_data, INMOST_MPI_Comm comm);
void SolverAssignDataK3biilu2(void * data, void * other_data);
void SolverSetMatrixK3biilu2(void * data, void * matrix_data, bool same_pattern, bool reuse_preconditioner);
bool SolverSolveK3biilu2(void * data, void * rhs_data, void * sol_data);
int SolverIterationNumberK3biilu2(void * data);
double SolverResidualNormK3biilu2(void * data);
void SolverAddOtherStatK3biilu2(void * data, unsigned int * pivmod, double * prdens, double * t_prec, double * t_iter);
//#endif //USE_K3SOLVER_BIILU2
#endif //SOLVER_K3BIILU2_H_INCLUDED
......@@ -36,24 +36,24 @@ memory requirements.
(*) Arguments
Usage: ./solver_test002 method_number<0:INNER_ILU2,1:INNER_MLILUC,2:PETSc,3:Trilinos_Aztec,4:Trilinos_Belos,5:Trilinos_Ifpack,6:Trilinos_ML,7:ANI> N<for NxNxN problem> [solver_options.txt]
Usage: ./solver_test002 method_number<0:INNER_ILU2,1:INNER_DDPQILUC,2:INNER_MPTILUC,3:INNER_MPTILU2,4:Trilinos_Aztec,5:Trilinos_Belos,6:Trilinos_ML,7:Trilinos_Ifpack,8:PETSc,9:ANI,10:FCBIILU2,11:K3BIILU2> N<for NxNxN problem> [solver_options.txt]
* First parameter is the Solver type:
0 – INNER_ILU2, inner Solver based on BiCGStab(L) solver with second
order ILU factorization as preconditioner;
1 – INNER_MLILUC, inner Solver based on BiCGStab(L) solver with second
order Crout-ILU with inversed-based condition estimation and unsymmetric
reordering for diagonal dominance as preconditioner;
2 – PETSc, external Solver AztecOO from Trilinos package;
3 – Trilinos_Aztec, external Solver Belos from Trilinos package,
currently without preconditioner;
4 – Trilinos_Belos, external Solver AztecOO with ML preconditioner;
5 – Trilinos_Ifpack, external Solver AztecOO with Ifpack
preconditioner;
6 – Trilinos_ML, external Solver PETSc;
7 – ANI, external Solver from ANI3D based on ILU2 (sequential Fortran
version).
order IIU factorization as preconditioner;
1 - INNER_DDPQILUC, inner Solver based on BiCGStab(L) solver with second order Crout-ILU with inversed-based condition estimation and unsymmetric reordering for diagonal dominance as preconditioner;
2 - INNER_MPTILUC, inner Solver based on BiCGStab(L) solver with second order Crout-ILU with inversed-based condition estimation and maximum product transversal reordering as preconditioner;
3 - INNER_MPTILU2, inner Solver based on BiCGStab(L) solver with second order ILU and maximum product transversal reordering as preconditione;
4 – Trilinos_Aztec, external Solver AztecOO from Trilinos package;
currentty without preconditioner;
5 – Trilinos_Belos, external Solver Belos from Trilinos package, currently without preconditioner;
6 – Trilinos_ML, external Solver AztecOO with ML preconditioner;
7 – Trilinos_Ifpack, external Solver AztecOO with Ifpack preconditioner;
8 - PETSc, external Solver PETSc;
9 – ANI, external Solver from ANI3D based on ILU2 (sequential Fortran version);
10 – FCBIILU2, external FCBIILU2 Solver (BIILU2 parallel F2C version);
11 – K3BIILU2, internal K3BIILU2 Solver (BIILU2 parallel version).
* Second parameter is the dimension N of the 3D Poisson problem for NxNxN
mesh.
* Third optional parameter is the file with solver parameters, see
......@@ -87,22 +87,24 @@ int main(int argc, char ** argv)
int rank,procs;
if( argc < 3 )
{
std::cout << "Usage: " << argv[0] << " method_number<0:INNER_ILU2,1:INNER_MLILUC,2:PETSc,3:Trilinos_Aztec,4:Trilinos_Belos,5:Trilinos_Ifpack,6:Trilinos_ML,7:ANI> N<for NxNxN problem> [solver_options.txt]" << std::endl;
std::cout << "Usage: " << argv[0] << " method_number<0:INNER_ILU2,1:INNER_DDPQILUC,2:INNER_MPTILUC,3:INNER_MPTILU2,4:Trilinos_Aztec,5:Trilinos_Belos,6:Trilinos_ML,7:Trilinos_Ifpack,8:PETSc,9:ANI,10:FCBIILU2,11:K3BIILU2> N<for NxNxN problem> [solver_options.txt]" << std::endl;
return -1;
}
Solver::Type type;
switch(atoi(argv[1]))
{
case 0: type = Solver::INNER_ILU2; break;
case 1: type = Solver::INNER_DDPQILUC; break;
case 2: type = Solver::PETSc; break;
case 3: type = Solver::Trilinos_Aztec; break;
case 4: type = Solver::Trilinos_Belos; break;
case 5: type = Solver::Trilinos_Ifpack; break;
case 6: type = Solver::Trilinos_ML; break;
case 7: type = Solver::ANI; break;
case 8: type = Solver::INNER_MPTILUC; break;
case 9: type = Solver::INNER_MPTILU2; break;
case 0: type = Solver::INNER_ILU2; break;
case 1: type = Solver::INNER_DDPQILUC; break;
case 2: type = Solver::INNER_MPTILUC; break;
case 3: type = Solver::INNER_MPTILU2; break;
case 4: type = Solver::Trilinos_Aztec; break;
case 5: type = Solver::Trilinos_Belos; break;
case 6: type = Solver::Trilinos_ML; break;
case 7: type = Solver::Trilinos_Ifpack; break;
case 8: type = Solver::PETSc; break;
case 9: type = Solver::ANI; break;
case 10: type = Solver::FCBIILU2; break;
case 11: type = Solver::K3BIILU2; break;
}
int n = atoi(argv[2]);
Solver::Initialize(&argc,&argv,argc > 3 ? argv[3] : NULL); // Initialize the linear solver in accordance with args
......@@ -261,5 +263,4 @@ void Poisson3D(int n1, int n2, int n3, Solver::Matrix & A)
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment