MacroReader.h 4.62 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
// ============================================================================
// ==                                                                        ==
// == 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>
Thomas Witkowski's avatar
Thomas Witkowski committed
26
#include "AMDiS_fwd.h"
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "Global.h"
#include "FixVec.h"
#include "Boundary.h"

namespace AMDiS {

  /** \defgroup Input Input module */

  /** \ingroup Input
   *  
   * \brief
   * Static class which reads a macro triangulation file and creates
   * the corresponding macro mesh.
   */
  class MacroReader
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
44
    /// Creates a Mesh by reading the macro file with the given filename.
45
46
47
48
49
50
51
    static MacroInfo* readMacro(const char *filename, 
				Mesh* mesh,
				const char *periodicFile,
				int check);

  protected:
    static void computeNeighbours(Mesh *mesh);
Thomas Witkowski's avatar
Thomas Witkowski committed
52

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
    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,
69
			     std::deque<MacroElement*>& macro_elements,
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
			     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);

Thomas Witkowski's avatar
Thomas Witkowski committed
87
    static int basicCheckFct(ElInfo* elInfo);
88

Thomas Witkowski's avatar
Thomas Witkowski committed
89
    static void basicDOFCheckFct(ElInfo* elInfo, Mesh *mesh, int iadmin);
90

Thomas Witkowski's avatar
Thomas Witkowski committed
91
    static int basicNodeFct(ElInfo* elInfo);
92
93
94
95
96
97
98
99
100
101
102

    friend class MacroInfo;
  };

  /** \ingroup Input
   * \brief
   * Used for reading a macro triangulation
   */
  class MacroInfo
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
103
    /// Pointer to the Mesh
104
105
    Mesh *mesh;

Thomas Witkowski's avatar
Thomas Witkowski committed
106
    /// list of macro elements
107
    std::deque<MacroElement*> mel;
108

Thomas Witkowski's avatar
Thomas Witkowski committed
109
    /// vector of all vertex dofs
110
111
    DegreeOfFreedom **dof;

Thomas Witkowski's avatar
Thomas Witkowski committed
112
    /// coords[j][k]: kth coordinate of global vertex j
113
114
    WorldVector<double> *coords;

Thomas Witkowski's avatar
Thomas Witkowski committed
115
    /// mel_vertex[i][k]: global index of kth vertex of element i
116
117
    int **mel_vertex;

Thomas Witkowski's avatar
Thomas Witkowski committed
118
    /// true, if neighbour information is in macro file
119
120
    bool neigh_set;

Thomas Witkowski's avatar
Thomas Witkowski committed
121
    /// true, if boundary information is in macro file
122
123
124
    bool bound_set;

  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
125
    /// Fills MacroInfo structure and some pointers in mesh 
126
127
128
129
130
131
132
133
134
    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);

Thomas Witkowski's avatar
Thomas Witkowski committed
135
    /// Frees memory of MacroInfo
136
137
138
139
140
141
142
143
144
145
146
    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:
Thomas Witkowski's avatar
Thomas Witkowski committed
147
    /// Reads indices from macro file
148
    int read_indices(FILE *file, DimVec<int> &id);
149
150
151
152
  };
}

#endif