ProblemStat.hpp 18.6 KB
Newer Older
1
2
3
4
#pragma once

#include <list>
#include <map>
5
6
7
8
9
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
10

11
12
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
13
14
#include <dune/common/shared_ptr.hh>

15
#include <dune/grid/common/grid.hh>
16

17
#include <amdis/AdaptInfo.hpp>
18
#include <amdis/AdaptiveGrid.hpp>
19
#include <amdis/BiLinearForm.hpp>
20
#include <amdis/CreatorInterface.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
21
#include <amdis/CreatorMap.hpp>
22
#include <amdis/DirichletBC.hpp>
23
#include <amdis/DOFVector.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
24
//#include <amdis/Estimator.hpp>
25
26
27
#include <amdis/Flag.hpp>
#include <amdis/Initfile.hpp>
#include <amdis/LinearAlgebra.hpp>
28
#include <amdis/LinearForm.hpp>
29
#include <amdis/Marker.hpp>
30
#include <amdis/MeshCreator.hpp>
31
#include <amdis/OperatorList.hpp>
32
#include <amdis/PeriodicBC.hpp>
33
34
35
#include <amdis/ProblemStatBase.hpp>
#include <amdis/ProblemStatTraits.hpp>
#include <amdis/StandardProblemIteration.hpp>
36
#include <amdis/common/SharedPtr.hpp>
37
#include <amdis/common/TupleUtility.hpp>
38
#include <amdis/common/TypeTraits.hpp>
39
#include <amdis/GridFunctions.hpp>
40
#include <amdis/gridfunctions/DiscreteFunction.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
41
#include <amdis/io/FileWriterBase.hpp>
42
#include <amdis/typetree/TreePath.hpp>
43

44
namespace AMDiS
45
{
46
47
48
49
  // forward declaration
  template <class Traits>
  class ProblemInstat;

50
  template <class Traits>
51
  class ProblemStat
Praetorius, Simon's avatar
Praetorius, Simon committed
52
      : public ProblemStatBase
53
      , public StandardProblemIterationAdaptor<ProblemStat<Traits>>
54
  {
55
    using Self = ProblemStat;
56

57
58
    friend class ProblemInstat<Traits>;

59
  public: // typedefs and static constants
60

61
    using GlobalBasis = typename Traits::GlobalBasis;
Praetorius, Simon's avatar
Praetorius, Simon committed
62
    using GridView    = typename GlobalBasis::GridView;
Praetorius, Simon's avatar
Praetorius, Simon committed
63
    using Grid        = AdaptiveGrid_t<typename GridView::Grid>;
Praetorius, Simon's avatar
Praetorius, Simon committed
64
    using Element     = typename GridView::template Codim<0>::Entity;
65
    using WorldVector = typename Element::Geometry::GlobalCoordinate;
66
    using WorldMatrix = FieldMatrix<typename WorldVector::field_type, WorldVector::dimension, WorldVector::dimension>;
67

68
    /// Dimension of the grid
69
    static constexpr int dim = Grid::dimension;
70

71
    /// Dimension of the world
72
    static constexpr int dow = Grid::dimensionworld;
73

Praetorius, Simon's avatar
Praetorius, Simon committed
74
75
76
77
78
  private:
    using LinAlgTraits = typename Traits::LinAlgTraits;
    using Mat = typename LinAlgTraits::template MatrixImpl<typename Traits::CoefficientType>;
    using Vec = typename LinAlgTraits::template VectorImpl<typename Traits::CoefficientType>;
    using PartitionSet = typename LinAlgTraits::PartitionSet;
79

Praetorius, Simon's avatar
Praetorius, Simon committed
80
81
82
83
84
  public:
    using LinearSolver = LinearSolverInterface<Mat,Vec>;
    using SystemMatrix = BiLinearForm<GlobalBasis, GlobalBasis, typename Traits::CoefficientType, LinAlgTraits>;
    using SystemVector = LinearForm<GlobalBasis, typename Traits::CoefficientType, LinAlgTraits>;
    using SolutionVector = DOFVector<GlobalBasis, typename Traits::CoefficientType, LinAlgTraits>;
85

86
  public:
87
88
    /**
     * \brief Constructor. Takes the name of the problem that is used to
89
     * access values corresponding to this problem in the parameter file.
90
     **/
91
    explicit ProblemStat(std::string const& name)
92
      : name_(name)
93
    {}
94

95
    /// Constructor taking additionally a grid that is used
96
    /// instead of the default created grid, \ref ProblemStat
97
98
    template <class Grid_>
    ProblemStat(std::string const& name, Grid_&& grid)
99
      : ProblemStat(name)
100
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
101
      adoptGrid(wrap_or_share(FWD(grid)));
102
103
    }

104
105
    /// \brief Constructor taking a grid and basis
    /// Wraps both in shared pointers.
Praetorius, Simon's avatar
Praetorius, Simon committed
106
107
    template <class Grid_, class Basis_>
    ProblemStat(std::string const& name, Grid_&& grid, Basis_&& globalBasis)
108
      : ProblemStat(name, FWD(grid))
109
    {
110
      adoptGlobalBasis(wrap_or_share(FWD(globalBasis)));
111
    }
Praetorius, Simon's avatar
Praetorius, Simon committed
112

113

Praetorius, Simon's avatar
Praetorius, Simon committed
114
    /// \brief Initialisation of the problem.
115
    /**
Praetorius, Simon's avatar
Praetorius, Simon committed
116
117
     * Parameters read in initialize()
     *   - `[GRID_NAME]->global refinements`:  nr of initial global refinements
118
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
119
    void initialize(Flag initFlag, Self* adoptProblem = nullptr, Flag adoptFlag = INIT_NOTHING);
120

Praetorius, Simon's avatar
Praetorius, Simon committed
121
122
123
124
125
126
127
128
    /// \brief Read the grid and solution from backup files and initialize the problem
    /**
     * Parameters read in restore() for problem with name 'PROB'
     *   - `[PROB]->restore->grid`:      name of the grid backup file
     *   - `[PROB]->restore->solution`:  name of the solution backup file
     **/
    void restore(Flag initFlag);

129

Praetorius, Simon's avatar
Praetorius, Simon committed
130
    /// Add an operator to \ref A.
131
    /** @{ */
Praetorius, Simon's avatar
Praetorius, Simon committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
    /// Operator evaluated on the whole element
    /**
     * Adds an operator to the list of element operators to be assembled in
     * quadrature points inside the element.
     *
     * \param op   A (pre-) local operator, \see LocalOperator, \see GridFunctionOperator
     * \param row  TreePath identifying the sub-basis in the global basis tree
     *             corresponding to the row basis. \see treepath()
     * \param col  TreePath identifying the sub-basis in the global basis tree
     *             corresponding to the column basis. \see treepath()
     *
     * Example:
     * ```
     * auto op = makeOperator(tag::test_trial{}, 1.0/tau);
     * prob.addMatrixOperator(op, _0, _0);
     * ```
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
149
    template <class Operator, class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
150
151
152
153
    void addMatrixOperator(Operator const& op, RowTreePath row = {}, ColTreePath col = {})
    {
      systemMatrix_->addOperator(tag::element_operator<Element>{}, op, row, col);
    }
154

Praetorius, Simon's avatar
Praetorius, Simon committed
155
156
157
158
159
    /// Operator evaluated on the boundary of the domain with boundary index `b`
    /**
     * Adds an operator to the list of boundary operators to be assembled in
     * quadrature points on the boundary intersections.
     *
Praetorius, Simon's avatar
Praetorius, Simon committed
160
     * \param b    Boundary identifier where to assemble this operator. Can be
Praetorius, Simon's avatar
Praetorius, Simon committed
161
162
163
164
165
166
167
168
169
170
171
172
173
     *             constructed from an integer. \see BoundaryType
     * \param op   A (pre-) local operator, \see LocalOperator, \see GridFunctionOperator
     * \param row  TreePath identifying the sub-basis in the global basis tree
     *             corresponding to the row basis. \see treepath()
     * \param col  TreePath identifying the sub-basis in the global basis tree
     *             corresponding to the column basis. \see treepath()
     *
     * Example:
     * ```
     * auto op = makeOperator(tag::test_trial{}, alpha);
     * prob.addMatrixOperator(BoundaryType{1}, op, _0, _0);
     * ```
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
174
    template <class Operator, class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
175
176
    void addMatrixOperator(BoundaryType b, Operator const& op, RowTreePath row = {}, ColTreePath col = {})
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
177
      using I = typename GridView::Intersection;
178
      systemMatrix_->addOperator(tag::boundary_operator<I>{*boundaryManager_,b}, op, row, col);
179
    }
180
    /** @} */
181
182


Praetorius, Simon's avatar
Praetorius, Simon committed
183
    /// Add an operator to \ref rhs.
184
    /** @{ */
Praetorius, Simon's avatar
Praetorius, Simon committed
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
    /// Operator evaluated on the whole element
    /**
     * Adds an operator to the list of element operators to be assembled in
     * quadrature points inside the element.
     *
     * \param op    A (pre-) local operator, \see LocalOperator, \see GridFunctionOperator
     * \param path  TreePath identifying the sub-basis in the global basis tree
     *              corresponding to the row basis. \see treepath()
     *
     * Example:
     * ```
     * auto op = makeOperator(tag::test{}, probInstat.getOldSolution(0) / tau);
     * prob.addVectorOperator(op, _0);
     * ```
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
200
    template <class Operator, class TreePath = RootTreePath>
201
202
203
204
    void addVectorOperator(Operator const& op, TreePath path = {})
    {
      rhs_->addOperator(tag::element_operator<Element>{}, op, path);
    }
205

Praetorius, Simon's avatar
Praetorius, Simon committed
206
207
208
209
210
    /// Operator evaluated on the boundary of the domain with boundary index `b`
    /**
     * Adds an operator to the list of boundary operators to be assembled in
     * quadrature points on the boundary intersections.
     *
Praetorius, Simon's avatar
Praetorius, Simon committed
211
     * \param b     Boundary identifier where to assemble this operator. Can be
Praetorius, Simon's avatar
Praetorius, Simon committed
212
213
214
215
216
217
218
219
220
221
222
     *              constructed from an integer. \see BoundaryType
     * \param op    A (pre-) local operator, \see LocalOperator, \see GridFunctionOperator
     * \param path  TreePath identifying the sub-basis in the global basis tree
     *              corresponding to the row basis. \see treepath()
     *
     * Example:
     * ```
     * auto op = makeOperator(tag::test{}, [g](auto const& x) { return g(x); });
     * prob.addVectorOperator(BoundaryType{1}, op, _0);
     * ```
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
223
    template <class Operator, class TreePath = RootTreePath>
224
225
    void addVectorOperator(BoundaryType b, Operator const& op, TreePath path = {})
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
226
      using I = typename GridView::Intersection;
227
      rhs_->addOperator(tag::boundary_operator<I>{*boundaryManager_,b}, op, path);
228
    }
229
    /** @} */
230

231

Praetorius, Simon's avatar
Praetorius, Simon committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
    /// Add boundary conditions to the system
    /** @{ */
    /// Dirichlet boundary condition
    /**
     * Enforce Dirichlet boundary values for the solution vector on boundary
     * regions identified by the predicate.
     *
     * \param predicate  Functor `bool(WorldVector)` returning true for all
     *                   DOFs on the boundary that should be assigned a value.
     * \param row        TreePath identifying the sub-basis in the global basis tree
     *                   corresponding to the row basis. \see treepath()
     * \param col        TreePath identifying the sub-basis in the global basis tree
     *                   corresponding to the column basis. \see treepath()
     * \param values     Functor `Range(WorldVector)` or any \ref GridFunction
     *                   that is evaluated in the DOFs identified by the predicate.
     *
     * Example:
     * ```
     * prob.addDirichletBC([](auto const& x) { return x[0] < 1.e-8; }, 0, 0,
     *                     [](auto const& x) { return 0.0; });
     * ```
     **/
254
    template <class Predicate, class RowTreePath, class ColTreePath, class Values>
255
    void addDirichletBC(Predicate const& predicate,
256
                        RowTreePath row, ColTreePath col,
Praetorius, Simon's avatar
Praetorius, Simon committed
257
                        Values const& values);
258
259
260
261
262
263

    template <class RowTreePath, class ColTreePath, class Values>
    void addDirichletBC(BoundaryType id,
                        RowTreePath row, ColTreePath col,
                        Values const& values);

264
265
266
267
268
269
    template <class Identifier, class Values>
    void addDirichletBC(Identifier&& id, Values&& values)
    {
      addDirichletBC(FWD(id), RootTreePath{}, RootTreePath{}, FWD(values));
    }

270
271
272
    /// Add a periodic boundary conditions to the system, by specifying a face transformation
    /// y = A*x + b of coordinates. We assume, that A is orthonormal.
    void addPeriodicBC(BoundaryType id, WorldMatrix const& A, WorldVector const& b);
Praetorius, Simon's avatar
Praetorius, Simon committed
273
274
    /** @} */

275

276
  public:
277

278
279
280
281
282
    /// Implementation of \ref StandardProblemIteration::oneIteration.
    Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) override
    {
      return StandardProblemIteration::oneIteration(adaptInfo, toDo);
    }
283

284
    /// Implementation of \ref ProblemStatBase::buildAfterCoarse
285
286
287
288
    void buildAfterAdapt(AdaptInfo& adaptInfo,
                         Flag flag,
                         bool asmMatrix = true,
                         bool asmVector = true) override;
289

Praetorius, Simon's avatar
Praetorius, Simon committed
290
291
292
293
294
295
296
    /// \brief Assemble the linear system by calling \ref buildAfterAdapt with
    /// `asmMatrix` and `asmVector` set to true.
    void assemble(AdaptInfo& adaptInfo)
    {
      buildAfterAdapt(adaptInfo, Flag{0}, true, true);
    }

297
298
299
300
301
302
    /// Implementation of \ref ProblemStatBase::solve
    void solve(AdaptInfo& adaptInfo,
               bool createMatrixData = true,
               bool storeMatrixData = false) override;

    /// Implementation of \ref ProblemStatBase::estimate.
303
    void estimate(AdaptInfo& /*adaptInfo*/) override { /* do nothing. */ }
304
305
306
307
308
309
310
311
312
313
314
315
316

    /// Implementation of \ref ProblemStatBase::refineMesh.
    Flag adaptGrid(AdaptInfo& adaptInfo) override;

    /// Implementation of \ref ProblemStatBase::markElements.
    Flag markElements(AdaptInfo& adaptInfo) override;

    /// Uniform global grid coarsening by up to n level
    Flag globalCoarsen(int n) override;

    /// Uniform global refinement by n level
    Flag globalRefine(int n) override;

Praetorius, Simon's avatar
Praetorius, Simon committed
317
    /// Writes output files. If force=true write even if timestep out of write rhythm.
318
    void writeFiles(AdaptInfo& adaptInfo, bool force = false);
319

Praetorius, Simon's avatar
Praetorius, Simon committed
320

321
  public: // get-methods
322

Praetorius, Simon's avatar
Praetorius, Simon committed
323
    /// Implementation of \ref ProblemStatBase::name
324
    std::string const& name() const override { return name_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
325

326
    /// Return the \ref grid_
327
328
    std::shared_ptr<Grid>       grid()       { return grid_; }
    std::shared_ptr<Grid const> grid() const { return grid_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
329

330
    /// Return the gridView of the basis
331
    GridView gridView() const { return globalBasis_->gridView(); }
Praetorius, Simon's avatar
Praetorius, Simon committed
332

333
    /// Return the boundary manager to identify boundary segments
334
335
    std::shared_ptr<BoundaryManager<Grid>>       boundaryManager()       { return boundaryManager_; }
    std::shared_ptr<BoundaryManager<Grid> const> boundaryManager() const { return boundaryManager_; }
336

Praetorius, Simon's avatar
Praetorius, Simon committed
337
    /// Return the \ref globalBasis_
338
339
    std::shared_ptr<GlobalBasis>       globalBasis()       { return globalBasis_; }
    std::shared_ptr<GlobalBasis const> globalBasis() const { return globalBasis_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
340
341

    /// Return a reference to the linear solver, \ref linearSolver
Praetorius, Simon's avatar
Praetorius, Simon committed
342
343
    std::shared_ptr<LinearSolver>       solver()       { return linearSolver_; }
    std::shared_ptr<LinearSolver const> solver() const { return linearSolver_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
344

345
    /// Returns a reference to system-matrix, \ref systemMatrix_
346
347
    std::shared_ptr<SystemMatrix>       systemMatrix()       { return systemMatrix_; }
    std::shared_ptr<SystemMatrix const> systemMatrix() const { return systemMatrix_; }
348
349

    /// Returns a reference to the solution vector, \ref solution_
Praetorius, Simon's avatar
Praetorius, Simon committed
350
351
    std::shared_ptr<SolutionVector>       solutionVector()       { return solution_; }
    std::shared_ptr<SolutionVector const> solutionVector() const { return solution_; }
352
353

    /// Return a reference to the rhs system-vector, \ref rhs
354
355
    std::shared_ptr<SystemVector>       rhsVector()       { return rhs_; }
    std::shared_ptr<SystemVector const> rhsVector() const { return rhs_; }
356

357
358
359

    /// Return a mutable view to a solution component
    template <class TreePath = RootTreePath>
Praetorius, Simon's avatar
Praetorius, Simon committed
360
    auto solution(TreePath path = {})
361
    {
362
      assert(bool(solution_) && "You have to call initialize() before.");
363
      return solution_->child(path);
364
    }
365

366
367
    /// Return a const view to a solution component
    template <class TreePath = RootTreePath>
Praetorius, Simon's avatar
Praetorius, Simon committed
368
    auto solution(TreePath path = {}) const
369
    {
370
      assert(bool(solution_) && "You have to call initialize() before.");
371
      return solution_->child(path);
372
    }
373
374


Praetorius, Simon's avatar
Praetorius, Simon committed
375
  public: // set-methods
376

377
    /// Set a new linear solver for the problem
Praetorius, Simon's avatar
Praetorius, Simon committed
378
379
    template <class Solver_>
    void setSolver(Solver_&& solver)
380
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
381
      linearSolver_ = wrap_or_share(FWD(solver));
Praetorius, Simon's avatar
Praetorius, Simon committed
382
383
    }

384

385
    /// Set the grid. Stores pointer and initializes feSpaces
Praetorius, Simon's avatar
Praetorius, Simon committed
386
    /// matrices and vectors, as well as markers and file-writers.
Praetorius, Simon's avatar
Praetorius, Simon committed
387
388
389
    /// If grid is given as reference, wrap it into a non-destroying shared_ptr
    template <class Grid_>
    void setGrid(Grid_&& grid)
390
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
391
      adoptGrid(wrap_or_share(FWD(grid)));
392
      createGlobalBasis();
393
      createMatricesAndVectors();
Praetorius, Simon's avatar
Praetorius, Simon committed
394
      createMarker();
395
396
397
      createFileWriter();
    }

398
399
400
401
402

    /// Store the shared_ptr and the name of the marker in the problem
    /**
     * Note: multiple markers can be added but must have different names
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
403
404
    template <class Marker_>
    void addMarker(Marker_&& m)
Praetorius, Simon's avatar
Praetorius, Simon committed
405
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
406
407
      auto marker = wrap_or_share(FWD(m));
      auto it = marker_.emplace(marker->name(), marker);
Praetorius, Simon's avatar
Praetorius, Simon committed
408
      if (marker_.size() > 1)
409
        it.first->second->setMaximumMarking(true);
Praetorius, Simon's avatar
Praetorius, Simon committed
410
411
    }

412
413
414
415
416
417
418
419
420
421
422
    /// Remove a marker with the given name from the problem
    void removeMarker(std::string name)
    {
      std::size_t num = marker_.erase(name);
      test_warning(num == 1, "A marker with the given name '{}' does not exist.", name);
    }

    /// Remove a marker from the problem
    void removeMarker(Marker<Grid> const& marker)
    {
      removeMarker(marker.name());
Praetorius, Simon's avatar
Praetorius, Simon committed
423
424
    }

425

426
  protected: // initialization methods
427

Praetorius, Simon's avatar
Praetorius, Simon committed
428
429
430
431
432
433
    void createGlobalBasis();
    void createGrid();
    void createMatricesAndVectors();
    void createSolver();
    void createMarker();
    void createFileWriter();
434

435
    void adoptGlobalBasis(std::shared_ptr<GlobalBasis> globalBasis)
436
    {
437
      globalBasis_ = std::move(globalBasis);
438
      initGlobalBasis();
439
440
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
441
    void adoptGrid(std::shared_ptr<Grid> const& grid,
442
                   std::shared_ptr<BoundaryManager<Grid>> const& boundaryManager)
443
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
444
      grid_ = grid;
445
      boundaryManager_ = boundaryManager;
446
      Parameters::get(name_ + "->mesh", gridName_);
447
    }
448

Praetorius, Simon's avatar
Praetorius, Simon committed
449
450
451
452
453
454
    void adoptGrid(std::shared_ptr<Grid> const& grid)
    {
      adoptGrid(grid, std::make_shared<BoundaryManager<Grid>>(grid));
    }

    void adoptGrid(std::shared_ptr<typename Grid::HostGrid> const& hostGrid)
455
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
456
      auto grid = std::make_shared<Grid>(hostGrid);
457
458
459
      adoptGrid(grid, std::make_shared<BoundaryManager<Grid>>(grid));
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
460
  private:
461

Praetorius, Simon's avatar
Praetorius, Simon committed
462
463
    void createGlobalBasisImpl(std::true_type);
    void createGlobalBasisImpl(std::false_type);
464

465
    void initGlobalBasis();
466

467
  private:
468
    /// Name of this problem.
469
    std::string name_;
470

471
    /// Grid of this problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
472
    std::shared_ptr<Grid> grid_;
473

474
    /// Name of the grid
475
    std::string gridName_ = "mesh";
476

477
478
479
    /// Management of boundary conditions
    std::shared_ptr<BoundaryManager<Grid>> boundaryManager_;

480
    /// FE space of this problem.
481
    std::shared_ptr<GlobalBasis> globalBasis_;
482

483
    /// A FileWriter object
484
    std::list<std::shared_ptr<FileWriterInterface>> filewriter_;
485

486
    /// Pointer to the adaptation markers
487
    std::map<std::string, std::shared_ptr<Marker<Grid>>> marker_;
Praetorius, Simon's avatar
Praetorius, Simon committed
488
489
490

    /// Pointer to the estimators for this problem
//    std::vector<Estimator*> estimator;
491

492
    /// An object of the linearSolver Interface
Praetorius, Simon's avatar
Praetorius, Simon committed
493
    std::shared_ptr<LinearSolver> linearSolver_;
494

Praetorius, Simon's avatar
Praetorius, Simon committed
495
    /// Matrix that is filled during assembling
496
    std::shared_ptr<SystemMatrix> systemMatrix_;
497

Praetorius, Simon's avatar
Praetorius, Simon committed
498
    /// Vector with the solution components
Praetorius, Simon's avatar
Praetorius, Simon committed
499
    std::shared_ptr<SolutionVector> solution_;
500

Praetorius, Simon's avatar
Praetorius, Simon committed
501
    /// Vector (load-vector) corresponding to the right-hand side
502
    /// of the equation, filled during assembling
503
    std::shared_ptr<SystemVector> rhs_;
504

Praetorius, Simon's avatar
Praetorius, Simon committed
505
506
507
508
    /// A vector with the local element error estimates
    /// for each node in the basis tree, indexed by [to_string(treePath)][element index]
    std::map<std::string, std::vector<double>> estimates_;

509
  private: // some internal data-structures
510
    BoundaryConditions<SystemMatrix, SolutionVector, SystemVector, GlobalBasis, GlobalBasis> boundaryConditions_;
511
  };
512

Praetorius, Simon's avatar
Praetorius, Simon committed
513

514
  // Deduction guide
515
  template <class Grid, class GlobalBasis>
516
  ProblemStat(std::string const& name, Grid& grid, GlobalBasis& globalBasis)
517
    -> ProblemStat<DefaultProblemTraits<GlobalBasis>>;
518

519

520
521
522
523
  // mark templates as explicitly instantiated in cpp file
  extern template class ProblemStat<YaspGridBasis<2,1>>;
  extern template class ProblemStat<YaspGridBasis<2,2>>;

524
} // end namespace AMDiS
525
526

#include "ProblemStat.inc.hpp"