StandardProblemIteration.cpp 2.22 KB
Newer Older
1
2
3
4
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

5
6
#include "StandardProblemIteration.hpp"

7
8
9
#include <amdis/AdaptInfo.hpp>
#include <amdis/Output.hpp>
#include <amdis/ProblemStatBase.hpp>
10
11
12

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

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

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

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


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

    if (toDo.isSet(SOLVE))
42
      problem_.solve(adaptInfo, true, false);
43
44

    if (toDo.isSet(SOLVE_RHS))
45
      problem_.solve(adaptInfo, true, false);
46
47

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

    return flag;
  }


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

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


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

    if (toDo.isSet(MARK))
69
      markFlag = problem_.markElements(adaptInfo);
70

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

    if (toDo.isSet(BUILD))
75
      problem_.buildAfterAdapt(adaptInfo, markFlag, true, true);
76
77

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

    return flag;
  }

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

89
} // end namespace AMDiS