Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

PetscSolverGlobalMatrix.h 3.53 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
// ============================================================================
// ==                                                                        ==
// == 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

26
#include <boost/tuple/tuple.hpp>
Thomas Witkowski's avatar
Thomas Witkowski committed
27 28
#include "AMDiS_fwd.h"
#include "parallel/PetscSolver.h"
29
#include "parallel/FeSpaceMapping.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
30 31 32 33 34 35 36 37 38 39 40 41 42

namespace AMDiS {

  using namespace std;

  class PetscSolverGlobalMatrix : public PetscSolver
  {
  public:
    PetscSolverGlobalMatrix()
      : PetscSolver(),
	d_nnz(NULL),
	o_nnz(NULL),
	lastMeshNnz(0),
43
	zeroStartVector(false),
44 45
	alwaysCreateNnzStructure(false),
	removeRhsNullSpace(false)
Thomas Witkowski's avatar
Thomas Witkowski committed
46
    {
47
      Parameters::get("parallel->use zero start vector", zeroStartVector);
48 49
      Parameters::get("parallel->always create nnz structure", 
		      alwaysCreateNnzStructure);
50 51
      Parameters::get("parallel->remove rhs null space", 
		      removeRhsNullSpace);
Thomas Witkowski's avatar
Thomas Witkowski committed
52 53
    }

54 55 56
    void fillPetscMatrix(Matrix<DOFMatrix*> *mat);

    void fillPetscRhs(SystemVector *vec);
Thomas Witkowski's avatar
Thomas Witkowski committed
57 58 59

    void solvePetscMatrix(SystemVector &vec, AdaptInfo *adaptInfo);    

60
    void destroyMatrixData();
61

Thomas Witkowski's avatar
Thomas Witkowski committed
62 63 64 65 66
  protected:
    /// Creates a new non zero pattern structure for the PETSc matrix. 
    void createPetscNnzStructure(Matrix<DOFMatrix*> *mat);
    
    /// Takes a DOF matrix and sends the values to the global PETSc matrix.
67
    void setDofMatrix(DOFMatrix* mat, int nRowMat = 0, int nColMat = 0);
Thomas Witkowski's avatar
Thomas Witkowski committed
68 69 70

    /// Takes a DOF vector and sends its values to a given PETSc vector.
    void setDofVector(Vec& petscVec, DOFVector<double>* vec, 
71
		      int nRowVec, bool rankOnly = false);
Thomas Witkowski's avatar
Thomas Witkowski committed
72

73 74
    void createGlobalDofMapping(vector<const FiniteElemSpace*> &feSpaces);

Thomas Witkowski's avatar
Thomas Witkowski committed
75 76 77 78 79 80 81 82 83 84 85 86 87
  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;
88 89 90 91 92 93 94 95

    /// 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;
96

97 98 99
    /// Mapping from global DOF indices to global matrix indices under 
    /// consideration of possibly multiple components.
    DofToMatIndex dofToMatIndex;
100 101 102

    /// If true, the constant null space is projected out of the RHS vector.
    bool removeRhsNullSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
103 104 105 106 107 108 109
  };


}

#endif