ProblemStat.h 20 KB
Newer Older
1 2 3 4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6 7
// ==                                                                        ==
// ============================================================================
8 9 10 11 12 13 14 15 16 17 18 19
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


20

21
/** \file ProblemStat.h */
22

23 24
#ifndef AMDIS_PROBLEM_STAT_H
#define AMDIS_PROBLEM_STAT_H
25

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

namespace AMDiS {

42 43
  using namespace std;

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

51

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

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

67
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
68
    /// Constructor
69
    ProblemStatSeq(string nameStr,
70 71
	       ProblemIterationInterface *problemIteration = NULL)
      : StandardProblemIteration(this),
Thomas Witkowski's avatar
Thomas Witkowski committed
72
	name(nameStr),
73
	nComponents(-1),
Thomas Witkowski's avatar
Thomas Witkowski committed
74 75 76 77 78 79 80
	nMeshes(0),
	traverseInfo(0),
	solver(NULL),
	solution(NULL),
	rhs(NULL),
	systemMatrix(NULL),
	useGetBound(true),
81 82
        refinementManager(NULL),
        coarseningManager(NULL),
Thomas Witkowski's avatar
Thomas Witkowski committed
83
	info(10),
84
	deserialized(false),
85
	computeExactError(false),
86 87
	boundaryConditionSet(false),
	writeAsmInfo(false)
88
    {
89
      Parameters::get(name + "->components", nComponents);
90
      TEST_EXIT(nComponents > 0)("components not set!\n");    
Thomas Witkowski's avatar
Thomas Witkowski committed
91
      estimator.resize(nComponents, NULL);
92
      marker.resize(nComponents, NULL);
93

Thomas Witkowski's avatar
Thomas Witkowski committed
94 95
      assembleMatrixOnlyOnce.resize(nComponents);
      assembledMatrix.resize(nComponents);
96
      for (int i = 0; i < nComponents; i++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
97 98
	assembleMatrixOnlyOnce[i].resize(nComponents);
	assembledMatrix[i].resize(nComponents);
99
	for (int j = 0; j < nComponents; j++) {
Thomas Witkowski's avatar
Thomas Witkowski committed
100 101
	  assembleMatrixOnlyOnce[i][j] = false;
	  assembledMatrix[i][j] = false;
102 103
	}
      }
104 105

      exactSolutionFcts.resize(nComponents);
Thomas Witkowski's avatar
Thomas Witkowski committed
106
    }
107

Thomas Witkowski's avatar
Thomas Witkowski committed
108
    /// Destructor
109
    virtual ~ProblemStatSeq() {}
110

Thomas Witkowski's avatar
Thomas Witkowski committed
111
    /// Initialisation of the problem.
112
    virtual void initialize(Flag initFlag,
113
			    ProblemStatSeq *adoptProblem = NULL,
114 115
			    Flag adoptFlag = INIT_NOTHING);

Thomas Witkowski's avatar
Thomas Witkowski committed
116
    /// Used in \ref initialize().
117 118
    virtual void createMesh();

119 120 121
    /// Used in \ref initialize().
    virtual void createRefCoarseManager();

Thomas Witkowski's avatar
Thomas Witkowski committed
122
    /// Used in \ref initialize().
123
    virtual void createFeSpace(DOFAdmin *admin);
124

Thomas Witkowski's avatar
Thomas Witkowski committed
125
    /// Used in \ref initialize().
126 127
    virtual void createMatricesAndVectors();

Thomas Witkowski's avatar
Thomas Witkowski committed
128
    /// Used in \ref initialize().
129 130
    virtual void createSolver();

Thomas Witkowski's avatar
Thomas Witkowski committed
131
    /// Used in \ref initialize().
132 133
    virtual void createEstimator();

Thomas Witkowski's avatar
Thomas Witkowski committed
134
    /// Used in \ref initialize().
135 136
    virtual void createMarker();

Thomas Witkowski's avatar
Thomas Witkowski committed
137
    /// Used in \ref initialize().
138 139
    virtual void createFileWriter();

140 141 142 143
    /** \brief
     * 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.
     */
144 145 146 147 148 149
    virtual void doOtherStuff();

    /** \brief
     * Implementation of ProblemStatBase::solve(). Deligates the solving
     * of problems system to \ref solver.
     */
150
    virtual void solve(AdaptInfo *adaptInfo, bool fixedMatrix = false);
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179

    /** \brief
     * Implementation of ProblemStatBase::estimate(). Deligates the estimation
     * to \ref estimator.
     */
    virtual void estimate(AdaptInfo *adaptInfo);

    /** \brief
     * Implementation of ProblemStatBase::markElements().
     * Deligated to \ref adapt.
     */
    virtual Flag markElements(AdaptInfo *adaptInfo);

    /** \brief
     * Implementation of ProblemStatBase::refineMesh(). Deligated to the
     * RefinementManager of \ref adapt.
     */
    virtual Flag refineMesh(AdaptInfo *adaptInfo);

    /** \brief
     * Implementation of ProblemStatBase::coarsenMesh(). Deligated to the
     * CoarseningManager of \ref adapt.
     */
    virtual Flag coarsenMesh(AdaptInfo *adaptInfo);

    /** \brief
     * Implementation of ProblemStatBase::buildBeforeRefine().
     * Does nothing here.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
180
    virtual void buildBeforeRefine(AdaptInfo *adaptInfo, Flag) {}
181 182 183 184 185

    /** \brief
     * Implementation of ProblemStatBase::buildBeforeCoarsen().
     * Does nothing here.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
186
    virtual void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag) {}
187 188 189

    /** \brief
     * Implementation of ProblemStatBase::buildAfterCoarsen().
190 191
     * Assembles \ref A and \ref rhs. With the last two parameters, assembling
     * can be restricted to matrices or vectors only.
192
     */
193 194 195
    virtual void buildAfterCoarsen(AdaptInfo *adaptInfo, Flag flag,
				   bool assembleMatrix = true,
				   bool assembleVector = true);
196

197 198
    void buildAfterCoarsen_sebastianMode(AdaptInfo *adaptInfo, Flag flag);

199 200
    bool dualMeshTraverseRequired();

201 202
    void dualAssemble(AdaptInfo *adaptInfo, Flag flag, 
		      bool asmMatrix = true, bool asmVector = true);
203

204 205 206 207 208 209 210
    /** \brief
     * 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.
     */
    virtual Flag oneIteration(AdaptInfo *adaptInfo, Flag toDo = FULL_ITERATION);

Thomas Witkowski's avatar
Thomas Witkowski committed
211
    /// Returns number of managed problems
212 213
    virtual int getNumProblems() 
    { 
214
      return 1; 
Thomas Witkowski's avatar
Thomas Witkowski committed
215
    }
216

Thomas Witkowski's avatar
Thomas Witkowski committed
217
    /// Implementation of ProblemStatBase::getNumComponents()
218 219
    virtual int getNumComponents() 
    { 
220
      return nComponents; 
Thomas Witkowski's avatar
Thomas Witkowski committed
221
    }
222 223 224 225 226

    /** \brief
     * Returns the problem with the given number. If only one problem
     * is managed by this master problem, the number hasn't to be given.
     */
227 228
    virtual ProblemStatBase *getProblem(int number = 0) 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
229
      return this; 
Thomas Witkowski's avatar
Thomas Witkowski committed
230
    }
231

232
    /// Writes output files. TODO: Make obsolete.
233 234
    void writeFiles(AdaptInfo *adaptInfo, bool force);

235 236 237
    /// Writes output files.
    void writeFiles(AdaptInfo &adaptInfo, bool force);

Thomas Witkowski's avatar
Thomas Witkowski committed
238
    /// Interpolates fct to \ref solution.
239
    void interpolInitialSolution(vector<AbstractFunction<double, WorldVector<double> >*> *fct);
240

241
    /// Adds an operator to \ref A.
242
    void addMatrixOperator(Operator *op, int i, int j,
243 244
			   double *factor = NULL, double *estFactor = NULL);

245
    /// Adds an operator to \ref A.
246 247
    void addMatrixOperator(Operator &op, int i, int j,
			   double *factor = NULL, double *estFactor = NULL);
248

249
    /// Adds an operator to \ref rhs.
250
    void addVectorOperator(Operator *op, int i,
251 252
			   double *factor = NULL, double *estFactor = NULL);

253
    /// Adds an operator to \ref rhs.
254 255
    void addVectorOperator(Operator &op, int i,
			   double *factor = NULL, double *estFactor = NULL);
256

257 258
    /// Adds a Dirichlet boundary condition, where the rhs is given by an 
    /// abstract function.
259
    virtual void addDirichletBC(BoundaryType type, int row, int col,
260 261
				AbstractFunction<double, WorldVector<double> > *b);

262 263
    /// Adds a Dirichlet boundary condition, where the rhs is given by a DOF
    /// vector.
264 265 266
    virtual void addDirichletBC(BoundaryType type, int row, int col,
				DOFVector<double> *vec);

267 268
    /// Adds a Neumann boundary condition, where the rhs is given by an
    /// abstract function.
269 270 271
    virtual void addNeumannBC(BoundaryType type, int row, int col, 
			      AbstractFunction<double, WorldVector<double> > *n);

272 273 274 275 276 277
    /// 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.
278 279 280 281
    virtual void addRobinBC(BoundaryType type, int row, int col, 
			    AbstractFunction<double, WorldVector<double> > *n,
			    AbstractFunction<double, WorldVector<double> > *r);

282 283 284 285 286 287 288 289 290 291
    /// 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);

292
    /// Adds a periodic boundary condition.
293 294
    virtual void addPeriodicBC(BoundaryType type, int row, int col);

295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
    /// 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);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
315 316 317 318
    /** \brief
     * This function assembles a DOFMatrix and a DOFVector for the case,
     * the meshes from row and col FE-space are equal.
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
319 320
    void assembleOnOneMesh(FiniteElemSpace *feSpace, 
			   Flag assembleFlag,
Thomas Witkowski's avatar
Thomas Witkowski committed
321 322
			   DOFMatrix *matrix, DOFVector<double> *vector);

Thomas Witkowski's avatar
Thomas Witkowski committed
323 324

    ///
325 326 327 328
    void assembleBoundaryConditions(DOFVector<double> *rhs,
				    DOFVector<double> *solution,
				    Mesh *mesh,
				    Flag assembleFlag);
329 330 331 332 333
  
    /** \name getting methods
     * \{ 
     */

Thomas Witkowski's avatar
Thomas Witkowski committed
334
    /// Returns \ref solution.
335 336
    inline SystemVector* getSolution() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
337 338
      return solution; 
    }
339

340
    inline DOFVector<double>* getSolution(int i)
341 342 343 344
    {
      return solution->getDOFVector(i);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
345
    /// Returns \ref rhs.
346
    inline SystemVector* getRhs() 
347
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
348 349
      return rhs; 
    }
350

351 352 353 354 355
    inline const DOFVector<double>* getRhsVector(int i = 0)
    {
      return rhs->getDOFVector(i);
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
356
    /// Returns \ref systemMatrix.
357 358
    inline Matrix<DOFMatrix*> *getSystemMatrix() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
359 360
      return systemMatrix; 
    }
361

Thomas Witkowski's avatar
Thomas Witkowski committed
362
    /// Returns a pointer to the corresponding DOFMatrix.
363 364
    inline DOFMatrix* getSystemMatrix(int row, int col) 
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
365 366 367 368
      return (*systemMatrix)[row][col];
    }

    /// Returns mesh of given component
369
    inline Mesh* getMesh(int comp = 0) 
370
    {
371
      FUNCNAME("ProblemStatSeq::getMesh()");
Thomas Witkowski's avatar
Thomas Witkowski committed
372
      TEST_EXIT(comp < static_cast<int>(componentMeshes.size()) && comp >= 0)
373
	("invalid component number\n");
Thomas Witkowski's avatar
Thomas Witkowski committed
374
      return componentMeshes[comp]; 
Thomas Witkowski's avatar
Thomas Witkowski committed
375
    }
376

Thomas Witkowski's avatar
Thomas Witkowski committed
377
    /// Returns \ref meshes
378
    inline vector<Mesh*> getMeshes() 
379
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
380 381
      return meshes; 
    }
382

Thomas Witkowski's avatar
Thomas Witkowski committed
383
    /// Returns \ref feSpace_.
384
    inline FiniteElemSpace* getFeSpace(int comp = 0) 
385
    { 
386
      FUNCNAME("ProblemStatSeq::getFeSpace()");
387
      TEST_EXIT(comp < static_cast<int>(componentSpaces.size()) && comp >= 0)
388
	("invalid component number\n");
389
      return componentSpaces[comp]; 
Thomas Witkowski's avatar
Thomas Witkowski committed
390
    }
391

Thomas Witkowski's avatar
Thomas Witkowski committed
392
    /// Returns \ref feSpaces.
393
    inline vector<FiniteElemSpace*> getFeSpaces() 
394
    { 
395
      return feSpaces; 
Thomas Witkowski's avatar
Thomas Witkowski committed
396
    }
397

Thomas Witkowski's avatar
Thomas Witkowski committed
398
    /// Returns \ref componentSpaces;
399
    inline vector<FiniteElemSpace*> getComponentFeSpaces() 
400
    {
401
      return componentSpaces;
402 403
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
404
    /// Returns \ref estimator.
405
    inline vector<Estimator*> getEstimators() 
406
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
407 408
      return estimator; 
    }
409

Thomas Witkowski's avatar
Thomas Witkowski committed
410
    /// Returns \ref estimator.
411
    inline Estimator* getEstimator(int comp = 0) 
412
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
413 414
      return estimator[comp]; 
    }
415

Thomas Witkowski's avatar
Thomas Witkowski committed
416
    /// Returns \ref refinementManager.
417
    inline RefinementManager* getRefinementManager(int comp = 0) 
418
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
419 420
      return refinementManager; 
    }
421

Thomas Witkowski's avatar
Thomas Witkowski committed
422
    /// Returns \ref refinementManager.
423
    inline CoarseningManager* getCoarseningManager(int comp = 0) 
424
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
425 426
      return coarseningManager; 
    }
427

Thomas Witkowski's avatar
Thomas Witkowski committed
428
    /// Returns \ref solver.
429 430
    inline OEMSolver* getSolver() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
431 432
      return solver; 
    }
433

Thomas Witkowski's avatar
Thomas Witkowski committed
434
    /// Returns \ref marker.
435
    inline Marker *getMarker(int comp = 0) 
436
    { 
437
      return marker[comp]; 
Thomas Witkowski's avatar
Thomas Witkowski committed
438
    }
439

Thomas Witkowski's avatar
Thomas Witkowski committed
440
    /// Returns \ref marker.
441
    inline vector<Marker*> getMarkers() 
442
    { 
443
      return marker; 
Thomas Witkowski's avatar
Thomas Witkowski committed
444
    }
445

Thomas Witkowski's avatar
Thomas Witkowski committed
446
    /// Returns the name of the problem
447
    inline virtual string getName() 
448
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
449 450
      return name; 
    }
451

Thomas Witkowski's avatar
Thomas Witkowski committed
452
    /// Returns \ref useGetBound.
453 454
    inline bool getBoundUsed() 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
455 456
      return useGetBound; 
    }
457

458 459 460 461 462 463
    /// Returns \ref info.
    int getInfo()
    {
      return info;
    }

464 465 466 467 468 469
    /// Returns \ref deserialized;
    bool isDeserialized()
    {
      return deserialized;
    }

470 471 472 473 474 475
    /** \} */

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

Thomas Witkowski's avatar
Thomas Witkowski committed
476
    /// Sets \ref estimator.
477
    inline void setEstimator(vector<Estimator*> est) 
478
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
479 480
      estimator = est; 
    }
481

Thomas Witkowski's avatar
Thomas Witkowski committed
482
    /// Sets the FE space for the given component.
483
    inline void setFeSpace(FiniteElemSpace *feSpace, int comp = 0) 
484
    {
485
      feSpaces[comp] = feSpace;
Thomas Witkowski's avatar
Thomas Witkowski committed
486
    }
487

Thomas Witkowski's avatar
Thomas Witkowski committed
488
    /// Sets \ref estimator.
489
    inline void setEstimator(Estimator* est, int comp = 0) 
490
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
491 492
      estimator[comp] = est; 
    }
493

Thomas Witkowski's avatar
Thomas Witkowski committed
494
    /// Sets \ref marker.
495
    inline void setMarker(Marker* mark, int comp = 0) 
496
    { 
497
      marker[comp] = mark; 
Thomas Witkowski's avatar
Thomas Witkowski committed
498
    }
499

Thomas Witkowski's avatar
Thomas Witkowski committed
500
    /// Sets \ref solver.
501 502
    inline void setSolver(OEMSolver* sol) 
    { 
Thomas Witkowski's avatar
Thomas Witkowski committed
503 504
      solver = sol; 
    }
505

Thomas Witkowski's avatar
Thomas Witkowski committed
506
    ///
507
    inline void setAssembleMatrixOnlyOnce(int i = 0, int j = 0, bool value = true) 
508
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
509
      assembleMatrixOnlyOnce[i][j] = value;
510 511
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
512
    ///
513
    void setExactSolutionFct(AbstractFunction<double, WorldVector<double> > *fct,
514 515
			     int component) 
    {
516 517 518
      exactSolutionFcts[component] = fct;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
519
    ///
520
    AbstractFunction<double, WorldVector<double> > *getExactSolutionFct(int i = 0) 
521
    {
522
      return exactSolutionFcts[i];
523 524
    }

525 526 527 528 529 530
    ///
    vector< AbstractFunction<double, WorldVector<double> >* > getExactSolutionFcts() 
    {
      return exactSolutionFcts;
    }

Thomas Witkowski's avatar
Thomas Witkowski committed
531
    ///
532 533
    void setComputeExactError(bool v) 
    {
534 535 536
      computeExactError = v;
    }

537 538 539 540 541 542
    /// Sets \ref writeAsmInfo;
    void setWriteAsmInfo(bool b)
    {
      writeAsmInfo = b;
    }

543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
    void setMeshes(vector<Mesh*> meshes_)
    {
      meshes = meshes_;
      nMeshes = static_cast<int>(meshes.size());
    }

    void setComponentMesh(int comp, Mesh* mesh)
    {
      if (static_cast<int>(componentMeshes.size()) < nComponents)
        componentMeshes.resize(nComponents);
      TEST_EXIT(comp >= 0 && comp < nComponents)
        ("Component number not in feasable range!");

      componentMeshes[comp] = mesh;
    }

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

    void setCoarseningManager(CoarseningManager *coarse)
    {
      coarseningManager = coarse;
    }
568 569
    /** \} */

Thomas Witkowski's avatar
Thomas Witkowski committed
570 571 572 573
    /** \brief
     * Outputs the mesh of the given component, but the values are taken from the 
     * residual error estimator. 
     */
574
    void writeResidualMesh(int comp, AdaptInfo *adaptInfo, string name);
575

Thomas Witkowski's avatar
Thomas Witkowski committed
576
    /// Function that implements the serialization procedure.
577
    virtual void serialize(ostream &out);
578

Thomas Witkowski's avatar
Thomas Witkowski committed
579
    /// Function that implements the deserialization procedure.
580
    virtual void deserialize(istream &in);
581

Thomas Witkowski's avatar
Thomas Witkowski committed
582 583

    /// Returns \ref fileWriters.
584
    vector<FileWriterInterface*>& getFileWriterList() 
585
    {
Thomas Witkowski's avatar
Thomas Witkowski committed
586 587
      return fileWriters;
    }
588

Thomas Witkowski's avatar
Thomas Witkowski committed
589 590 591 592 593 594 595
  protected:
    /** \brief
     * If the exact solution is known, the problem can compute the exact
     * error instead of the error estimation. This is done in this function.
     */
    void computeError(AdaptInfo *adaptInfo);

596
  protected:
Thomas Witkowski's avatar
Thomas Witkowski committed
597 598
    
    /// Name of this problem.
599
    string name;
600

Thomas Witkowski's avatar
Thomas Witkowski committed
601
    /// Number of problem components
602
    int nComponents;
603 604

    /** \brief
Thomas Witkowski's avatar
Thomas Witkowski committed
605 606 607
     * 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.
608
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
609 610 611
    int nMeshes;

    /// FE spaces of this problem.
612
    vector<FiniteElemSpace*> feSpaces;
613

Thomas Witkowski's avatar
Thomas Witkowski committed
614
    /// Meshes of this problem.
615
    vector<Mesh*> meshes;
616

Thomas Witkowski's avatar
Thomas Witkowski committed
617
    /// Pointer to the fe spaces for the different problem components
618
    vector<FiniteElemSpace*> componentSpaces;
619

Thomas Witkowski's avatar
Thomas Witkowski committed
620
    /// Pointer to the meshes for the different problem components
621
    vector<Mesh*> componentMeshes;
622 623

    /** \brief
Thomas Witkowski's avatar
Thomas Witkowski committed
624 625 626
     * 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.
627
     */
Thomas Witkowski's avatar
Thomas Witkowski committed
628 629 630
    ComponentTraverseInfo traverseInfo;
    
    /// Responsible for element marking.
631
    vector<Marker*> marker;
632

Thomas Witkowski's avatar
Thomas Witkowski committed
633
    /// Estimator of this problem. Used in \ref estimate().
634
    vector<Estimator*> estimator;
635

Thomas Witkowski's avatar
Thomas Witkowski committed
636
    /// Linear solver of this problem. Used in \ref solve().
637
    OEMSolver *solver;
638

Thomas Witkowski's avatar
Thomas Witkowski committed
639 640
    /// System vector  storing the calculated solution of the problem.
    SystemVector *solution;
641

Thomas Witkowski's avatar
Thomas Witkowski committed
642 643
    /// System vector for the right hand side 
    SystemVector *rhs;
644

Thomas Witkowski's avatar
Thomas Witkowski committed
645 646
    /// System matrix
    Matrix<DOFMatrix*> *systemMatrix;
647

648 649 650
    /// Composed system matrix
    SolverMatrix<Matrix<DOFMatrix*> > solverMatrix;

651 652 653 654 655 656 657
    /** \brief
     * 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.
     */
658
    vector<vector<bool> > assembleMatrixOnlyOnce;
659 660 661

    /** \brief
     * If [i][j] of this field is set to true, the corresponding DOFMatrix of
Thomas Witkowski's avatar
Thomas Witkowski committed
662
     * the systemMatrix has been assembled at least once. This field is used
663 664 665
     * to determine, if assembling of a matrix can be ommitted, if it is set
     * to be assembled only once.
     */
666
    vector<vector<bool> > assembledMatrix;
667

Thomas Witkowski's avatar
Thomas Witkowski committed
668 669
    /// Determines whether domain boundaries should be considered at assembling.
    bool useGetBound;
670

Thomas Witkowski's avatar
Thomas Witkowski committed
671
    /// Writes the meshes and solution after the adaption loop.
672
    vector<FileWriterInterface*> fileWriters;
673 674 675 676 677 678

    /** \brief
     * 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
679
    RefinementManager *refinementManager;
680 681 682 683 684 685

    /** \brief
     * 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
686
    CoarseningManager *coarseningManager;
687
  
Thomas Witkowski's avatar
Thomas Witkowski committed
688 689
    /// Info level.
    int info;
690

691 692 693
    /// If true, the stationary problem was deserialized from some serialization file.
    bool deserialized;

694 695 696 697 698
    /** \brief
     * 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.
     */
699
    vector<AbstractFunction<double, WorldVector<double> >*> exactSolutionFcts;
700 701 702 703 704 705

    /** \brief
     * If true, the error is not estimated but computed from the exact solution
     * defined by \ref exactSolutionFcts.
     */
    bool computeExactError;
706 707 708 709 710 711 712
    
    /** \brief
     * 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.
     */
    bool boundaryConditionSet;
713

714 715
    /// If true, AMDiS prints information about the assembling procedure to the screen.
    bool writeAsmInfo;
716

717
    map<Operator*, vector<OperatorPos> > operators;
718

719
    map<Operator*, Flag> opFlags;
720
  };
721 722 723 724

#ifndef HAVE_PARALLEL_DOMAIN_AMDIS
  typedef ProblemStatSeq ProblemStat;
#endif
725 726 727
}

#endif