diff --git a/AMDiS/cmake/enable_hypre.cmake b/AMDiS/cmake/enable_hypre.cmake index 7bd469630f3a086c6064673df301a5fc3264b404..7e03ef39b6102a78e3b27eaaf38dc7325337bc4f 100644 --- a/AMDiS/cmake/enable_hypre.cmake +++ b/AMDiS/cmake/enable_hypre.cmake @@ -17,7 +17,7 @@ macro(enable_hypre _FLAGS_ _INC_DIRS_ _LIBS_) HINTS ${PETSC_INCLUDE_DIRS}) if (_HYPRE_H) - get_filename_component(HYPRE_INCLUDE_DIRECTORIES ${HYPRE_H} PATH) + get_filename_component(HYPRE_INCLUDE_DIRECTORIES ${_HYPRE_H} PATH) list(APPEND ${_INC_DIRS_} ${HYPRE_INCLUDE_DIRECTORIES}) endif (_HYPRE_H) diff --git a/AMDiS/cmake3/amdis_seq_petsc.cmake b/AMDiS/cmake3/amdis_seq_petsc.cmake index d482098c65dd9ad6bcf7d3c3a858afaa2decf067..c0caa15acb54b48cf4cf5f0bd01d06b887886b0f 100644 --- a/AMDiS/cmake3/amdis_seq_petsc.cmake +++ b/AMDiS/cmake3/amdis_seq_petsc.cmake @@ -1,8 +1,8 @@ if (ENABLE_SEQ_PETSC) - target_enable_mpi(amdis PRIVATE) - target_enable_petsc(amdis PRIVATE) + target_enable_mpi(amdis PUBLIC) + target_enable_petsc(amdis PUBLIC) - target_compile_definitions(amdis PRIVATE HAVE_SEQ_PETSC=1) + target_compile_definitions(amdis PUBLIC HAVE_SEQ_PETSC=1) target_sources(amdis PRIVATE ${SOURCE_DIR}/solver/PetscSolver.cc diff --git a/AMDiS/cmake3/target_enable_hypre.cmake b/AMDiS/cmake3/target_enable_hypre.cmake index 725385fd5e0b90db17f69c7bd91a7a21da55077a..51e934178f0881458db377ae745525c2b0bcc4a2 100644 --- a/AMDiS/cmake3/target_enable_hypre.cmake +++ b/AMDiS/cmake3/target_enable_hypre.cmake @@ -17,7 +17,7 @@ macro(target_enable_hypre _TARGET_ _SCOPE_) HINTS ${PETSC_INCLUDE_DIRS}) if (_HYPRE_H) - get_filename_component(HYPRE_INCLUDE_DIRECTORIES ${HYPRE_H} PATH) + get_filename_component(HYPRE_INCLUDE_DIRECTORIES ${_HYPRE_H} PATH) target_include_directories(${_TARGET_} ${_SCOPE_} ${HYPRE_INCLUDE_DIRECTORIES}) endif (_HYPRE_H) diff --git a/AMDiS/src/ProblemStat.cc b/AMDiS/src/ProblemStat.cc index e208657b3049f10f251ec2659969c7318ea87513..904d0ac06e88415e23e90c7bd6b346ef52bfe187 100644 --- a/AMDiS/src/ProblemStat.cc +++ b/AMDiS/src/ProblemStat.cc @@ -566,14 +566,16 @@ namespace AMDiS { FUNCNAME("ProblemStat::createSolver()"); // definition of standard-backends -#if defined HAVE_PARALLEL_PETSC - string backend("p_petsc"); -#elif defined HAVE_PARALLEL_MTL - string backend("p_mtl"); -#elif defined HAVE_SEQ_PETSC - string backend("petsc"); +#ifdef HAVE_PARALLEL_DOMAIN_AMDIS + std::string backend = "p_"; +#else + std::string backend = ""; +#endif + +#if defined(HAVE_PARALLEL_PETSC) || defined(HAVE_SEQ_PETSC) + backend += "petsc"; #else - string backend("mtl"); + backend += "mtl"; #endif // === read backend-name === diff --git a/AMDiS/src/parallel/PetscHelper.h b/AMDiS/src/parallel/PetscHelper.h index 4ac633ff8a849efa4e12fe20b42c4de2d0d27fd5..d36da4ac6de0b2695e9ac9a04ec0d9beb2a49ab2 100644 --- a/AMDiS/src/parallel/PetscHelper.h +++ b/AMDiS/src/parallel/PetscHelper.h @@ -30,6 +30,7 @@ #include <vector> #include <petsc.h> #include "AMDiS_fwd.h" +#include "utility/PetscWrapper.h" namespace AMDiS { @@ -121,80 +122,4 @@ namespace AMDiS } // end namespace petsc_helper } // end namespace Parallel - - - // functions for PETSc API changes - namespace petsc - { - inline PetscErrorCode options_view(PetscViewer viewer) - { -#if (PETSC_VERSION_MINOR >= 7) - return PetscOptionsView(PETSC_NULL, viewer); -#else - return PetscOptionsView(viewer); -#endif - } - - inline PetscErrorCode options_insert_string(const char in_str[]) - { -#if (PETSC_VERSION_MINOR >= 7) - return PetscOptionsInsertString(PETSC_NULL, in_str); -#else - return PetscOptionsInsertString(in_str); -#endif - } - - inline PetscErrorCode ksp_set_operators(KSP ksp, Mat Amat,Mat Pmat) - { -#if (PETSC_VERSION_MINOR >= 5) - return KSPSetOperators(ksp, Amat, Pmat); -#else - return KSPSetOperators(ksp, Amat, Pmat, SAME_NONZERO_PATTERN); -#endif - } - - inline PetscErrorCode ksp_get_operators(KSP ksp, Mat *Amat,Mat *Pmat) - { -#if (PETSC_VERSION_MINOR >= 5) - return KSPGetOperators(ksp, Amat, Pmat); -#else - return KSPGetOperators(ksp, Amat, Pmat, SAME_NONZERO_PATTERN); -#endif - } - - template <class Monitor> - inline PetscErrorCode ksp_monitor_set(KSP ksp, Monitor monitor) - { -#if (PETSC_VERSION_MINOR >= 7) - PetscViewerAndFormat *vf; - PetscErrorCode ierr; - ierr = PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_DEFAULT,&vf);CHKERRQ(ierr); - ierr = KSPMonitorSet(ksp,(PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); - return ierr; -#else - return KSPMonitorSet(ksp, monitor, PETSC_NULL, PETSC_NULL); -#endif - } - - inline PetscErrorCode mat_create_vecs(Mat mat,Vec *right,Vec *left) - { -#if (PETSC_VERSION_MINOR >= 6) - return MatCreateVecs(mat, right, left); -#else - return MatGetVecs(mat, right, left); -#endif - } - - inline PetscErrorCode mat_nullspace_remove(MatNullSpace sp,Vec vec) - { -#if (PETSC_VERSION_MINOR >= 5) - return MatNullSpaceRemove(sp, vec); -#else - return MatNullSpaceRemove(sp, vec, PETSC_NULL); -#endif - } - - } // end namespace petsc } // end namespace AMDiS - -#endif diff --git a/AMDiS/src/solver/BlockPreconditioner.h b/AMDiS/src/solver/BlockPreconditioner.h index 3f11b42bcc4fa06b14f79ac096f5490bd645b250..a867310f1ff7628d84b640c7cbdc796af3e66ac1 100644 --- a/AMDiS/src/solver/BlockPreconditioner.h +++ b/AMDiS/src/solver/BlockPreconditioner.h @@ -91,14 +91,16 @@ namespace AMDiS { int max_iter = 100, double tol = 1.e-8) { // definition of standard-backends -#if defined HAVE_PARALLEL_PETSC - std::string backend("p_petsc"); -#elif defined HAVE_PARALLEL_MTL - std::string backend("p_mtl"); -#elif defined HAVE_PETSC - std::string backend("petsc"); +#ifdef HAVE_PARALLEL_DOMAIN_AMDIS + std::string backend = "p_"; #else - std::string backend("mtl"); + std::string backend = ""; +#endif + +#if defined(HAVE_PARALLEL_PETSC) || defined(HAVE_SEQ_PETSC) + backend += "petsc"; +#else + backend += "mtl"; #endif // === read backend-name === diff --git a/AMDiS/src/solver/KrylovPreconditioner.h b/AMDiS/src/solver/KrylovPreconditioner.h index 9ed2c60a3575cd52f744610e9ef5d8443ffdb99a..50d66731e5a11ffad0a6570e591d2b2fb9024e4a 100644 --- a/AMDiS/src/solver/KrylovPreconditioner.h +++ b/AMDiS/src/solver/KrylovPreconditioner.h @@ -70,15 +70,16 @@ namespace AMDiS { solver(NULL), runner(NULL) { +#ifdef HAVE_PARALLEL_DOMAIN_AMDIS + std::string backend = "p_"; +#else + std::string backend = ""; +#endif -#if defined HAVE_PARALLEL_PETSC - std::string backend("p_petsc"); -#elif defined HAVE_PARALLEL_MTL - std::string backend("p_mtl"); -#elif defined HAVE_PETSC || defined HAVE_SEQ_PETSC - std::string backend("petsc"); +#if defined(HAVE_PARALLEL_PETSC) || defined(HAVE_SEQ_PETSC) + backend += "petsc"; #else - std::string backend("mtl"); + backend += "mtl"; #endif // === read backend-name === diff --git a/AMDiS/src/solver/PetscSolver.h b/AMDiS/src/solver/PetscSolver.h index 2df75926b28902dc34e4f8461707a45aa0c6af35..1889a562a5cca10a930d778ebdac2c24d3645d47 100644 --- a/AMDiS/src/solver/PetscSolver.h +++ b/AMDiS/src/solver/PetscSolver.h @@ -29,6 +29,7 @@ #include "solver/LinearSolver.h" #include "solver/PetscTypes.h" #include "solver/MatrixStreams.h" +#include "utility/PetscWrapper.h" #include "Timer.h" #include <vector> #include <iostream> @@ -58,7 +59,7 @@ namespace AMDiS { virtual void init(PC pc, const SolverMatrix<Matrix<DOFMatrix*> >& A, const MatrixType& fullMatrix) { - petsc_options_insert_string(("-" + prefix + "pc_type " + name).c_str()); + petsc::options_insert_string(("-" + prefix + "pc_type " + name).c_str()); PCSetFromOptions(pc); } diff --git a/AMDiS/src/utility/PetscWrapper.h b/AMDiS/src/utility/PetscWrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..3955fbb282a9b786162d99e34199cbd96af9bcf5 --- /dev/null +++ b/AMDiS/src/utility/PetscWrapper.h @@ -0,0 +1,108 @@ +/****************************************************************************** + * + * AMDiS - Adaptive multidimensional simulations + * + * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved. + * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis + * + * Authors: + * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * + * This file is part of AMDiS + * + * See also license.opensource.txt in the distribution. + * + ******************************************************************************/ + + + +/** \file PetscWrapper.h */ + +#ifndef AMDIS_PETSCWRAPPER_H +#define AMDIS_PETSCWRAPPER_H + +#include <mpi.h> +#include <petsc.h> + +namespace AMDiS +{ + + // functions for PETSc API changes + namespace petsc + { + inline PetscErrorCode options_view(PetscViewer viewer) + { +#if (PETSC_VERSION_MINOR >= 7) + return PetscOptionsView(PETSC_NULL, viewer); +#else + return PetscOptionsView(viewer); +#endif + } + + inline PetscErrorCode options_insert_string(const char in_str[]) + { +#if (PETSC_VERSION_MINOR >= 7) + return PetscOptionsInsertString(PETSC_NULL, in_str); +#else + return PetscOptionsInsertString(in_str); +#endif + } + + inline PetscErrorCode ksp_set_operators(KSP ksp, Mat Amat,Mat Pmat) + { +#if (PETSC_VERSION_MINOR >= 5) + return KSPSetOperators(ksp, Amat, Pmat); +#else + return KSPSetOperators(ksp, Amat, Pmat, SAME_NONZERO_PATTERN); +#endif + } + + inline PetscErrorCode ksp_get_operators(KSP ksp, Mat *Amat,Mat *Pmat) + { +#if (PETSC_VERSION_MINOR >= 5) + return KSPGetOperators(ksp, Amat, Pmat); +#else + return KSPGetOperators(ksp, Amat, Pmat, SAME_NONZERO_PATTERN); +#endif + } + + template <class Monitor> + inline PetscErrorCode ksp_monitor_set(KSP ksp, Monitor monitor) + { +#if (PETSC_VERSION_MINOR >= 7) + PetscViewerAndFormat *vf; + PetscErrorCode ierr; + ierr = PetscViewerAndFormatCreate(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_DEFAULT,&vf);CHKERRQ(ierr); + ierr = KSPMonitorSet(ksp,(PetscErrorCode (*)(KSP,PetscInt,PetscReal,void*))monitor,vf,(PetscErrorCode (*)(void**))PetscViewerAndFormatDestroy);CHKERRQ(ierr); + return ierr; +#else + return KSPMonitorSet(ksp, monitor, PETSC_NULL, PETSC_NULL); +#endif + } + + inline PetscErrorCode mat_create_vecs(Mat mat,Vec *right,Vec *left) + { +#if (PETSC_VERSION_MINOR >= 6) + return MatCreateVecs(mat, right, left); +#else + return MatGetVecs(mat, right, left); +#endif + } + + inline PetscErrorCode mat_nullspace_remove(MatNullSpace sp,Vec vec) + { +#if (PETSC_VERSION_MINOR >= 5) + return MatNullSpaceRemove(sp, vec); +#else + return MatNullSpaceRemove(sp, vec, PETSC_NULL); +#endif + } + + } // end namespace petsc +} // end namespace AMDiS + +#endif diff --git a/extensions/demo/pfc/CMakeLists.txt b/extensions/demo/pfc/CMakeLists.txt index 7420732889ca5ef567576f582c26115fceacfd31..ad1f024fd695d7c8113612c6e3f666dab46e66b7 100644 --- a/extensions/demo/pfc/CMakeLists.txt +++ b/extensions/demo/pfc/CMakeLists.txt @@ -2,21 +2,18 @@ project("extensions_demo_pfc") cmake_minimum_required(VERSION 2.8) find_package(AMDIS REQUIRED) +include(${AMDIS_USE_FILE}) -if(AMDIS_FOUND) - message("amdis was found\n") - include(${AMDIS_USE_FILE}) - SET(BASIS_LIBS ${AMDIS_LIBRARIES}) -endif(AMDIS_FOUND) +add_definitions(-DUSE_MTL=1) set(pfc src/pfc.cc) add_executable("pfc" ${pfc}) -target_link_libraries("pfc" ${BASIS_LIBS}) +target_link_libraries("pfc" ${AMDIS_LIBRARIES}) set(pfc_rb src/pfc_rb.cc) add_executable("pfc_rb" ${pfc_rb}) -target_link_libraries("pfc_rb" ${BASIS_LIBS}) +target_link_libraries("pfc_rb" ${AMDIS_LIBRARIES}) set(vpfc src/vpfc.cc) add_executable("vpfc" ${vpfc}) -target_link_libraries("vpfc" ${BASIS_LIBS}) +target_link_libraries("vpfc" ${AMDIS_LIBRARIES}) diff --git a/extensions/demo/pfc/init/pfc.dat.2d b/extensions/demo/pfc/init/pfc.dat.2d index 02107d975f1ea711156ac1a965e4873066f9b1b5..5e6c2b9d8a8e51e5a0e0b69563a018c54d2dbfff 100644 --- a/extensions/demo/pfc/init/pfc.dat.2d +++ b/extensions/demo/pfc/init/pfc.dat.2d @@ -28,16 +28,8 @@ pfc->space->dim: 2 % ================== SOLVER ====================================== -%#include "init/pfc_solver.inc" -pfc->space->solver: cg -pfc->space->MG->number of levels: 10 -pfc->space->MG->max iteration: 100 -pfc->space->MG->tolerance: 1.e-8 -pfc->space->MG->nu1: 20 -pfc->space->MG->nu2: 20 -pfc->space->MG->gamma: 1 -pfc->space->MG->mu: 3 -pfc->space->MG->fine level: 12 +pfc->space->solver->backend: bpetsc +#include "init/pfc_solver.mtl.inc" % ==================== TIMESTEPS =============================== adapt->timestep: 1.e-1 diff --git a/extensions/demo/pfc/init/pfc_rb.mtl.dat.2d b/extensions/demo/pfc/init/pfc_rb.mtl.dat.2d index 4085cd815077a49d3215e6571245b014349f6e80..b55365566e0788fc2fd5bc7e05e417601f04f41c 100644 --- a/extensions/demo/pfc/init/pfc_rb.mtl.dat.2d +++ b/extensions/demo/pfc/init/pfc_rb.mtl.dat.2d @@ -29,6 +29,7 @@ pfc->space->dim: 2 % ================== SOLVER ====================================== +pfc->space->solver->backend: mtl #include "init/pfc_solver.mtl.inc" diff --git a/extensions/demo/pfc/init/pfc_solver.inc b/extensions/demo/pfc/init/pfc_solver.inc index 598213e2a0765853fb07bc1227cc25cbdcaa0d1f..b614d5b0aa78ace0da4259c13090b672d096b96b 100644 --- a/extensions/demo/pfc/init/pfc_solver.inc +++ b/extensions/demo/pfc/init/pfc_solver.inc @@ -1,4 +1,4 @@ -%pfc->space->solver->backend: p_petsc +pfc->space->solver->backend: petsc pfc->space->solver->petsc prefix: pfc_ pfc->space->solver: pfc pfc->space->solver->ksp_type: fgmres @@ -26,4 +26,4 @@ precon_pfc_MpL2->max iteration: 1000 precon_pfc_MpL2->relative tolerance: 1.e-3 precon_pfc_MpL2->use direct solver: 0 precon_pfc_MpL2->solver: cg -precon_pfc_MpL2->use AMG: 0 \ No newline at end of file +precon_pfc_MpL2->use AMG: 0 diff --git a/extensions/demo/pfc/src/pfc.cc b/extensions/demo/pfc/src/pfc.cc index 30c7f52a77dbef3c24e951984c95a42340461220..11862d7c439717785424eddefb6f2659b8c52b69 100644 --- a/extensions/demo/pfc/src/pfc.cc +++ b/extensions/demo/pfc/src/pfc.cc @@ -2,13 +2,11 @@ #include "Helpers.h" #include "PhaseFieldCrystal.h" -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) +#if defined(USE_SEQ_PETSC) #include "preconditioner/PetscPreconPfc.h" -#endif -#ifdef HAVE_PARALLEL_DOMAIN_AMDIS +#elif defined(USE_PARALLEL_PETSC) #include "preconditioner/PetscSolverPfc.h" -#endif -#if (!defined HAVE_SEQ_PETSC) && (!defined HAVE_PETSC) && (!defined HAVE_PARALLEL_DOMAIN_AMDIS) +#elif defined(USE_MTL) #include "preconditioner/MTLPreconPfc.h" #endif @@ -30,33 +28,24 @@ public: { super::finalizeData(); -#ifdef USE_PRECON - +#if defined(USE_SEQ_PETSC) // sequential PFC preconditioner -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) PetscPreconPfc* precon = dynamic_cast<PetscPreconPfc*>(prob->getSolver()->getRightPrecon()); if (precon) { precon->setData(getTau(), M0); } -// PetscPreconPfcDiag* precon2 = dynamic_cast<PetscPreconPfcDiag*>(prob->getSolver()->getRightPrecon()); -// if (precon2) { -// precon2->setData(getTau(), M0); - } -#elif !defined(HAVE_PARALLEL_DOMAIN_AMDIS) - MTLPreconPfc* precon = dynamic_cast<MTLPreconPfc*>(prob->getSolver()->getRightPrecon()); - if (precon) - precon->setData(getTau(), M0); -#else +#elif defined(USE_PARALLEL_PETSC) // parallel PFC preconditioner Parallel::PetscSolverPfc* solver = dynamic_cast<Parallel::PetscSolverPfc*>(prob->getSolver()); - if (solver) + if (solver) { solver->setData(getTau(), M0); - -// Parallel::PetscSolverPfcDiag* solver2 = dynamic_cast<Parallel::PetscSolverPfcDiag*>(prob->getSolver()); -// if (solver2) -// solver2->setData(getTau(), M0); -#endif - + } +#elif defined(USE_MTL) + // mtl4 preconditioner + MTLPreconPfc* precon = dynamic_cast<MTLPreconPfc*>(prob->getSolver()->getRightPrecon()); + if (precon) { + precon->setData(getTau(), M0); + } #endif } @@ -82,20 +71,13 @@ int main(int argc, char** argv) AMDiS::init(argc, argv); Timer t; -#ifdef USE_PRECON - // add preconditioner / solver to the parameter list. Must be added before problem is initialized. -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) +#if defined(USE_SEQ_PETSC) CreatorMap<PetscPreconditionerNested>::addCreator("pfc", new PetscPreconPfc::Creator); -// CreatorMap<PetscPreconditionerNested>::addCreator("pfc_diag", new PetscPreconPfcDiag::Creator); -#elif !defined(HAVE_PARALLEL_DOMAIN_AMDIS) - CreatorMap<typename MTLPreconPfc::precon_base>::addCreator("pfc", new MTLPreconPfc::Creator); -// CreatorMap<typename MTLPreconPfc_Diag::base_precon>::addCreator("pfc", new MTLPreconPfc::Creator); -#else +#elif defined(USE_PARALLEL_PETSC) CreatorMap<LinearSolverInterface>::addCreator("p_petsc_pfc", new Parallel::PetscSolverPfc::Creator); -// CreatorMap<LinearSolverInterface>::addCreator("p_petsc_pfc_diag", new Parallel::PetscSolverPfcDiag::Creator); -#endif - +#elif defined(USE_MTL) + CreatorMap<typename MTLPreconPfc::precon_base>::addCreator("pfc", new MTLPreconPfc::Creator); #endif // create and initialize the PFC BaseProblem diff --git a/extensions/demo/pfc/src/pfc_rb.cc b/extensions/demo/pfc/src/pfc_rb.cc index 2db0f0b8c3bd2c1f960ca8d01230f181ac1677f8..789e590b3d49467d6c13f50680a1351e55005b4c 100644 --- a/extensions/demo/pfc/src/pfc_rb.cc +++ b/extensions/demo/pfc/src/pfc_rb.cc @@ -2,13 +2,11 @@ #include "Helpers.h" #include "PhaseFieldCrystal.h" -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) +#if defined(USE_SEQ_PETSC) #include "preconditioner/PetscPreconPfc.h" -#endif -#ifdef HAVE_PARALLEL_DOMAIN_AMDIS +#elif defined(USE_PARALLEL_PETSC) #include "preconditioner/PetscSolverPfc.h" -#endif -#if (!defined HAVE_SEQ_PETSC) && (!defined HAVE_PETSC) && (!defined HAVE_PARALLEL_DOMAIN_AMDIS) +#elif defined(USE_MTL) #include "preconditioner/MTLPreconPfc.h" #endif @@ -49,24 +47,19 @@ public: { super::initData(); +#if defined(USE_SEQ_PETSC) // sequential PFC preconditioner -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) PetscPreconPfc* runner = dynamic_cast<PetscPreconPfc*>(prob->getSolver()->getRunner()); if (runner) { - dynamic_cast<PetscSolver<PetscPreconPfc>*>(prob->getSolver())->setNested(true); runner->setData(getTau()); } -#endif - +#elif defined(USE_PARALLEL_PETSC) // parallel PFC preconditioner -#ifdef HAVE_PARALLEL_DOMAIN_AMDIS Parallel::PetscSolverPfc* solver = dynamic_cast<Parallel::PetscSolverPfc*>(prob->getSolver()); if (solver) solver->setData(getTau()); -#endif - +#elif defined(USE_MTL) // sequential PFC preconditioner using MTL -#if (!defined HAVE_SEQ_PETSC) && (!defined HAVE_PETSC) && (!defined HAVE_PARALLEL_DOMAIN_AMDIS) using AMDiS::extensions::MTLPreconPfc; MTLPreconPfc* precon = dynamic_cast<MTLPreconPfc*>(prob->getSolver()->getRightPrecon()); if (precon) @@ -197,15 +190,11 @@ int main(int argc, char** argv) Timer t; // add preconditioner / solver to the parameter list. Must be added before problem is initialized. -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) - CreatorMap<LinearSolverInterface>::addCreator("petsc_pfc", new PetscSolver<PetscPreconPfc>::Creator); -#endif - -#ifdef HAVE_PARALLEL_DOMAIN_AMDIS +#if defined(USE_SEQ_PETSC) + CreatorMap<PetscPreconditionerNested>::addCreator("petsc_pfc", new PetscPreconPfc::Creator); +#elif defined(USE_PARALLEL_PETSC) CreatorMap<LinearSolverInterface>::addCreator("p_petsc_pfc", new Parallel::PetscSolverPfc::Creator); -#endif - -#if (!defined HAVE_SEQ_PETSC) && (!defined HAVE_PETSC) && (!defined HAVE_PARALLEL_DOMAIN_AMDIS) +#elif defined(USE_MTL) using AMDiS::extensions::MTLPreconPfc; CreatorMap<typename MTLPreconPfc::precon_base>::addCreator("pfc", new MTLPreconPfc::Creator); #endif @@ -216,7 +205,7 @@ int main(int argc, char** argv) // Adapt-Infos AdaptInfo adaptInfo("adapt", pfcProb.getNumComponents()); - RosenbrockAdaptInstationary adaptInstat("adapt", pfcProb.getProblem(), &adaptInfo, &pfcProb, &adaptInfo); + RosenbrockAdaptInstationary adaptInstat("adapt", pfcProb.getProblem(), pfcProb.getProblem(), &adaptInfo, &pfcProb, &adaptInfo); pfcProb.initTimeInterface(); // fill operators and BC // Scale Mesh diff --git a/extensions/demo/pfc/src/vpfc.cc b/extensions/demo/pfc/src/vpfc.cc index d39e92fba4569bd5607ff81e981cd470c4ec4118..bb6ea567d3af7740f744476b9f1897e5c9e3fcbb 100644 --- a/extensions/demo/pfc/src/vpfc.cc +++ b/extensions/demo/pfc/src/vpfc.cc @@ -2,12 +2,12 @@ #include "Helpers.h" #include "base_problems/PhaseFieldCrystal.h" -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) +#if defined(USE_SEQ_PETSC) #include "preconditioner/PetscPreconPfc.h" -#elif !defined(HAVE_PARALLEL_DOMAIN_AMDIS) -#include "preconditioner/MTLPreconPfc.h" -#else +#elif defined(USE_PARALLEL_PETSC) #include "preconditioner/PetscSolverPfc.h" +#elif defined(USE_MTL) +#include "preconditioner/MTLPreconPfc.h" #endif // #include "OneModeApproximation.h" @@ -95,18 +95,18 @@ public: { super::finalizeData(); -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) +#if defined(USE_SEQ_PETSC) PetscPreconPfc* precon = dynamic_cast<PetscPreconPfc*>(prob->getSolver()->getRightPrecon()); if (precon) precon->setData(getTau(), M0); -#elif !defined(HAVE_PARALLEL_DOMAIN_AMDIS) - MTLPreconPfc* precon = dynamic_cast<MTLPreconPfc*>(prob->getSolver()->getRightPrecon()); - if (precon) - precon->setData(getTau(), M0); -#else +#elif defined(USE_PARALLEL_PETSC) Parallel::PetscSolverPfc* solver = dynamic_cast<Parallel::PetscSolverPfc*>(prob->getSolver()); if (solver) solver->setData(getTau(), M0); +#elif defined(USE_MTL) + MTLPreconPfc* precon = dynamic_cast<MTLPreconPfc*>(prob->getSolver()->getRightPrecon()); + if (precon) + precon->setData(getTau(), M0); #endif } @@ -233,12 +233,12 @@ int main(int argc, char** argv) AMDiS::init(argc, argv); -#if (defined HAVE_SEQ_PETSC) || (defined HAVE_PETSC) +#if defined(USE_SEQ_PETSC) CreatorMap<PetscPreconditionerNested>::addCreator("pfc", new PetscPreconPfc::Creator); -#elif !defined(HAVE_PARALLEL_DOMAIN_AMDIS) - CreatorMap<typename MTLPreconPfc::precon_base>::addCreator("pfc", new MTLPreconPfc::Creator); -#else +#elif defined(USE_PARALLEL_PETSC) CreatorMap<LinearSolverInterface>::addCreator("p_petsc_pfc", new Parallel::PetscSolverPfc::Creator); +#elif defined(USE_MTL) + CreatorMap<typename MTLPreconPfc::precon_base>::addCreator("pfc", new MTLPreconPfc::Creator); #endif Timer t;