ProblemStat.h 20.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * 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.
 * 
 ******************************************************************************/
20
21


22

23
/** \file ProblemStat.h */
24

25
26
#ifndef AMDIS_PROBLEM_STAT_H
#define AMDIS_PROBLEM_STAT_H
27

Thomas Witkowski's avatar
Thomas Witkowski committed
28
29
#include <vector>
#include <list>
30
#include "AMDiS_fwd.h"
31
#include "ProblemStatBase.h"
32
#include "Initfile.h"
33
34
35
#include "Boundary.h"
#include "MatrixVector.h"
#include "StandardProblemIteration.h"
36
#include "io/ElementFileWriter.h"
Thomas Witkowski's avatar
Thomas Witkowski committed
37
#include "ComponentTraverseInfo.h"
38
#include "AbstractFunction.h"
39
#include "solver/SolverMatrix.h"
40
#include "SystemVector.h"
41
42
43

namespace AMDiS {

44
45
46
47
48
49
  struct OperatorPos 
  {
    int row, col;
    double *factor, *estFactor;
  };

50

51
52
53
54
55
56
57
  /**
   * \ingroup Problem 
   *
   * \brief
   * This class defines the stationary problem definition in sequential
   * computations. For parallel computations, see \ref ParallelProblemStatBase.
   **/
58
  class ProblemStatSeq : public ProblemStatBase
59
  {
60
  protected:
61
    // Defines a mapping type from dof indices to world coordinates.
62
    typedef std::map<DegreeOfFreedom, WorldVector<double> > DofToCoord;
63
64

    // Defines a mapping type from dof indices to world coordinates.
65
    typedef std::map<WorldVector<double>, DegreeOfFreedom> CoordToDof;
66

67
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
68
    /// Constructor
69
    ProblemStatSeq(std::string nameStr,
70
		   ProblemIterationInterface *problemIteration = NULL);
71

Thomas Witkowski's avatar
Thomas Witkowski committed
72
    /// Destructor
Thomas Witkowski's avatar
Thomas Witkowski committed
73
    virtual ~ProblemStatSeq();
74

Thomas Witkowski's avatar
Thomas Witkowski committed
75
    /// Initialisation of the problem.
76
    virtual void initialize(Flag initFlag,
77
			    ProblemStatSeq *adoptProblem = NULL,
78
79
			    Flag adoptFlag = INIT_NOTHING);

Thomas Witkowski's avatar
Thomas Witkowski committed
80
    /// Used in \ref initialize().
81
82
    virtual void createMesh();

83
84
85
    /// Used in \ref initialize().
    virtual void createRefCoarseManager();

Thomas Witkowski's avatar
Thomas Witkowski committed
86
    /// Used in \ref initialize().
87
    virtual void createFeSpace(DOFAdmin *admin);
88

Thomas Witkowski's avatar
Thomas Witkowski committed
89
    /// Used in \ref initialize().
90
91
    virtual void createMatricesAndVectors();

Thomas Witkowski's avatar
Thomas Witkowski committed
92
    /// Used in \ref initialize().
93
94
    virtual void createSolver();

Thomas Witkowski's avatar
Thomas Witkowski committed
95
    /// Used in \ref initialize().
96
97
    virtual void createEstimator();

Thomas Witkowski's avatar
Thomas Witkowski committed
98
    /// Used in \ref initialize().
99
100
    virtual void createMarker();

Thomas Witkowski's avatar
Thomas Witkowski committed
101
    /// Used in \ref initialize().
102
103
    virtual void createFileWriter();

104
105
    /// Used in \ref initialize(). This function is deprecated and should not 
    /// be used anymore. There is no guarantee that it will work in the future.
106
107
    virtual void doOtherStuff();

108
109
    /// Implementation of ProblemStatBase::solve(). Deligates the solving
    /// of problems system to \ref solver.
110
111
    void solve(AdaptInfo *adaptInfo,
	       bool createMatrixData = true,
112
	       bool storeMatrixData = false) override;
113

114
115
    /// Implementation of ProblemStatBase::estimate(). Deligates the estimation
    /// to \ref estimator.
116
    void estimate(AdaptInfo *adaptInfo) override;
117

118
119
    /// Implementation of ProblemStatBase::markElements().
    /// Deligated to \ref adapt.
120
    Flag markElements(AdaptInfo *adaptInfo) override;
121

122
123
    /// Implementation of ProblemStatBase::refineMesh(). Deligated to the
    /// RefinementManager of \ref adapt.
124
    Flag refineMesh(AdaptInfo *adaptInfo) override;
125

126
127
    /// Implementation of ProblemStatBase::coarsenMesh(). Deligated to the
    /// CoarseningManager of \ref adapt.
128
    Flag coarsenMesh(AdaptInfo *adaptInfo) override;
129

130
131
    /// Implementation of ProblemStatBase::buildBeforeRefine().
    /// Does nothing here.
132
    void buildBeforeRefine(AdaptInfo *adaptInfo, Flag) override {}
133

134
135
    /// Implementation of ProblemStatBase::buildBeforeCoarsen().
    /// Does nothing here.
136
    void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag) override {}
137

138
139
140
    /// Implementation of ProblemStatBase::buildAfterCoarsen().
    /// Assembles \ref A and \ref rhs. With the last two parameters, assembling
    /// can be restricted to matrices or vectors only.
141
    void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag flag,
142
				   bool assembleMatrix = true,
143
				   bool assembleVector = true) override;
144

145
146
    bool dualMeshTraverseRequired();

147
148
    void dualAssemble(AdaptInfo *adaptInfo, Flag flag, 
		      bool asmMatrix = true, bool asmVector = true);
149

150
151
152
    /// Determines the execution order of the single adaption steps. If adapt is
    /// true, mesh adaption will be performed. This allows to avoid mesh adaption,
    /// e.g. in timestep adaption loops of timestep adaptive strategies.
153
    Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION) override;
154

Thomas Witkowski's avatar
Thomas Witkowski committed
155
    /// Returns number of managed problems
156
    int getNumProblems() override
157
    { 
158
      return 1; 
Thomas Witkowski's avatar
Thomas Witkowski committed
159
    }
160

161
    /// Implementation of ProblemStatBase::getNumComponents(), TODO: Wrong!!
162
163
    virtual int getNumComponents() 
    { 
164
      return nComponents; 
Thomas Witkowski's avatar
Thomas Witkowski committed
165
    }
166
167
168
169
170
    
    virtual int getNumAddComponents()
    {
      return nAddComponents;
    }
171

172
173
    /// Returns the problem with the given number. If only one problem
    /// is managed by this master problem, the number hasn't to be given.
174
    ProblemStatBase *getProblem(int number = 0) override
175
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
176
      return this; 
Thomas Witkowski's avatar
Thomas Witkowski committed
177
    }
178

179
    /// Writes output files. TODO: Make obsolete.
180
181
    void writeFiles(AdaptInfo *adaptInfo, bool force);

182
183
184
    /// Writes output files.
    void writeFiles(AdaptInfo &adaptInfo, bool force);

Thomas Witkowski's avatar
Thomas Witkowski committed
185
    /// Interpolates fct to \ref solution.
186
    void interpolInitialSolution(std::vector<AbstractFunction<double, WorldVector<double> >*> *fct);
187

188
    /// Adds an operator to \ref A.
189
    void addMatrixOperator(Operator *op, int i, int j,
190
			   double *factor = NULL, double *estFactor = NULL);
191

192
    /// Adds an operator to \ref A.
193
    void addMatrixOperator(Operator &op, int i, int j,
194
			   double *factor = NULL, double *estFactor = NULL);
195

196
    /// Adds an operator to \ref rhs.
197
    void addVectorOperator(Operator *op, int i,
198
			   double *factor = NULL, double *estFactor = NULL);
199

200
    /// Adds an operator to \ref rhs.
201
    void addVectorOperator(Operator &op, int i,
202
			   double *factor = NULL, double *estFactor = NULL);
203

204
205
    /// Adds a Dirichlet boundary condition, where the rhs is given by an 
    /// abstract function.
206
    virtual void addDirichletBC(BoundaryType type, int row, int col,
207
208
				AbstractFunction<double, WorldVector<double> > *b);

209
210
    /// Adds a Dirichlet boundary condition, where the rhs is given by a DOF
    /// vector.
211
212
213
    virtual void addDirichletBC(BoundaryType type, int row, int col,
				DOFVector<double> *vec);

214
215
    /// Adds a Neumann boundary condition, where the rhs is given by an
    /// abstract function.
216
217
218
    virtual void addNeumannBC(BoundaryType type, int row, int col, 
			      AbstractFunction<double, WorldVector<double> > *n);

219
220
221
222
223
224
    /// Adds a Neumann boundary condition, where the rhs is given by an DOF
    /// vector.
    virtual void addNeumannBC(BoundaryType type, int row, int col, 
			      DOFVector<double> *n);

    /// Adds Robin boundary condition.
225
226
227
228
    virtual void addRobinBC(BoundaryType type, int row, int col, 
			    AbstractFunction<double, WorldVector<double> > *n,
			    AbstractFunction<double, WorldVector<double> > *r);

229
230
231
232
233
234
235
236
237
238
    /// Adds Robin boundary condition.
    virtual void addRobinBC(BoundaryType type, int row, int col, 
			    DOFVector<double> *n,
			    DOFVector<double> *r);

    /// Adds Robin boundary condition.
    virtual void addRobinBC(BoundaryType type, int row, int col, 
			    Operator *n,
			    Operator *r);

239
    /// Adds a periodic boundary condition.
240
241
    virtual void addPeriodicBC(BoundaryType type, int row, int col);

242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
    /// add boundary operator to matrix side
    virtual void addBoundaryMatrixOperator(BoundaryType type, 
          Operator *op, int row, int col);

    virtual void addBoundaryMatrixOperator(BoundaryType type, 
          Operator &op, int row, int col)
    {
      addBoundaryMatrixOperator(type, &op, row, col);
    }

    /// add boundary operator to rhs (vector) side
    virtual void addBoundaryVectorOperator(BoundaryType type, 
          Operator *op, int row);

    virtual void addBoundaryVectorOperator(BoundaryType type, 
          Operator &op, int row)
    {
      addBoundaryVectorOperator(type, &op, row);
    }

262
263
    /// This function assembles a DOFMatrix and a DOFVector for the case,
    /// the meshes from row and col FE-space are equal.
264
    void assembleOnOneMesh(const FiniteElemSpace *feSpace, 
Thomas Witkowski's avatar
Thomas Witkowski committed
265
			   Flag assembleFlag,
Thomas Witkowski's avatar
Thomas Witkowski committed
266
267
			   DOFMatrix *matrix, DOFVector<double> *vector);

Thomas Witkowski's avatar
Thomas Witkowski committed
268
269

    ///
270
271
272
273
    void assembleBoundaryConditions(DOFVector<double> *rhs,
				    DOFVector<double> *solution,
				    Mesh *mesh,
				    Flag assembleFlag);
274
275

 
276
277
278
279
    /** \name getting methods
     * \{ 
     */

Thomas Witkowski's avatar
Thomas Witkowski committed
280
    /// Returns \ref solution.
281
282
    inline SystemVector* getSolution() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
283
284
      return solution; 
    }
285

286
    inline DOFVector<double>* getSolution(int i)
287
288
289
290
    {
      return solution->getDOFVector(i);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
291
    /// Returns \ref rhs.
292
    inline SystemVector* getRhs() 
293
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
294
295
      return rhs; 
    }
296

297
    inline DOFVector<double>* getRhsVector(int i = 0)
298
299
300
301
    {
      return rhs->getDOFVector(i);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
302
    /// Returns \ref systemMatrix.
303
304
    inline Matrix<DOFMatrix*> *getSystemMatrix() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
305
306
      return systemMatrix; 
    }
307

Thomas Witkowski's avatar
Thomas Witkowski committed
308
    /// Returns a pointer to the corresponding DOFMatrix.
309
310
    inline DOFMatrix* getSystemMatrix(int row, int col) 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
311
312
313
314
      return (*systemMatrix)[row][col];
    }

    /// Returns mesh of given component
315
    inline Mesh* getMesh(int comp = 0) 
316
    {
317
      FUNCNAME("ProblemStatSeq::getMesh()");
Thomas Witkowski's avatar
Thomas Witkowski committed
318
      TEST_EXIT(comp < static_cast<int>(componentMeshes.size()) && comp >= 0)
319
	("invalid component number\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
320
      return componentMeshes[comp]; 
Thomas Witkowski's avatar
Thomas Witkowski committed
321
    }
322

Thomas Witkowski's avatar
Thomas Witkowski committed
323
    /// Returns \ref meshes
324
    inline std::vector<Mesh*> getMeshes() 
325
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
326
327
      return meshes; 
    }
328

Thomas Witkowski's avatar
Thomas Witkowski committed
329
    /// Returns \ref feSpace_.
330
    inline const FiniteElemSpace* getFeSpace(int comp = 0) 
331
    { 
332
      FUNCNAME("ProblemStatSeq::getFeSpace()");
333
      TEST_EXIT(comp < static_cast<int>(componentSpaces.size()) && comp >= 0)
334
	("invalid component number: %d\n", comp);
335
      return componentSpaces[comp]; 
Thomas Witkowski's avatar
Thomas Witkowski committed
336
    }
337

Thomas Witkowski's avatar
Thomas Witkowski committed
338
    /// Returns \ref feSpaces.
339
    inline std::vector<const FiniteElemSpace*>& getFeSpaces() 
340
    { 
341
      return feSpaces; 
Thomas Witkowski's avatar
Thomas Witkowski committed
342
    }
343

Thomas Witkowski's avatar
Thomas Witkowski committed
344
    /// Returns \ref componentSpaces;
345
    inline std::vector<const FiniteElemSpace*>& getComponentSpaces() 
346
    {
347
      return componentSpaces;
348
349
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
350
    /// Returns \ref estimator.
351
    inline std::vector<Estimator*> getEstimators() 
352
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
353
354
      return estimator; 
    }
355

Thomas Witkowski's avatar
Thomas Witkowski committed
356
    /// Returns \ref estimator.
357
    inline Estimator* getEstimator(int comp = 0) 
358
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
359
360
      return estimator[comp]; 
    }
361

Thomas Witkowski's avatar
Thomas Witkowski committed
362
    /// Returns \ref refinementManager.
363
    inline RefinementManager* getRefinementManager(int comp = 0) 
364
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
365
366
      return refinementManager; 
    }
367

Thomas Witkowski's avatar
Thomas Witkowski committed
368
    /// Returns \ref refinementManager.
369
    inline CoarseningManager* getCoarseningManager(int comp = 0) 
370
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
371
372
      return coarseningManager; 
    }
373

Thomas Witkowski's avatar
Thomas Witkowski committed
374
    /// Returns \ref solver.
375
    inline LinearSolverInterface* getSolver() 
376
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
377
378
      return solver; 
    }
379

Thomas Witkowski's avatar
Thomas Witkowski committed
380
    /// Returns \ref marker.
381
    inline Marker *getMarker(int comp = 0) 
382
    { 
383
      return marker[comp]; 
Thomas Witkowski's avatar
Thomas Witkowski committed
384
    }
385

Thomas Witkowski's avatar
Thomas Witkowski committed
386
    /// Returns \ref marker.
387
    inline std::vector<Marker*> getMarkers() 
388
    { 
389
      return marker; 
Thomas Witkowski's avatar
Thomas Witkowski committed
390
    }
391

Thomas Witkowski's avatar
Thomas Witkowski committed
392
    /// Returns the name of the problem
393
    inline std::string getName() override
394
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
395
396
      return name; 
    }
397

Praetorius, Simon's avatar
Praetorius, Simon committed
398
    /// Returns the name of the problem
399
    inline std::string getComponentName(int comp = 0)
Praetorius, Simon's avatar
Praetorius, Simon committed
400
401
402
403
404
405
    {
      TEST_EXIT(comp < static_cast<int>(componentNames.size()) && comp >= 0)
	("invalid component number\n");
      return componentNames[comp];
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
406
    /// Returns \ref useGetBound.
407
408
    inline bool getBoundUsed() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
409
410
      return useGetBound; 
    }
411

412
413
414
415
416
417
    /// Returns \ref info.
    int getInfo()
    {
      return info;
    }

418
419
420
421
422
423
    /// Returns \ref deserialized;
    bool isDeserialized()
    {
      return deserialized;
    }

424
425
426
427
428
429
    /** \} */

    /** \name setting methods
     * \{ 
     */

Thomas Witkowski's avatar
Thomas Witkowski committed
430
    /// Sets \ref estimator.
431
    inline void setEstimator(std::vector<Estimator*> est) 
432
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
433
434
      estimator = est; 
    }
435

Thomas Witkowski's avatar
Thomas Witkowski committed
436
    /// Sets the FE space for the given component.
437
    inline void setFeSpace(const FiniteElemSpace *feSpace, int comp = 0) 
438
    {
439
      feSpaces[comp] = feSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
440
    }
441

442
443
444
445
446
    void setFeSpaces(std::vector<FiniteElemSpace const*> feSpaces_)
    {
      feSpaces = feSpaces_;
    }

447
    void setComponentSpace(int comp, const FiniteElemSpace *feSpace)
448
449
450
    {
      if (static_cast<int>(componentSpaces.size()) < nComponents)
        componentSpaces.resize(nComponents);
451
      TEST_EXIT(comp >= 0 && comp < nComponents + nAddComponents)
452
453
454
455
456
        ("Component number not in feasable range!");

      componentSpaces[comp] = feSpace;
    }
    
Thomas Witkowski's avatar
Thomas Witkowski committed
457
    /// Sets \ref estimator.
458
    inline void setEstimator(Estimator* est, int comp = 0) 
459
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
460
461
      estimator[comp] = est; 
    }
462

Thomas Witkowski's avatar
Thomas Witkowski committed
463
    /// Sets \ref marker.
464
    inline void setMarker(Marker* mark, int comp = 0) 
465
    { 
466
      marker[comp] = mark; 
Thomas Witkowski's avatar
Thomas Witkowski committed
467
    }
468

Thomas Witkowski's avatar
Thomas Witkowski committed
469
    /// Sets \ref solver.
470
    inline void setSolver(LinearSolverInterface* sol) 
471
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
472
473
      solver = sol; 
    }
474

475
476
477
478
479
    void setSolverMatrix(SolverMatrix<Matrix<DOFMatrix*> >& solverMatrix_)
    {
      solverMatrix.setMatrix(*solverMatrix_.getOriginalMat());
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
480
    ///
481
    inline void setAssembleMatrixOnlyOnce(int i = 0, int j = 0, bool value = true) 
482
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
483
      assembleMatrixOnlyOnce[i][j] = value;
484
485
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
486
    ///
487
    void setExactSolutionFct(AbstractFunction<double, WorldVector<double> > *fct,
488
489
			     int component) 
    {
490
491
492
      exactSolutionFcts[component] = fct;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
493
    ///
494
    AbstractFunction<double, WorldVector<double> > *getExactSolutionFct(int i = 0) 
495
    {
496
      return exactSolutionFcts[i];
497
498
    }

499
    ///
500
    std::vector< AbstractFunction<double, WorldVector<double> >* > getExactSolutionFcts() 
501
502
503
504
    {
      return exactSolutionFcts;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
505
    ///
506
507
    void setComputeExactError(bool v) 
    {
508
509
510
      computeExactError = v;
    }

511
512
513
514
515
516
    /// Sets \ref writeAsmInfo;
    void setWriteAsmInfo(bool b)
    {
      writeAsmInfo = b;
    }

517
    void setMeshes(std::vector<Mesh*> meshes_)
518
519
520
521
522
523
524
525
526
    {
      meshes = meshes_;
      nMeshes = static_cast<int>(meshes.size());
    }

    void setComponentMesh(int comp, Mesh* mesh)
    {
      if (static_cast<int>(componentMeshes.size()) < nComponents)
        componentMeshes.resize(nComponents);
527
      TEST_EXIT(comp >= 0 && comp < nComponents + nAddComponents)
528
529
530
531
532
533
534
535
536
537
538
539
540
541
        ("Component number not in feasable range!");

      componentMeshes[comp] = mesh;
    }

    void setRefinementManager(RefinementManager *ref)
    {
      refinementManager = ref;
    }

    void setCoarseningManager(CoarseningManager *coarse)
    {
      coarseningManager = coarse;
    }
542
543
    /** \} */

544
545
    /// Outputs the mesh of the given component, but the values are taken from
    /// the residual error estimator. 
546
    void writeResidualMesh(int comp, AdaptInfo *adaptInfo, std::string name);
547

Thomas Witkowski's avatar
Thomas Witkowski committed
548
    /// Function that implements the serialization procedure.
549
    void serialize(std::ostream &out) override;
550

Thomas Witkowski's avatar
Thomas Witkowski committed
551
    /// Function that implements the deserialization procedure.
552
    void deserialize(std::istream &in) override;
Thomas Witkowski's avatar
Thomas Witkowski committed
553
554

    /// Returns \ref fileWriters.
555
    std::vector<FileWriterInterface*>& getFileWriterList() 
556
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
557
558
      return fileWriters;
    }
559
560
561
562
563
564
565
566
567
568
    
    double getSolutionTime()
    {
      return solutionTime;
    }
    
    double getBuildTime()
    {
      return buildTime;
    }
569

Thomas Witkowski's avatar
Thomas Witkowski committed
570
  protected:
571
572
    /// If the exact solution is known, the problem can compute the exact
    /// error instead of the error estimation. This is done in this function.
Thomas Witkowski's avatar
Thomas Witkowski committed
573
574
    void computeError(AdaptInfo *adaptInfo);

575
  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
576
577
    
    /// Name of this problem.
578
    std::string name;
579

Thomas Witkowski's avatar
Thomas Witkowski committed
580
    /// Number of problem components
581
    int nComponents;
582
583
584
    
    /// Number of additional components
    int nAddComponents;
585

586
587
    /// Stores the names for all components. Is used for naming the solution
    /// vectors, \ref solution.
588
    std::vector<std::string> componentNames;
589

590
591
592
    /// Number of problem meshes. If all components are defined on the same mesh,
    /// this number is 1. Otherwise, this variable is the number of different meshes
    /// within the problem.
Thomas Witkowski's avatar
Thomas Witkowski committed
593
594
595
    int nMeshes;

    /// FE spaces of this problem.
596
    std::vector<const FiniteElemSpace*> feSpaces;
597

Thomas Witkowski's avatar
Thomas Witkowski committed
598
    /// Meshes of this problem.
599
    std::vector<Mesh*> meshes;
600

Thomas Witkowski's avatar
Thomas Witkowski committed
601
    /// Pointer to the fe spaces for the different problem components
602
    std::vector<const FiniteElemSpace*> componentSpaces;
603

Thomas Witkowski's avatar
Thomas Witkowski committed
604
    /// Pointer to the meshes for the different problem components
605
    std::vector<Mesh*> componentMeshes;
606

607
608
609
    /// Stores information about which meshes must be traversed to assemble the
    /// specific components. I.e., it was implemented to make use of different
    /// meshes for different components.
Thomas Witkowski's avatar
Thomas Witkowski committed
610
611
612
    ComponentTraverseInfo traverseInfo;
    
    /// Responsible for element marking.
613
    std::vector<Marker*> marker;
614

Thomas Witkowski's avatar
Thomas Witkowski committed
615
    /// Estimator of this problem. Used in \ref estimate().
616
    std::vector<Estimator*> estimator;
617

Thomas Witkowski's avatar
Thomas Witkowski committed
618
    /// Linear solver of this problem. Used in \ref solve().
619
    LinearSolverInterface *solver;
620

Thomas Witkowski's avatar
Thomas Witkowski committed
621
622
    /// System vector  storing the calculated solution of the problem.
    SystemVector *solution;
623

Thomas Witkowski's avatar
Thomas Witkowski committed
624
625
    /// System vector for the right hand side 
    SystemVector *rhs;
626

Thomas Witkowski's avatar
Thomas Witkowski committed
627
628
    /// System matrix
    Matrix<DOFMatrix*> *systemMatrix;
629

630
631
632
    /// Composed system matrix
    SolverMatrix<Matrix<DOFMatrix*> > solverMatrix;

633
634
635
636
637
    /// Some DOFMatrices of the systemMatrix may be assembled only once (for
    /// example if they are independent of the time or older solutions). If
    /// [i][j] of this field is set to true, the corresponding DOFMatrix will
    /// be assembled only once. All other matrices will be assembled at every
    /// time step.
638
    std::vector<std::vector<bool> > assembleMatrixOnlyOnce;
639

640
641
642
643
    /// If [i][j] of this field is set to true, the corresponding DOFMatrix of
    /// the systemMatrix has been assembled at least once. This field is used
    /// to determine, if assembling of a matrix can be ommitted, if it is set
    /// to be assembled only once.
644
    std::vector<std::vector<bool> > assembledMatrix;
645

Thomas Witkowski's avatar
Thomas Witkowski committed
646
647
    /// Determines whether domain boundaries should be considered at assembling.
    bool useGetBound;
648

Thomas Witkowski's avatar
Thomas Witkowski committed
649
    /// Writes the meshes and solution after the adaption loop.
650
    std::vector<FileWriterInterface*> fileWriters;
651

652
653
654
    /// All actions of mesh refinement are performed by refinementManager.
    /// If new refinement algorithms should be realized, one has to override
    /// RefinementManager and give one instance of it to AdaptStationary.
Thomas Witkowski's avatar
Thomas Witkowski committed
655
    RefinementManager *refinementManager;
656

657
658
659
    /// All actions of mesh coarsening are performed by coarseningManager.
    /// If new coarsening algorithms should be realized, one has to override
    /// CoarseningManager and give one instance of it to AdaptStationary.
Thomas Witkowski's avatar
Thomas Witkowski committed
660
    CoarseningManager *coarseningManager;
661
  
Thomas Witkowski's avatar
Thomas Witkowski committed
662
663
    /// Info level.
    int info;
664

665
666
    /// If true, the stationary problem was deserialized from some serialization
    /// file.
667
668
    bool deserialized;

669
670
671
    /// This vectors stores pointers to functions defining the exact solution of
    /// the problem. This may be used to compute the real error of the computed
    /// solution.
672
    std::vector<AbstractFunction<double, WorldVector<double> >*> exactSolutionFcts;
673

674
675
    /// If true, the error is not estimated but computed from the exact solution
    /// defined by \ref exactSolutionFcts.
676
    bool computeExactError;
677
    
678
679
680
681
    /// If at least on boundary condition is set, this variable is true. It is 
    /// used to ensure that no operators are added after boundary condition were
    /// set. If this would happen, boundary conditions could set wrong on off 
    /// diagonal matrices.
682
    bool boundaryConditionSet;
683

684
685
    /// If true, AMDiS prints information about the assembling procedure to 
    /// the screen.
686
    bool writeAsmInfo;
687

688
    std::map<Operator*, std::vector<OperatorPos> > operators;
689
690
691
    
    double solutionTime;
    double buildTime;
692
693
    
    template <class> friend class detail::CouplingProblemStat;
694
  };
695
696

#ifndef HAVE_PARALLEL_DOMAIN_AMDIS
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
  struct ProblemStat : public ProblemStatSeq, 
		       public StandardProblemIteration
  {
    typedef ProblemStatSeq super;
    using super::getName;
    
    ProblemStat(std::string nameStr,
		ProblemIterationInterface *problemIteration = NULL)
      : super(nameStr, problemIteration),
	StandardProblemIteration(this)
    { }

    Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo)
    {
      for (int i = 0; i < getNumComponents(); i++)
	if (adaptInfo->spaceToleranceReached(i))
	  adaptInfo->allowRefinement(false, i);
	else
	  adaptInfo->allowRefinement(true, i);	

      return StandardProblemIteration::oneIteration(adaptInfo, toDo);
    }
  };
720
#endif
721
722
723
}

#endif