xc
FileDatastore.h
1 //----------------------------------------------------------------------------
2 // XC program; finite element analysis code
3 // for structural analysis and design.
4 //
5 // Copyright (C) Luis Claudio Pérez Tato
6 //
7 // This program derives from OpenSees <http://opensees.berkeley.edu>
8 // developed by the «Pacific earthquake engineering research center».
9 //
10 // Except for the restrictions that may arise from the copyright
11 // of the original program (see copyright_opensees.txt)
12 // XC is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation, either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program.
25 // If not, see <http://www.gnu.org/licenses/>.
26 //----------------------------------------------------------------------------
27 /* ****************************************************************** **
28 ** OpenSees - Open System for Earthquake Engineering Simulation **
29 ** Pacific Earthquake Engineering Research Center **
30 ** **
31 ** **
32 ** (C) Copyright 1999, The Regents of the University of California **
33 ** All Rights Reserved. **
34 ** **
35 ** Commercial use of this program without express permission of the **
36 ** University of California, Berkeley, is strictly prohibited. See **
37 ** file 'COPYRIGHT' in main directory for information on usage and **
38 ** redistribution, and for a DISCLAIMER OF ALL WARRANTIES. **
39 ** **
40 ** Developed by: **
41 ** Frank McKenna (fmckenna@ce.berkeley.edu) **
42 ** Gregory L. Fenves (fenves@ce.berkeley.edu) **
43 ** Filip C. Filippou (filippou@ce.berkeley.edu) **
44 ** **
45 ** ****************************************************************** */
46 
47 // $Revision: 1.14 $
48 // $Date: 2006/01/03 20:49:21 $
49 // $Source: /usr/local/cvs/OpenSees/SRC/utility/database/FileDatastore.h,v $
50 
51 
52 #ifndef FileDatastore_h
53 #define FileDatastore_h
54 
55 // Written: fmk
56 // Created: 10/98
57 //
58 // Description: This file contains the class definition for FileDatastore.
59 // FileDatastore is a concrete subclas of FE_Datastore. A FileDatastore
60 // object is used in the program to store/restore the geometry and state
61 // information in a modeler at a particular instance in the analysis. The
62 // information is stored in text files.
63 //
64 // What: "@(#) FileDatastore.h, revA"
65 
66 #include <utility/database/FE_Datastore.h>
67 
68 #include <fstream>
69 #include <map>
70 using std::fstream;
71 using std::map;
72 
73 
74 #define STREAM_POSITION_TYPE int
75 
76 namespace XC {
77 class FEM_ObjectBroker;
78 
80  {
81  fstream *theFile;
82  STREAM_POSITION_TYPE fileEnd;
83  int maxDbTag;
85 
86 typedef map<int, FileDatastoreOutputFile *> MAP_FILES;
87 typedef MAP_FILES::value_type MAP_FILES_TYPE;
88 typedef MAP_FILES::iterator MAP_FILES_ITERATOR;
89 
90 typedef struct intData
91  {
92  int *dbTag;
93  int *values;
94  } IntData;
95 
96 
97 typedef struct doubleData
98  {
99  int *dbTag;
100  double *values;
101  } DoubleData;
102 
103 
128  {
129  private:
130  // Private methods
131  int resizeInt(int newSize);
132  int resizeDouble(int newSize);
133  void resetFilePointers(void);
134  int openFile(const std::string &fileName, FileDatastoreOutputFile *, int dataSize);
135 
136  // private attributes
137  std::string dataBase;
138  MAP_FILES theIDFiles;
139  MAP_FILES theVectFiles;
140  MAP_FILES theMatFiles;
141  MAP_FILES_ITERATOR theIDFilesIter;
142  MAP_FILES_ITERATOR theVectFilesIter;
143  MAP_FILES_ITERATOR theMatFilesIter;
144 
145  int lastDomainChangeStamp;
146  int currentCommitTag;
147  char *charPtrData;
148  int sizeData;
149 
150  IntData theIntData;
151  DoubleData theDoubleData;
152 
153  int currentMaxInt;
154  int currentMaxDouble;
155 
156  void free_mem(void);
157  void alloc(const size_t &sz);
158  std::string getFileName(const std::string &, int idSize,int commitTag) const;
159  public:
160  FileDatastore(const std::string &dataBase,Preprocessor &preprocessor, FEM_ObjectBroker &theBroker);
161 
162  ~FileDatastore(void);
163 
164  // methods for sending and receiving the data
165  int sendMsg(int dbTag, int commitTag, const Message &, ChannelAddress *theAddress =0);
166  int recvMsg(int dbTag, int commitTag, Message &, ChannelAddress *theAddress =0);
167 
168  int sendMatrix(int dbTag, int commitTag, const Matrix &, ChannelAddress *theAddress= nullptr);
169  int recvMatrix(int dbTag, int commitTag, Matrix &, ChannelAddress *theAddress= nullptr);
170 
171  int sendVector(int dbTag, int commitTag, const Vector &, ChannelAddress *theAddress= nullptr);
172  int recvVector(int dbTag, int commitTag, Vector &, ChannelAddress *theAddress= nullptr);
173 
174  int sendID(int dbTag, int commitTag,const ID &, ChannelAddress *theAddress= nullptr);
175  int recvID(int dbTag, int commitTag,ID &, ChannelAddress *theAddress= nullptr);
176 
177  int createTable(const std::string &tableName,const std::vector<std::string> &columns);
178  int insertData(const std::string &tableName,const std::vector<std::string> &columns, int commitTag, const Vector &);
179  int getData(const std::string &tableName,const std::vector<std::string> &columns, int commitTag, Vector &);
180 
181  // the commitState method
182  int commitState(int commitTag);
183  };
184 } // end of XC namespace
185 
186 #endif
187 
Float vector abstraction.
Definition: Vector.h:93
Objects of this class are used in the program to store/restore the geometry and state information in ...
Definition: FE_Datastore.h:81
Definition: FileDatastore.h:79
Finite element model generation tools.
Definition: Preprocessor.h:58
FEM_ObjectBroker is is an object broker class for the finite element method.
Definition: FEM_ObjectBroker.h:145
Vector of integers.
Definition: ID.h:93
Definition: FileDatastore.h:90
Message between processes.
Definition: Message.h:76
used in the program to store/restore the geometry and state information in the domain at particular i...
Definition: FileDatastore.h:127
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:34
Definition: FileDatastore.h:97
Definition: ChannelAddress.h:69
Matrix of floats.
Definition: Matrix.h:108