CouplingBaseProblem.h 3.22 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
37
38
39
40
41
42
43
44
45
46
		     BaseProblemType *prob0_,
		     BaseProblemType *prob1_=NULL, 
		     BaseProblemType *prob2_=NULL, 
		     BaseProblemType *prob3_=NULL, 
		     BaseProblemType *prob4_=NULL)
  : CProblemStat(name_)
  {
    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
52
53
54
  
  virtual void initialize(Flag initFlag,
			  ProblemStat *adoptProblem = NULL,
			  Flag adoptFlag = INIT_NOTHING)
  {  
    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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
      
      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() {}  
  
  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();
  }
  
  
  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
92
  { FUNCNAME("CouplingBaseProblem::getSolution(i,j)");
Praetorius, Simon's avatar
Praetorius, Simon committed
93
94
95
96
97
98
99
100
    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
101
  { FUNCNAME("CouplingBaseProblem::getFeSpace(i,j)");
Praetorius, Simon's avatar
Praetorius, Simon committed
102
103
104
105
106
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); 
  }

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

  unsigned dim;	// dimension of the meshes
111
  unsigned dow;	// dimension of the world
Praetorius, Simon's avatar
Praetorius, Simon committed
112
113
114
};


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