StandardProblemIteration.cpp 2.2 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
#include <config.h>
2

3
4
#include "StandardProblemIteration.hpp"

5
6
7
#include <amdis/AdaptInfo.hpp>
#include <amdis/Output.hpp>
#include <amdis/ProblemStatBase.hpp>
8
9
10

namespace AMDiS
{
Praetorius, Simon's avatar
Praetorius, Simon committed
11
  ProblemStatBase& StandardProblemIteration::problem(int number)
12
13
  {
    AMDIS_FUNCNAME_DBG("StandardProblemIteration::getProblem");
14
    test_exit_dbg(number == 0, "Problem number out of range!");
15
    return problem_;
16
17
  }

Praetorius, Simon's avatar
Praetorius, Simon committed
18
  ProblemStatBase& StandardProblemIteration::problem(std::string const& name)
19
20
  {
    AMDIS_FUNCNAME_DBG("StandardProblemIteration::getProblem");
Praetorius, Simon's avatar
Praetorius, Simon committed
21
    test_exit_dbg(name == problem_.name(), "Problem name does not match!\n");
22
    return problem_;
23
24
25
26
27
28
  }

  void StandardProblemIteration::beginIteration(AdaptInfo& adaptInfo)
  {
    AMDIS_FUNCNAME("StandardProblemIteration::beginIteration()");

29
    msg("");
Praetorius, Simon's avatar
Praetorius, Simon committed
30
    msg("begin of iteration number: {}", (adaptInfo.spaceIteration() + 1));
31
    msg("=============================");
32
33
34
35
36
37
38
39
  }


  Flag StandardProblemIteration::oneIteration(AdaptInfo& adaptInfo, Flag toDo)
  {
    Flag flag = buildAndAdapt(adaptInfo, toDo);

    if (toDo.isSet(SOLVE))
40
      problem_.solve(adaptInfo, true, false);
41
42

    if (toDo.isSet(SOLVE_RHS))
43
      problem_.solve(adaptInfo, true, false);
44
45

    if (toDo.isSet(ESTIMATE))
46
      problem_.estimate(adaptInfo);
47
48
49
50
51
52
53
54
55

    return flag;
  }


  void StandardProblemIteration::endIteration(AdaptInfo& adaptInfo)
  {
    AMDIS_FUNCNAME("StandardProblemIteration::endIteration()");

56
    msg("");
Praetorius, Simon's avatar
Praetorius, Simon committed
57
    msg("end of iteration number: {}", (adaptInfo.spaceIteration() + 1));
58
    msg("=============================");
59
60
61
62
63
64
65
66
  }


  Flag StandardProblemIteration::buildAndAdapt(AdaptInfo& adaptInfo, Flag toDo)
  {
    Flag flag = 0, markFlag = 0;

    if (toDo.isSet(MARK))
67
      markFlag = problem_.markElements(adaptInfo);
68

Praetorius, Simon's avatar
Praetorius, Simon committed
69
    if (toDo.isSet(ADAPT) && markFlag.isSet(MESH_ADAPTED))
70
      flag |= problem_.adaptGrid(adaptInfo);
71
72

    if (toDo.isSet(BUILD))
73
      problem_.buildAfterAdapt(adaptInfo, markFlag, true, true);
74
75

    if (toDo.isSet(BUILD_RHS))
76
      problem_.buildAfterAdapt(adaptInfo, markFlag, false, true);
77
78
79
80
81

    return flag;
  }

  /// Returns the name of the problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
82
  std::string const& StandardProblemIteration::name() const
83
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
84
    return problem_.name();
85
  }
86

87
} // end namespace AMDiS