ProblemStatBase.hpp 4.27 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
/**
 * \defgroup Problem Problem module
 *  @{ <img src="problem.png"> @}
 */

#pragma once

#include <string>

#include "Flag.hpp"

namespace AMDiS
{
  // Flags for controling which part of the problem should be initialized

  // For all problems
  const Flag INIT_FE_SPACE         = 0x01L;
  const Flag INIT_MESH             = 0x02L;
  const Flag CREATE_MESH           = 0x04L;
  const Flag INIT_SYSTEM           = 0x08L;
  const Flag INIT_SOLVER           = 0x10L;
  const Flag INIT_ESTIMATOR        = 0x20L;
  const Flag INIT_MARKER           = 0x40L;
  const Flag INIT_ADAPT            = 0x80L;
  const Flag INIT_FILEWRITER       = 0x100L;
  const Flag INIT_GLOBAL_REFINES   = 0x1000L;

  // For time dependent problems
  const Flag INIT_INITIAL_PROBLEM  = 0x200L;
  const Flag INIT_UH_OLD           = 0x400L;

  // For non linear problems
  const Flag INIT_UPDATER          = 0x800L;
  const Flag INIT_NONLIN_SOLVER    = 0x1000L;

  // Combined Flags
  const Flag INIT_NOTHING          = 0x00L;
  const Flag INIT_ALL        = INIT_FE_SPACE | INIT_MESH | CREATE_MESH | INIT_SYSTEM |
                               INIT_SOLVER | INIT_ESTIMATOR | INIT_MARKER |
                               INIT_ADAPT | INIT_FILEWRITER | INIT_INITIAL_PROBLEM |
                               INIT_UH_OLD | INIT_UPDATER | INIT_NONLIN_SOLVER ;

Praetorius, Simon's avatar
Praetorius, Simon committed
43
  const Flag MESH_ADAPTED   = 1;
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

  // forward declaration
  class AdaptInfo;

  /**
   * \ingroup Problem
   *
   * \brief
   * Interface for time independent problems. Concrete problems must override
   * all pure virtual methods. The method \ref adaptMethodStat() should
   * initiate the adaption loop which in turn uses the other pure virtual
   * functions. The default stationary adaption loop is implemented in the class
   * AdaptStationary.
   */
  class ProblemStatBase
  {
  public:
61
    virtual ~ProblemStatBase() = default;
62
63

    /// Marks mesh elements for refinement and coarsening.
64
    virtual Flag markElements(AdaptInfo& adaptInfo) = 0;
65
66
67
68
69
70

    /** \brief
     * Assembling of system matrices and vectors after coarsening.
     * By the last two parameters, assembling can be restricted to either
     * matrices or vectors only.
     */
71
    virtual void buildAfterAdapt(AdaptInfo& adaptInfo, Flag flag,
Praetorius, Simon's avatar
Praetorius, Simon committed
72
                                 bool assembleMatrix, bool assembleVector) = 0;
73

74
75
    /// Refinement/coarsening of the grid.
    virtual Flag adaptGrid(AdaptInfo& adaptInfo) = 0;
76

77
78
79
80
81
82
83
84
    /// Uniform global grid coarsening by up to n level.
    /// Returns MESH_ADAPTED if grid was changed
    virtual Flag globalCoarsen(int n) = 0;

    /// Uniform global refinement by n level
    /// Returns MESH_ADAPTED if grid was changed
    virtual Flag globalRefine(int n) = 0;

85
86
87
88
89
    /** \brief
     * Solves the assembled system. The result is an approximative solution.
     * The last two boolean arguments can be used to controll successive
     * solutions of systems with the same matrix.
     *
90
     * \param  adaptInfo          Reference to an \ref AdaptInfo object.
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
     * \param  createMatrixData   If false, the solver assumes that all of its
     *                            internal data structures for the system
     *                            matrix are already created. This is the case,
     *                            if we solve different systems but with the
     *                            same matrix. After the first call to this
     *                            function (with this parameter set to true),
     *                            all other calls may set it to false.
     * \param  storeMatrixData    If true, all internal data structures for the
     *                            system matrix are not deleted such that they
     *                            can be used for next solutions with the same
     *                            system matrix.
     */
    virtual void solve(AdaptInfo& adaptInfo,
                       bool createMatrixData = true,
                       bool storeMatrixData = false) = 0;

    /** \brief
     * A posteriori error estimation of the calculated solution. Should store
     * a local error estimation at each elements leaf data and return the
     * total error sum.
     */
112
    virtual void estimate(AdaptInfo& adaptInfo) = 0;
113
114

    /// Returns the name of the problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
115
    virtual std::string const& name() const = 0;
116
  };
117

118
} // end namespace AMDiS