CPP-snippets 0.0.1
A silly C++ project to use for demonstrating code integration
Loading...
Searching...
No Matches
poisson.hpp
1#pragma once
2
3#include <Eigen/Core>
4#include <Eigen/SparseCore>
5
6
7class PoissonSolver{
8/*
9 * This class describes the solution of a 1D poisson quattion discretized as three capacitors:
10 *
11 * |-- cap0 --|-- cap1 --|-- cap2 --|
12 * | | | |
13 * o----------o----------o----------o--> x
14 * Fil CE AG IC
15 */
16private:
17
18 // Finite difference system matrices
19 Eigen::SparseMatrix<double> m_cap0_mat, m_cap1_mat, m_cap2_mat;
20
21 // Tri-diagonal sparse system matrix fct (stencilwidth 3)
22 Eigen::SparseMatrix<double> tridiag(int size);
23
24public:
25
26 explicit PoissonSolver(Eigen::Vector4d positions, Eigen::Vector4d potentials, Eigen::Vector3i cells);
27
28 // exposed to other classes
29 Eigen::Vector3i m_cap_cells;
30 Eigen::Vector4d m_cap_pots, m_cap_xpos;
31 Eigen::VectorXd m_dx, m_nodes;
32
33 Eigen::VectorXd solve_potential(Eigen::VectorXd& nodal_rho);
34 Eigen::VectorXd solve_efield(Eigen::VectorXd& nodal_phi);
35
36};