StandardProblemIteration.cc 2.25 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "StandardProblemIteration.h"
#include "AdaptInfo.h"
#include "ProblemStatBase.h"
#include "Global.h"

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()");
  
    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;
  }

  const ::std::string& StandardProblemIteration::getName()
  {
    return problem_->getName();
  }

  void StandardProblemIteration::serialize(::std::ostream &out)
  {
    problem_->serialize(out);
  }

  void StandardProblemIteration::deserialize(::std::istream &in)
  {
    problem_->deserialize(in);
  }
};