StandardProblemIteration.cc 2.38 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()");

Thomas Witkowski's avatar
Thomas Witkowski committed
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()");

Thomas Witkowski's avatar
Thomas Witkowski committed
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
  }

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

    Flag flag = 0, markFlag = 0;

Thomas Witkowski's avatar
Thomas Witkowski committed
53
    if (toDo.isSet(MARK))
54
      markFlag = problem->markElements(adaptInfo);
Thomas Witkowski's avatar
Thomas Witkowski committed
55
    else
56
57
      markFlag = 3;

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

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

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

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

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

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

    return flag;
  }

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

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

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