XC Open source finite element analysis program
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 
105 //
107  {
108  private:
109  // Private methods
110  int resizeInt(int newSize);
111  int resizeDouble(int newSize);
112  void resetFilePointers(void);
113  int openFile(const std::string &fileName, FileDatastoreOutputFile *, int dataSize);
114 
115  // private attributes
116  std::string dataBase;
117  MAP_FILES theIDFiles;
118  MAP_FILES theVectFiles;
119  MAP_FILES theMatFiles;
120  MAP_FILES_ITERATOR theIDFilesIter;
121  MAP_FILES_ITERATOR theVectFilesIter;
122  MAP_FILES_ITERATOR theMatFilesIter;
123 
124  int lastDomainChangeStamp;
125  int currentCommitTag;
126  char *charPtrData;
127  int sizeData;
128 
129  IntData theIntData;
130  DoubleData theDoubleData;
131 
132  int currentMaxInt;
133  int currentMaxDouble;
134 
135  void libera(void);
136  void alloc(const size_t &sz);
137  std::string getFileName(const std::string &, int idSize,int commitTag) const;
138  public:
139  FileDatastore(const std::string &dataBase,Preprocessor &preprocessor, FEM_ObjectBroker &theBroker);
140 
141  ~FileDatastore(void);
142 
143  // methods for sending and receiving the data
144  int sendMsg(int dbTag, int commitTag, const Message &, ChannelAddress *theAddress =0);
145  int recvMsg(int dbTag, int commitTag, Message &, ChannelAddress *theAddress =0);
146 
147  int sendMatrix(int dbTag, int commitTag, const Matrix &, ChannelAddress *theAddress= nullptr);
148  int recvMatrix(int dbTag, int commitTag, Matrix &, ChannelAddress *theAddress= nullptr);
149 
150  int sendVector(int dbTag, int commitTag, const Vector &, ChannelAddress *theAddress= nullptr);
151  int recvVector(int dbTag, int commitTag, Vector &, ChannelAddress *theAddress= nullptr);
152 
153  int sendID(int dbTag, int commitTag,const ID &, ChannelAddress *theAddress= nullptr);
154  int recvID(int dbTag, int commitTag,ID &, ChannelAddress *theAddress= nullptr);
155 
156  int createTable(const std::string &tableName,const std::vector<std::string> &columns);
157  int insertData(const std::string &tableName,const std::vector<std::string> &columns, int commitTag, const Vector &);
158  int getData(const std::string &tableName,const std::vector<std::string> &columns, int commitTag, Vector &);
159 
160  // the commitState method
161  int commitState(int commitTag);
162  };
163 } // end of XC namespace
164 
165 #endif
166 
Definition: FileDatastore.h:79
Definition: Vector.h:82
Definition: FileDatastore.h:90
Definition: FE_Datastore.h:76
FEM_ObjectBroker is is an object broker class for the finite element method. All methods are virtual ...
Definition: FEM_ObjectBroker.h:138
Definition: ChannelAddress.h:69
Finite element model generation tools.
Definition: Preprocessor.h:58
Definition: ID.h:77
Definition: Matrix.h:82
Definition: FileDatastore.h:97
Message between processes.
Definition: Message.h:67
Definition: FileDatastore.h:106
================================================================================
Definition: ContinuaReprComponent.h:34