// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. /** \file PetscSolverGlobalMatrix.h */ #ifndef AMDIS_PETSC_SOLVER_GLOBAL_MATRIX_H #define AMDIS_PETSC_SOLVER_GLOBAL_MATRIX_H #include #include "AMDiS_fwd.h" #include "parallel/MatrixNnzStructure.h" #include "parallel/PetscSolver.h" namespace AMDiS { using namespace std; /** * PETSc solver which creates a globally distributed matrix. Supports also * coarse space assembling. */ class PetscSolverGlobalMatrix : public PetscSolver { public: PetscSolverGlobalMatrix(string name); void fillPetscMatrix(Matrix *mat); void fillPetscMatrixWithCoarseSpace(Matrix *mat); void fillPetscRhs(SystemVector *vec); void solvePetscMatrix(SystemVector &vec, AdaptInfo *adaptInfo); void solveGlobal(Vec &rhs, Vec &sol); void destroyMatrixData(); void destroyVectorData(); protected: void removeDirichletRows(Matrix *seqMat); void removeDirichletRows(SystemVector *seqVec); /// Reads field split information and creats a splitting based on /// component numbers. void createFieldSplit(PC pc); /** \brief * Creates a new field split for a preconditioner object. * * \param[in] pc PETSc preconditioner object, must be of * type PCFIELDSPLIT * \param[in] splitName Name of the field split, can be used to set other * parameters of the PCFIELDSPLIT preconditioner on * the command line. * \param[in] components System component numbers of the field split. At * the moment only continuous splits are allowed. */ void createFieldSplit(PC pc, string splitName, vector &components); /// Wrapper to create field split from only one component. void createFieldSplit(PC pc, string splitName, int component) { vector components; components.push_back(component); createFieldSplit(pc, splitName, components); } virtual void initSolver(KSP &ksp); virtual void exitSolver(KSP ksp); virtual void initPreconditioner(PC pc); virtual void exitPreconditioner(PC pc); /// Takes a DOF matrix and sends the values to the global PETSc matrix. void setDofMatrix(DOFMatrix* mat, int rowComp = 0, int colComp = 0); /// Takes a DOF vector and sends its values to a given PETSc vector. void setDofVector(Vec vecInterior, Vec vecCoarse, DOFVector* vec, int rowCompxo, bool rankOnly = false); inline void setDofVector(Vec vecInterior, DOFVector* vec, int rowComp, bool rankOnly = false) { setDofVector(vecInterior, PETSC_NULL, vec, rowComp, rankOnly); } inline void setDofVector(Vec vecInterior, SystemVector &vec, bool rankOnly = false) { for (int i = 0; i < vec.getSize(); i++) setDofVector(vecInterior, PETSC_NULL, vec.getDOFVector(i), i, rankOnly); } PetscSolver* createSubSolver(int component, string kspPrefix); void setConstantNullSpace(KSP ksp, int constFeSpace, bool test = false); protected: bool zeroStartVector; /// If true, after parallel assembling, information about the matrix /// are printed. bool printMatInfo; }; } #endif