Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
d5d188e7
Commit
d5d188e7
authored
Dec 27, 2016
by
Dmitry Bagaev
Browse files
K3 interface improvements
parent
d64fd943
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
.gitignore
View file @
d5d188e7
...
@@ -6,3 +6,9 @@ build*/
...
@@ -6,3 +6,9 @@ build*/
*.iml
*.iml
*.xml
*.xml
Source/Solver/solver_fcbiilu2/fcbiilu2.cpp
Source/Solver/solver_k3biilu2/k3d.cpp
Source/Solver/solver_k3biilu2/k3d.h
Source/Solver/solver_k3biilu2/SolverK3BIILU2.cpp
View file @
d5d188e7
#include "SolverK3BIILU2.h"
#include "SolverK3BIILU2.h"
#include "solver_k3biilu2.h"
namespace
INMOST
{
namespace
INMOST
{
SolverK3BIILU2
::
SolverK3BIILU2
()
{
SolverK3BIILU2
::
SolverK3BIILU2
()
{
solver_data
=
NULL
;
matrix_data
=
NULL
;
}
}
SolverInterface
*
SolverK3BIILU2
::
Copy
(
const
SolverInterface
*
other
)
{
SolverInterface
*
SolverK3BIILU2
::
Copy
(
const
SolverInterface
*
other
)
{
...
@@ -47,7 +49,7 @@ namespace INMOST {
...
@@ -47,7 +49,7 @@ namespace INMOST {
void
SolverK3BIILU2
::
Setup
(
int
*
argc
,
char
***
argv
,
SolverParameters
&
p
)
{
void
SolverK3BIILU2
::
Setup
(
int
*
argc
,
char
***
argv
,
SolverParameters
&
p
)
{
SolverInitDataK3biilu2
(
&
solver_data
,
communicator
,
p
.
solverPrefix
.
c_str
());
SolverInitDataK3biilu2
(
&
solver_data
,
communicator
,
p
.
solverPrefix
.
c_str
());
SolverInitializeK3biilu2
(
argc
,
argv
,
p
.
internalFile
);
SolverInitializeK3biilu2
(
solver_data
,
argc
,
argv
,
p
.
internalFile
.
c_str
()
);
}
}
void
SolverK3BIILU2
::
SetMatrix
(
Sparse
::
Matrix
&
A
,
bool
ModifiedPattern
,
bool
OldPreconditioner
)
{
void
SolverK3BIILU2
::
SetMatrix
(
Sparse
::
Matrix
&
A
,
bool
ModifiedPattern
,
bool
OldPreconditioner
)
{
...
@@ -122,8 +124,8 @@ namespace INMOST {
...
@@ -122,8 +124,8 @@ namespace INMOST {
bool
SolverK3BIILU2
::
Solve
(
INMOST
::
Sparse
::
Vector
&
RHS
,
INMOST
::
Sparse
::
Vector
&
SOL
)
{
bool
SolverK3BIILU2
::
Solve
(
INMOST
::
Sparse
::
Vector
&
RHS
,
INMOST
::
Sparse
::
Vector
&
SOL
)
{
INMOST_DATA_ENUM_TYPE
vbeg
,
vend
;
INMOST_DATA_ENUM_TYPE
vbeg
,
vend
;
RHS
.
GetInterval
(
vbeg
,
vend
);
RHS
.
GetInterval
(
vbeg
,
vend
);
v
oid
*
rhs_data
=
NULL
;
v
ector_k3biilu2
*
rhs_data
=
NULL
;
v
oid
*
solution_data
=
NULL
;
v
ector_k3biilu2
*
solution_data
=
NULL
;
VectorInitDataK3biilu2
(
&
rhs_data
,
RHS
.
GetCommunicator
(),
RHS
.
GetName
().
c_str
());
VectorInitDataK3biilu2
(
&
rhs_data
,
RHS
.
GetCommunicator
(),
RHS
.
GetName
().
c_str
());
VectorPreallocateK3biilu2
(
rhs_data
,
local_size
);
VectorPreallocateK3biilu2
(
rhs_data
,
local_size
);
...
@@ -161,8 +163,9 @@ namespace INMOST {
...
@@ -161,8 +163,9 @@ namespace INMOST {
}
}
void
SolverK3BIILU2
::
SetParameter
(
std
::
string
name
,
std
::
string
value
)
{
void
SolverK3BIILU2
::
SetParameter
(
std
::
string
name
,
std
::
string
value
)
{
std
::
cout
<<
"SolverK3BIILU2::SetParameter unsupported operation"
<<
std
::
endl
;
const
char
*
val
=
value
.
c_str
();
//throw INMOST::SolverUnsupportedOperation;
if
(
name
==
"msglev"
)
solver_data
->
pParIter
->
msglev
=
atoi
(
val
);
else
std
::
cout
<<
"Parameter "
<<
name
<<
" is unknown"
<<
std
::
endl
;
}
}
const
INMOST_DATA_ENUM_TYPE
SolverK3BIILU2
::
Iterations
()
const
{
const
INMOST_DATA_ENUM_TYPE
SolverK3BIILU2
::
Iterations
()
const
{
...
...
Source/Solver/solver_k3biilu2/SolverK3BIILU2.h
View file @
d5d188e7
...
@@ -8,8 +8,8 @@ namespace INMOST {
...
@@ -8,8 +8,8 @@ namespace INMOST {
class
SolverK3BIILU2
:
public
SolverInterface
{
class
SolverK3BIILU2
:
public
SolverInterface
{
private:
private:
void
*
solver_data
;
bcg_k3biilu2
*
solver_data
;
void
*
matrix_data
;
matrix_k3biilu2
*
matrix_data
;
INMOST_DATA_ENUM_TYPE
local_size
,
global_size
;
INMOST_DATA_ENUM_TYPE
local_size
,
global_size
;
public:
public:
SolverK3BIILU2
();
SolverK3BIILU2
();
...
...
Source/Solver/solver_k3biilu2/solver_k3biilu2.cpp
View file @
d5d188e7
This diff is collapsed.
Click to expand it.
Source/Solver/solver_k3biilu2/solver_k3biilu2.h
View file @
d5d188e7
#ifndef SOLVER_K3BIILU2_H_INCLUDED
#ifndef SOLVER_K3BIILU2_H_INCLUDED
#define SOLVER_K3BIILU2_H_INCLUDED
#define SOLVER_K3BIILU2_H_INCLUDED
#include "k3d.h"
#include "inmost.h"
#include "inmost_solver.h"
#include "inmost_solver.h"
typedef
struct
{
int
ittype
;
// 0 - BiCGStab; 1,2,3 - GMRES(niter_cycle); 2 - +Poly(ncoef)_BiCGStab; 3 - +Poly(ncoef)_GMRESb(niter_cycle2)
int
niter_cycle
;
// outer GMRES cycle (=kgmr by IEK); 1 - BiCGStab
int
ncoef
;
// polynomial degree (=kdeg by IEK); ittype=2,3
int
niter_cycle2
;
// internal GMRES cycle size for ittype=3
double
eps
;
// the residual precision: ||r|| < eps * ||b||; eps=1e-6
int
maxit
;
// number of iterations permitted; maxit=999
int
ichk
;
// number of skipped iterations to check the convergence
int
msglev
;
// messages level; msglev=0 for silent; msglev>0 to output solution statistics
}
ParIter
;
void
ParametersDefault
(
ParIter
&
parIter
,
k3d
::
SParams
&
parPrec
);
/* BiCGStab solver structure */
typedef
struct
{
int
n
;
// local number of unknowns at the local processor
int
nproc
;
// total number of processors
int
*
ibl
;
// block splitting: ibl[0]=0; ibl[nproc]=nglob
int
*
ia
;
// row pointers: ia[0]=0; ia[nloc]=nzloc
int
*
ja
;
// global column numbers (NOTE: starting from 0 or 1); ja[nzloc]
double
*
a
;
// nonzero coefficients of local matrix A; a[nzloc]
k3d
::
SParams
*
pParams
;
// preconditioner construction parameters
ParIter
*
pParIter
;
// preconditioner construction parameters
k3d
::
CK3D_Solver
<
int
,
double
,
double
>
*
pSolver
;
// pointer to the solver structure
int
ierr
;
// error flag on return; ierr=0 for success
int
istat
[
16
];
// integer statistics array on return
double
dstat
[
16
];
// double statistics array on return
double
RESID
;
// residual norm
int
ITER
;
// number of BiCGStab iterations performed
}
bcg_k3biilu2
;
typedef
struct
{
int
n
;
// local number of unknowns at the local processor
int
nproc
;
// total number of processors
int
*
ibl
;
// block splitting: ibl[0]=0; ibl[nproc]=nglob
int
*
ia
;
// row pointers: ia[0]=0; ia[nloc]=nzloc
int
*
ja
;
// global column numbers (NOTE: starting from 0 or 1); ja[nzloc]
double
*
A
;
// nonzero coefficients of local matrix A; a[nzloc]
}
matrix_k3biilu2
;
typedef
struct
{
int
n
;
// local number of unknowns at the local processor
double
*
v
;
// local data vector
}
vector_k3biilu2
;
/*****************************************************************************/
/* Initialize bcg solver */
int
initbcg_k3
(
bcg_k3biilu2
*
s
,
matrix_k3biilu2
*
A
,
double
eps
);
int
newmatrixbcg_k3
(
bcg_k3biilu2
*
s
,
matrix_k3biilu2
*
A
,
bool
same_precond
);
/* Reinitialize solver preconditioner with new matrix A */
int
renewbcg_k3
(
bcg_k3biilu2
*
s
,
double
*
A
);
/* Solve linear system */
int
solvebcg_k3
(
bcg_k3biilu2
*
s
,
vector_k3biilu2
*
b
,
vector_k3biilu2
*
x
);
/* Free memory used by solver */
void
freebcg_k3
(
bcg_k3biilu2
*
s
);
/*****************************************************************************/
//#define USE_SOLVER_K3BIILU2 //just for test; see flag HAVE_SOLVER_K3BIILU2
//#define USE_SOLVER_K3BIILU2 //just for test; see flag HAVE_SOLVER_K3BIILU2
//#if defined(USE_SOLVER_K3BIILU2)
//#if defined(USE_SOLVER_K3BIILU2)
void
MatrixCopyDataK3biilu2
(
void
**
ppA
,
void
*
pB
);
void
MatrixCopyDataK3biilu2
(
matrix_k3biilu2
**
ppA
,
matrix_k3biilu2
*
pB
);
void
MatrixAssignDataK3biilu2
(
void
*
pA
,
void
*
pB
);
void
MatrixInitDataK3biilu2
(
void
**
ppA
,
INMOST_MPI_Comm
comm
,
const
char
*
name
);
void
MatrixAssignDataK3biilu2
(
matrix_k3biilu2
*
pA
,
matrix_k3biilu2
*
pB
);
void
MatrixDestroyDataK3biilu2
(
void
**
pA
);
void
MatrixFillK3biilu2
(
void
*
pA
,
int
size
,
int
nproc
,
int
*
ibl
,
int
*
ia
,
int
*
ja
,
double
*
values
);
void
MatrixInitDataK3biilu2
(
matrix_k3biilu2
**
ppA
,
INMOST_MPI_Comm
comm
,
const
char
*
name
);
void
MatrixFillValuesK3biilu2
(
void
*
pA
,
double
*
values
);
void
MatrixFinalizeK3biilu2
(
void
*
data
);
void
MatrixDestroyDataK3biilu2
(
matrix_k3biilu2
**
pA
);
void
VectorInitDataK3biilu2
(
void
**
ppA
,
INMOST_MPI_Comm
comm
,
const
char
*
name
);
void
MatrixFillK3biilu2
(
matrix_k3biilu2
*
pA
,
int
size
,
int
nproc
,
int
*
ibl
,
int
*
ia
,
int
*
ja
,
double
*
values
);
void
VectorCopyDataK3biilu2
(
void
**
ppA
,
void
*
pB
);
void
VectorAssignDataK3biilu2
(
void
*
pA
,
void
*
pB
);
void
MatrixFillValuesK3biilu2
(
matrix_k3biilu2
*
pA
,
double
*
values
);
void
VectorPreallocateK3biilu2
(
void
*
pA
,
int
size
);
void
VectorFillK3biilu2
(
void
*
pA
,
double
*
values
);
void
MatrixFinalizeK3biilu2
(
matrix_k3biilu2
*
data
);
void
VectorLoadK3biilu2
(
void
*
pA
,
double
*
values
);
void
VectorFinalizeK3biilu2
(
void
*
data
);
void
VectorInitDataK3biilu2
(
vector_k3biilu2
**
ppA
,
INMOST_MPI_Comm
comm
,
const
char
*
name
);
void
VectorDestroyDataK3biilu2
(
void
**
ppA
);
void
VectorCopyDataK3biilu2
(
vector_k3biilu2
**
ppA
,
vector_k3biilu2
*
pB
);
void
SolverInitializeK3biilu2
(
int
*
argc
,
char
***
argv
,
const
char
*
file_options
);
void
VectorAssignDataK3biilu2
(
vector_k3biilu2
*
pA
,
vector_k3biilu2
*
pB
);
void
VectorPreallocateK3biilu2
(
vector_k3biilu2
*
pA
,
int
size
);
void
VectorFillK3biilu2
(
vector_k3biilu2
*
pA
,
double
*
values
);
void
VectorLoadK3biilu2
(
vector_k3biilu2
*
pA
,
double
*
values
);
void
VectorFinalizeK3biilu2
(
vector_k3biilu2
*
data
);
void
VectorDestroyDataK3biilu2
(
vector_k3biilu2
**
ppA
);
void
SolverInitializeK3biilu2
(
bcg_k3biilu2
*
data
,
int
*
argc
,
char
***
argv
,
const
char
*
file_options
);
bool
SolverIsFinalizedK3biilu2
();
bool
SolverIsFinalizedK3biilu2
();
void
SolverFinalizeK3biilu2
();
void
SolverFinalizeK3biilu2
();
void
SolverDestroyDataK3biilu2
(
void
**
data
);
void
SolverInitDataK3biilu2
(
void
**
data
,
INMOST_MPI_Comm
comm
,
const
char
*
name
);
void
SolverDestroyDataK3biilu2
(
bcg_k3biilu2
**
data
);
void
SolverCopyDataK3biilu2
(
void
**
data
,
void
*
other_data
,
INMOST_MPI_Comm
comm
);
void
SolverAssignDataK3biilu2
(
void
*
data
,
void
*
other_data
);
void
SolverInitDataK3biilu2
(
bcg_k3biilu2
**
data
,
INMOST_MPI_Comm
comm
,
const
char
*
name
);
void
SolverSetMatrixK3biilu2
(
void
*
data
,
void
*
matrix_data
,
bool
same_pattern
,
bool
reuse_preconditioner
);
bool
SolverSolveK3biilu2
(
void
*
data
,
void
*
rhs_data
,
void
*
sol_data
);
void
SolverCopyDataK3biilu2
(
bcg_k3biilu2
**
data
,
bcg_k3biilu2
*
other_data
,
INMOST_MPI_Comm
comm
);
int
SolverIterationNumberK3biilu2
(
void
*
data
);
double
SolverResidualNormK3biilu2
(
void
*
data
);
void
SolverAssignDataK3biilu2
(
bcg_k3biilu2
*
data
,
bcg_k3biilu2
*
other_data
);
void
SolverAddOtherStatK3biilu2
(
void
*
data
,
unsigned
int
*
pivmod
,
double
*
prdens
,
double
*
t_prec
,
double
*
t_iter
);
//#endif //USE_K3SOLVER_BIILU2
void
SolverSetMatrixK3biilu2
(
bcg_k3biilu2
*
data
,
matrix_k3biilu2
*
matrix_data
,
bool
same_pattern
,
bool
reuse_preconditioner
);
bool
SolverSolveK3biilu2
(
bcg_k3biilu2
*
data
,
vector_k3biilu2
*
rhs_data
,
vector_k3biilu2
*
sol_data
);
int
SolverIterationNumberK3biilu2
(
bcg_k3biilu2
*
data
);
double
SolverResidualNormK3biilu2
(
bcg_k3biilu2
*
data
);
#endif //SOLVER_K3BIILU2_H_INCLUDED
#endif //SOLVER_K3BIILU2_H_INCLUDED
Tests/solver_test000/CMakeLists.txt
View file @
d5d188e7
...
@@ -123,5 +123,9 @@ if(SOLVER_DEFINITIONS MATCHES "^.*HAVE_SOLVER_FCBIILU2.*$")
...
@@ -123,5 +123,9 @@ if(SOLVER_DEFINITIONS MATCHES "^.*HAVE_SOLVER_FCBIILU2.*$")
add_test
(
NAME solver_test000_parallel_normal_fcbiilu2 COMMAND
${
MPIEXEC
}
-np 4 $<TARGET_FILE:solver_test000> 0 fcbiilu2
)
add_test
(
NAME solver_test000_parallel_normal_fcbiilu2 COMMAND
${
MPIEXEC
}
-np 4 $<TARGET_FILE:solver_test000> 0 fcbiilu2
)
endif
()
endif
()
if
(
SOLVER_DEFINITIONS MATCHES
"^.*HAVE_SOLVER_K3BIILU2.*$"
)
add_test
(
NAME solver_test000_parallel_normal_k3biilu2 COMMAND
${
MPIEXEC
}
-np 4 $<TARGET_FILE:solver_test000> 0 k3biilu2
)
endif
()
endif
()
endif
()
endif
()
endif
()
Tests/solver_test002/CMakeLists.txt
View file @
d5d188e7
...
@@ -55,6 +55,10 @@ if(SOLVER_DEFINITIONS MATCHES "^.*HAVE_SOLVER_FCBIILU2.*$")
...
@@ -55,6 +55,10 @@ if(SOLVER_DEFINITIONS MATCHES "^.*HAVE_SOLVER_FCBIILU2.*$")
add_test
(
NAME solver_test002_serial_fcbiilu2 COMMAND $<TARGET_FILE:solver_test002> fcbiilu2 20
)
add_test
(
NAME solver_test002_serial_fcbiilu2 COMMAND $<TARGET_FILE:solver_test002> fcbiilu2 20
)
endif
()
endif
()
if
(
SOLVER_DEFINITIONS MATCHES
"^.*HAVE_SOLVER_K3BIILU2.*$"
)
add_test
(
NAME solver_test002_serial_k3biilu2 COMMAND $<TARGET_FILE:solver_test002> k3biilu2 20
)
endif
()
if
(
USE_SOLVER_TRILINOS AND USE_MPI
)
if
(
USE_SOLVER_TRILINOS AND USE_MPI
)
add_test
(
NAME solver_test002_serial_trilinos_aztec COMMAND $<TARGET_FILE:solver_test002> trilinos_aztec 20
)
add_test
(
NAME solver_test002_serial_trilinos_aztec COMMAND $<TARGET_FILE:solver_test002> trilinos_aztec 20
)
add_test
(
NAME solver_test002_serial_trilinos_belos COMMAND $<TARGET_FILE:solver_test002> trilinos_belos 20
)
add_test
(
NAME solver_test002_serial_trilinos_belos COMMAND $<TARGET_FILE:solver_test002> trilinos_belos 20
)
...
@@ -94,5 +98,9 @@ if(SOLVER_DEFINITIONS MATCHES "^.*HAVE_SOLVER_FCBIILU2.*$")
...
@@ -94,5 +98,9 @@ if(SOLVER_DEFINITIONS MATCHES "^.*HAVE_SOLVER_FCBIILU2.*$")
add_test
(
NAME solver_test002_parallel_fcbiilu2 COMMAND $<TARGET_FILE:solver_test002> fcbiilu2 20
)
add_test
(
NAME solver_test002_parallel_fcbiilu2 COMMAND $<TARGET_FILE:solver_test002> fcbiilu2 20
)
endif
()
endif
()
if
(
SOLVER_DEFINITIONS MATCHES
"^.*HAVE_SOLVER_K3BIILU2.*$"
)
add_test
(
NAME solver_test002_parallel_k3biilu2 COMMAND $<TARGET_FILE:solver_test002> k3biilu2 20
)
endif
()
endif
()
endif
()
endif
()
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment