MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
invsolwrap.cc
Go to the documentation of this file.
1 #include "mbconfig.h"
2 #include "solver.h"
3 #include "invsolver.h"
4 
5 struct mb_sol_wrap_t {
6  Table *pT;
8  std::ifstream streamIn;
12 };
13 
14 static mb_sol_wrap_t *
15 mb_sol_create_(const char *sIn, const char *sOut)
16 {
17  mb_sol_wrap_t *pSW = new mb_sol_wrap_t;
18  pSW->pT = new Table(true);
19  pSW->pMP = new MathParser(*pSW->pT, false);
20  pSW->streamIn.open(sIn);
21  pSW->pIn = new InputStream(pSW->streamIn);
22  pSW->pHP = new MBDynParser(*pSW->pMP, *pSW->pIn, sIn);
23 
24  return pSW;
25 }
26 
27 extern "C" void *
28 mb_sol_create(const char *sIn, const char *sOut)
29 {
30  mb_sol_wrap_t *pSW = mb_sol_create_(sIn, sOut);
31  pSW->pS = new Solver(*pSW->pHP, sIn, sOut, false);
32  return (void *)pSW;
33 }
34 
35 extern "C" void *
36 mb_sol_create_inv(const char *sIn, const char *sOut)
37 {
38  mb_sol_wrap_t *pSW = mb_sol_create_(sIn, sOut);
39  pSW->pS = new InverseSolver(*pSW->pHP, sIn, sOut, false);
40  return (void *)pSW;
41 }
42 
43 extern "C" int
45 {
46  mb_sol_wrap_t *pSW = (mb_sol_wrap_t *)p;
47  if (!pSW->pS->Prepare()) {
48  return -1;
49  }
50 
51  return 0;
52 }
53 
54 extern "C" int
55 mb_sol_start(void *p)
56 {
57  mb_sol_wrap_t *pSW = (mb_sol_wrap_t *)p;
58  if (!pSW->pS->Start()) {
59  return -1;
60  }
61 
62  return 0;
63 }
64 
65 extern "C" int
67 {
68  mb_sol_wrap_t *pSW = (mb_sol_wrap_t *)p;
69  if (!pSW->pS->Advance()) {
70  return -1;
71  }
72 
73  return 0;
74 }
75 
76 extern "C" int
78 {
79  mb_sol_wrap_t *pSW = (mb_sol_wrap_t *)p;
80  delete pSW->pS;
81  delete pSW->pIn;
82  delete pSW->pMP;
83  delete pSW->pT;
84  delete pSW;
85 
86  return 0;
87 }
88 
89 extern "C" int
90 mb_sol_setbufin(void *p, unsigned uLabel, integer iSize, doublereal *pdBuf)
91 {
92  mb_sol_wrap_t *pSW = (mb_sol_wrap_t *)p;
93  DataManager *pDM = pSW->pS->pGetDataManager();
94  pDM->SetBufInRaw(uLabel, iSize, pdBuf);
95 
96  return 0;
97 }
98 
99 extern "C" int
100 mb_sol_setbufout(void *p, unsigned uLabel, integer iSize, doublereal *pdBuf)
101 {
102  mb_sol_wrap_t *pSW = (mb_sol_wrap_t *)p;
103  DataManager *pDM = pSW->pS->pGetDataManager();
104  pDM->SetBufOutRaw(uLabel, iSize, pdBuf);
105 
106  return 0;
107 }
virtual bool Prepare(void)
Definition: solver.cc:399
Solver * pS
Definition: invsolwrap.cc:11
static mb_sol_wrap_t * mb_sol_create_(const char *sIn, const char *sOut)
Definition: invsolwrap.cc:15
MathParser * pMP
Definition: invsolwrap.cc:7
Table * pT
Definition: invsolwrap.cc:6
int mb_sol_prepare(void *p)
Definition: invsolwrap.cc:44
std::ifstream streamIn
Definition: invsolwrap.cc:8
virtual bool Start(void)
Definition: solver.cc:1202
int mb_sol_start(void *p)
Definition: invsolwrap.cc:55
int mb_sol_setbufout(void *p, unsigned uLabel, integer iSize, doublereal *pdBuf)
Definition: invsolwrap.cc:100
MBDynParser * pHP
Definition: invsolwrap.cc:10
virtual bool Advance(void)
Definition: solver.cc:1376
Definition: solver.h:78
void * mb_sol_create_inv(const char *sIn, const char *sOut)
Definition: invsolwrap.cc:36
void SetBufOutRaw(unsigned uL, integer n, const doublereal *p)
Definition: dataman2.cc:2804
virtual DataManager * pGetDataManager(void) const
Definition: solver.h:395
Definition: table.h:43
void * mb_sol_create(const char *sIn, const char *sOut)
Definition: invsolwrap.cc:28
void SetBufInRaw(unsigned uL, integer n, const doublereal *p)
Definition: dataman2.cc:2769
double doublereal
Definition: colamd.c:52
int mb_sol_advance(void *p)
Definition: invsolwrap.cc:66
long int integer
Definition: colamd.c:51
int mb_sol_setbufin(void *p, unsigned uLabel, integer iSize, doublereal *pdBuf)
Definition: invsolwrap.cc:90
int mb_sol_destroy(void *p)
Definition: invsolwrap.cc:77
InputStream * pIn
Definition: invsolwrap.cc:9