// ============================================================================ // == == // == 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() : PetscSolver(), zeroStartVector(false), printMatInfo(false) { Parameters::get("parallel->use zero start vector", zeroStartVector); Parameters::get("parallel->print matrix info", printMatInfo); } void fillPetscMatrix(Matrix *mat); /// This function is just a small wrapper that creates a 1x1 matrix that /// contains exactly one DOFMatrix and than calls \ref fillPetscMatrix void fillPetscMatrix(DOFMatrix *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 createFieldSplit(PC pc); 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 nRowMat = 0, int nColMat = 0); /// Takes a DOF vector and sends its values to a given PETSc vector. void setDofVector(Vec vecInterior, Vec vecCoarse, DOFVector* vec, int nRowVec, bool rankOnly = false); inline void setDofVector(Vec vecInterior, DOFVector* vec, int nRowVec, bool rankOnly = false) { setDofVector(vecInterior, PETSC_NULL, vec, nRowVec, rankOnly); } protected: bool zeroStartVector; /// If true, after parallel assembling, information about the matrix /// are printed. bool printMatInfo; }; } #endif