Skip to content
Snippets Groups Projects
Commit 710cf434 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

support petsc 3.6

parent 7cae26a2
No related branches found
No related tags found
No related merge requests found
......@@ -938,22 +938,19 @@ if(HAVE_SOLVER)
else(PETSC_ARCH)
set(ENV_PETSC_ARCH $ENV{PETSC_ARCH})
endif(PETSC_ARCH)
if(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables)
set(PETSC_POSSIBLE_CONF_FILES
${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables
${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables
${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc/conf/petscvariables)
foreach(FILE ${PETSC_POSSIBLE_CONF_FILES})
if(EXISTS ${FILE})
# old-style PETSc installations (using PETSC_DIR and PETSC_ARCH)
message(STATUS "Using PETSc dir: ${ENV_PETSC_DIR}")
message(STATUS "Using PETSc arch: ${ENV_PETSC_ARCH}")
# find includes by parsing the petscvariables file
file(STRINGS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables
PETSC_VARIABLES NEWLINE_CONSUME)
endif(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/conf/petscvariables)
if(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables)
# old-style PETSc installations (using PETSC_DIR and PETSC_ARCH)
message(STATUS "Using PETSc dir: ${ENV_PETSC_DIR}")
message(STATUS "Using PETSc arch: ${ENV_PETSC_ARCH}")
# find includes by parsing the petscvariables file
file(STRINGS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables
PETSC_VARIABLES NEWLINE_CONSUME)
endif(EXISTS ${ENV_PETSC_DIR}/${ENV_PETSC_ARCH}/lib/petsc-conf/petscvariables)
file(STRINGS ${FILE} PETSC_VARIABLES NEWLINE_CONSUME)
endif(EXISTS ${FILE})
endforeach(FILE)
if(PETSC_VARIABLES)
# try to find PETSC_CC_INCLUDES for PETSc >= 3.4
string(REGEX MATCH "PETSC_CC_INCLUDES = [^\n\r]*" PETSC_PACKAGES_INCLUDES
......
......@@ -18,7 +18,8 @@ void eigenSolver::_try(int ierr) const
CHKERRABORT(PETSC_COMM_WORLD, ierr);
}
eigenSolver::eigenSolver(dofManager<double> *manager, std::string A, std::string B, bool hermitian)
eigenSolver::eigenSolver(dofManager<double> *manager, std::string A, std::string B,
bool hermitian)
: _A(0), _B(0), _hermitian(hermitian)
{
if (A.size()) {
......@@ -34,7 +35,8 @@ eigenSolver::eigenSolver(dofManager<double> *manager, std::string A, std::string
eigenSolver::eigenSolver(linearSystemPETSc<double> *A, linearSystemPETSc<double> *B,
bool hermitian) : _A(A), _B(B), _hermitian(hermitian) {}
bool eigenSolver::solve(int numEigenValues, std::string which, std::string method, double tolVal, int iterMax)
bool eigenSolver::solve(int numEigenValues, std::string which, std::string method,
double tolVal, int iterMax)
{
if(!_A) return false;
Mat A = _A->getMatrix();
......@@ -138,15 +140,24 @@ bool eigenSolver::solve(int numEigenValues, std::string which, std::string metho
if (nconv>0) {
Vec xr, xi;
#if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR < 6)
_try(MatGetVecs(A, PETSC_NULL, &xr));
_try(MatGetVecs(A, PETSC_NULL, &xi));
#else
_try(MatCreateVecs(A, PETSC_NULL, &xr));
_try(MatCreateVecs(A, PETSC_NULL, &xi));
#endif
Msg::Debug(" Re[EigenValue] Im[EigenValue]"
" Relative error");
for (int i=0; i<nconv; i++) {
PetscScalar kr, ki;
_try(EPSGetEigenpair(eps, i, &kr, &ki, xr, xi));
PetscReal error;
#if (PETSC_VERSION_MAJOR == 3) && (PETSC_VERSION_MINOR < 6)
_try(EPSComputeRelativeError(eps, i, &error));
#else
_try(EPSComputeError(eps, i, EPS_ERROR_RELATIVE, &error));
#endif
#if defined(PETSC_USE_COMPLEX)
PetscReal re = PetscRealPart(kr);
PetscReal im = PetscImaginaryPart(kr);
......@@ -189,7 +200,8 @@ bool eigenSolver::solve(int numEigenValues, std::string which, std::string metho
}
void eigenSolver::normalize_mode(std::vector<int> modeView, double scale) {
void eigenSolver::normalize_mode(std::vector<int> modeView, double scale)
{
Msg::Info("Normalize all eigenvectors");
for (unsigned int imode=0; imode<modeView.size(); imode++) {
int i = modeView[imode];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment