1 /*
2  *_________________________________________________________________________*
3  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
4  *      DESCRIPTION: SEE READ-ME                                           *
5  *      FILE NAME: workspace.h                                             *
6  *      AUTHORS: See Author List                                           *
7  *      GRANTS: See Grants List                                            *
8  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
9  *      LICENSE: Please see License Agreement                              *
10  *      DOWNLOAD: Free at www.rpi.edu/~anderk5                             *
11  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
12  *                     Computational Dynamics Lab                          *
13  *                     Rensselaer Polytechnic Institute                    *
14  *                     110 8th St. Troy NY 12180                           *
15  *      CONTACT:        anderk5@rpi.edu                                    *
16  *_________________________________________________________________________*/
17 
18 
19 #ifndef WORKSPACE_H
20 #define WORKSPACE_H
21 
22 #include "matrices.h"
23 #include <iostream>
24 #include <fstream>
25 #include <string>
26 #include <cstdio>
27 #include <iomanip>
28 #include <vector>
29 
30 
31 class System;
32 class Solver;
33 
34 struct SysData{
35         System * system;
36         int solver;
37         int integrator;
38 };
39 
40 class Workspace {
41         SysData * system; // the multibody systems data
42         int currentIndex;
43         int maxAlloc;
44 
45 public:
46      Workspace();
47      ~Workspace();
48 
49      double Thalf;
50      double Tfull;
51      double ConFac;
52      double KE_val;
53           int FirstTime;
54 
55      bool LoadFile(char* filename);
56 
57      bool SaveFile(char* filename, int index = -1);
58 
59      System* GetSystem(int index = -1);
60 
61      void AddSolver(Solver* s, int index = -1);
62 
63 
64      void LobattoOne(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space);
65 
66      void LobattoTwo(double **&vcm,double **&omega,double **&torque, double **&fcm);
67 
68 
69      bool MakeSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, int &njoint, int **&jointbody, double **&xjoint, int& nfree, int*freelist, double dthalf, double dtv, double tempcon, double KE);
70 
71 
72           bool SaveSystem(int& nbody, double *&masstotal, double **&inertia, double **&xcm, double **&xjoint, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space, double **&acm, double **&alpha, double **&torque, double **&fcm, int **&jointbody, int &njoint);
73 
74          bool MakeDegenerateSystem(int& nfree, int*freelist, double *&masstotal, double **&inertia, double **&xcm, double **&vcm, double **&omega, double **&ex_space, double **&ey_space, double **&ez_space);
75      int getNumberOfSystems();
76 
77      void SetLammpsValues(double dtv, double dthalf, double tempcon);
78      void SetKE(int temp, double SysKE);
79 
80           void RKStep(double **&xcm, double **&vcm,double **&omega,double **&torque, double **&fcm, double **&ex_space, double **&ey_space, double **&ez_space);
81 
82           void WriteFile(char* filename);
83 
84 private:
85         void allocateNewSystem(); //helper function to handle vector resizing and such for the array of system pointers
86 };
87 
88 #endif
89