AMR-Solver  1.0
Block-based Octree AMR grid flow solver
vecfield.cpp
Go to the documentation of this file.
1 #include "block.h"
2 namespace myOctree {
3 
4 //parametrized constructor with initialization fields
5 VecField::VecField( int N_x, int N_y, int N_z, std::string info ) : Nx(N_x), Ny(N_y), Nz(N_z), name(info) {
6  //std::cerr << "parametrized constructor of vecfield is working" << std::endl;
7 
8  N = Nx*Ny*Nz;
9  x = new double** [Nx];
10  y = new double** [Nx];
11  z = new double** [Nx];
12  for(int i=0;i<Nx;i++) {
13  x[i] = new double* [Ny];
14  y[i] = new double* [Ny];
15  z[i] = new double* [Ny];
16  for(int j=0;j<Ny;j++) {
17  x[i][j] = new double [Nz];
18  y[i][j] = new double [Nz];
19  z[i][j] = new double [Nz];
20  }
21  }
22 
23  set_field(0.0);
24 
25 }
26 
27 //default constructor
29  // std::cerr << "default constructor of vecfield is working" << std::endl;
30 
31  Nx = 0;
32  Ny = 0;
33  Nz = 0;
34  N = Nx*Ny*Nz;
35  x = new double** [Nx];
36  y = new double** [Nx];
37  z = new double** [Nx];
38  for(int i=0;i<Nx;i++) {
39  x[i] = new double* [Ny];
40  y[i] = new double* [Ny];
41  z[i] = new double* [Ny];
42  for(int j=0;j<Ny;j++) {
43  x[i][j] = new double [Nz];
44  y[i][j] = new double [Nz];
45  z[i][j] = new double [Nz];
46  }
47  }
48 }
49 
50  //Copy constructor
52 
53 // std::cerr << "copy constructor of vecfield is working" << std::endl;
54 
55  Nx = obj.Nx;
56  Ny = obj.Ny;
57  Nz = obj.Nz;
58  N = obj.N;
59  name = obj.name;
60 
61  x = new double** [Nx];
62  y = new double** [Nx];
63  z = new double** [Nx];
64  for(int i=0;i<Nx;i++) {
65  x[i] = new double* [Ny];
66  y[i] = new double* [Ny];
67  z[i] = new double* [Ny];
68  for(int j=0;j<Ny;j++) {
69  x[i][j] = new double [Nz];
70  y[i][j] = new double [Nz];
71  z[i][j] = new double [Nz];
72  memcpy(x[i][j],obj.x[i][j],sizeof(double)*Nz);
73  memcpy(y[i][j],obj.y[i][j],sizeof(double)*Nz);
74  memcpy(z[i][j],obj.z[i][j],sizeof(double)*Nz);
75  }
76  }
77 
78  for(int i = 0; i < 3; ++ i) {
79  memcpy(&(xbc[i][0]), &(obj.xbc[i][0]), 2 * sizeof(FieldBc));
80  memcpy(&(ybc[i][0]), &(obj.ybc[i][0]), 2 * sizeof(FieldBc));
81  memcpy(&(zbc[i][0]), &(obj.zbc[i][0]), 2 * sizeof(FieldBc));
82  }
83 
84 }
85 
86 //Destructor
88  //std::cerr << "destructor of vecfield is working" << std::endl;
89 
90  for (int i = 0; i < Nx; ++i) {
91  for (int j = 0; j < Ny; ++j) {
92  delete [] x[i][j];
93  delete [] y[i][j];
94  delete [] z[i][j];
95  }
96  delete [] x[i];
97  delete [] y[i];
98  delete [] z[i];
99  }
100 
101  delete [] x;
102  delete [] y;
103  delete [] z;
104 }
105 
106 //member function
107 void VecField::set_field(double value) {
108 
109  for(int i=0;i<this->Nx;i++) {
110  for(int j=0;j<this->Ny;j++) {
111  for(int k=0;k<this->Nz;k++) {
112  this->x[i][j][k] = value;
113  this->y[i][j][k] = value;
114  this->z[i][j][k] = value;
115  }
116  }
117  }
118 }
119 
120 }
FieldBc zbc[3][2]
Definition: vecfield.h:37
double *** z
Definition: vecfield.h:27
void set_field(double)
Definition: vecfield.cpp:107
Template class for any vector field variable in the domain.
Definition: vecfield.h:13
AMR grid stuff.
Definition: adapt.cpp:6
std::string name
Definition: vecfield.h:31
double *** x
Definition: vecfield.h:25
double *** y
Definition: vecfield.h:26
FieldBc xbc[3][2]
Definition: vecfield.h:35
FieldBc ybc[3][2]
Definition: vecfield.h:36
field_boundary_flags
Definition: boundary.h:16