DPsim
Loading...
Searching...
No Matches
example.c
1#include <dpsim/MNASolverDynInterface.h>
2
3#include <stdio.h>
4#include <string.h>
5
6int example_init(struct dpsim_csr_matrix *matrix);
7int example_decomp(struct dpsim_csr_matrix *matrix);
8int example_solve(double *rhs_values, double *lhs_values);
9void example_log(const char *str);
10void example_cleanup(void);
11
12static const char *PLUGIN_NAME = "plugin";
13static struct dpsim_mna_plugin example_plugin = {
14 .log =
15 example_log, //a properly working dpsim will override this with the spdlog logger
16 .init = example_init,
17 .lu_decomp = example_decomp,
18 .solve = example_solve,
19 .cleanup = example_cleanup,
20};
21
22struct dpsim_mna_plugin *get_mna_plugin(const char *name) {
23 if (name == NULL || strcmp(name, PLUGIN_NAME) != 0) {
24 printf("error: name mismatch\n");
25 return NULL;
26 }
27 return &example_plugin;
28}
29
30int example_init(struct dpsim_csr_matrix *matrix) {
31 example_plugin.log("initialize");
32 return 0;
33}
34
35int example_decomp(struct dpsim_csr_matrix *matrix) {
36 example_plugin.log("decomp");
37 return 0;
38}
39
40int example_solve(double *rhs_values, double *lhs_values) {
41 example_plugin.log("solve");
42 return 0;
43}
44
45void example_cleanup(void) { example_plugin.log("cleanup"); }
46
47void example_log(const char *str) { puts(str); }