blockgrid.h 5.07 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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();
    void delete_blockgrid_coordinates();
    std::vector<std::vector<std::vector<int> > > blockgrid_hexa_boundary;

    std::vector< std::vector< D3vector > > blockgrid_hexa_coordinates;
    std::vector< std::vector< D3vector > > blockgrid_edge_coordinates;

    Blockgrid *bg;

    bool blockgrid_edge_coordinates_calculated;
    bool blockgrid_hexa_coordinates_calculated;
    bool blockgrid_hexa_boundaries_calculated;
    std::vector< std::vector< bool > > blockgrid_edge_coordinates_set;


};

Phillip Lino Rall's avatar
Phillip Lino Rall committed
67
68
69
70
71
72
73

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);
74
  Blockgrid(Unstructured_grid *ug, int Nx,  int Ny,  int Nz, int Nr, int Nr2);
Phillip Lino Rall's avatar
Phillip Lino Rall committed
75
76
  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
77
  Blockgrid(Unstructured_grid *ug_, std::vector<int> Nvec);  
Phillip Lino Rall's avatar
Phillip Lino Rall committed
78
79
80
81
82
83
84
85
86
87
88
89
90

  /** 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
91
92
  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
93

94
  D3vector Give_coord_hexahedron(int id, int i, int j, int k) const ;
Phillip Lino Rall's avatar
Phillip Lino Rall committed
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  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;

116

Phillip Lino Rall's avatar
Phillip Lino Rall committed
117
118
119



Phillip Lino Rall's avatar
Phillip Lino Rall committed
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  /*** 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]; }
  
136
137


Phillip Lino Rall's avatar
Phillip Lino Rall committed
138
139
140
141
142
 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
143

144
  Blockgrid_coordinates * bg_coord{};
Phillip Lino Rall's avatar
Phillip Lino Rall committed
145
146
147
148
149
  Unstructured_grid *ug;  

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

150
151
152
153




Phillip Lino Rall's avatar
Phillip Lino Rall committed
154
155
156
157
158
  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
159
/* @} */
Phillip Lino Rall's avatar
Phillip Lino Rall committed
160
161
#endif // BLOCKGRID_H