For the construction of multilevel grids or multilevel variables or multilevel stiffness matrices the general array construction is very helpful. This construction can be applied to any object of type T. To construct an array of lenghth n, apply the constructor
MG_array< T > obj(n);
Then, allocate memory as follows:
obj(i) = new T(...);
To get access to the i-th component, use the operator
obj[i]
Example: A multilevel grid and a multilevel variable can be constructed as follows:
int n=10; MG_array<Blockgrid> blockgrids(n); int m_max = 2; for(int i=1;i<n;++i) m_max = m_max * 2; int m = 2; for(int i=0;i<n;++i) { blockgrids(i) = new Blockgrid(&hexa,m,m,m_max); m = m * 2; } MG_array<Variable<double> > u(n); for(i=0;i<n;++i) u(i) = new Variable<double>(blockgrids[i]); ...
Last modified: Thu Feb 10 16:28:05 MET 2000