// ============================================================================ // == == // == 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/PetscSolver.h" namespace AMDiS { using namespace std; class PetscSolverGlobalMatrix : public PetscSolver { public: PetscSolverGlobalMatrix() : PetscSolver(), d_nnz(NULL), o_nnz(NULL), lastMeshNnz(0), zeroStartVector(false), alwaysCreateNnzStructure(false) { Parameters::get("parallel->use zero start vector", zeroStartVector); Parameters::get("parallel->always create nnz structure", alwaysCreateNnzStructure); } void fillPetscMatrix(Matrix *mat); void fillPetscRhs(SystemVector *vec); void solvePetscMatrix(SystemVector &vec, AdaptInfo *adaptInfo); void destroyMatrixData(); void destroyVectorData(); protected: /// Creates a new non zero pattern structure for the PETSc matrix. void createPetscNnzStructure(Matrix *mat); /// 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& petscVec, DOFVector* vec, int nRowVec, bool rankOnly = false); protected: /// Arrays definig the non zero pattern of Petsc's matrix. int *d_nnz, *o_nnz; /** \brief * Stores the mesh change index of the mesh the nnz structure was created for. * Therefore, if the mesh change index is higher than this value, we have to create * a new nnz structure for PETSc matrices, because the mesh has been changed and * therefore also the assembled matrix structure. */ int lastMeshNnz; bool zeroStartVector; /// If this variable is set to true, the non-zero matrix structure is /// created each time from scratch by calling \ref createPetscNnzStrcuture. /// This can be necessary if the number of non-zeros in the matrix varies /// though the mesh does not change. This may happen if there are many /// operators using DOFVectors from old timestep containing many zeros due to /// some phase fields. bool alwaysCreateNnzStructure; }; } #endif