ProblemIterationInterface.h 3.44 KB
Newer Older
1
2
3
4
5
6
7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9
10
11
12
13
14
15
16
17
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
18
 *
19
 ******************************************************************************/
20
21


22
23
24
25
26
27
28
29
30
31
32
33
34

/** \file ProblemIterationInterface.h */

#ifndef AMDIS_PROBLEMITERATIONINTERFACE_H
#define AMDIS_PROBLEMITERATIONINTERFACE_H

#include "Flag.h"

namespace AMDiS {

  class AdaptInfo;
  class ProblemStatBase;

35
36
37
38
39
40
41
  const Flag BUILD = 1;              // Assemble vectors and matrices
  const Flag BUILD_RHS = 2;          // Assemble rhs vectors only
  const Flag ADAPT = 4;              // Run adaption procedure
  const Flag SOLVE = 8;              // Solve system
  const Flag SOLVE_RHS = 16;         // Solve system, where only rhs vectors have changed
  const Flag ESTIMATE = 32;          // Estimate error
  const Flag MARK = 64;              // Mark elements
42
43
44
45
46
47
48
49
50
51
52
53
54

  const Flag FULL_ITERATION = BUILD | ADAPT | SOLVE | ESTIMATE | MARK;
  const Flag NO_ADAPTION = BUILD | SOLVE | ESTIMATE;

  /** \brief
   * Interface for master problems needed by the adaption loop. A master problem
   * can handle one single or multiple coupled problems. In the latter case,
   * the master problem can determine the execution order of the build, solve,
   * estimate, and adapt steps of the single problems in \ref oneIteration().
   */
  class ProblemIterationInterface
  {
  public:
55
    virtual ~ProblemIterationInterface() {}
56

57
58
    /// Called before each adaption loop iteration.
    virtual void beginIteration(AdaptInfo *adaptInfo) {}
59
60
61
62
63
64
65
66

    /** \brief
     * Determines the execution order of the single adaption steps. If adapt is
     * true, mesh adaption will be performed. This allows to avoid mesh adaption,
     * e.g. in timestep adaption loops of timestep adaptive strategies.
     */
    virtual Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION) = 0;

67
68
    /// Called after each adaption loop iteration.
    virtual void endIteration(AdaptInfo *adaptInfo) {}
69

70
    /// Returns number of managed problems
Praetorius, Simon's avatar
Praetorius, Simon committed
71
    virtual int getNumProblems() const = 0;
72
73
74
75
76
77

    /** \brief
     * Returns the problem with the given number. If only one problem
     * is managed by this master problem, the number hasn't to be given.
     */
    virtual ProblemStatBase *getProblem(int number = 0) = 0;
Praetorius, Simon's avatar
Praetorius, Simon committed
78
79
80
81
82
83
    
    // dirty hack
    virtual ProblemStatBase const* getProblem(int number = 0) const
    {
      return const_cast<ProblemStatBase const*>(const_cast<ProblemIterationInterface*>(this)->getProblem(number));
    }
84

85
86
87
88
    /// Returns the problem with the given name.
    virtual ProblemStatBase *getProblem(std::string name)
    {
      return NULL;
89
    }
90

91
    /// Returns the name of the problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
92
    virtual std::string getName() const = 0;
93

94
    /// Function that serializes the problem plus information about the iteration.
95
    virtual void serialize(std::ostream &out) = 0;
96

97
    /// Function that deserializes the problem plus information about the iteration.
98
    virtual void deserialize(std::istream &in) = 0;
99
100
101
102
103
104
  };

}

#endif