StandardProblemIteration.cc 2.39 KB
Newer Older
1
2
3
4
#include "StandardProblemIteration.h"
#include "AdaptInfo.h"
#include "ProblemStatBase.h"
#include "Global.h"
5
#include "OpenMP.h"
6
7
8

namespace AMDiS {

9
  int StandardProblemIteration::info = 10;
10
11
12
13
14

  void StandardProblemIteration::beginIteration(AdaptInfo *adaptInfo) 
  {
    FUNCNAME("StandardProblemIteration::beginIteration()");

15
16
17
    INFO(info,4)("\n");
    INFO(info,4)("begin of iteration number: %d\n", adaptInfo->getSpaceIteration() + 1);
    INFO(info,4)("=============================\n");
18
19
20
21
22
  }

  Flag StandardProblemIteration::oneIteration(AdaptInfo *adaptInfo, Flag toDo) 
  {
    FUNCNAME("StandardProblemIteration::oneIteration()");
23

24
25
    Flag flag = buildAndAdapt(adaptInfo, toDo);

26
    if (toDo.isSet(SOLVE))
27
      problem->solve(adaptInfo, false);
28
29

    if (toDo.isSet(SOLVE_RHS))
30
      problem->solve(adaptInfo, true);
31
32

    if (toDo.isSet(ESTIMATE)) 
33
      problem->estimate(adaptInfo);
34
35
36
37
38
39
40
41

    return flag;
  }

  void StandardProblemIteration::endIteration(AdaptInfo *adaptInfo) 
  {
    FUNCNAME("StandardProblemIteration::endIteration()");

42
43
44
    INFO(info,4)("\n");
    INFO(info,4)("end of iteration number: %d\n", adaptInfo->getSpaceIteration() + 1);
    INFO(info,4)("=============================\n");
45
46
47
48
49
50
51
52
53
  }

  Flag StandardProblemIteration::buildAndAdapt(AdaptInfo *adaptInfo, Flag toDo)
  {
    FUNCNAME("StandardProblemIteration::buildAndAdapt()");

    Flag flag = 0, markFlag = 0;

    if (toDo.isSet(MARK)) {
54
      markFlag = problem->markElements(adaptInfo);
55
56
57
58
    }  else {
      markFlag = 3;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
59
    if (toDo.isSet(BUILD))
60
      problem->buildBeforeRefine(adaptInfo, markFlag);
61
62

    // refine
Thomas Witkowski's avatar
Thomas Witkowski committed
63
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_REFINED))
64
      flag = problem->refineMesh(adaptInfo);
65

Thomas Witkowski's avatar
Thomas Witkowski committed
66
    if (toDo.isSet(BUILD))
67
      problem->buildBeforeCoarsen(adaptInfo, markFlag);
68
69

    // coarsen
Thomas Witkowski's avatar
Thomas Witkowski committed
70
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_COARSENED))
71
      flag |= problem->coarsenMesh(adaptInfo);
72

Thomas Witkowski's avatar
Thomas Witkowski committed
73
    if (toDo.isSet(BUILD))
74
      problem->buildAfterCoarsen(adaptInfo, markFlag, true, true);
75

Thomas Witkowski's avatar
Thomas Witkowski committed
76
    if (toDo.isSet(BUILD_RHS))
77
      problem->buildAfterCoarsen(adaptInfo, markFlag, false, true);
78
79
80
81

    return flag;
  }

82
  const std::string& StandardProblemIteration::getName()
83
  {
84
    return problem->getName();
85
86
  }

87
  void StandardProblemIteration::serialize(std::ostream &out)
88
  {
89
    problem->serialize(out);
90
91
  }

92
  void StandardProblemIteration::deserialize(std::istream &in)
93
  {
94
    problem->deserialize(in);
95
96
  }
};