DPsim
example.c
1 #include <dpsim/MNASolverDynInterface.h>
2 
3 #include <stdio.h>
4 #include <string.h>
5 
6 int example_init(struct dpsim_csr_matrix *matrix);
7 int example_decomp(struct dpsim_csr_matrix *matrix);
8 int example_solve(double *rhs_values, double *lhs_values);
9 void example_log(const char *str);
10 void example_cleanup(void);
11 
12 static const char *PLUGIN_NAME = "plugin.so";
13 static 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 
22 struct 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 
30 int example_init(struct dpsim_csr_matrix *matrix) {
31  example_plugin.log("initialize");
32  return 0;
33 }
34 
35 int example_decomp(struct dpsim_csr_matrix *matrix) {
36  example_plugin.log("decomp");
37  return 0;
38 }
39 
40 int example_solve(double *rhs_values, double *lhs_values) {
41  example_plugin.log("solve");
42  return 0;
43 }
44 
45 void example_cleanup(void) { example_plugin.log("cleanup"); }
46 
47 void example_log(const char *str) { puts(str); }