-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathelectrostatSolver.h
More file actions
78 lines (62 loc) · 3.41 KB
/
electrostatSolver.h
File metadata and controls
78 lines (62 loc) · 3.41 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef electrostat_h
#define electrostat_h
/** \file electrostatSolver.h
\brief solver for electrostatic problem when spin accumulation is required
header containing electrostatSolver class. It uses biconjugate stabilized gradient with diagonal
preconditioner. The solver is only called once to compute voltages V for each nodes of the mesh,
when spin accumulation computation is involved.
*/
#include <iostream>
#include <map>
#include "solver.h"
#include "config.h"
#include "algebra/algebra.h"
/** dimensionnality of the electrostatic problem */
const int DIM_PB_ELEC = 1;
/** \class electrostatSolver
this class is containing both data and a solver to compute potential from dirichlet boundary
conditions problem for the current density flowing in the sample.
*/
class electrostatSolver: public solver<DIM_PB_ELEC>
{
public:
/** constructor */
electrostatSolver(
Mesh::mesh & _msh /**< [in] reference to the mesh */,
std::vector<Tetra::prm> & _pTetra /**< [in] ref to vector of param tetra (volume region parameters) */,
std::vector<Facette::prm> & _pFac /**< [in] ref to vector of param facette (surface region parameters) */,
const double _tol /**< [in] cg_dir tolerance */,
const bool v /**< [in] verbose mode for iteration monitor */,
const int max_iter /**< [in] maximum number of iterations */):
solver<DIM_PB_ELEC>(_msh,_pTetra,_pFac,"cg_dir",_tol,v,max_iter) {}
/** electrostatic potential values for boundary conditions, V.size() is the size of the vector
* of nodes */
std::vector<double> V;
/** basic informations on boundary conditions */
void infos(void);
/** compute side problem (electrostatic potential on the nodes) integrales for matrix
* coefficients,inputs from tet */
void integrales(Tetra::Tet const &tet, Eigen::Ref<Eigen::Matrix<double,Tetra::N,Tetra::N> > AE);
/** compute integrales for vector coefficients, input from facette */
void integrales(Facette::Fac const &fac, std::vector<double> &BE);
/** text file (tsv) writing function for the solution V over all volume regions of the mesh,
* node indices are zero based */
bool save(const std::string V_fileName /**< [in] output file name */, std::string const &metadata /**< [in] */) const;
/** returns sigma of the tetraedron, (conductivity in (Ohm.m)^-1 */
double getSigma(Tetra::Tet const &tet) const;
/** returns current density of the facette if it is defined in the boundary conditions, else zero */
double getCurrentDensity(Facette::Fac const &fac) const;
/** solves the potential and stores result in V, save to text file if needed
* if verbose set to true, some printing are sent to terminal */
void compute(const bool verbose /**< [in] */, const std::string V_fileName /**< [in] output file name for V solution */);
/** check boundary conditions: mesh and settings have to define a single surface with constant current
* density J (normal componant to the surface) and another single surface with constant potential V */
void checkBoundaryConditions(void) const;
private:
/** number of digits in the optional output file */
const int precision = 8;
/** solver, using conjugate gradient with masking, with diagonal preconditionner and Dirichlet
* boundary conditions, returns true if has converged */
bool solve(void);
}; // end class electrostatSolver
#endif