FileWriterInterface.h 3.44 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
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
 * Authors: 
 * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 *
 * This file is part of AMDiS
 *
 * See also license.opensource.txt in the distribution.
 * 
 ******************************************************************************/



/** \file FileWriterInterface.h */

/** \defgroup Output Output module
 * @{ <img src="output.png"> @}
 */

#ifndef AMDIS_FILEWRITER_INTERFACE_H
#define AMDIS_FILEWRITER_INTERFACE_H

#include <vector>
#include <string>
#include "AMDiS_fwd.h"
#include "Mesh.h"

namespace AMDiS {

  class FileWriterInterface
  {
  public:
    FileWriterInterface()
      : filename(""),
44
45
46
47
48
49
50
	appendIndex(0),
	indexLength(5),
	indexDecimals(3),
	createSubDir(-1),
	tsModulo(1),
	timeModulo(-1.0),
	lastWriteTime(-1.0),
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
	traverseLevel(-1),
	traverseFlag(Mesh::CALL_LEAF_EL),
	writeElement(NULL)
    {}

    virtual ~FileWriterInterface() {}

    /** \brief
     * Interface. Must be overridden in subclasses.
     * \param time time index of solution std::vector.
     * \param force enforces the output operation for the last timestep.
     */
    virtual void writeFiles(AdaptInfo *adaptInfo, bool force,
			    int level = -1,
			    Flag traverseFlag = Mesh::CALL_LEAF_EL,
			    bool (*writeElem)(ElInfo*) = NULL) = 0;

68
69
    /// Test whether timestep should be written
    virtual bool doWriteTimestep(AdaptInfo *adaptInfo, bool force);
70
71
72
73
74
75
76
77
78
79

    std::string getFilename() 
    { 
      return filename; 
    }
    
    void setFilename(std::string n) 
    { 
      filename = n; 
    }
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    
    void setWriteModulo(int tsModulo_ = 1, double timeModulo_ = -1.0)
    {
      tsModulo = tsModulo_;
      timeModulo = timeModulo_;
    }

    void setTraverseProperties(int level, 
			       Flag flag,
			       bool (*writeElem)(ElInfo*))
    {
      traverseLevel = level;
      traverseFlag |= flag;
      writeElement = writeElem;
    }
95
96

  protected:
97
98
99
100
101
102
103
104
105
106
    /// Reads all file writer dependend parameters from the init file.
    virtual void readParameters(std::string name);
    
    /// create a filename that includes the timestep and possibly a processor ID in parallel mode
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
    void getFilename(AdaptInfo* adaptInfo, std::string& fn, std::string& paraFilename, std::string& postfix);
#else
    void getFilename(AdaptInfo* adaptInfo, std::string& fn);
#endif
      
107
108
109
    /// Used filename prefix.
    std::string filename;

110
111
112
    /// 0: Don't append time index to filename prefix.
    /// 1: Append time index to filename prefix.
    int appendIndex;
113

114
115
    /// Total length of appended time index.
    int indexLength;
116

117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    /// Number of decimals in time index.
    int indexDecimals;
      
    /// create a subdirectory where to put the files
    int createSubDir;
    
    /// Timestep modulo: write only every tsModulo-th timestep! 
    int tsModulo;
    
    /// Time modulo: write at first iteration after lastWriteTime + timeModulo
    double timeModulo;
    double lastWriteTime;

    /// Traverse properties
    int traverseLevel;
    Flag traverseFlag;
133
134
135
136
137
138
    bool (*writeElement)(ElInfo*);  
  };

}

#endif