changed: do not build dummy petsc code if petsc is not enabled

This commit is contained in:
Arne Morten Kvarving authored and Knut Morten Okstad committed 2016-09-02 09:30:53 +02:00
1 parent fbb6185d82
commit f7694c942f
15 files changed
+79 -70

No files matched your search

+11
View File
@@ -99,6 +99,17 @@ file(GLOB IFEM_SRCS ${PROJECT_SOURCE_DIR}/src/IFEM.C
${PROJECT_SOURCE_DIR}/src/Eig/*.f
${PROJECT_SOURCE_DIR}/3rdparty/expreval/*.cpp)
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/ASM/ASMs.DInterpolate.C" "" IFEM_SRCS "${IFEM_SRCS}")
if(NOT PETSC_FOUND)
list(REMOVE_ITEM IFEM_SRCS
${PROJECT_SOURCE_DIR}/src/ASM/SAMpatchPara.C
${PROJECT_SOURCE_DIR}/src/LinAlg/PETScBlockMatrix.C
${PROJECT_SOURCE_DIR}/src/LinAlg/PETScMatrix.C
${PROJECT_SOURCE_DIR}/src/LinAlg/PETScPCPerm.C
${PROJECT_SOURCE_DIR}/src/LinAlg/PETScPCProd.C
${PROJECT_SOURCE_DIR}/src/LinAlg/PETScPCScale.C)
endif()
if(LRSPLINE_FOUND OR LRSpline_FOUND)
file(GLOB LR_SRCS ${PROJECT_SOURCE_DIR}/src/ASM/LR/*.C)
list(APPEND IFEM_SRCS ${LR_SRCS})
+6 -1
View File
@@ -50,7 +50,12 @@ macro(IFEM_add_test_app path workdir name)
endmacro()
macro(IFEM_add_unittests IFEM_PATH)
IFEM_add_test_app("${IFEM_PATH}/src/Utility/Test/*.C;${IFEM_PATH}/src/ASM/Test/*.C;${IFEM_PATH}/src/LinAlg/Test/*.C;${IFEM_PATH}/src/SIM/Test/*.C"
file(GLOB TEST_SOURCES ${IFEM_PATH}/src/Utility/Test/*.C;${IFEM_PATH}/src/ASM/Test/*.C;${IFEM_PATH}/src/LinAlg/Test/*.C;${IFEM_PATH}/src/SIM/Test/*.C)
if(NOT PETSC_FOUND)
list(REMOVE_ITEM TEST_SOURCES ${IFEM_PATH}/src/LinAlg/Test/TestPETScMatrix.C)
endif()
IFEM_add_test_app("${TEST_SOURCES}"
${IFEM_PATH}
IFEM
${IFEM_LIBRARIES} ${IFEM_DEPLIBS})
+2
View File
@@ -14,7 +14,9 @@
#include "EigSolver.h"
#include "DenseMatrix.h"
#include "SPRMatrix.h"
#ifdef HAS_SLEPC
#include "PETScMatrix.h"
#endif
#if defined(_WIN32) && !defined(__MINGW32__) && !defined(__MINGW64__)
#define eig_av_ EIG_AV
+3 -1
View File
@@ -12,7 +12,9 @@
//==============================================================================
#include "LinSolParams.h"
#include "PCPerm.h"
#ifdef HAS_PETSC
#include "PETScPCPerm.h"
#endif
#include "Utilities.h"
#include "tinyxml.h"
#include <fstream>
+2 -2
View File
@@ -18,8 +18,8 @@
#include "LinAlgInit.h"
#include "SAMpatchPara.h"
#include "SIMenums.h"
#include "PCPerm.h"
#include "PCScale.h"
#include "PETScPCPerm.h"
#include "PETScPCScale.h"
#include <sstream>
#ifdef USE_OPENMP
#include <omp.h>
+1 -1
View File
@@ -17,7 +17,7 @@
#include "PETScMatrix.h"
#ifdef HAS_PETSC
#include "PCProd.h"
#include "PETScPCProd.h"
#endif
typedef std::vector<int> IntVec; //!< 3D PETSc integer matrix
-3
View File
@@ -12,7 +12,6 @@
//==============================================================================
#include "PETScMatrix.h"
#ifdef HAS_PETSC
#include "LinSolParams.h"
#include "LinAlgInit.h"
#include "SAMpatchPara.h"
@@ -751,5 +750,3 @@ PETScVector operator/(SystemMatrix& A, const PETScVector& b)
A.solve(b, results);
return results;
}
#endif // HAS_PETSC
-33
View File
@@ -37,7 +37,6 @@ typedef std::vector<ISVec> ISMat; //!< Index set matrix
class PETScVector : public SystemVector
{
public:
#ifdef HAS_PETSC
//! \brief Constructor creating an empty vector.
PETScVector(const ProcessAdm& padm);
//! \brief Constructor creating a vector of length \a n.
@@ -48,12 +47,10 @@ public:
PETScVector(const PETScVector& vec);
//! \brief Destructor.
virtual ~PETScVector();
#endif
//! \brief Returns the vector type.
virtual Type getType() const { return PETSC; }
#ifdef HAS_PETSC
//! \brief Returns the dimension of the system vector.
virtual size_t dim() const;
@@ -109,19 +106,6 @@ public:
protected:
Vec x; //!< The actual PETSc vector
const ProcessAdm& adm; //!< Process administrator
#else // dummy implementation when PETSc is not included
virtual SystemVector* copy() const { return 0; }
virtual size_t dim() const { return 0; }
virtual void redim(size_t) {}
virtual Real* getPtr() { return 0; }
virtual const Real* getRef() const { return 0; }
virtual void init(Real = Real(0)) {}
virtual void mult(Real) {}
virtual Real L1norm() const { return Real(0); }
virtual Real L2norm() const { return Real(0); }
virtual Real Linfnorm() const { return Real(0); }
#endif
};
@@ -134,7 +118,6 @@ protected:
class PETScMatrix : public SystemMatrix
{
public:
#ifdef HAS_PETSC
//! \brief Constructor.
PETScMatrix(const ProcessAdm& padm, const LinSolParams& spar,
LinAlg::LinearSystemType ltype);
@@ -142,10 +125,6 @@ public:
PETScMatrix(const PETScMatrix& A);
//! \brief The destructor frees the dynamically allocated arrays.
virtual ~PETScMatrix();
#else
//! \brief Constructor.
PETScMatrix(const ProcessAdm&, const LinSolParams&) {}
#endif
//! \brief Returns the matrix type.
virtual Type getType() const { return PETSC; }
@@ -153,7 +132,6 @@ public:
//! \brief Returns the dimension of the system matrix.
virtual size_t dim(int = 1) const { return 0; }
#ifdef HAS_PETSC
//! \brief Creates a copy of the system matrix and returns a pointer to it.
virtual SystemMatrix* copy() const { return new PETScMatrix(*this); }
@@ -261,24 +239,13 @@ protected:
ISMat dirIndexSet; //!< Direction ordering
int nLinSolves; //!< Number of linear solves
LinAlg::LinearSystemType linsysType; //!< Linear system type
#else // dummy implementation when PETSc is not included
virtual SystemMatrix* copy() const { return 0; }
virtual void init() {}
virtual void initAssembly(const SAM&, bool) {}
virtual bool assemble(const Matrix&, const SAM&, int) { return false; }
virtual bool assemble(const Matrix&, const SAM&,
SystemVector&, int) { return false; }
#endif
};
#ifdef HAS_PETSC
//! \brief Matrix-vector product
PETScVector operator*(const SystemMatrix& A, const PETScVector& b);
//! \brief Solve linear system
PETScVector operator/(const SystemMatrix& A, const PETScVector& b);
#endif
#endif
@@ -1,7 +1,21 @@
#ifdef HAS_PETSC
#include "PCPerm.h"
// $Id$
//==============================================================================
//!
//! \file PETScPCPerm.C
//!
//! \date Jan 15 2010
//!
//! \author Runar Holdahl / SINTEF
//!
//! \brief Permutation for PETSc preconditioners
//!
//==============================================================================
#include "PETScPCPerm.h"
#include <iostream>
PetscErrorCode PCPermCreate(PCPerm **pcperm)
{
PCPerm *newctx;
@@ -52,13 +66,13 @@ PetscErrorCode PCPermApply(PC pc, Vec x, Vec y)
{
PCPerm *shell;
PCShellGetContext(pc,(void**)&shell);
PCShellGetContext(pc,(void**)&shell);
if (!shell->identity)
VecPermute(x,*(shell->order),PETSC_FALSE);
PCApply(shell->pc,x,y);
if (!shell->identity)
VecPermute(y,*(shell->order),PETSC_TRUE);
return 0;
}
@@ -76,5 +90,3 @@ PetscErrorCode PCPermDestroy(PC pc)
return 0;
}
#endif
@@ -1,6 +1,5 @@
#ifndef PCPERM_H_IS_INCLUDED
#define PCPERM_H_IS_INCLUDED
#ifdef HAS_PETSC
#include "petscksp.h"
@@ -20,4 +19,3 @@ extern PetscErrorCode PCPermApply(PC pc, Vec x, Vec y);
extern PetscErrorCode PCPermDestroy(PC pc);
#endif
#endif
@@ -1,7 +1,21 @@
#ifdef HAS_PETSC
#include "PCProd.h"
// $Id$
//==============================================================================
//!
//! \file PCProd.C
//!
//! \date Jan 15 2010
//!
//! \author Runar Holdahl / SINTEF
//!
//! \brief Tensor-product of PETSc preconditioners
//!
//==============================================================================
#include "PETScPCProd.h"
#include <iostream>
PetscErrorCode PCProdCreate(PCProd **pcprod)
{
PCProd *newctx;
@@ -47,7 +61,7 @@ PetscErrorCode PCProdApply(PC pc, Vec x, Vec y)
VecGetArray(x,&xvec);
VecGetArray(y,&yvec);
VecGetLocalSize(*(shell->pc1),&n);
for (int i = 0;i < n;i++)
yvec[i] = xvec[i]*svec[i];
@@ -61,7 +75,7 @@ PetscErrorCode PCProdApply(PC pc, Vec x, Vec y)
PCApply(*(shell->pc2),x,y);
VecCopy(y,x);
}
if (shell->pc3)
if (shell->pc3)
PCApply(*(shell->pc3),x,y);
return 0;
@@ -78,10 +92,8 @@ PetscErrorCode PCProdDestroy(PC pc)
if (shell->pc2)
PCDestroy(shell->pc2);
if (shell->pc3)
PCDestroy(shell->pc3);
PCDestroy(shell->pc3);
PetscFree(shell);
return 0;
}
#endif
@@ -3,8 +3,6 @@
#include "petscksp.h"
#ifdef HAS_PETSC
/* Define context for user-defined preconditioner */
typedef struct {
Vec *pc1;
@@ -19,5 +17,3 @@ extern PetscErrorCode PCProdApply(PC pc, Vec x, Vec y);
extern PetscErrorCode PCProdDestroy(PC pc);
#endif
#endif
@@ -1,7 +1,21 @@
#ifdef HAS_PETSC
#include "PCScale.h"
// $Id$
//==============================================================================
//!
//! \file PCScale.C
//!
//! \date Jan 15 2010
//!
//! \author Runar Holdahl / SINTEF
//!
//! \brief Scaling for PETSc preconditioners
//!
//==============================================================================
#include "PETScPCScale.h"
#include <iostream>
PetscErrorCode PCScaleCreate(PCScale **pcscale)
{
PCScale *newctx;
@@ -49,7 +63,7 @@ PetscErrorCode PCScaleApply(PC pc, Vec x, Vec y)
VecRestoreArray(*(shell->scaling),&svec);
VecRestoreArray(x,&xvec);
VecRestoreArray(y,&yvec);
return 0;
}
@@ -64,5 +78,3 @@ PetscErrorCode PCScaleDestroy(PC pc)
return 0;
}
#endif
@@ -3,8 +3,6 @@
#include "petscksp.h"
#ifdef HAS_PETSC
/* Define context for user-defined preconditioner */
typedef struct {
Vec *scaling;
@@ -17,5 +15,3 @@ extern PetscErrorCode PCScaleApply(PC pc, Vec x, Vec y);
extern PetscErrorCode PCScaleDestroy(PC pc);
#endif
#endif
-1
View File
@@ -143,4 +143,3 @@ StdVector SystemMatrix::operator/(const StdVector& b)
solve(b, results);
return results;
}