ProblemStat.hpp 19 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
36
#include <amdis/ProblemStatBase.hpp>
#include <amdis/ProblemStatTraits.hpp>
#include <amdis/StandardProblemIteration.hpp>

37
#include <amdis/common/SharedPtr.hpp>
38
#include <amdis/common/TupleUtility.hpp>
39
#include <amdis/common/TypeTraits.hpp>
40
41

#include <amdis/GridFunctions.hpp>
42
#include <amdis/gridfunctions/DiscreteFunction.hpp>
43

Praetorius, Simon's avatar
Praetorius, Simon committed
44
#include <amdis/io/FileWriterBase.hpp>
45

46
47
#include <amdis/typetree/TreeData.hpp>
#include <amdis/typetree/TreePath.hpp>
48

49
namespace AMDiS
50
{
51
52
53
54
  // forward declaration
  template <class Traits>
  class ProblemInstat;

55
  template <class Traits>
56
  class ProblemStat
Praetorius, Simon's avatar
Praetorius, Simon committed
57
      : public ProblemStatBase
58
      , public StandardProblemIterationAdaptor<ProblemStat<Traits>>
59
  {
60
    using Self = ProblemStat;
61

62
63
    friend class ProblemInstat<Traits>;

64
  public: // typedefs and static constants
65

66
    using GlobalBasis = typename Traits::GlobalBasis;
Praetorius, Simon's avatar
Praetorius, Simon committed
67
    using GridView    = typename GlobalBasis::GridView;
Praetorius, Simon's avatar
Praetorius, Simon committed
68
    using Grid        = AdaptiveGrid_t<typename GridView::Grid>;
Praetorius, Simon's avatar
Praetorius, Simon committed
69
    using Element     = typename GridView::template Codim<0>::Entity;
70
    using WorldVector = typename Element::Geometry::GlobalCoordinate;
71
    using WorldMatrix = FieldMatrix<typename WorldVector::field_type, WorldVector::dimension, WorldVector::dimension>;
72

73
    /// Dimension of the grid
74
    static constexpr int dim = Grid::dimension;
75

76
    /// Dimension of the world
77
    static constexpr int dow = Grid::dimensionworld;
78

Praetorius, Simon's avatar
Praetorius, Simon committed
79
80
81
82
83
  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;
84

Praetorius, Simon's avatar
Praetorius, Simon committed
85
86
87
88
89
  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>;
90

91
  public:
92
93
    /**
     * \brief Constructor. Takes the name of the problem that is used to
94
     * access values corresponding to this problem in the parameter file.
95
     **/
96
    explicit ProblemStat(std::string const& name)
97
      : name_(name)
98
    {}
99

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

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

118

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

Praetorius, Simon's avatar
Praetorius, Simon committed
126
127
128
129
130
131
132
133
    /// \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);

134

Praetorius, Simon's avatar
Praetorius, Simon committed
135
    /// Add an operator to \ref A.
136
    /** @{ */
Praetorius, Simon's avatar
Praetorius, Simon committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    /// 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
154
    template <class Operator, class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
155
156
157
158
    void addMatrixOperator(Operator const& op, RowTreePath row = {}, ColTreePath col = {})
    {
      systemMatrix_->addOperator(tag::element_operator<Element>{}, op, row, col);
    }
159

Praetorius, Simon's avatar
Praetorius, Simon committed
160
161
162
163
164
    /// 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
165
     * \param b    Boundary identifier where to assemble this operator. Can be
Praetorius, Simon's avatar
Praetorius, Simon committed
166
167
168
169
170
171
172
173
174
175
176
177
178
     *             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
179
    template <class Operator, class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
180
181
    void addMatrixOperator(BoundaryType b, Operator const& op, RowTreePath row = {}, ColTreePath col = {})
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
182
      using I = typename GridView::Intersection;
183
      systemMatrix_->addOperator(tag::boundary_operator<I>{boundaryManager_,b}, op, row, col);
184
    }
185
    /** @} */
186
187


Praetorius, Simon's avatar
Praetorius, Simon committed
188
    /// Add an operator to \ref rhs.
189
    /** @{ */
Praetorius, Simon's avatar
Praetorius, Simon committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
    /// 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
205
    template <class Operator, class TreePath = RootTreePath>
206
207
208
209
    void addVectorOperator(Operator const& op, TreePath path = {})
    {
      rhs_->addOperator(tag::element_operator<Element>{}, op, path);
    }
210

Praetorius, Simon's avatar
Praetorius, Simon committed
211
212
213
214
215
    /// 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
216
     * \param b     Boundary identifier where to assemble this operator. Can be
Praetorius, Simon's avatar
Praetorius, Simon committed
217
218
219
220
221
222
223
224
225
226
227
     *              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
228
    template <class Operator, class TreePath = RootTreePath>
229
230
    void addVectorOperator(BoundaryType b, Operator const& op, TreePath path = {})
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
231
      using I = typename GridView::Intersection;
232
      rhs_->addOperator(tag::boundary_operator<I>{boundaryManager_,b}, op, path);
233
    }
234
    /** @} */
235

236

Praetorius, Simon's avatar
Praetorius, Simon committed
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
    /// 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; });
     * ```
     **/
259
    template <class Predicate, class RowTreePath, class ColTreePath, class Values>
260
    void addDirichletBC(Predicate const& predicate,
261
                        RowTreePath row, ColTreePath col,
Praetorius, Simon's avatar
Praetorius, Simon committed
262
                        Values const& values);
263
264
265
266
267
268

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

269
270
271
272
273
274
    template <class Identifier, class Values>
    void addDirichletBC(Identifier&& id, Values&& values)
    {
      addDirichletBC(FWD(id), RootTreePath{}, RootTreePath{}, FWD(values));
    }

275
276
277
    /// 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
278
279
    /** @} */

280

281
  public:
282

283
284
285
286
287
    /// Implementation of \ref StandardProblemIteration::oneIteration.
    Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) override
    {
      return StandardProblemIteration::oneIteration(adaptInfo, toDo);
    }
288

289
    /// Implementation of \ref ProblemStatBase::buildAfterCoarse
290
291
292
293
    void buildAfterAdapt(AdaptInfo& adaptInfo,
                         Flag flag,
                         bool asmMatrix = true,
                         bool asmVector = true) override;
294

Praetorius, Simon's avatar
Praetorius, Simon committed
295
296
297
298
299
300
301
    /// \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);
    }

302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
    /// Implementation of \ref ProblemStatBase::solve
    void solve(AdaptInfo& adaptInfo,
               bool createMatrixData = true,
               bool storeMatrixData = false) override;

    /// Implementation of \ref ProblemStatBase::estimate.
    void estimate(AdaptInfo& adaptInfo) override { /* do nothing. */ }

    /// 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
322
    /// Writes output files. If force=true write even if timestep out of write rhythm.
323
    void writeFiles(AdaptInfo& adaptInfo, bool force = false);
324

Praetorius, Simon's avatar
Praetorius, Simon committed
325

326
  public: // get-methods
327

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

331
    /// Return the \ref grid_
332
333
    std::shared_ptr<Grid>       grid()       { return grid_; }
    std::shared_ptr<Grid const> grid() const { return grid_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
334

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

338
    /// Return the boundary manager to identify boundary segments
339
340
    std::shared_ptr<BoundaryManager<Grid>>       boundaryManager()       { return boundaryManager_; }
    std::shared_ptr<BoundaryManager<Grid> const> boundaryManager() const { return boundaryManager_; }
341

Praetorius, Simon's avatar
Praetorius, Simon committed
342
    /// Return the \ref globalBasis_
343
344
    std::shared_ptr<GlobalBasis>       globalBasis()       { return globalBasis_; }
    std::shared_ptr<GlobalBasis const> globalBasis() const { return globalBasis_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
345
346

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

350
    /// Returns a reference to system-matrix, \ref systemMatrix_
351
352
    std::shared_ptr<SystemMatrix>       systemMatrix()       { return systemMatrix_; }
    std::shared_ptr<SystemMatrix const> systemMatrix() const { return systemMatrix_; }
353
354

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

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

362
363
364

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

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


Praetorius, Simon's avatar
Praetorius, Simon committed
380
  public: // set-methods
381

382
    /// Set a new linear solver for the problem
Praetorius, Simon's avatar
Praetorius, Simon committed
383
384
    template <class Solver_>
    void setSolver(Solver_&& solver)
385
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
386
      linearSolver_ = wrap_or_share(FWD(solver));
Praetorius, Simon's avatar
Praetorius, Simon committed
387
388
    }

389

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

403
404
405
406
407

    /// 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
408
409
    template <class Marker_>
    void addMarker(Marker_&& m)
Praetorius, Simon's avatar
Praetorius, Simon committed
410
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
411
412
      auto marker = wrap_or_share(FWD(m));
      auto it = marker_.emplace(marker->name(), marker);
Praetorius, Simon's avatar
Praetorius, Simon committed
413
      if (marker_.size() > 1)
414
        it.first->second->setMaximumMarking(true);
Praetorius, Simon's avatar
Praetorius, Simon committed
415
416
    }

417
418
419
420
421
422
423
424
425
426
427
    /// 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
428
429
    }

430

431
  protected: // initialization methods
432

Praetorius, Simon's avatar
Praetorius, Simon committed
433
434
435
436
437
438
    void createGlobalBasis();
    void createGrid();
    void createMatricesAndVectors();
    void createSolver();
    void createMarker();
    void createFileWriter();
439

440
    void adoptGlobalBasis(std::shared_ptr<GlobalBasis> globalBasis)
441
    {
442
      globalBasis_ = std::move(globalBasis);
443
      initGlobalBasis();
444
445
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
446
    void adoptGrid(std::shared_ptr<Grid> const& grid,
447
                   std::shared_ptr<BoundaryManager<Grid>> const& boundaryManager)
448
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
449
      grid_ = grid;
450
      boundaryManager_ = boundaryManager;
451
      Parameters::get(name_ + "->mesh", gridName_);
452
    }
453

Praetorius, Simon's avatar
Praetorius, Simon committed
454
455
456
457
458
459
    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)
460
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
461
      auto grid = std::make_shared<Grid>(hostGrid);
462
463
464
      adoptGrid(grid, std::make_shared<BoundaryManager<Grid>>(grid));
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
465
  private:
466

Praetorius, Simon's avatar
Praetorius, Simon committed
467
468
    void createGlobalBasisImpl(std::true_type);
    void createGlobalBasisImpl(std::false_type);
469

470
    void initGlobalBasis();
471

472
  private:
473
    /// Name of this problem.
474
    std::string name_;
475

476
    /// Grid of this problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
477
    std::shared_ptr<Grid> grid_;
478

479
    /// Name of the grid
480
    std::string gridName_ = "mesh";
481

482
483
484
    /// Management of boundary conditions
    std::shared_ptr<BoundaryManager<Grid>> boundaryManager_;

485
    /// FE space of this problem.
486
    std::shared_ptr<GlobalBasis> globalBasis_;
487

488
    /// A FileWriter object
489
    std::list<std::shared_ptr<FileWriterInterface>> filewriter_;
490

491
    /// Pointer to the adaptation markers
492
    std::map<std::string, std::shared_ptr<Marker<Grid>>> marker_;
Praetorius, Simon's avatar
Praetorius, Simon committed
493
494
495

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

497
    /// An object of the linearSolver Interface
Praetorius, Simon's avatar
Praetorius, Simon committed
498
    std::shared_ptr<LinearSolver> linearSolver_;
499

Praetorius, Simon's avatar
Praetorius, Simon committed
500
    /// Matrix that is filled during assembling
501
    std::shared_ptr<SystemMatrix> systemMatrix_;
502

Praetorius, Simon's avatar
Praetorius, Simon committed
503
    /// Vector with the solution components
Praetorius, Simon's avatar
Praetorius, Simon committed
504
    std::shared_ptr<SolutionVector> solution_;
505

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

Praetorius, Simon's avatar
Praetorius, Simon committed
510
511
512
513
    /// 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_;

514

515
516
  private: // some internal data-structures

517
518
    DirichletBCs<GlobalBasis, GlobalBasis> dirichletBCs_;
    PeriodicBCs<GlobalBasis, GlobalBasis> periodicBCs_;
519
  };
520

Praetorius, Simon's avatar
Praetorius, Simon committed
521

522
523
524
#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
  // Deduction rule
  template <class Grid, class GlobalBasis>
525
  ProblemStat(std::string const& name, Grid& grid, GlobalBasis& globalBasis)
526
527
528
529
530
531
    -> ProblemStat<DefaultProblemTraits<GlobalBasis>>;
#endif

  // Generator for ProblemStat with given Grid and GlobalBasis
  template <class Grid, class GlobalBasis>
  ProblemStat<DefaultProblemTraits<GlobalBasis>>
532
  makeProblemStat(std::string const& name, Grid& grid, GlobalBasis& globalBasis)
533
  {
534
    return {name, grid, globalBasis};
535
536
  }

537
538
539
540
  // mark templates as explicitly instantiated in cpp file
  extern template class ProblemStat<YaspGridBasis<2,1>>;
  extern template class ProblemStat<YaspGridBasis<2,2>>;

541
} // end namespace AMDiS
542
543

#include "ProblemStat.inc.hpp"