StandardProblemIteration.cc 2.26 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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
    Flag flag = buildAndAdapt(adaptInfo, toDo);

    if (toDo.isSet(SOLVE)) 
      problem_->solve(adaptInfo);

    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;
    }

    if (toDo.isSet(BUILD)) {
      problem_->buildBeforeRefine(adaptInfo, markFlag);
    }

    // refine
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_REFINED)) {
      flag = problem_->refineMesh(adaptInfo);
    }

    if (toDo.isSet(BUILD)) {
      problem_->buildBeforeCoarsen(adaptInfo, markFlag);
    }

    // coarsen
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_COARSENED)) {
      flag |= problem_->coarsenMesh(adaptInfo);
    }

    if (toDo.isSet(BUILD)) {
      problem_->buildAfterCoarsen(adaptInfo, markFlag);
    }

    return flag;
  }

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

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

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