CouplingBaseProblem.h 3.45 KB
Newer Older
Praetorius, Simon's avatar
Praetorius, Simon committed
1
/** \file CouplingBaseProblem.h */
Praetorius, Simon's avatar
Praetorius, Simon committed
2

Praetorius, Simon's avatar
Praetorius, Simon committed
3
4
#ifndef COUPLING_BASE_PROBLEM_H
#define COUPLING_BASE_PROBLEM_H
Praetorius, Simon's avatar
Praetorius, Simon committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#include "AMDiS.h"

// coupling structures
#include "CouplingIterationInterface.h"
#include "CouplingTimeInterface.h"
#include "CouplingProblemStat.h"
#include "BaseProblem.h"
#include "ProblemInstat.h"

using namespace AMDiS;


/**
  * \ingroup Problem 
  *
  * \brief
  */
template<class ProblemType=ProblemStat, class BaseProblemType=BaseProblem<ProblemStat> >
Praetorius, Simon's avatar
Praetorius, Simon committed
24
class CouplingBaseProblem : public CouplingIterationInterface,
Praetorius, Simon's avatar
Praetorius, Simon committed
25
26
27
28
29
30
			   public CouplingTimeInterface,
			   public CouplingProblemStatImpl<ProblemType>
{
public:
  typedef CouplingProblemStatImpl<ProblemType> CProblemStat;

Praetorius, Simon's avatar
Praetorius, Simon committed
31
  CouplingBaseProblem(std::string name_, 
Praetorius, Simon's avatar
Praetorius, Simon committed
32
33
34
35
36
		     BaseProblemType *prob0_,
		     BaseProblemType *prob1_=NULL, 
		     BaseProblemType *prob2_=NULL, 
		     BaseProblemType *prob3_=NULL, 
		     BaseProblemType *prob4_=NULL)
Praetorius, Simon's avatar
Praetorius, Simon committed
37
  : CProblemStat(name_), name(name_)
Praetorius, Simon's avatar
Praetorius, Simon committed
38
39
40
41
42
43
44
45
46
  {
    dow = Global::getGeo(WORLD);
    baseProblems.push_back(prob0_);
    if (prob1_) baseProblems.push_back(prob1_);
    if (prob2_) baseProblems.push_back(prob2_);
    if (prob3_) baseProblems.push_back(prob3_);
    if (prob4_) baseProblems.push_back(prob4_);
  }

Praetorius, Simon's avatar
Praetorius, Simon committed
47
  ~CouplingBaseProblem() { }  
Praetorius, Simon's avatar
Praetorius, Simon committed
48
  
49
50
51
  void initialize(Flag initFlag,
			  ProblemStatSeq *adoptProblem = NULL,
			  Flag adoptFlag = INIT_NOTHING) _OVERRIDE_
Praetorius, Simon's avatar
Praetorius, Simon committed
52
53
54
  {  
    for (size_t i = 0; i < baseProblems.size(); i++) {
      for (size_t j = 0; j < baseProblems[i]->getNumProblems(); j++)
55
	this->addProblem(dynamic_cast<ProblemType*>(baseProblems[i]->getProblem(j)));
Praetorius, Simon's avatar
Praetorius, Simon committed
56
57
58
59
60
61
62
63
64
65
66
67
68
      
      addIterationInterface(baseProblems[i]);
      addTimeInterface(baseProblems[i]);
    }

    // initialize all ProblemStat
    CProblemStat::initialize(initFlag, adoptProblem, adoptFlag);
    
    // set mesh dimension
    dim = CProblemStat::getMesh(0)->getDim();
  }  
  
  virtual void initData() {}  
Praetorius, Simon's avatar
Praetorius, Simon committed
69
  virtual void finalizeData() {}  
Praetorius, Simon's avatar
Praetorius, Simon committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
  
  virtual void initTimeInterface()
  {
    for (size_t i = 0; i < baseProblems.size(); i++)
      baseProblems[i]->initData();
    initData();
    
    for (size_t i = 0; i < baseProblems.size(); i++)
      baseProblems[i]->fillOperators();
    fillCouplingOperators();
    
    for (size_t i = 0; i < baseProblems.size(); i++)
      baseProblems[i]->fillBoundaryConditions();
    fillCouplingBoundaryConditions();
Praetorius, Simon's avatar
Praetorius, Simon committed
84
85
86
87
    
    for (size_t i = 0; i < baseProblems.size(); i++)
      baseProblems[i]->initData();
    finalizeData();
Praetorius, Simon's avatar
Praetorius, Simon committed
88
89
90
91
92
93
94
95
96
  }
  
  
  virtual void fillCouplingOperators() {}
  virtual void fillCouplingBoundaryConditions() {}
  
  
  /// get the j-th solution-vector of the i-th problem
  DOFVector<double> *getSolution(int i, int j)
Praetorius, Simon's avatar
Praetorius, Simon committed
97
  { FUNCNAME("CouplingBaseProblem::getSolution(i,j)");
Praetorius, Simon's avatar
Praetorius, Simon committed
98
99
100
101
102
103
104
105
    TEST_EXIT(0<=i && 0<=j && i<baseProblems.size() && j<=baseProblems[i]->getNumComponents())
      ("Indices out of range!\n");
    return baseProblems[i]->getSolution()->getDOFVector(j);
  }
  
  
  /// pointer to the j-th feSpace of the i-th problem
  inline const FiniteElemSpace* getFeSpace(int i, int j=0) 
Praetorius, Simon's avatar
Praetorius, Simon committed
106
  { FUNCNAME("CouplingBaseProblem::getFeSpace(i,j)");
Praetorius, Simon's avatar
Praetorius, Simon committed
107
108
109
110
    TEST_EXIT(0<=i && 0<=j && i<baseProblems.size() && j<=baseProblems[i]->getNumComponents())
      ("Indices out of range!\n");
    return baseProblems[i]->getFeSpace(j); 
  }
Praetorius, Simon's avatar
Praetorius, Simon committed
111
112
  
  std::string getName() { return name; }
Praetorius, Simon's avatar
Praetorius, Simon committed
113
114
115
116
117

protected:
  std::vector<BaseProblemType*> baseProblems;

  unsigned dim;	// dimension of the meshes
118
  unsigned dow;	// dimension of the world
Praetorius, Simon's avatar
Praetorius, Simon committed
119
120
  
  std::string name;
Praetorius, Simon's avatar
Praetorius, Simon committed
121
122
123
};


Praetorius, Simon's avatar
Praetorius, Simon committed
124
#endif // COUPLING_BASE_PROBLEM_H