TecPlotWriter.cc 3.36 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "TecPlotWriter.h"
#include "DOFVector.h"
#include "SystemVector.h"

namespace AMDiS {

  template<>
  int TecPlotWriter<DOFVector<double> >::writeValuesFct(ElInfo* elinfo)
  {
    const DOFAdmin* admin = values->getFESpace()->getAdmin(); 
    int n0 = admin->getNumberOfPreDOFs(VERTEX);
    const DegreeOfFreedom **dof = elinfo->getElement()->getDOF();
  
    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
	(*outFile) << (*values)[dof[i][n0]] << ::std::endl;

      }
    }
    return 0;
  }

  template<>
  int TecPlotWriter<SystemVector>::writeValuesFct(ElInfo* elinfo)
  {
    const DOFAdmin* admin = values->getDOFVector(0)->getFESpace()->getAdmin(); 
    int n0 = admin->getNumberOfPreDOFs(VERTEX);
    const DegreeOfFreedom **dof = elinfo->getElement()->getDOF();
  
    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]] << " ";
	}
	(*outFile) << ::std::endl;
      }
    }
    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");
    }
    (*outFile) << ",\"" << values->getName() << "\"" << ::std::endl;
  }

  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() << "\"";
    }
    (*outFile) << ::std::endl;
  }

}