ParMooN
 All Classes Functions Variables Friends Pages
aggregation.h
1 #ifndef MPIMIS_AGGREGATION
2 #define MPIMIS_AGGREGATION
3 
4 #include "basictools.h"
5 #include "piecewise_lin_cont.h"
6 #include "constants.h"
7 #include "timer.h"
8 
9 #include <stdlib.h>
10 #include <math.h>
11 
12 typedef class Aggregation aggregation;
13 typedef aggregation* paggregation;
14 
15 enum GRID_TYPE {UNIFORM, REFINED};
16 
17 double u0_brown(double x);
18 double v0_brown(double y);
19 double u1_brown(double x);
20 double v1_brown(double y);
21 
22 double u0_shear(double x);
23 double v0_shear(double y);
24 double u1_shear(double x);
25 double v1_shear(double y);
26 
27 class Aggregation {
28 public:
29  // Constructor for uniform grid
30  Aggregation(double _xmin, double _xmax, int _na, int _nx, int _ny, int _nz, double* _grid, double* params) {
31  xmin = _xmin, xmax = _xmax, na = _na - 1, nx = _nx, ny = _ny, nz = _nz;
32  space_dim = iround(params[0]);
33  INCLUDE_BROWNIAN_KERNEL = iround(params[1]);
34  POLYNOM_DEGREE = iround(params[2]);
35  BROWNIAN_FACTOR_TYPE = iround(params[3]);
36  BROWNIAN_FACTOR = params[4];
37  SHEAR_INDUCED_FACTOR_TYPE = iround(params[5]);
38  SHEAR_INDUCED_FACTOR = params[6];
39  ETA_C = params[7];
40 
41  a = allocate_vector(na + 1);
42  memcpy(a, _grid, (na + 1) * sizeof(double));
43  scale_vector(a, na + 1, cube(xmax));
44 
45  stepping = a[na] - a[na - 1];
46 
47  create_hierarchical_structure();
48 
49  generate_piecewise_constant_template(pcf);
50  generate_piecewise_constant_template(pcg);
51  generate_piecewise_constant_template(pcw);
52 
53  generate_piecewise_linear_template(plf);
54  generate_piecewise_linear_template(plg);
55  generate_piecewise_linear_template(plw);
56 
57  generate_piecewise_linear_continuous_template(psd);
58  generate_piecewise_linear_continuous_template(rhs);
59  generate_piecewise_linear_continuous_template(fc);
60  generate_piecewise_linear_continuous_template(gc);
61  generate_piecewise_linear_continuous_template(wb0);
62  generate_piecewise_linear_continuous_template(wb1);
63  generate_piecewise_linear_continuous_template(ws0);
64  generate_piecewise_linear_continuous_template(ws1);
65  generate_piecewise_linear_continuous_template(wbps);
66 
67  generate_func_p0_p_template(pf0);
68  generate_func_p0_p_template(pg0);
69  generate_func_p0_p_template(pw0);
70  generate_func_p0_p_template(convolution_result0);
71 
72  u0_brown_v = allocate_vector(na);
73  fill_vector_from_function(u0_brown, a, na, u0_brown_v, DS_L2_CONSTANT);
74  u1_brown_v = allocate_vector(na);
75  fill_vector_from_function(u1_brown, a, na, u1_brown_v, DS_L2_CONSTANT);
76  v0_brown_v = allocate_vector(na);
77  fill_vector_from_function(v0_brown, a, na, v0_brown_v, DS_L2_CONSTANT);
78  v1_brown_v = allocate_vector(na);
79  fill_vector_from_function(v1_brown, a, na, v1_brown_v, DS_L2_CONSTANT);
80  u0_shear_v = allocate_vector(na);
81  fill_vector_from_function(u0_shear, a, na, u0_shear_v, DS_L2_CONSTANT);
82  u1_shear_v = allocate_vector(na);
83  fill_vector_from_function(u1_shear, a, na, u1_shear_v, DS_L2_CONSTANT);
84  v0_shear_v = allocate_vector(na);
85  fill_vector_from_function(v0_shear, a, na, v0_shear_v, DS_L2_CONSTANT);
86  v1_shear_v = allocate_vector(na);
87  fill_vector_from_function(v1_shear, a, na, v1_shear_v, DS_L2_CONSTANT);
88 
89  generate_func_p1_p_template(pf1);
90  generate_func_p1_p_template(pg1);
91  generate_func_p1_p_template(pw1);
92  generate_func_p1_p_template(convolution_result1);
93 
94  diag = new double[na + 1];
95  subdiag = new double[na];
96  fill_diagonal_part_of_Gramm_matrix(na, a, diag);
97  fill_subdiagonal_part_of_Gramm_matrix(na, a, subdiag);
98 
99  fill_l2m_and_m2l_values();
100  };
101 
102  double* a;
103 
104 private:
105  GRID_TYPE gt;
106  double xmin;
107  double xmax;
108  int na;
109 
110  int L; // number of levels in the hierarchy
111  double* length; // array of size L. Describes the length of each interval
112  int* count; // array of size L. Indicates the number of intervals in the corresponding level
113  int* count2; // array of size L. Indicates the number of intervals in the corresponding level
114  double** nonzero_value_start;
115  double** nonzero_value_end;
116  int* nl; // array of size L. Indicates the first grid index of the corresponding level
117 
118  double* diag;
119  double* subdiag;
120 
121  int INCLUDE_BROWNIAN_KERNEL;
122  int POLYNOM_DEGREE;
123  int BROWNIAN_FACTOR_TYPE;
124  double BROWNIAN_FACTOR;
125  int SHEAR_INDUCED_FACTOR_TYPE;
126  double SHEAR_INDUCED_FACTOR;
127  double ETA_C;
128 
129 public:
130  piecewise_constant pcf, pcg, pcw;
131  piecewise_linear plf, plg, plw;
132 
133  piecewise_linear_continuous psd, rhs, fc, gc;
134  piecewise_linear_continuous wb0, wb1, ws0, ws1, wbps;
135 
136  interval_p* intervals;
137  double* hl;
138  double* sqrt_hl;
139 
140  func_p0_p pf0, pg0, pw0, convolution_result0;
141  func_p1_p pf1, pg1, pw1, convolution_result1;
142 
143  double* u0_brown_v;
144  double* v0_brown_v;
145  double* u1_brown_v;
146  double* v1_brown_v;
147  double* u0_shear_v;
148  double* v0_shear_v;
149  double* u1_shear_v;
150  double* v1_shear_v;
151  double* l2m_start_value_k;
152  double* l2m_start_value_b;
153  double* l2m_end_value_k;
154  double* l2m_end_value_b;
155  double* m2l_start_value_k;
156  double* m2l_start_value_b;
157  double* m2l_end_value_k;
158  double* m2l_end_value_b;
159 
160 
161  double stepping;
162  int nx, ny, nz, space_dim;
163 
164 public:
165  void apply_aggregation(double* input, double* output, double* grad_v, double* temp);
166 
167 private:
168  void generate_piecewise_linear_template(piecewise_linear& pl);
169  void generate_piecewise_constant_template(piecewise_constant& pl);
170  void generate_piecewise_linear_continuous_template(piecewise_linear_continuous& plc);
171  void generate_func_p0_p_template(func_p0_p& fp);
172  void generate_func_p1_p_template(func_p1_p& fp);
173 
174  void convert_func_p0_to_piecewise_constant(func_p0_p& function, piecewise_constant& pl);
175  void convert_pl2func1(piecewise_linear pl, func_p1_p); // l is the level
176  void convert_func12pl(func_p1_p fncp1, piecewise_linear plin);
177  int create_hierarchical_structure();
178 
179  void fill_l2m_and_m2l_values();
180  void transform_length2mass(double* input, double* output);
181  void transform_mass2length(double* input, double* output);
182 
183  // f, g, w are the hidden variables for this
184  int rank1_aggregation(piecewise_linear_continuous& r1w);
185 
186  int convolution();
187 };
188 
189 #endif // MPIMIS_AGGREGATION
Definition: funktion.h:9
Definition: aggregation.h:27
Definition: piecewise_lin_cont.h:5
Definition: fepc_easy.h:9
Definition: piecewise_lin_cont.h:15
Definition: funktion.h:80
Definition: piecewise_lin_cont.h:26