Skip to content
Snippets Groups Projects
Forked from iwr / amdis
2111 commits behind the upstream repository.
MacroWriter.h 3.43 KiB
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==                                                                        ==
// ==  Institut für Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

/** \file MacroWriter.h */

#ifndef AMDIS_MACROWRITER_H
#define AMDIS_MACROWRITER_H

#include <list>
#include <vector>
#include "AMDiS_fwd.h"
#include "VertexInfo.h"
#include "ElementInfo.h"
#include "DataCollector.h"
#include "FixVec.h"
#include "Boundary.h"
#include "Projection.h"
#include "Flag.h"
#include "Mesh.h"

namespace AMDiS {

  /** 
   * \ingroup Output
   *
   * \brief
   * Writes the current leaf elements of a mesh as macro triangulation to
   * a text file. Pure static class.
   */
  class MacroWriter
  {
  public:
    /// Stores a list of vertex infos for each dof.
    static DOFVector< std::list<VertexInfo> > *vertexInfos;

    /// List that stores an ElementInfo for each element.
    static std::list<ElementInfo> elements;

  public:
    /// Writes the leaf elements of a Mesh as a macro triangulation to a file.
    static int writeMacro(DataCollector *dc,
			  const char *name, 		       
			  double time = 0.0,
			  int level = -1,
			  Flag traverseFlag = Mesh::CALL_LEAF_EL,
			  bool (*writeElem)(ElInfo*) = NULL);

    /// Init \ref periodicFile for the next macro to be written.
    static void writePeriodicFile(DataCollector *dc, std::string filename);

 
  protected:
    /// Mesh that should be written
    static Mesh *mesh;

    /// File to which the mesh should be written
    static FILE *macroFile;

    /// File in which the periodic infos are stored.
    static FILE *periodicFile;

    /// vertex pre-dofs
    static int n0;

    /// Number of vertices.
    static int nv;

    /// Number of elements.
    static int ne;

    /// Number of connections.
    static int nc;

    /// Dimension of \ref mesh
    static int dim;

    /// Maps internal element indices to global output indices.
    static std::map<int, int> outputIndices;

    /** \brief
     * periodicConnections[i][j] stores whether the connection at side j of 
     * the element with output index i has already been written.
     */
    static std::vector<DimVec<bool> > periodicConnections;

    ///
    static bool (*writeElement)(ElInfo*);
  };

}

#endif