PetscProblemStat.cc 3.36 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
// 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.


#include <vector>
#include <set>

16
#include "io/VtkWriter.h"
17
18
#include "parallel/PetscProblemStat.h"
#include "parallel/PetscSolver.h"
19
#include "parallel/MpiHelper.h"
20
#include "parallel/BddcMlSolver.h"
21
22
23
24
25
26

namespace AMDiS {

  using namespace std;


27
28
  PetscProblemStat::PetscProblemStat(string nameStr,
				     ProblemIterationInterface *problemIteration)
29
30
    : ParallelProblemStatBase(nameStr, problemIteration),
      deleteSolver(true)
31
32
33
34
35
36
37
38
39
40
  {
    FUNCNAME("PetscProblemStat::PetscProblemStat()");

    string name("");
    Parameters::get("parallel->solver", name);
    
    if (name == "petsc-schur") {
      petscSolver = new PetscSolverSchur();
    } else if (name == "petsc-feti") {
      petscSolver = new PetscSolverFeti();
41
42
    } else if (name == "petsc-block") {
      petscSolver = new PetscSolverGlobalBlockMatrix();
43
44
    } else if (name == "petsc" || name == "") {
      petscSolver = new PetscSolverGlobalMatrix();
45
46
47
48
49
50
    } else if (name == "bddcml") {
#ifdef HAVE_BDDC_ML
      petscSolver = new BddcMlSolver();
#else
      ERROR_EXIT("AMDiS was compiled without BDDC-ML support!\n");
#endif
51
52
53
54
55
56
    } else {
      ERROR_EXIT("No parallel solver %s available!\n", name.c_str());
    }
  }


57
58
59
60
61
62
63
64
  PetscProblemStat::PetscProblemStat(string nameStr,
				     PetscSolver *solver)
    : ParallelProblemStatBase(nameStr, NULL),
      petscSolver(solver),
      deleteSolver(false)
  {}


65
66
67
68
69
70
71
72
73
74
  void PetscProblemStat::initialize(Flag initFlag, 
				    ProblemStatSeq* adoptProblem,
				    Flag adoptFlag)
  {
      ParallelProblemStatBase::initialize(initFlag, adoptProblem, adoptFlag);

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


75
76
77
  void PetscProblemStat::solve(AdaptInfo *adaptInfo,
			       bool createMatrixData,
			       bool storeMatrixData)
78
79
80
81
82
83
84
  {
    FUNCNAME("PetscProblemStat::solve()");

    TEST_EXIT(meshDistributor)("Should not happen!\n");

    double wtime = MPI::Wtime();

85
#if 0
86
    double vm, rss;
87
    processMemUsage(vm, rss);       
88
    MSG("STAGE 1\n");
89
    MSG("My memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);    
90
91
92
    mpi::globalAdd(vm);
    mpi::globalAdd(rss);
    MSG("Overall memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);
93
#endif
94

95
96
97
98
99
100
101
    if (createMatrixData) {
      petscSolver->setMeshDistributor(meshDistributor);
      petscSolver->fillPetscMatrix(systemMatrix);
    }

    petscSolver->fillPetscRhs(rhs);

102
#if 0
103
104
    processMemUsage(vm, rss);   
    MSG("STAGE 2\n");
105
    MSG("My memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);    
106
107
108
    mpi::globalAdd(vm);
    mpi::globalAdd(rss);
    MSG("Overall memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);
109
#endif
110

111
    petscSolver->solvePetscMatrix(*solution, adaptInfo);   
112

113
114
115
    if (!storeMatrixData)
      petscSolver->destroyMatrixData();

116
#if 0
117
118
    processMemUsage(vm, rss);   
    MSG("STAGE 3\n");
119
    MSG("My memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);    
120
121
122
    mpi::globalAdd(vm);
    mpi::globalAdd(rss);
    MSG("Overall memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);
123
#endif
124

125
126
127
128
129
    INFO(info, 8)("solution of discrete system needed %.5f seconds\n", 
		  MPI::Wtime() - wtime);
  }

}