summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/solver/nld_solver.h
blob: c47b356ab61154a782dd25b46cd242b01f49bb4f (plain) (blame)
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
// license:GPL-2.0+
// copyright-holders:Couriersud

#ifndef NLD_SOLVER_H_
#define NLD_SOLVER_H_

///
/// \file nld_solver.h
///

#include "netlist/nl_base.h"
#include "nld_matrix_solver.h"
#include "../plib/pstream.h"

#include <map>
#include <memory>
#include <vector>

// ----------------------------------------------------------------------------------------
// solver
// ----------------------------------------------------------------------------------------

namespace netlist
{
namespace devices
{
	NETLIB_OBJECT(solver)
	{
		NETLIB_CONSTRUCTOR(solver)
		, m_fb_step(*this, "FB_step")
		, m_Q_step(*this, "Q_step")
		, m_params(*this)
		{
			// internal staff

			connect(m_fb_step, m_Q_step);
		}

		void post_start();
		void stop();

		nl_fptype gmin() const { return m_params.m_gmin(); }

		void create_solver_code(std::map<pstring, pstring> &mp);

		NETLIB_UPDATEI();
		NETLIB_RESETI();
		// NETLIB_UPDATE_PARAMI();

	private:
		logic_input_t m_fb_step;
		logic_output_t m_Q_step;

		std::vector<plib::unique_ptr<solver::matrix_solver_t>> m_mat_solvers;
		std::vector<solver::matrix_solver_t *> m_mat_solvers_all;
		std::vector<solver::matrix_solver_t *> m_mat_solvers_timestepping;

		solver::solver_parameters_t m_params;

		template <typename FT, int SIZE>
		plib::unique_ptr<solver::matrix_solver_t> create_solver(std::size_t size,
			const pstring &solvername, analog_net_t::list_t &nets);

		template <typename FT>
		plib::unique_ptr<solver::matrix_solver_t> create_solvers(
			const pstring &sname, analog_net_t::list_t &nets);
	};

} // namespace devices
} // namespace netlist

#endif // NLD_SOLVER_H_