DofWriter.cc 1.68 KB
Newer Older
Thomas Witkowski's avatar
Thomas Witkowski committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


#include "DofWriter.h"
#include "DOFVector.h"
#include "BasisFunction.h"

namespace AMDiS {

19
20
21
  using namespace std;

  void DofWriter::writeFile(string filename, vector<DOFVector<double>*> &vec)
Thomas Witkowski's avatar
Thomas Witkowski committed
22
23
24
25
26
27
28
29
  {
    FUNCNAME("DofWriter::writeFile()");

    DOFVector<WorldVector<double> > coordDof(feSpace, "tmp");
    
    Mesh *mesh = feSpace->getMesh();
    const BasisFunction* basFcts = feSpace->getBasisFcts();
    int nBasFcts = basFcts->getNumber();
30
    vector<DegreeOfFreedom> dofVec(nBasFcts);
Thomas Witkowski's avatar
Thomas Witkowski committed
31
32
33
34
35
    
    TraverseStack stack;
    ElInfo *elInfo = 
      stack.traverseFirst(mesh, -1, Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS);
    while (elInfo) {
36
37
      basFcts->getLocalIndices(elInfo->getElement(), 
			       feSpace->getAdmin(), dofVec);
Thomas Witkowski's avatar
Thomas Witkowski committed
38
39
40
41
42
43
44
45
      for (int i = 0; i < nBasFcts; i++) {
	DimVec<double> *baryCoords = basFcts->getCoords(i);
	elInfo->coordToWorld(*baryCoords, coordDof[dofVec[i]]);
      }
      
      elInfo = stack.traverseNext(elInfo);
    }   
    
46
    ofstream outfile;
Thomas Witkowski's avatar
Thomas Witkowski committed
47
48
49
50
51
52
53
54
55
56
57
58
    outfile.open(filename.c_str());
    outfile.precision(10);
    
    DOFIterator<WorldVector<double> > it(&coordDof, USED_DOFS);
    for (it.reset(); !it.end(); ++it) {
      outfile << it.getDOFIndex() << " ";
      
      for (int i = 0; i < Global::getGeo(WORLD); i++)
	outfile << (*it)[i] << " ";
      
      for (unsigned int i = 0; i < vec.size(); i++) 
	outfile << (*(vec[i]))[it.getDOFIndex()] << " ";
59
      outfile << endl;
Thomas Witkowski's avatar
Thomas Witkowski committed
60
61
62
63
64
65
    }   
    
    outfile.close();
  }
    
}