CouplingIterationInterface.h 3.49 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * 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.
 * 
 ******************************************************************************/
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



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

    virtual int getNumProblems();

66
67
68
    /// Returns number of managed problems
    virtual size_t getNumIterationInterfaces() { return problems.size(); }

69
70
71
72
73
74
    /** \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);

75
76
    virtual ProblemIterationInterface *getIterationInterface(size_t number = 0) { return problems[number]; }

77
    /// Returns the name of the problem with the given number.
78
    virtual std::string getName(size_t number);
79
80
    virtual std::string getName() { return getName(0); }

81
82
83
    virtual void setSolveProblem(size_t number, bool flag = true) { solveProblem[number] = flag; }
    virtual void setSolveProblem(std::string name, bool flag = true);

84
85
86
87
88
89
90
91
92
93
    /// 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;
94
    std::vector<bool> solveProblem;
95
96
97
98
99
100
  };

}

#endif // AMDIS_COUPLINGITERATIONINTERFACE_H