AMR-Solver  1.0
Block-based Octree AMR grid flow solver
amrsolver.cpp
Go to the documentation of this file.
1 #include "octreegrid.h"
2 #include "poisson.h"
3 #include "adapt.h"
4 #include "vtk.h"
5 #include "input.h"
6 #include "output.h"
7 #include <iostream>
8 
9 using myOctree::Octree;
10 using myOctree::Field;
11 using myOctree::VecField;
12 
14 
15 namespace amrsolver {
16 
17 
19 
21 
22  for (std::list<Octree*>::iterator i = myOctree::leaf_nodes.begin(), end = myOctree::leaf_nodes.end(); i != end; ++i) {
23 
24  Field* field = (*i)->get_block_data()->field;
25  VecField* location = (*i)->get_block_data()->mesh;
26 
27  for(int i=0;i<field->Nx;i++) {
28  for(int j=0;j<field->Ny;j++) {
29  for(int k=0;k<field->Nz;k++) {
30 
31  double x = location->x[i][j][k];
32  double y = location->y[i][j][k];
33  double z = location->z[i][j][k];
34 
35  ((x-1.0)*(x-1.0) + (y-1.0)*(y-1.0) >= 0.5625)?(field->val[i][j][k] = 1.0):(field->val[i][j][k] = 100.0);
36 
37 // ((x-1.0)*(x-1.0) + (y-1.0)*(y-1.0) + (z-1.0)*(z-1.0) >= 0.421875)?(field->val[i][j][k] = 1.0):(field->val[i][j][k] = 100.0);
38  //((x-1.0)*(x-1.0) + (y-1.0)*(y-1.0) >= 0.5625)?(field->val[i][j][k] = 1.0):(field->val[i][j][k] = 100.0);
39  // (x*x + y*y >= 1.0)?(field->val[i][j][k] = 1.0):(field->val[i][j][k] = 100.0);
40  if(x*x + y*y <= 1.0) {field->val[i][j][k] = 0.1; }
41  if(x*x + y*y >= 3.0) {field->val[i][j][k] = 100.0; }
42  }
43  }
44  }
45  }
46 }
47 
48 void set_field() {
49 
51 
52  for (std::list<Octree*>::iterator i = myOctree::leaf_nodes.begin(), end = myOctree::leaf_nodes.end(); i != end; ++i) {
53 
54  Field* field = (*i)->get_block_data()->scalarfields[0];
55  VecField* location = (*i)->get_block_data()->mesh;
56 
57  for(int i=0;i<field->Nx;i++) {
58  for(int j=0;j<field->Ny;j++) {
59  for(int k=0;k<field->Nz;k++) {
60 
61  double x = location->x[i][j][k];
62  double y = location->y[i][j][k];
63  double z = location->z[i][j][k];
64 
65  ((x-1.0)*(x-1.0) + (y-1.0)*(y-1.0) >= 0.5625)?(field->val[i][j][k] = 1.0):(field->val[i][j][k] = 100.0);
66  //if(x*x + y*y >= 3.0) {field->val[i][j][k] = 100.0; }
67  }
68  }
69  }
70 
71  }
72 
73 }
74 
77 
78  //refinement
79  /*change number to a variable*/
80  for(int i=0;i<=myOctree::max_level;i++) {
81 
82 
86 
87  //reassigning neighbours after every level of refine call
91 // }
92 
93 
94  //coaresning
95  /*change number to a variable*/
96  // for(int i=0;i<5;i++) {
97 
98 
100 
102 
104 
106 
107  //reassigning neighbours after every level of refine call
111  }
112 
114 
115 }
116 
117 }
118 
119 
120 using namespace std;
121 
122 
123 int main(int argc, char **argv) {
124 
125 
126  //reading input
127  read_input_file();
128 
129  //setting up grid
132 
133  //setting initial condition
135 
136  //solving
137  //amrsolver::jacobi(0, "beta");
138  amrsolver::gauss_seidel(0, "beta");
139 
140  //writing vtk
143 
144  //writing output file
146 
147  cerr << "\n" << "Finishing" << endl;
148 }
void gauss_seidel(int level, std::string name)
Definition: poisson.cpp:69
void set_initial_field()
Definition: amrsolver.cpp:18
void reset_refine_flags()
Definition: adapt.cpp:116
void set_field()
Definition: amrsolver.cpp:48
std::list< Octree * > leaf_nodes
Definition: octreegrid.cpp:15
void reset_coarsen_flags()
Definition: adapt.cpp:128
void adapt_gradient()
Definition: amrsolver.cpp:76
void recheck_siblings_coarsen_flags()
Definition: adapt.cpp:253
int max_level
Definition: adapt.cpp:8
Standard input output stuff.
Definition: input.cpp:12
double *** z
Definition: vecfield.h:27
void set_refine_flag_based_on_gradient()
Definition: adapt.cpp:138
Template class for any vector field variable in the domain.
Definition: vecfield.h:13
void set_coarsen_flag_based_on_gradient()
Definition: adapt.cpp:193
void OctreeGrid()
Definition: octreegrid.cpp:251
Template class for any scalar field variable in the domain.
Definition: field.h:11
Solver stuff.
Definition: amrsolver.cpp:15
void reassign_neighbours()
Definition: octreegrid.cpp:90
double *** val
Definition: field.h:20
void coarsen_nodes()
Definition: adapt.cpp:85
void create_list_of_leaf_nodes()
Definition: octreegrid.cpp:21
void read_input_file()
Definition: input.cpp:374
Class to store octree datastructure as nodes of the tree.
Definition: octree.h:26
double *** x
Definition: vecfield.h:25
double *** y
Definition: vecfield.h:26
void write_output_file()
Definition: output.cpp:33
void create_lists_of_level_nodes()
Definition: octreegrid.cpp:43
int main(int argc, char **argv)
Definition: amrsolver.cpp:123
void write_vtk(std::list< Octree * > &nodes)
Definition: vtk.cpp:22
void refine_nodes()
Definition: adapt.cpp:39