ProblemStatBase.h 5.3 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
35
36
37
38
39

/** \file ProblemStatBase.h */

/**
 * \defgroup Problem Problem module
 *  @{ <img src="problem.png"> @}
 */

#ifndef AMDIS_PROBLEMSTATBASE_H
#define AMDIS_PROBLEMSTATBASE_H

#include "Flag.h"

namespace AMDiS {

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

  // For all problems
40
41
42
  const Flag INIT_FE_SPACE         = 0x01L;
  const Flag INIT_MESH             = 0x02L;
  const Flag CREATE_MESH           = 0x04L;
43
  const Flag INIT_SYSTEM           = 0x08L;
44
45
46
47
48
  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;
49

50
  // For time dependent problems
51
52
  const Flag INIT_INITIAL_PROBLEM  = 0x200L;
  const Flag INIT_UH_OLD           = 0x400L;
53

54
55
56
  // For non linear problems
  const Flag INIT_UPDATER          = 0x800L;
  const Flag INIT_NONLIN_SOLVER    = 0x1000L;
57

58
  const Flag INIT_GLOBAL_REFINES   = 0x2000L;
59

60
61
  // for parallel problem stat
  const Flag INIT_DOFMAP           = 0x4000L;
62
63

  // Combined Flags
64
  const Flag INIT_NOTHING          = 0x00L;
65
66
67
  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 |
68
    INIT_UH_OLD | INIT_UPDATER | INIT_NONLIN_SOLVER | INIT_DOFMAP;
69
70
71
72
73
74
75

  const Flag MESH_REFINED   = 1;
  const Flag MESH_COARSENED = 2;

  class AdaptInfo;

  /**
76
   * \ingroup Problem
77
78
79
80
   *
   * \brief
   * Interface for time independent problems. Concrete problems must override
   * all pure virtual methods. The method \ref adaptMethodStat() should
81
   * initiate the adaption loop which in turn uses the other pure virtual
82
83
84
85
86
87
   * functions. The default stationary adaption loop is implemented in the class
   * AdaptStationary.
   */
  class ProblemStatBase
  {
  public:
88
    virtual ~ProblemStatBase() {}
89

90
    /// Marks mesh elements for refinement and coarsening.
91
92
    virtual Flag markElements(AdaptInfo *adaptInfo) = 0;

93
    /// Assembling of system matrices and vectors before refinement.
94
95
    virtual void buildBeforeRefine(AdaptInfo *adaptInfo, Flag flag) = 0;

96
    /// Assembling of system matrices and vectors before coarsening.
97
98
99
100
    virtual void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag flag) = 0;

    /** \brief
     * Assembling of system matrices and vectors after coarsening.
101
102
     * By the last two parameters, assembling can be restricted to either
     * matrices or vectors only.
103
     */
104
    virtual void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag flag,
105
				   bool assembleMatrix, bool assembleVector) = 0;
106

107
    /// Refinement of the mesh.
108
109
    virtual Flag refineMesh(AdaptInfo *adaptInfo) = 0;

110
    /// Coarsening of the mesh.
111
112
    virtual Flag coarsenMesh(AdaptInfo *adaptInfo) = 0;

113
    /** \brief
114
115
116
117
118
119
     * 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.
     *
     * \param  adaptInfo          Pointer to an \ref AdaptInfo object.
     * \param  createMatrixData   If false, the solver assumes that all of its
120
     *                            internal data structures for the system
121
     *                            matrix are already created. This is the case,
122
     *                            if we solve different systems but with the
123
124
125
126
127
128
129
130
131
132
133
     *                            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;
134
135
136
137
138
139
140
141

    /** \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.
     */
    virtual void estimate(AdaptInfo *adaptInfo) = 0;

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

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

148
    /// Function that deserializes the problem plus information about the iteration.
149
    virtual void deserialize(std::istream &in) = 0;
150
151
152
153
154
  };

}

#endif