Skip to content
Snippets Groups Projects
MacroReader.h 4.7 KiB
Newer Older
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file MacroReader.h */

#ifndef AMDIS_MACROREADER_H
#define AMDIS_MACROREADER_H

#include <deque>
#include "Global.h"
#include "FixVec.h"
#include "Boundary.h"

namespace AMDiS {

  class Mesh;
  class MacroElement;
  class ElInfo;
  class MacroInfo;

  /** \defgroup Input Input module */

  /** \ingroup Input
   *  
   * \brief
   * Static class which reads a macro triangulation file and creates
   * the corresponding macro mesh.
   */
  class MacroReader
  {
  public:
    /// Creates a Mesh by reading the macro file with the given filename.
    static MacroInfo* readMacro(const char *filename, 
				Mesh* mesh,
				const char *periodicFile,
				int check);

  protected:
    static void computeNeighbours(Mesh *mesh);
    static void boundaryDOFs(Mesh *mesh);

    static void umb(int *ele, Mesh *mesh,
		    void (*umbvk)(Mesh *mesh, MacroElement*,int k, int *el));

    static int macrotest(Mesh *mesh);

    static void macroTest(Mesh *mesh, const char *nameneu);

    static bool newEdge(Mesh *mesh, MacroElement *mel,
			int mel_edge_no, int *n_neigh);

    static void fillMelBoundary(Mesh *, MacroElement *mel,
				FixVec<BoundaryType ,NEIGH>);

    static void fillMelNeigh(MacroElement *mel,
			     std::deque<MacroElement*>& macro_elements,
			     FixVec<int,NEIGH> ind);

    static void umbVkantMacro(Mesh *mesh,
			      MacroElement *,
			      int ka,
			      int *ele);

    static void recumb(Mesh *mesh, 
		       MacroElement *mel, MacroElement *macroalt,
		       int *test, double lg, int ka, int *ele, 
		       void (*umbvk)(Mesh *mesh, MacroElement*,int k, int *el));

    static void laengstekante(FixVec<WorldVector<double>,VERTEX> coord, 
			      double *l, int *v);

    static void checkMesh(Mesh *mesh);

    static int basicCheckFct(ElInfo* elInfo);
    static void basicDOFCheckFct(ElInfo* elInfo, Mesh *mesh, int iadmin);
    static int basicNodeFct(ElInfo* elInfo);

    friend class MacroInfo;
  };

  /** \ingroup Input
   * \brief
   * Used for reading a macro triangulation
   */
  class MacroInfo
  {
  public:
    MEMORY_MANAGED(MacroInfo);

    /// Pointer to the Mesh
    /// list of macro elements
    std::deque<MacroElement*> mel;
    /// vector of all vertex dofs
    DegreeOfFreedom **dof;

    /// coords[j][k]: kth coordinate of global vertex j
    WorldVector<double> *coords;

    /// mel_vertex[i][k]: global index of kth vertex of element i
    /// true, if neighbour information is in macro file
    /// true, if boundary information is in macro file
    /// Fills MacroInfo structure and some pointers in mesh 
    void fill(Mesh *mesh, int ne, int nv);  

    /** \brief
     * Reads macro triangulation from ascii file in AMDiS format.
     * Fills MacroInfo structure.
     * Called by Mesh::readMacro(), fills missing information  
     */
    void readAMDiSMacro(const char *filename, Mesh* mesh);

    /// Frees memory of MacroInfo
    void clear(int ne, int nv);

    /** \brief
     * Sets the boundary of all edges/faces with no neigbour to a straight  
     * line/face with dirichlet boundary type
     */
    void dirichletBoundary();

    void fillBoundaryInfo(Mesh *mesh);

  protected:
    /// Reads indices from macro file
    int  read_indices(FILE *file, DimVec<int> &id);
  };
}

#endif