ParametricProject.hh 2.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/** \brief
 * Implementation of a scalar problem. In \ref buildBeforeCoarsen() parametric
 * coordinates for the vertices are filled in a DOFVector. This DOFVector is
 * used in \ref parametric to parametrize elements while mesh traversal. 
 */
class ParametricSphere : public ProblemScal 
{
public:
  /// constructor
  ParametricSphere(const char *name) 
    : ProblemScal(name),
      parametric(NULL)
  {}

  /// destructor
  ~ParametricSphere() 
  {
    for (int i = 0; i < Global::getGeo(WORLD); i++)
      delete parametricCoords[i];

    delete parametric;
  }

  /// initialization of the base class and creation of \ref parametric.
  void initialize(Flag initFlag,
		  ProblemScal *adoptProblem = NULL,
		  Flag adoptFlag = INIT_NOTHING)
  {
    ProblemScal::initialize(initFlag, adoptProblem, adoptFlag);

    // ===== create projection =====
    WorldVector<double> ballCenter;
    ballCenter.set(0.0);
    new BallProject(1, 
		    VOLUME_PROJECTION, 
		    ballCenter, 
		    1.0);

    // ===== create coords vector =====
    for (int i = 0; i < Global::getGeo(WORLD); i++)
      parametricCoords[i] = new DOFVector<double>(this->getFeSpace(), 
						  "parametric coords");

    // ===== create parametric object =====
    parametric = new ParametricFirstOrder(&parametricCoords);

    // ===== enable parametric traverse =====
    this->getMesh()->setParametric(parametric);
  };

  /** \brief
   * Implementation of ProblemStatBase::buildBeforeCoarsen().
   */
  void buildBeforeCoarsen(AdaptInfo *adaptInfo, Flag flag) {
    FUNCNAME("ParametricSphere::buildAfterCoarsen()");
    MSG("calculation of parametric coordinates\n");
57
    int preDOFs = this->getFeSpace()->getAdmin()->getNumberOfPreDofs(VERTEX);
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
92
93
94
    int dim = this->getMesh()->getDim();
    int dow = Global::getGeo(WORLD);
    WorldVector<double> vertexCoords;
    const DegreeOfFreedom **dof;
    DegreeOfFreedom vertexIndex;

    // ===== disable parametric traverse =====
    this->getMesh()->setParametric(NULL);

    TraverseStack stack;
    ElInfo *elInfo = NULL;
    elInfo = stack.traverseFirst(this->getMesh(), -1, 
				 Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
    while (elInfo) {
      dof = elInfo->getElement()->getDof();
      for (int i = 0; i < dim + 1; i++) {
	vertexCoords = elInfo->getCoord(i);
	Projection::getProjection(1)->project(vertexCoords);
	for (int j = 0; j < dow; j++)
	  (*(parametricCoords[j]))[dof[i][preDOFs]] = vertexCoords[j];
      }
      elInfo = stack.traverseNext(elInfo);
    }
    

    // ===== enable parametric traverse =====
    this->getMesh()->setParametric(parametric);
  }

protected:
  /// DOFVector storing parametric coordinates.
  WorldVector<DOFVector<double>*> parametricCoords;

  /// Parametrizes vertex coordinates while mesh traversal.
  ParametricFirstOrder *parametric;
};