StandardProblemIteration.cc 2.41 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
9
10
11
12
13
14
15
16
17
18
19
20
21
22

namespace AMDiS {

  int StandardProblemIteration::info_ = 10;

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

    INFO(info_,4)("\n");
    INFO(info_,4)("begin of iteration number: %d\n", adaptInfo->getSpaceIteration() + 1);
    INFO(info_,4)("=============================\n");
  }

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

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

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

    if (toDo.isSet(SOLVE_RHS))
      problem_->solve(adaptInfo, true);
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

    if (toDo.isSet(ESTIMATE)) 
      problem_->estimate(adaptInfo);

    return flag;
  }

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

    INFO(info_,4)("\n");
    INFO(info_,4)("end of iteration number: %d\n", adaptInfo->getSpaceIteration() + 1);
    INFO(info_,4)("=============================\n");
  }

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

    Flag flag = 0, markFlag = 0;

    if (toDo.isSet(MARK)) {
      markFlag = problem_->markElements(adaptInfo);
    }  else {
      markFlag = 3;
    }

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

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

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

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

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

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
85
86
  {
    return problem_->getName();
  }

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

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