-
Notifications
You must be signed in to change notification settings - Fork 9
/
field_solver.h
44 lines (40 loc) · 1.58 KB
/
field_solver.h
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
34
35
36
37
38
39
40
41
42
43
44
#ifndef _FIELD_SOLVER_H_
#define _FIELD_SOLVER_H_
#include <iostream>
#include <boost/multi_array.hpp>
#include <vector>
#include "spatial_mesh.h"
#include "inner_region.h"
class Field_solver {
public:
Field_solver( Spatial_mesh &spat_mesh, Inner_regions_manager &inner_regions );
void eval_potential( Spatial_mesh &spat_mesh, Inner_regions_manager &inner_regions );
void eval_fields_from_potential( Spatial_mesh &spat_mesh );
virtual ~Field_solver();
private:
int nx, ny, nz;
double dx, dy, dz;
private:
int max_Jacobi_iterations;
double rel_tolerance;
double abs_tolerance;
boost::multi_array<double, 3> phi_current;
boost::multi_array<double, 3> phi_next;
void allocate_current_next_phi();
// Solve potential
void solve_poisson_eqn_Jacobi( Spatial_mesh &spat_mesh,
Inner_regions_manager &inner_regions );
void init_current_phi_from_spat_mesh_phi( Spatial_mesh &spat_mesh );
void single_Jacobi_iteration( Spatial_mesh &spat_mesh,
Inner_regions_manager &inner_regions );
void set_phi_next_at_boundaries();
void compute_phi_next_at_inner_points( Spatial_mesh &spat_mesh );
void set_phi_next_at_inner_regions( Inner_regions_manager &inner_regions );
bool iterative_Jacobi_solutions_converged();
void set_phi_next_as_phi_current();
void transfer_solution_to_spat_mesh( Spatial_mesh &spat_mesh );
// Eval fields from potential
double boundary_difference( double phi1, double phi2, double dx );
double central_difference( double phi1, double phi2, double dx );
};
#endif /* _FIELD_SOLVER_H_ */