TecPlotWriter.cc 3.35 KB
Newer Older
1
2
3
4
5
6
7
8
9
#include "TecPlotWriter.h"
#include "DOFVector.h"
#include "SystemVector.h"

namespace AMDiS {

  template<>
  int TecPlotWriter<DOFVector<double> >::writeValuesFct(ElInfo* elinfo)
  {
10
    const DOFAdmin* admin = values->getFeSpace()->getAdmin(); 
11
    int n0 = admin->getNumberOfPreDOFs(VERTEX);
12
    const DegreeOfFreedom **dof = elinfo->getElement()->getDof();
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
  
    int dim = elinfo->getMesh()->getDim();
    int dow = Global::getGeo(WORLD);

    // for every vertex
    for(int i=0; i < dim+1; i++) {

      // search for coords of this vertex in the coord-list of this dof 
      DOFCoords::iterator coords = find(dofCoords[dof[i][n0]].begin(),
					dofCoords[dof[i][n0]].end(),
					elinfo->getCoord(i));

      if(coords == dofCoords[dof[i][n0]].end()) { // coords not found
	// add coords to list
	VertexInfo newCoords;
	newCoords.coord = elinfo->getCoord(i);
	newCoords.vertex_index = nv++;
	dofCoords[dof[i][n0]].push_back(newCoords);

	// write coords of vertex
	if(writeCoords) {
	  for(int j=0; j < dow; j++) {
	    (*outFile) << elinfo->getCoord(i)[j] << " ";
	  }
	}

	// write value
40
	(*outFile) << (*values)[dof[i][n0]] << std::endl;
41
42
43
44
45
46
47
48
49

      }
    }
    return 0;
  }

  template<>
  int TecPlotWriter<SystemVector>::writeValuesFct(ElInfo* elinfo)
  {
50
    const DOFAdmin* admin = values->getDOFVector(0)->getFeSpace()->getAdmin(); 
51
    int n0 = admin->getNumberOfPreDOFs(VERTEX);
52
    const DegreeOfFreedom **dof = elinfo->getElement()->getDof();
53
54
55
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
  
    int dim = elinfo->getMesh()->getDim();
    int dow = Global::getGeo(WORLD);

    // for every vertex
    for(int i=0; i < dim+1; i++) {

      // search for coords of this vertex in the coord-list of this dof 
      DOFCoords::iterator coords = find(dofCoords[dof[i][n0]].begin(),
					dofCoords[dof[i][n0]].end(),
					elinfo->getCoord(i));

      if(coords == dofCoords[dof[i][n0]].end()) { // coords not found
	// add coords to list
	VertexInfo newCoords;
	newCoords.coord = elinfo->getCoord(i);
	newCoords.vertex_index = nv++;
	dofCoords[dof[i][n0]].push_back(newCoords);

	// write coords of vertex
	if(writeCoords) {
	  for(int j=0; j < dow; j++) {
	    (*outFile) << elinfo->getCoord(i)[j] << " ";
	  }
	}

	// write value
	for(int j=0; j < values->getNumVectors(); j++) {
	  (*outFile) << (*(values->getDOFVector(i)))[dof[i][n0]] << " ";
	}
83
	(*outFile) << std::endl;
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
      }
    }
    return 0;
  }

  template<>
  void TecPlotWriter<DOFVector<double> >::writeVarName(int dim)
  {
    switch(Global::getGeo(WORLD)) {
    case 1:
      (*outFile) << "VARIABLES = \"x\"";
      break;
    case 2:
      (*outFile) << "VARIABLES = \"x\",\"y\"";
      break;
    case 3:
      (*outFile) << "VARIABLES = \"x\",\"y\",\"z\"";
      break;
    default:
      ERROR_EXIT("invalid dim of world\n");
    }
105
    (*outFile) << ",\"" << values->getName() << "\"" << std::endl;
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  }

  template<>
  void TecPlotWriter<SystemVector>::writeVarName(int dim)
  {
    switch(Global::getGeo(WORLD)) {
    case 1:
      (*outFile) << "VARIABLES = \"x\"";
      break;
    case 2:
      (*outFile) << "VARIABLES = \"x\",\"y\"";
      break;
    case 3:
      (*outFile) << "VARIABLES = \"x\",\"y\",\"z\"";
      break;
    default:
      ERROR_EXIT("invalid dim of world\n");
    }

    int i, number = values->getNumVectors();
    for(i = 0; i < number; i++) {
      (*outFile) << ",\"" << values->getDOFVector(i)->getName() << "\"";
    }
129
    (*outFile) << std::endl;
130
131
132
133
  }

}