CouplingIterationInterface.h 3.22 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==  http://www.amdis-fem.org                                              ==
// ==                                                                        ==
// ============================================================================
//
// 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.



/** \file CouplingIterationInterface.h */

#ifndef AMDIS_COUPLINGITERATIONINTERFACE_H
#define AMDIS_COUPLINGITERATIONINTERFACE_H

#include "Flag.h"
#include "AdaptInfo.h"
#include "ProblemIterationInterface.h"

namespace AMDiS {

  /** \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().
   * Standard execution order depends on the ordering of the problems in the
   * problem-list, that is filled by addProblem. Alternatively one can a access
   * each problem by an unique name.
   */
  class CouplingIterationInterface : public ProblemIterationInterface
  {
  public:
    virtual ~CouplingIterationInterface() {}

    /// add problem by number
    virtual void addIterationInterface(ProblemIterationInterface* probIter, int number = -1);

    /// Called before each adaption loop iteration.
    virtual void beginIteration(AdaptInfo *adaptInfo);

    /** \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);

    /// Called after each adaption loop iteration.
    virtual void endIteration(AdaptInfo *adaptInfo);

    /// Returns number of managed problems
    virtual int getNumProblems();

    /** \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);

    /// Returns the name of the problem with the given number.
    virtual std::string getName(int number);
    virtual std::string getName() { return getName(0); }

    /// Function that serializes the problem plus information about the iteration.
    virtual void serialize(std::ostream &out) {};

    /// Function that deserializes the problem plus information about the iteration.
    virtual void deserialize(std::istream &in) {};

  protected:

    /// vector/map of coupled stationary problems
    std::vector<ProblemIterationInterface*> problems;
  };

}

#endif // AMDIS_COUPLINGITERATIONINTERFACE_H