PetscProblemStat.cc 3.15 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
21
22
23
24
25

namespace AMDiS {

  using namespace std;


26
27
  PetscProblemStat::PetscProblemStat(string nameStr,
				     ProblemIterationInterface *problemIteration)
28
29
    : ParallelProblemStatBase(nameStr, problemIteration),
      deleteSolver(true)
30
31
32
33
34
35
36
37
38
39
  {
    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();
40
41
    } else if (name == "petsc-block") {
      petscSolver = new PetscSolverGlobalBlockMatrix();
42
43
44
45
46
47
48
49
    } else if (name == "petsc" || name == "") {
      petscSolver = new PetscSolverGlobalMatrix();
    } else {
      ERROR_EXIT("No parallel solver %s available!\n", name.c_str());
    }
  }


50
51
52
53
54
55
56
57
  PetscProblemStat::PetscProblemStat(string nameStr,
				     PetscSolver *solver)
    : ParallelProblemStatBase(nameStr, NULL),
      petscSolver(solver),
      deleteSolver(false)
  {}


58
59
60
61
62
63
64
65
66
67
  void PetscProblemStat::initialize(Flag initFlag, 
				    ProblemStatSeq* adoptProblem,
				    Flag adoptFlag)
  {
      ParallelProblemStatBase::initialize(initFlag, adoptProblem, adoptFlag);

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


68
69
70
  void PetscProblemStat::solve(AdaptInfo *adaptInfo,
			       bool createMatrixData,
			       bool storeMatrixData)
71
72
73
74
75
76
77
  {
    FUNCNAME("PetscProblemStat::solve()");

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

    double wtime = MPI::Wtime();

78
#if 0
79
    double vm, rss;
80
    processMemUsage(vm, rss);       
81
    MSG("STAGE 1\n");
82
    MSG("My memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);    
83
84
85
    mpi::globalAdd(vm);
    mpi::globalAdd(rss);
    MSG("Overall memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);
86
#endif
87

88
89
90
91
92
93
94
    if (createMatrixData) {
      petscSolver->setMeshDistributor(meshDistributor);
      petscSolver->fillPetscMatrix(systemMatrix);
    }

    petscSolver->fillPetscRhs(rhs);

95
#if 0
96
97
    processMemUsage(vm, rss);   
    MSG("STAGE 2\n");
98
    MSG("My memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);    
99
100
101
    mpi::globalAdd(vm);
    mpi::globalAdd(rss);
    MSG("Overall memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);
102
#endif
103

104
    petscSolver->solvePetscMatrix(*solution, adaptInfo);   
105

106
107
108
    if (!storeMatrixData)
      petscSolver->destroyMatrixData();

109
#if 0
110
111
    processMemUsage(vm, rss);   
    MSG("STAGE 3\n");
112
    MSG("My memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);    
113
114
115
    mpi::globalAdd(vm);
    mpi::globalAdd(rss);
    MSG("Overall memory usage is VM = %.1f MB    RSS = %.1f MB\n", vm, rss);
116
#endif
117

118
119
120
121
122
    INFO(info, 8)("solution of discrete system needed %.5f seconds\n", 
		  MPI::Wtime() - wtime);
  }

}