blockgrid.h 6.54 KB
Newer Older
Phillip Lino Rall's avatar
Phillip Lino Rall committed
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
/**********************************************************************************
 * Copyright 2010 Christoph Pflaum 
 * 		Department Informatik Lehrstuhl 10 - Systemsimulation
 *		Friedrich-Alexander Universität Erlangen-Nürnberg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **********************************************************************************/
 
#ifndef BLOCKGRID_H
#define BLOCKGRID_H
#include <vector>
/*
Ny    *  *  *  *  *  *
Ny-1  *  +  +  +  +  *
3     *  +  +  +  +  *
2     *  +  +  +  +  *
1     *  +  +  +  +  *
0     *  *  *  *  *  *
      0  1  2  3 Nx-1 Nx
*/

template <class DTyp>
class Variable;
Phillip Lino Rall's avatar
Phillip Lino Rall committed
34
35
class Blockgrid;

Christoph Pflaum's avatar
Christoph Pflaum committed
36
37
38
/** \defgroup GridGeneration  ''Grid Generation''    
 **/
/* @{  */ 
Phillip Lino Rall's avatar
Phillip Lino Rall committed
39
40
41
42
43
44
45
46
47
48
49
50
class Blockgrid_coordinates {
     public:
    Blockgrid_coordinates(Blockgrid *bg_) : bg(bg_){};
    public:
    /*
     * berechnet werte an allen knoten und speichert diese. Beschleunigt Give_coord_**** Funktionen deutlich.
     * */
    void init_blockgrid_coordinates();
    /*
     * berechnet indizies der randkoordinaten, sodass direkt die benachabrten konten am Rand von hexahedrons angesprochen werden können.
     * */
    void init_blockgrid_coordinates_boundary();
51
52
    void init_blockgrid_coordinates_boundary_fast();
    void addBoundaryPlane(int id_hex, int i, int j, int k, int id_hexInner, int iInner, int jInner, int kInner,int Nx, int Ny, int Nz,int NxInner,int NyInner, int NzInner);
Phillip Lino Rall's avatar
Phillip Lino Rall committed
53
    void delete_blockgrid_coordinates();
54
    std::vector<std::vector<std::vector<int> > > getHexaCoordiantesBoundary(){return blockgrid_hexa_boundary;}
Phillip Lino Rall's avatar
Phillip Lino Rall committed
55
56
    std::vector<std::vector<std::vector<int> > > blockgrid_hexa_boundary;

57
58
    std::vector< std::vector< D3vector > > * getBlockgridHexaCoordinates(){return &blockgrid_hexa_coordinates;}
    std::vector< std::vector< D3vector > > * getBlockgridEdgeCoordinates(){return &blockgrid_edge_coordinates;}
59
60
61
62
    std::vector< D3vector > * getBlockgridPointCoordinates(){return &blockgrid_point_coordinates;}
    std::vector< std::vector< D3vector > > * getBlockgridQuadCoordinates(){return &blockgrid_quad_coordinates;}


63
64
    void setBlockgridHexaCoordinates(std::vector< std::vector< D3vector > > coords){blockgrid_hexa_coordinates = coords;}
    void setBlockgridEdgeCoordinates(std::vector< std::vector< D3vector > > coords){blockgrid_edge_coordinates = coords;}
65
66
    void setBlockgridPointCoordinates(std::vector< D3vector >  coords)             {blockgrid_point_coordinates = coords;}
    void setBlockgridQuadCoordinates(std::vector< std::vector< D3vector > > coords){blockgrid_quad_coordinates = coords;}
67
68


Phillip Lino Rall's avatar
Phillip Lino Rall committed
69
70
    std::vector< std::vector< D3vector > > blockgrid_hexa_coordinates;
    std::vector< std::vector< D3vector > > blockgrid_edge_coordinates;
71
72
    std::vector< std::vector< D3vector > > blockgrid_quad_coordinates;
    std::vector< D3vector >  blockgrid_point_coordinates;
Phillip Lino Rall's avatar
Phillip Lino Rall committed
73

74

Phillip Lino Rall's avatar
Phillip Lino Rall committed
75
76
77
78
    Blockgrid *bg;

    bool blockgrid_edge_coordinates_calculated;
    bool blockgrid_hexa_coordinates_calculated;
79
80
    bool blockgrid_quad_coordinates_calculated;
    bool blockgrid_point_coordinates_calculated;
Phillip Lino Rall's avatar
Phillip Lino Rall committed
81
82
83
    bool blockgrid_hexa_boundaries_calculated;
    std::vector< std::vector< bool > > blockgrid_edge_coordinates_set;

84
85
    int counter;

Phillip Lino Rall's avatar
Phillip Lino Rall committed
86
87
88

};

Phillip Lino Rall's avatar
Phillip Lino Rall committed
89
90
91
92
93
94
95

class  Blockgrid {
 public:
  Blockgrid(Unstructured_grid *ug);
  Blockgrid(Unstructured_grid *ug, int N);
  Blockgrid(Unstructured_grid *ug, int Nx,  int Ny,  int Nz);
  Blockgrid(Unstructured_grid *ug, int Nx,  int Ny,  int Nz, int Nr);
96
  Blockgrid(Unstructured_grid *ug, int Nx,  int Ny,  int Nz, int Nr, int Nr2);
Phillip Lino Rall's avatar
Phillip Lino Rall committed
97
98
  Blockgrid(Unstructured_grid *ug_, int Nx, int Ny, std::vector<int>& Nz);
  Blockgrid(Unstructured_grid *ug_, std::vector<int>& Nx, std::vector<int>& Ny, std::vector<int>& Nz);
Phillip Lino Rall's avatar
Phillip Lino Rall committed
99
  Blockgrid(Unstructured_grid *ug_, std::vector<int> Nvec);  
Phillip Lino Rall's avatar
Phillip Lino Rall committed
100
101
102
103
104
105
106
107
108
109
110
111
112

  /** Constructor for vector of Cylinders
  *** @param Nx: Number of grid points in x-direction
  *** @param Ny: Number of grid points in y-direction
  *** @param Nz: Vector of numbers of grid points in z-direction
  *** @param Nr: Number of grid points in radial direction
  **/
  Blockgrid(Unstructured_grid *ug_, int Nx, int Ny, std::vector<int>& Nz, int Nr);

  ~Blockgrid();

  void Set_grid_points(int d, int Nd);
  Unstructured_grid* Give_unstructured_grid() const { return ug; };
Phillip Lino Rall's avatar
Phillip Lino Rall committed
113
114
  Blockgrid_coordinates* Give_blockgrid_coordinates() const { return bg_coord; };
  void Set_blockgrid_coordinates(Blockgrid_coordinates* bg_coord_ ) {      bg_coord = bg_coord_; };
Phillip Lino Rall's avatar
Phillip Lino Rall committed
115

116
  D3vector Give_coord_hexahedron(int id, int i, int j, int k) const ;
Phillip Lino Rall's avatar
Phillip Lino Rall committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  D3vector Give_coord_quadrangle(int id, int i, int j) const;
  D3vector Give_coord_edge(int id, int i) const;
  D3vector Give_coord_point(int id) const;

  int Give_Nx_hexahedron(int id) const;
  int Give_Ny_hexahedron(int id) const;
  int Give_Nz_hexahedron(int id) const;

  int Give_N_total_hexahedron(int id) const;

  int Give_Nx_quadrangle(int id) const;
  int Give_Ny_quadrangle(int id) const;

  int Give_N_total_quadrangle(int id) const;

  int Give_Nx_edge(int id) const;

  int Give_N_color(int color) const; 

  int Total_number_of_points() const;

138

Phillip Lino Rall's avatar
Phillip Lino Rall committed
139
140
141



Phillip Lino Rall's avatar
Phillip Lino Rall committed
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
  /*** Komische Konstruktion wegen Phasenshift von Matthias und Christoph
   * sollte vielleicht mal weg!!!!
   ***/
  void Set_phase_shift(Variable<std::complex<double> > *phase_shift_) {
    phase_shift = phase_shift_; }
  void Set_phase_shift(Variable<std::complex<double> > &phase_shift_) {
    phase_shift = &phase_shift_; }

  void Remove_phase_shift() { phase_shift = NULL; }
  bool Exists_phase_shift() { return phase_shift != NULL; }
  Variable<std::complex<double> > * Give_phase_shift() { return phase_shift; }

  int getId() { return id_of_grid; }
  
  int getNumberPointsDegree(int d) { return number_points[d]; }
  
158
159


Phillip Lino Rall's avatar
Phillip Lino Rall committed
160
161
162
163
164
 protected: 
  Blockgrid();    
  int *number_points;    // number_points[i] 
                         // Anzahl der Punkte in Richtung i
                         // i=0, ..., degree_of_freedom()-1  
Phillip Lino Rall's avatar
Phillip Lino Rall committed
165

166
  Blockgrid_coordinates * bg_coord{};
Phillip Lino Rall's avatar
Phillip Lino Rall committed
167
168
169
170
171
  Unstructured_grid *ug;  

 private:
  Variable<std::complex<double> > *phase_shift;

172
173
174
175




Phillip Lino Rall's avatar
Phillip Lino Rall committed
176
177
178
179
180
  bool variable_set;     // set true falls eine Variable konstruiert

  int id_of_grid;
  static int id_count_grid;
};
Christoph Pflaum's avatar
Christoph Pflaum committed
181
/* @} */
Phillip Lino Rall's avatar
Phillip Lino Rall committed
182
183
#endif // BLOCKGRID_H