ProblemStat.hpp 20 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
    /// \brief Constructor taking a grid and basis.
105
    /// Wraps both in shared pointers.
106
107
108
    template <class Grid_, class Basis_,
      class B_ = Underlying_t<Basis_>,
      REQUIRES(Concepts::GlobalBasis<B_>)>
Praetorius, Simon's avatar
Praetorius, Simon committed
109
    ProblemStat(std::string const& name, Grid_&& grid, Basis_&& globalBasis)
110
      : ProblemStat(name, FWD(grid))
111
    {
112
      adoptGlobalBasis(wrap_or_share(FWD(globalBasis)));
113
    }
Praetorius, Simon's avatar
Praetorius, Simon committed
114

115
116
117
118
119
120
121
122
123
124
    /// \brief Constructor taking a grid and pre-basis factory to create a global basis
    /// on the fly.
    template <class Grid_, class PBF_,
      class GV_ = typename Underlying_t<Grid_>::LeafGridView,
      REQUIRES(Concepts::PreBasisFactory<PBF_,GV_>)>
    ProblemStat(std::string const& name, Grid_&& grid, PBF_ const& preBasisFactory)
      : ProblemStat(name, FWD(grid))
    {
      adoptGlobalBasis(makeSharedPtr(ParallelGlobalBasis{grid_->leafGridView(), preBasisFactory}));
    }
125

Praetorius, Simon's avatar
Praetorius, Simon committed
126
    /// \brief Initialisation of the problem.
127
    /**
Praetorius, Simon's avatar
Praetorius, Simon committed
128
129
     * Parameters read in initialize()
     *   - `[GRID_NAME]->global refinements`:  nr of initial global refinements
130
     **/
Praetorius, Simon's avatar
Praetorius, Simon committed
131
    void initialize(Flag initFlag, Self* adoptProblem = nullptr, Flag adoptFlag = INIT_NOTHING);
132

Praetorius, Simon's avatar
Praetorius, Simon committed
133
134
135
136
137
138
139
140
    /// \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);

141

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

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


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

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

243

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

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

276
277
278
279
280
281
    template <class Identifier, class Values>
    void addDirichletBC(Identifier&& id, Values&& values)
    {
      addDirichletBC(FWD(id), RootTreePath{}, RootTreePath{}, FWD(values));
    }

282
283
284
    /// 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
285
286
    /** @} */

287

288
  public:
289

290
291
292
293
294
    /// Implementation of \ref StandardProblemIteration::oneIteration.
    Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) override
    {
      return StandardProblemIteration::oneIteration(adaptInfo, toDo);
    }
295

296
    /// Implementation of \ref ProblemStatBase::buildAfterCoarse
297
298
299
300
    void buildAfterAdapt(AdaptInfo& adaptInfo,
                         Flag flag,
                         bool asmMatrix = true,
                         bool asmVector = true) override;
301

Praetorius, Simon's avatar
Praetorius, Simon committed
302
303
304
305
306
307
308
    /// \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);
    }

309
310
311
312
313
314
    /// Implementation of \ref ProblemStatBase::solve
    void solve(AdaptInfo& adaptInfo,
               bool createMatrixData = true,
               bool storeMatrixData = false) override;

    /// Implementation of \ref ProblemStatBase::estimate.
315
    void estimate(AdaptInfo& /*adaptInfo*/) override { /* do nothing. */ }
316
317
318
319
320
321
322
323
324
325
326
327
328

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

Praetorius, Simon's avatar
Praetorius, Simon committed
332

333
  public: // get-methods
334

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

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

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

345
    /// Return the boundary manager to identify boundary segments
346
347
    std::shared_ptr<BoundaryManager<Grid>>       boundaryManager()       { return boundaryManager_; }
    std::shared_ptr<BoundaryManager<Grid> const> boundaryManager() const { return boundaryManager_; }
348

Praetorius, Simon's avatar
Praetorius, Simon committed
349
    /// Return the \ref globalBasis_
350
351
    std::shared_ptr<GlobalBasis>       globalBasis()       { return globalBasis_; }
    std::shared_ptr<GlobalBasis const> globalBasis() const { return globalBasis_; }
Praetorius, Simon's avatar
Praetorius, Simon committed
352
353

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

357
    /// Returns a reference to system-matrix, \ref systemMatrix_
358
359
    std::shared_ptr<SystemMatrix>       systemMatrix()       { return systemMatrix_; }
    std::shared_ptr<SystemMatrix const> systemMatrix() const { return systemMatrix_; }
360
361

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

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

369
370
371

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

378
379
    /// Return a const view to a solution component
    template <class TreePath = RootTreePath>
Praetorius, Simon's avatar
Praetorius, Simon committed
380
    auto solution(TreePath path = {}) const
381
    {
382
      assert(bool(solution_) && "You have to call initialize() before.");
383
      return solution_->child(path);
384
    }
385
386


Praetorius, Simon's avatar
Praetorius, Simon committed
387
  public: // set-methods
388

389
    /// Set a new linear solver for the problem
Praetorius, Simon's avatar
Praetorius, Simon committed
390
391
    template <class Solver_>
    void setSolver(Solver_&& solver)
392
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
393
      linearSolver_ = wrap_or_share(FWD(solver));
Praetorius, Simon's avatar
Praetorius, Simon committed
394
395
    }

396

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

410
411
412
413
414

    /// 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
415
416
    template <class Marker_>
    void addMarker(Marker_&& m)
Praetorius, Simon's avatar
Praetorius, Simon committed
417
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
418
419
      auto marker = wrap_or_share(FWD(m));
      auto it = marker_.emplace(marker->name(), marker);
Praetorius, Simon's avatar
Praetorius, Simon committed
420
      if (marker_.size() > 1)
421
        it.first->second->setMaximumMarking(true);
Praetorius, Simon's avatar
Praetorius, Simon committed
422
423
    }

424
425
426
427
428
429
430
431
432
433
434
    /// 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
435
436
    }

437

438
  protected: // initialization methods
439

Praetorius, Simon's avatar
Praetorius, Simon committed
440
441
442
443
444
445
    void createGlobalBasis();
    void createGrid();
    void createMatricesAndVectors();
    void createSolver();
    void createMarker();
    void createFileWriter();
446

447
    void adoptGlobalBasis(std::shared_ptr<GlobalBasis> globalBasis)
448
    {
449
      globalBasis_ = std::move(globalBasis);
450
      initGlobalBasis();
451
452
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
453
    void adoptGrid(std::shared_ptr<Grid> const& grid,
454
                   std::shared_ptr<BoundaryManager<Grid>> const& boundaryManager)
455
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
456
      grid_ = grid;
457
      boundaryManager_ = boundaryManager;
458
      Parameters::get(name_ + "->mesh", gridName_);
459
    }
460

Praetorius, Simon's avatar
Praetorius, Simon committed
461
462
463
464
465
466
    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)
467
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
468
      auto grid = std::make_shared<Grid>(hostGrid);
469
470
471
      adoptGrid(grid, std::make_shared<BoundaryManager<Grid>>(grid));
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
472
  private:
473

Praetorius, Simon's avatar
Praetorius, Simon committed
474
475
    void createGlobalBasisImpl(std::true_type);
    void createGlobalBasisImpl(std::false_type);
476

477
    void initGlobalBasis();
478

479
  private:
480
    /// Name of this problem.
481
    std::string name_;
482

483
    /// Grid of this problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
484
    std::shared_ptr<Grid> grid_;
485

486
    /// Name of the grid
487
    std::string gridName_ = "mesh";
488

489
490
491
    /// Management of boundary conditions
    std::shared_ptr<BoundaryManager<Grid>> boundaryManager_;

492
    /// FE space of this problem.
493
    std::shared_ptr<GlobalBasis> globalBasis_;
494

495
    /// A FileWriter object
496
    std::list<std::shared_ptr<FileWriterInterface>> filewriter_;
497

498
    /// Pointer to the adaptation markers
499
    std::map<std::string, std::shared_ptr<Marker<Grid>>> marker_;
Praetorius, Simon's avatar
Praetorius, Simon committed
500
501
502

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

504
    /// An object of the linearSolver Interface
Praetorius, Simon's avatar
Praetorius, Simon committed
505
    std::shared_ptr<LinearSolver> linearSolver_;
506

Praetorius, Simon's avatar
Praetorius, Simon committed
507
    /// Matrix that is filled during assembling
508
    std::shared_ptr<SystemMatrix> systemMatrix_;
509

Praetorius, Simon's avatar
Praetorius, Simon committed
510
    /// Vector with the solution components
Praetorius, Simon's avatar
Praetorius, Simon committed
511
    std::shared_ptr<SolutionVector> solution_;
512

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

Praetorius, Simon's avatar
Praetorius, Simon committed
517
518
519
520
    /// 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_;

521
  private: // some internal data-structures
522
    BoundaryConditions<SystemMatrix, SolutionVector, SystemVector, GlobalBasis, GlobalBasis> boundaryConditions_;
523
  };
524

Praetorius, Simon's avatar
Praetorius, Simon committed
525

526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
  namespace Impl
  {
    template <class Grid, class B, class = void>
    struct DeducedProblemTraits;

    template <class Grid, class PB>
    struct DeducedProblemTraits<Grid,ParallelGlobalBasis<PB>,void>
    {
      using type = DefaultProblemTraits<ParallelGlobalBasis<PB>>;
    };

    template <class G, class PBF>
    struct DeducedProblemTraits<G,PBF,
      std::enable_if_t<Concepts::PreBasisFactory<PBF,typename G::LeafGridView>>>
    {
      using Grid = AdaptiveGrid_t<G>;
      using GridView = typename Grid::LeafGridView;
      using Basis = decltype(ParallelGlobalBasis{std::declval<GridView>(),std::declval<PBF>()});

      using type = DefaultProblemTraits<Basis>;
    };

    template <class Grid, class Basis>
    using DeducedProblemTraits_t = typename DeducedProblemTraits<Grid,Basis>::type;
  }


553
  // Deduction guide
554
555
556
  template <class Grid, class Basis>
  ProblemStat(std::string name, Grid&& grid, Basis&& globalBasis)
    -> ProblemStat<Impl::DeducedProblemTraits_t<Underlying_t<Grid>,Underlying_t<Basis>>>;
557

558

559
560
561
562
  // mark templates as explicitly instantiated in cpp file
  extern template class ProblemStat<YaspGridBasis<2,1>>;
  extern template class ProblemStat<YaspGridBasis<2,2>>;

563
} // end namespace AMDiS
564
565

#include "ProblemStat.inc.hpp"