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

#include "parallel/PetscProblemStat.h"
#include "parallel/PetscSolver.h"
18
#include "parallel/MpiHelper.h"
19
20
21
22
23
24

namespace AMDiS {

  using namespace std;


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  PetscProblemStat::PetscProblemStat(string nameStr,
				     ProblemIterationInterface *problemIteration)
    : ParallelProblemStatBase(nameStr, problemIteration)
  {
    FUNCNAME("PetscProblemStat::PetscProblemStat()");

    string name("");
    Parameters::get("parallel->solver", name);
    
    if (name == "petsc-schur") {
#ifdef HAVE_PETSC_DEV
      petscSolver = new PetscSolverSchur();
#else
      ERROR_EXIT("PETSc schur complement solver is only supported when petsc-dev is used!\n");
#endif
    } else if (name == "petsc-feti") {
#ifdef HAVE_PETSC_DEV
      petscSolver = new PetscSolverFeti();
#else
      ERROR_EXIT("PETSc FETI-DP solver is only supported when petsc-dev is used!\n");
#endif
    } else if (name == "petsc" || name == "") {
      petscSolver = new PetscSolverGlobalMatrix();
    } else {
      ERROR_EXIT("No parallel solver %s available!\n", name.c_str());
    }
  }


  void PetscProblemStat::initialize(Flag initFlag, 
				    ProblemStatSeq* adoptProblem,
				    Flag adoptFlag)
  {
      ParallelProblemStatBase::initialize(initFlag, adoptProblem, adoptFlag);

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


64
65
66
  void PetscProblemStat::solve(AdaptInfo *adaptInfo,
			       bool createMatrixData,
			       bool storeMatrixData)
67
68
69
70
71
72
73
  {
    FUNCNAME("PetscProblemStat::solve()");

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

    double wtime = MPI::Wtime();

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

84
85
86
87
88
89
90
    if (createMatrixData) {
      petscSolver->setMeshDistributor(meshDistributor);
      petscSolver->fillPetscMatrix(systemMatrix);
    }

    petscSolver->fillPetscRhs(rhs);

91

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

101
    petscSolver->solvePetscMatrix(*solution, adaptInfo);   
102

103
104
105
    if (!storeMatrixData)
      petscSolver->destroyMatrixData();

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

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

}