StandardProblemIteration.cc 2.86 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


13
14
15
16
17
18
19
#include "StandardProblemIteration.h"
#include "AdaptInfo.h"
#include "ProblemStatBase.h"
#include "Global.h"

namespace AMDiS {

20
  int StandardProblemIteration::info = 10;
21

22

23
24
25
26
  void StandardProblemIteration::beginIteration(AdaptInfo *adaptInfo) 
  {
    FUNCNAME("StandardProblemIteration::beginIteration()");

Thomas Witkowski's avatar
Thomas Witkowski committed
27
28
29
    INFO(info, 4)("\n");
    INFO(info, 4)("begin of iteration number: %d\n", adaptInfo->getSpaceIteration() + 1);
    INFO(info, 4)("=============================\n");
30
31
  }

32

33
34
35
  Flag StandardProblemIteration::oneIteration(AdaptInfo *adaptInfo, Flag toDo) 
  {
    FUNCNAME("StandardProblemIteration::oneIteration()");
36

37
38
    Flag flag = buildAndAdapt(adaptInfo, toDo);

39
    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

    return flag;
  }

51

52
53
54
55
  void StandardProblemIteration::endIteration(AdaptInfo *adaptInfo) 
  {
    FUNCNAME("StandardProblemIteration::endIteration()");

Thomas Witkowski's avatar
Thomas Witkowski committed
56
57
58
    INFO(info, 4)("\n");
    INFO(info, 4)("end of iteration number: %d\n", adaptInfo->getSpaceIteration() + 1);
    INFO(info, 4)("=============================\n");
59
60
  }

61

62
63
64
65
66
67
  Flag StandardProblemIteration::buildAndAdapt(AdaptInfo *adaptInfo, Flag toDo)
  {
    FUNCNAME("StandardProblemIteration::buildAndAdapt()");

    Flag flag = 0, markFlag = 0;

68
69
70
71
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    double first = MPI::Wtime();
#endif

Thomas Witkowski's avatar
Thomas Witkowski committed
72
    if (toDo.isSet(MARK))
73
      markFlag = problem->markElements(adaptInfo);
Thomas Witkowski's avatar
Thomas Witkowski committed
74
    else
75
76
      markFlag = 3;

Thomas Witkowski's avatar
Thomas Witkowski committed
77
    if (toDo.isSet(BUILD))
78
      problem->buildBeforeRefine(adaptInfo, markFlag);
79
80

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

Thomas Witkowski's avatar
Thomas Witkowski committed
84
    if (toDo.isSet(BUILD))
85
      problem->buildBeforeCoarsen(adaptInfo, markFlag);
86
87

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

91
92
93
94
95
96
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    MPI::COMM_WORLD.Barrier();
    INFO(info, 8)("Local mesh adaption needed %.5f seconds\n", 
		  MPI::Wtime() - first);
#endif

Thomas Witkowski's avatar
Thomas Witkowski committed
97
    if (toDo.isSet(BUILD))
98
      problem->buildAfterCoarsen(adaptInfo, markFlag, true, true);
99

Thomas Witkowski's avatar
Thomas Witkowski committed
100
    if (toDo.isSet(BUILD_RHS))
101
      problem->buildAfterCoarsen(adaptInfo, markFlag, false, true);
102
103
104
105

    return flag;
  }

106

Thomas Witkowski's avatar
Thomas Witkowski committed
107
  std::string StandardProblemIteration::getName()
108
  {
109
    return problem->getName();
110
111
  }

112

113
  void StandardProblemIteration::serialize(std::ostream &out)
114
  {
115
    problem->serialize(out);
116
117
  }

118

119
  void StandardProblemIteration::deserialize(std::istream &in)
120
  {
121
    problem->deserialize(in);
122
  }
123

124
};