PetscProblemStat.h 2.27 KB
Newer Older
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 26 27
// ============================================================================
// ==                                                                        ==
// == 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 PetscProblemStat.h */

#ifndef AMDIS_PETSC_PROBLEM_STAT_H
#define AMDIS_PETSC_PROBLEM_STAT_H

#include "AMDiS_fwd.h"
#include "Global.h"
28 29
#include "parallel/ParallelProblemStatBase.h"
#include "parallel/PetscSolver.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
30 31
#include "parallel/PetscSolverGlobalMatrix.h"
#include "parallel/PetscSolverSchur.h"
32 33 34 35 36 37 38 39

namespace AMDiS {
  
  class PetscProblemStat : public ParallelProblemStatBase
  {
  public:
    PetscProblemStat(std::string nameStr,
		     ProblemIterationInterface *problemIteration = NULL)
40
      : ParallelProblemStatBase(nameStr, problemIteration)
41
    {
42
      string name("");
43
      Parameters::get("parallel->solver", name);
44 45 46
      
      if (name == "petsc-schur") {
#ifdef HAVE_PETSC_DEV
47
	petscSolver = new PetscSolverSchur();
48 49 50 51
#else
	ERROR_EXIT("Petsc schur complement solver is only supported when petsc-dev is used!\n");
#endif
      } else if (name == "petsc" || name == "") {
52
	petscSolver = new PetscSolverGlobalMatrix();
53 54 55
      } else {
	ERROR_EXIT("No parallel solver %s available!\n", name.c_str());
      }
56
    }
57 58

    ~PetscProblemStat()
59 60 61
    {
      delete petscSolver;
    }
62

Thomas Witkowski's avatar
Thomas Witkowski committed
63 64 65 66 67 68 69
    void addToMeshDistributor(MeshDistributor& m)
    {
      ParallelProblemStatBase::addToMeshDistributor(m);

      meshDistributor->setBoundaryDofRequirement(petscSolver->getBoundaryDofRequirement());
    }

70 71 72
    void solve(AdaptInfo *adaptInfo, bool fixedMatrix = false);

  protected:
73
    PetscSolver *petscSolver;
74 75 76 77 78 79 80
  };

  typedef PetscProblemStat ParallelProblemStat;

} // namespace AMDiS

#endif