// ============================================================================ // == == // == 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 PetscSolverGlobalBlockMatrix.h */ #ifndef AMDIS_PETSC_SOLVER_GLOBAL_BLOCK_MATRIX_H #define AMDIS_PETSC_SOLVER_GLOBAL_BLOCK_MATRIX_H #include "AMDiS_fwd.h" #include "parallel/PetscSolver.h" namespace AMDiS { using namespace std; class PetscSolverGlobalBlockMatrix : public PetscSolver { public: /// Creator class class Creator : public OEMSolverCreator { public: virtual ~Creator() {} /// Returns a new PetscSolver object. OEMSolver* create() { return new PetscSolverGlobalBlockMatrix(this->name); } }; PetscSolverGlobalBlockMatrix(string name) : PetscSolver(name), nComponents(0), nBlocks(-1) {} void fillPetscMatrix(Matrix *mat); void fillPetscRhs(SystemVector *vec); void solvePetscMatrix(SystemVector &vec, AdaptInfo *adaptInfo); void destroyMatrixData(); void destroyVectorData(); protected: /// Takes a DOF matrix and sends the values to the global PETSc matrix. void setDofMatrix(Mat& petscMat, DOFMatrix* mat, int dispRowBlock, int dispColBlock); /// Takes a DOF vector and sends its values to a given PETSc vector. void setDofVector(Vec& petscVec, DOFVector* vec); virtual void initSolver(KSP &ksp); virtual void exitSolver(KSP ksp); virtual void initPreconditioner(PC pc); virtual void exitPreconditioner(PC pc); protected: vector nestMat; vector nestVec; Vec petscSolVec; /// Number of components (= number of unknowns in the PDE) int nComponents; /// Number of blocks for the solver, must be 1 <= nBlocks <= nComponents int nBlocks; /// Maps to each component number the block number the component is in. map componentInBlock; }; } #endif