Commit 8fa00d6a authored by Kirill Terekhov's avatar Kirill Terekhov

Solver updates

Added support of Trilinos: AztecOO, ML, Ifpack, Belos. Added Petsc
divergence reasons. Described parameters, some parameters unified with
Trilinos.
parent d7217797
......@@ -59,7 +59,8 @@ option(COMPILE_TESTS "Compile some tests" OFF)
option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" OFF)
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" OFF)
option(USE_SOLVER_PETSC "Use PETSc solver" OFF)
option(USE_SOLVER_PETSC "Use PETSc solvers" OFF)
option(USE_SOLVER_TRILINOS "Use Trilinos solvers" OFF)
option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation (under work)" OFF)
option(USE_AUTODIFF_ASMJIT "Use AsmJit for automatic differentiation" OFF)
option(USE_AUTODIFF_EXPRESSION_TEMPLATES "Use c++ expression templates for automatic differentiation" OFF)
......@@ -142,6 +143,40 @@ if(USE_SOLVER_PETSC)
endif()
if(USE_SOLVER_TRILINOS)
set(CMAKE_PREFIX_PATH ${TRILINOS_PATH} ${CMAKE_PREFIX_PATH})
find_package(Trilinos PATHS ${TRILINOS_PATH}/lib/cmake/Trilinos ${TRILINOS_PATH})
if(NOT Trilinos_FOUND)
set(USE_SOLVER_TRILINOS OFF)
message("Trilinos NOT FOUND")
else()
MESSAGE("\nFound Trilinos! Here are the details: ")
MESSAGE(" Trilinos_DIR = ${Trilinos_DIR}")
MESSAGE(" Trilinos_VERSION = ${Trilinos_VERSION}")
MESSAGE(" Trilinos_PACKAGE_LIST = ${Trilinos_PACKAGE_LIST}")
MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES}")
MESSAGE(" Trilinos_INCLUDE_DIRS = ${Trilinos_INCLUDE_DIRS}")
MESSAGE(" Trilinos_LIBRARY_DIRS = ${Trilinos_LIBRARY_DIRS}")
MESSAGE(" Trilinos_TPL_LIST = ${Trilinos_TPL_LIST}")
MESSAGE(" Trilinos_TPL_INCLUDE_DIRS = ${Trilinos_TPL_INCLUDE_DIRS}")
MESSAGE(" Trilinos_TPL_LIBRARIES = ${Trilinos_TPL_LIBRARIES}")
MESSAGE(" Trilinos_TPL_LIBRARY_DIRS = ${Trilinos_TPL_LIBRARY_DIRS}")
MESSAGE(" Trilinos_BUILD_SHARED_LIBS = ${Trilinos_BUILD_SHARED_LIBS}")
MESSAGE("End of Trilinos details\n")
include_directories(${Trilinos_INCLUDE_DIRS})
include_directories(${Trilinos_TPL_INCLUDE_DIRS})
link_directories(${Trilinos_LIBRARY_DIRS})
link_directories(${Trilinos_TPL_LIBRARY_DIRS})
set(USE_SOLVER_TRILINOS ON)
message("Trilinos FOUND")
endif()
endif()
if(USE_AUTODIFF_OPENCL)
find_package(OpenCL)
if(OPENCL_FOUND)
......@@ -167,6 +202,14 @@ if(USE_AUTODIFF_EXPRESSION_TEMPLATES)
endif()
if(MSVC)
if(USE_SOLVER_TRILINOS)
message("Putting workaround for Visual Studio that allow to use Trilinos Release libraries in Debug mode")
message("Note that this workaround may affect your debugging experience, you may want to debug without Trilinos")
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
endif()
endif()
configure_file("inmost_options_cmake.h" "${PROJECT_BINARY_DIR}/inmost_options.h")
include_directories("${PROJECT_BINARY_DIR}")
......
......@@ -5,4 +5,4 @@ add_subdirectory(MatSolve)
add_subdirectory(GridGen)
add_subdirectory(FVDiscr)
#add_subdirectory(OctreeCutcell)
#add_subdirectory(Solver)
add_subdirectory(Solver)
......@@ -4,28 +4,40 @@ find_package(OpenGL)
find_package(GLUT)
if(OPENGL_FOUND)
if(GLUT_FOUND)
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(DrawMatrix ${SOURCE})
target_link_libraries(DrawMatrix inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(DrawMatrix ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(DrawMatrix PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
if(USE_SOLVER_ANI3D)
target_link_libraries(DrawMatrix ani3d)
endif()
if(USE_SOLVER_PETSC)
add_definitions(${PETSC_DEFINITIONS})
target_link_libraries(DrawMatrix ${PETSC_LIBRARIES})
endif()
else(GLUT_FOUND)
message("GLUT not found")
endif(GLUT_FOUND)
if(GLUT_FOUND)
message("linking DrawMatrix with GLUT and OpenGL")
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(DrawMatrix ${SOURCE})
target_link_libraries(DrawMatrix inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(DrawMatrix ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(DrawMatrix PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
if(USE_SOLVER)
if(USE_SOLVER_ANI3D)
message("linking DrawMatrix with ANI3d")
target_link_libraries(DrawMatrix ani3d)
endif()
if(USE_SOLVER_PETSC)
message("linking DrawMatrix with PETSc")
add_definitions(${PETSC_DEFINITIONS})
target_link_libraries(DrawMatrix ${PETSC_LIBRARIES})
endif()
if(USE_SOLVER_TRILINOS)
message("linking DrawMatrix with Trilinos")
link_directories(${Trilinos_LIBRARY_DIRS})
link_directories(${Trilinos_TPL_LIBRARY_DIRS})
target_link_libraries(DrawMatrix ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})
endif()
endif()
else(GLUT_FOUND)
message("GLUT not found, not building DrawMatrix")
endif(GLUT_FOUND)
else(OPENGL_FOUND)
message("OpenGL not found")
message("OpenGL not found, not building DrawMatrix")
endif(OPENGL_FOUND)
//g++ main.cpp rotate.cpp -L/usr/X11R6/lib -lX11 -lXi -lXmu -lGL -lglut -lGLU ../../inmost.a -O5
// press space - explode mesh to see connection
#define _CRT_SECURE_NO_WARNINGS
#include "../../inmost.h"
#include "my_glut.h"
#include <iostream>
......@@ -140,7 +141,7 @@ class Reorder_ARMS
for (INMOST_DATA_ENUM_TYPE k = 0; k < neighbours[block_entries[j]].size(); ++k)
A[neighbours[block_entries[j]][k]].SetMarker();
}
sblock += block_entries.size();
sblock += static_cast<int>(block_entries.size());
block_ends.push_back(sblock);
nblocks++;
stack.clear();
......@@ -168,7 +169,7 @@ class Reorder_ARMS
}
INMOST_DATA_ENUM_TYPE GetOrder(INMOST_DATA_ENUM_TYPE ind)
{
return neighbours[ind].size();
return static_cast<Storage::enumerator>(neighbours[ind].size());
INMOST_DATA_ENUM_TYPE ret = 0, k;
for (k = 0; k < neighbours[ind].size(); k++)
if (!A[neighbours[ind][k]].GetMarker())
......@@ -306,11 +307,11 @@ public:
if (qi == qj && qi != block_ends.end())
{
p = qi - block_ends.begin();
if (p < nblocks)
if (p < static_cast<unsigned>(nblocks))
nnz[p] += 1.0;
}
}
for (INMOST_DATA_ENUM_TYPE k = 0; k < nblocks; ++k)
for (INMOST_DATA_ENUM_TYPE k = 0; k < static_cast<unsigned>(nblocks); ++k)
{
nnz[k] /= static_cast<INMOST_DATA_REAL_TYPE>((block_ends[k + 1] - block_ends[k])*(block_ends[k + 1] - block_ends[k]));
nnzall += nnz[k];
......
......@@ -5,22 +5,32 @@ add_executable(FVDiscr ${SOURCE})
target_link_libraries(FVDiscr inmost)
if(USE_SOLVER_ANI)
message("linking FVDiscr with ani3d")
target_link_libraries(FVDiscr ani3d)
if(USE_SOLVER)
if(USE_SOLVER_ANI)
message("linking FVDiscr with ani3d")
target_link_libraries(FVDiscr ani3d)
endif()
if(USE_SOLVER_PETSC)
message("linking FVDiscr with PETSc")
link_directories(${PETSC_LIBRARY_DIRS})
target_link_libraries(FVDiscr ${PETSC_LIBRARIES})
endif()
if(USE_SOLVER_TRILINOS)
message("linking FVDiscr with Trilinos")
link_directories(${Trilinos_LIBRARY_DIRS})
link_directories(${Trilinos_TPL_LIBRARY_DIRS})
target_link_libraries(FVDiscr ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})
endif()
endif()
if(USE_SOLVER_PETSC)
message("linking FVDiscr with PETSc")
link_directories(${PETSC_LIBRARY_DIRS})
target_link_libraries(FVDiscr ${PETSC_LIBRARIES})
endif()
if(USE_PARTITIONER)
if(USE_PARTITIONER_ZOLTAN)
message("linking FVDiscr with Zoltan")
target_link_libraries(FVDiscr ${ZOLTAN_LIBRARIES})
endif()
if(USE_PARTITIONER_PARMETIS)
message("linking FVDiscr with ParMETIS")
target_link_libraries(FVDiscr ${PARMETIS_LIBRARIES})
endif()
endif()
......@@ -32,3 +42,5 @@ if(USE_MPI)
set_target_properties(FVDiscr PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
......@@ -13,12 +13,20 @@ if(USE_MPI)
endif()
endif(USE_MPI)
if(USE_SOLVER_ANI)
message("linking MatSolve with ani3d")
target_link_libraries(MatSolve ani3d)
endif()
if(USE_SOLVER_PETSC)
message("linking MatSolve with PETSc")
link_directories(${PETSC_LIBRARY_DIRS})
target_link_libraries(MatSolve ${PETSC_LIBRARIES})
if(USE_SOLVER)
if(USE_SOLVER_ANI)
message("linking MatSolve with ani3d")
target_link_libraries(MatSolve ani3d)
endif()
if(USE_SOLVER_PETSC)
message("linking MatSolve with PETSc")
link_directories(${PETSC_LIBRARY_DIRS})
target_link_libraries(MatSolve ${PETSC_LIBRARIES})
endif()
if(USE_SOLVER_TRILINOS)
message("linking MatSolve with Trilinos")
link_directories(${Trilinos_LIBRARY_DIRS})
link_directories(${Trilinos_TPL_LIBRARY_DIRS})
target_link_libraries(MatSolve ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})
endif()
endif()
......@@ -7,27 +7,21 @@ find_package(OpenGL)
find_package(GLUT)
if(OPENGL_FOUND)
if(GLUT_FOUND)
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(OldDrawGrid ${SOURCE})
target_link_libraries(OldDrawGrid inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(OldDrawGrid ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(OldDrawGrid PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
if(USE_SOLVER_ANI3D)
target_link_libraries(OldDrawGrid ani3d)
endif()
if(USE_SOLVER_PETSC)
add_definitions(${PETSC_DEFINITIONS})
target_link_libraries(OldDrawGrid ${PETSC_LIBRARIES})
endif()
else(GLUT_FOUND)
message("GLUT not found")
endif(GLUT_FOUND)
if(GLUT_FOUND)
message("linking OldDrawGrid with GLUT and OpenGL")
include_directories(${OPENGL_INCLUDE_DIR})
include_directories(${GLUT_INCLUDE_DIR})
add_executable(OldDrawGrid ${SOURCE})
target_link_libraries(OldDrawGrid inmost ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
if(USE_MPI)
target_link_libraries(OldDrawGrid ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(OldDrawGrid PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
else(GLUT_FOUND)
message("GLUT not found, not building OldDrawGrid")
endif(GLUT_FOUND)
else(OPENGL_FOUND)
message("OpenGL not found")
message("OpenGL not found, not building OldDrawGrid")
endif(OPENGL_FOUND)
......@@ -14,11 +14,19 @@ if(USE_SOLVER_PETSC)
link_directories(${PETSC_LIBRARY_DIRS})
target_link_libraries(Solver ${PETSC_LIBRARIES})
endif()
if(USE_SOLVER_TRILINOS)
message("linking Solver with Trilinos")
link_directories(${Trilinos_LIBRARY_DIRS})
link_directories(${Trilinos_TPL_LIBRARY_DIRS})
target_link_libraries(Solver ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})
endif()
if(USE_PARTITIONER)
if(USE_PARTITIONER_ZOLTAN)
message("linking Solver with Zoltan")
target_link_libraries(Solver ${ZOLTAN_LIBRARIES})
endif()
if(USE_PARTITIONER_PARMETIS)
message("linking Solver with ParMETIS")
target_link_libraries(Solver ${PARMETIS_LIBRARIES})
endif()
endif()
......
......@@ -212,7 +212,7 @@ int main(int argc,char ** argv)
if( !repartition && m->HaveTag("CM_INDEX") )
{
id = m->GetTag("CM_INDEX");
m->ExchangeData(id,CELL);
m->ExchangeData(id,CELL,0);
}
else
{
......@@ -263,7 +263,7 @@ int main(int argc,char ** argv)
Solver::Matrix A;
Solver::Vector x,b;
std::map<GeometricData,ElementType> table;
Mesh::GeomParam table;
table[MEASURE] = CELL | FACE;
table[CENTROID] = CELL | FACE;
......@@ -293,10 +293,10 @@ int main(int argc,char ** argv)
{
//~ std::cout << face->LocalID() << " / " << m->NumberOfFaces() << std::endl;
Element::Status s1,s2;
Cell * r1 = face->BackCell();
Cell * r2 = face->FrontCell();
if( ((r1 == NULL || (s1 = r1->GetStatus()) == Element::Ghost)?0:1)+
((r2 == NULL || (s2 = r2->GetStatus()) == Element::Ghost)?0:1) == 0) continue;
Cell r1 = face->BackCell();
Cell r2 = face->FrontCell();
if( ((!r1.isValid() || (s1 = r1->GetStatus()) == Element::Ghost)?0:1)+
((!r2.isValid() || (s2 = r2->GetStatus()) == Element::Ghost)?0:1) == 0) continue;
Storage::real f_nrm[3], r1_cnt[3], r2_cnt[3], f_cnt[3], d1[3], d2[3], T1, T2, Coef;
Storage::real f_area = face->Area();
Storage::real vol1 = r1->Volume(), vol2;
......@@ -308,7 +308,7 @@ int main(int argc,char ** argv)
f_nrm[2] /= f_area;
r1->Barycenter(r1_cnt);
face->Barycenter(f_cnt);
if( r2 == NULL ) //boundary condition
if( !r2.isValid() ) //boundary condition
{
if( r1->Integer(mat) == 2 ) //direchlet boundary for second material
{
......@@ -433,7 +433,7 @@ int main(int argc,char ** argv)
if( m->GetProcessorRank() == 0 ) std::cout << "Retrive data: " << Timer()-ttt << std::endl;
ttt = Timer();
m->ExchangeData(phi,CELL);
m->ExchangeData(phi,CELL,0);
BARRIER
if( m->GetProcessorRank() == 0 ) std::cout << "Exchange phi: " << Timer()-ttt << std::endl;
......@@ -444,19 +444,19 @@ int main(int argc,char ** argv)
m->SetParallelStrategy(s);
ttt = Timer();
m->ExchangeData(tensor_K,CELL);
m->ExchangeData(tensor_K,CELL,0);
BARRIER
if( m->GetProcessorRank() == 0 ) std::cout << "Exchange dense fixed data: " << Timer()-ttt << std::endl;
ttt = Timer();
m->ExchangeData(m->ProcessorsTag(),CELL);
m->ExchangeData(m->ProcessorsTag(),CELL,0);
BARRIER
if( m->GetProcessorRank() == 0 ) std::cout << "Exchange dense variable data: " << Timer()-ttt << std::endl;
ttt = Timer();
m->ExchangeData(test,CELL);
m->ExchangeData(test,CELL,0);
BARRIER
if( m->GetProcessorRank() == 0 ) std::cout << "Exchange sparse fixed data: " << Timer()-ttt << std::endl;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -16,6 +16,7 @@
#define USE_SOLVER
//#define USE_SOLVER_PETSC
//#define USE_SOLVER_TRILINOS
//#define USE_SOLVER_ANI
#define USE_AUTODIFF
......
......@@ -16,6 +16,7 @@
#cmakedefine USE_SOLVER
#cmakedefine USE_SOLVER_PETSC
#cmakedefine USE_SOLVER_TRILINOS
#cmakedefine USE_SOLVER_ANI
......
......@@ -6,6 +6,21 @@
#include "inmost_common.h"
//#include "solver_prototypes.hpp"
#define DEFAULT_ADDITIVE_SCHWARTZ_OVERLAP 2
#define DEFAULT_ABSOLUTE_TOLERANCE 1.0e-5
#define DEFAULT_RELATIVE_TOLERANCE 1.0e-12
#define DEFAULT_DIVERGENCE_TOLERANCE 1.0e+20
#define DEFAULT_MAXIMUM_ITERATIONS 2500
#define DEFAULT_SOLVER_GMRES_SUBSTEPS 2
#define DEFAULT_PRECONDITIONER_DROP_TOLERANCE 0.001
#define DEFAULT_PRECONDITIONER_REUSE_TOLERANCE 0.00001
#define DEFAULT_PRECONDITIONER_FILL_LEVEL 3
#define DEFAULT_PRECONDITIONER_DDPQ_TOLERANCE 0.75
#define DEFAULT_PRECONDITIONER_REORDER_NONZEROS 0
#define DEFAULT_PRECONDITIONER_RESCALE_ITERS 5
#define DEFAULT_PRECONDITIONER_CONDITION_ESTIMATION 1
#define DEFAULT_PRECONDITIONER_ADAPT_DDPQ_TOLERANCE 1
#if defined(USE_SOLVER)
namespace INMOST
{
......@@ -25,10 +40,14 @@ namespace INMOST
/// Type of the Solver can be currently used in this version of INMOST.
enum Type
{
INNER_ILU2, ///< inner Solver based on second order ILU factorization.
INNER_MLILUC, ///< inner Solver based on Saad multilevel ILU with pivoting.
PETSC, ///< external Solver PETSc, @see http://www.mcs.anl.gov/petsc/.
ANI ///< external Solver from ANI3D based on ILU2 (sequential Fortran version).
INNER_ILU2, ///< inner Solver based on second order ILU factorization.
INNER_MLILUC, ///< inner Solver based on Saad multilevel ILU with pivoting.
Trilinos_Aztec, ///< external Solver AztecOO from Trilinos package
Trilinos_Belos, ///< external Solver Belos from Trilinos package, currently without preconditioner
Trilinos_ML, ///< external Solver AztecOO with ML preconditioner
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).
};
static INMOST_MPI_Type & GetRowEntryType() {return RowEntryType;}
......@@ -148,7 +167,7 @@ namespace INMOST
const_iterator End() const {return data.end();}
bool Empty() const {return data.empty();}
/// Set the start and the end of the distributed vector interval.
void SetInterval(INMOST_DATA_ENUM_TYPE start, INMOST_DATA_ENUM_TYPE end) {data.set_interval_beg(start); data.set_interval_end(end);}
void SetInterval(INMOST_DATA_ENUM_TYPE start, INMOST_DATA_ENUM_TYPE end) {assert(start<=end); data.set_interval_beg(start); data.set_interval_end(end);}
/// Get the start and the end of the distributed vector interval.
void GetInterval(INMOST_DATA_ENUM_TYPE & start, INMOST_DATA_ENUM_TYPE & end) const {start = data.get_interval_beg(); end = data.get_interval_end();}
void ShiftInterval(INMOST_DATA_ENUM_TYPE shift) {data.shift_interval(shift);}
......@@ -410,7 +429,26 @@ namespace INMOST
INMOST_DATA_ENUM_TYPE last_it;
INMOST_DATA_REAL_TYPE last_resid;
OrderInfo info;
INMOST_DATA_ENUM_TYPE overlap;
INMOST_DATA_ENUM_TYPE additive_schwartz_overlap;
INMOST_DATA_ENUM_TYPE maximum_iterations;
INMOST_DATA_REAL_TYPE absolute_tolerance;
INMOST_DATA_REAL_TYPE relative_tolerance;
INMOST_DATA_REAL_TYPE divergance_tolerance;
INMOST_DATA_REAL_TYPE preconditioner_drop_tolerance;
INMOST_DATA_REAL_TYPE preconditioner_reuse_tolerance;
INMOST_DATA_REAL_TYPE preconditioner_ddpq_tolerance;
INMOST_DATA_ENUM_TYPE preconditioner_reorder_nonzero;
INMOST_DATA_ENUM_TYPE preconditioner_fill_level;
INMOST_DATA_ENUM_TYPE preconditioner_rescale_iterations;
INMOST_DATA_ENUM_TYPE preconditioner_condition_estimation;
INMOST_DATA_ENUM_TYPE preconditioner_adapt_ddpq_tolerance;
INMOST_DATA_ENUM_TYPE solver_gmres_substeps;
std::string return_reason;
void * solver_data;
void * matrix_data;
......@@ -424,8 +462,65 @@ namespace INMOST
Solver & operator =(Solver const & other); //prohibit assignment
public:
/// Set the solver parameter of the integer type.
/// You can find defaults for parameters in the top of the file inmost_solver.h
/// Parameters:
/// "maximum_iterations" - total number of iterations
/// "schwartz_overlap" - number of overlapping levels for additive schwartz method
/// works for:
/// INNER_ILU2, INNER_MLILUC
/// Trilinos_Aztec, Trilinos_Belos, Trilinos_ML, Trilinos_Ifpack
/// PETSc
/// "gmres_substeps" - number of gmres steps performed after each bicgstab step
/// works for:
/// INNER_ILU2, INNER_MLILUC
/// "fill_level" - level of fill for ILU-type preconditioners
/// works for:
/// INNER_ILU2 (if LFILL is defined in solver_ilu2.hpp)
/// Trilinos_Ifpack
/// "reorder_nonzeros" - place sparser rows at the beggining of matrix during reordering
/// works for:
/// INNER_MLILUC
/// "rescale_iterations" - number of iterations for two-side matrix rescaling
/// works for:
/// INNER_ILU2, INNER_MLILUC
/// "condition_estimation" - exploit condition estimation of inversed factors to adapt
/// drop and reuse tolerances
/// works for:
/// INNER_MLILUC
/// "adapt_ddpq_tolerance" - adapt ddpq tolerance depending from the complexity
// of calculation of Schur complement
/// works for:
/// INNER_MLILUC
void SetParameterEnum(std::string name, INMOST_DATA_ENUM_TYPE value);
/// Set the solver parameter of the real type.
/// You can find defaults for parameters in the top of the file inmost_solver.h
/// Parameters:
/// "absolute_tolerance" - iterative method will stop on i-th iteration
/// if ||A x(i)-b|| < absolute_tolerance
/// "relative_tolerance" - iterative method will stop on i-th iteration
/// if ||A x(i)-b||/||A x(0) - b||
/// "divergence_tolerance" - iterative method will fail if
/// ||A x(i) - b|| > divergence_tolerance
/// "drop_tolerance" - tolerance for dropping values during incomplete factorization
/// works for:
/// INNER_ILU2, INNER_MLILUC
/// Trilinos_Aztec, Trilinos_ML, Trilinos_Ifpack
/// PETSc
/// "reuse_tolerance" - tolerance for reusing values during incomplete factorization
/// these values are used only during calculation of L and U factors
/// and/or Schur complement and discarded once factorization is done
/// value should be less then "drop_tolerance"
/// typical value is drop_tolerance^2
/// works for:
/// INNER_ILU2, INNER_MLILUC
/// "ddpq_tolerance" - by this tolerance most diagonnaly-dominant elements will be selected
/// to form the next level of factorization, the closer the tolerance
/// is to one the smaller will be the level. Actual rule is:
/// A(i,j)/(sum(A(i,:))+sum(A(:,j))-A(i,j)) > ddpq_tolerance *
/// A(imax,jmax)/(sum(A(imax,:))+sum(A(:,jmax))-A(imax,jmax))
/// where on imax, jmax maximum is reached.
/// works for:
/// INNER_MLILUC
void SetParameterReal(std::string name, INMOST_DATA_REAL_TYPE value);
/// Get the used defined name of the Solver.
std::string GetName() {return name;}
......
This diff is collapsed.
......@@ -85,8 +85,10 @@ public:
interval<INMOST_DATA_INTEGER_TYPE, INMOST_DATA_REAL_TYPE> RowValues(vbeg, vend);
#if defined(LFILL)
interval<INMOST_DATA_INTEGER_TYPE, INMOST_DATA_ENUM_TYPE> RowFill(vbeg, vend);
//std::fill(RowFill.begin(),RowFill.end(),ENUMUNDEF);
#endif
interval<INMOST_DATA_INTEGER_TYPE, INMOST_DATA_ENUM_TYPE> RowIndeces(vbeg - 1, vend);
ilu.set_interval_beg(mobeg);
ilu.set_interval_end(moend + 1);
iu.set_interval_beg(mobeg);
......
......@@ -316,5 +316,72 @@ double SolverResidualNormPetsc(void * data)
if( ierr != PETSC_SUCCESS ) throw INMOST::ErrorInSolver;
return norm;
}
const char * SolverConvergedReasonPetsc(void * data)
{
static char reason[4096];
KSPConvergedReason reason;
KSP * ksp = static_cast<KSP *>(data);
PetscErrorCode ierr = KSPGetConvergedReason(*ksp,&reason);
if( ierr != PETSC_SUCCESS ) throw INMOST::ErrorInSolver;
switch(reason)
{
case KSP_CONVERGED_RTOL:
case KSP_CONVERGED_RTOL_NORMAL:
strcpy(reason,"norm decreased by a factor of relative tolerance");
break;
case KSP_CONVERGED_ATOL:
case KSP_CONVERGED_ATOL_NORMAL:
strcpy(reason,"norm less then absolute tolerance");
break;
case KSP_CONVERGED_ITS:
strcpy(reason,"converged by direct solver");
break;
case KSP_CONVERGED_CG_NEG_CURVE:
case KSP_CONVERGED_CG_CONSTRAINED:
strcpy(reason,"converged due to some condition in conjugate gradient method");
break;
case KSP_CONVERGED_STEP_LENGTH:
strcpy(reason,"converged due to step length");
break;
case KSP_CONVERGED_HAPPY_BREAKDOWN :
strcpy(reason,"converged due to happy breakdown");
break;
case KSP_CONVERGED_ITERATING:
strcpy(reason,"converged");
break;
case KSP_DIVERGED_NULL:
strcpy(reason,"diverged due to null");
break;
case KSP_DIVERGED_ITS:
strcpy(reason,"diverged due to maximum iteration number");
break;
case KSP_DIVERGED_DTOL:
strcpy(reason,"diverged as divergence tolerance was reached");
break;
case KSP_DIVERGED_BREAKDOWN:
strcpy(reason,"diverged due to breakdown in method");
break;
case KSP_DIVERGED_BREAKDOWN_BICG:
strcpy(reason,"diverged due to breakdown in Biconjugate Gradients method");
break;
case KSP_DIVERGED_NONSYMMETRIC:
strcpy(reason,"diverged since matrix is nonsymmetric");
break;
case KSP_DIVERGED_INDEFINITE_PC:
strcpy(reason,"diverged since preconditioner is not defined");
break;
case KSP_DIVERGED_NANORINF:
strcpy(reason,"diverged since not a number or infinite was encountered");
break;
case KSP_DIVERGED_INDEFINITE_MAT:
strcpy(reason,"diverged due to matrix is not definite");
break;
default:
strcpy(reason,"reason code was not defined in manual");
break;
}
return reason;
}
#endif
#endif
......@@ -34,5 +34,6 @@ void SolverSetMatrixPetsc(void * data, void * matrix_data, bool same_pattern, bo
bool SolverSolvePetsc(void * data, void * rhs_data, void * sol_data);
int SolverIterationNumberPetsc(void * data);
double SolverResidualNormPetsc(void * data);
const char * SolverConvergedReasonPetsc(void * data);
#endif
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